Hi guys,
I mange to resolve this after reading the explanation from MQL Discussion at
EA places multiple instances iCustom indicator on chart - Debugging and Testing - MQL DiscussionsMy issues was due to the parameters use in conjunctions wit iCustom, which the right way is to declare the indicator parameters as variables then call direct as value in iCustom. The explanation from the post above
"When the integer is implicitly casted the runtime allocates a small piece of memory to hold the resulting string (here “100”) and passes a pointer to this memory to iCustom(). This happens on each call of iCustom() and here is the point. This piece of memory changes on every call (each time a new allocation), so the pointer passed to iCustom() changes on every call, too. To iCustom() it looks like you pass each time a different variable (indeed you do, even if it holds each time the same value: “100”)."
I have declared the variables as below:
//+--------------------Indicator Preset--------------------------------- //SetHA========= Heiken Settings ======== string SetHA=""; int MainPeriod=10; int MethodMA=3; int UptrendColor=13749760; int DowntrendColor=3937500; bool PlotInBackground=false; //SetOther========= Other Settings ======== string SetHAOther=""; bool EnablePushNotifications=false; bool EnableAlerts=false; bool ShowWaterMark=false;
Then call the iCustom as below:
array_HAS_Open[0]=iCustom(NULL,0,"Market\\HeikenAshi Smoothed",SetHA,MainPeriod,MethodMA,UptrendColor,DowntrendColor,PlotInBackground,SetHAOther,EnablePushNotifications,EnableAlerts,ShowWaterMark,2,0);
This works out for me :-)
if(Volume[0]==1){
For a new bar test, Bars is unreliable (a refresh/reconnect can change number of bars on chart), volume is unreliable (miss ticks), Price is unreliable (duplicate prices and The == operand. - MQL4 programming forum.) Always use time.
New candle - MQL4 programming forum #3 2014.04.04
I disagree with making a new bar function, because it can only be called once per tick. A variable can be tested multiple times.
Running EA once at the start of each bar - MQL4 programming forum 2011.05.06
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi Guys,
I am testing out to write a strategy base on a custom indicator "Heiken Ashi Smoothed". The simple code as below, with a simple PRINT to verify if I get the right value.
Below is the screenshot shows the issue i am facing, where is seems like every time the iCustom every new bar, a new instance of indicator added to the chart.
Kindly advice or point me some reference if there is steps i am missing here.
Thanks.