Hi Guys,
New to MQL and trying to automate my trades from an indicator that I have. I've been reading up on the various threads here and been able to get some code together but it keeps firing everybar. Would appreciate if someone could point me in the right direction in order for me to fix.
Code:
When I add this to my chart, it fires immediately (the correct direction) and adds the time when added to the chart. And then you see the time keep updating which indicates that if I had an orderopen instead of comments, that it would be opening an order each candle.
Since you intend to execute once per bar, then the last parameter of your iCustoms should be 1, not 0 (and definitely not uninitialized Shift).
Also, your indicators' EMPTY_VALUE may not be EMPTY_VALUE... indicators can use any value, so you need to open your Data Window to verify.So, updated it and removed shift as well as it wasn't needed. But it's still trying to execute the order on every bar? I only want it to execute on the bar that shows the arrow.
Update section:
int start() // this starts the engine of the code. { if(newbar==Time[0])return(0); // else newbar=Time[0]; double ArrowUP=iCustom(Symbol(), 0, "AlertArrow", Step1, Step2, Step3, 0, 0, 0, 0); double ArrowDN=iCustom(Symbol(), 0, "AlertArrow", Step1, Step2, Step3, 0, 0, 0, 1); double HistoUP=iCustom(Symbol(), 0, "AlertValidated", Histo1, Histo2, Histo3, 0, 0, 0, 0); double HistoDN=iCustom(Symbol(), 0, "AlertValidated", Histo1, Histo2, Histo3, 0, 0, 0, 1); if ((ArrowDN != EMPTY_VALUE ) && (HistoDN != EMPTY_VALUE ) && (CheckMoneyForTrade(Symbol(), lots, 1))) { Comment("Sell - ", TimeToStr(TimeCurrent(),TIME_SECONDS)); } if ((ArrowUP != EMPTY_VALUE ) && (HistoUP != EMPTY_VALUE ) && (CheckMoneyForTrade(Symbol(), lots, 0))) { Comment("Buy - ", TimeToStr(TimeCurrent(),TIME_SECONDS)); } return(0); // returns back to the start function of the program. }
double ArrowUP=iCustom(Symbol(), 0, "AlertArrow", Step1, Step2, Step3, 0, 0, 0, 0); //Buffer 0, shift 0 ?? double ArrowDN=iCustom(Symbol(), 0, "AlertArrow", Step1, Step2, Step3, 0, 0, 0, 1); //Buffer 0, shift 1 ?? double HistoUP=iCustom(Symbol(), 0, "AlertValidated", Histo1, Histo2, Histo3, 0, 0, 0, 0); //Buffer 0, shift 0 ?? double HistoDN=iCustom(Symbol(), 0, "AlertValidated", Histo1, Histo2, Histo3, 0, 0, 0, 1); //Buffer 0, shift 1 ??
Your iCustom calls cannot be correct.
Ok, perhaps it's my interpretation of what the indicator writer gave me (I don't have the source code)
All i have from them is:
if(!TestOP){ ArrowUP=iCustom(Symbol(),0,AlertArrow,Step1,Step2,Step3,0,0,0,0,Shift); ArrowDN=iCustom(Symbol(),0,AlertArrow,Step1,Step2,Step3,0,0,0,1,Shift); HistoUP=iCustom(Symbol(),0,AlertValidated,Histo1,Histo2,Histo3,0,0,0,0,0); HistoDN=iCustom(Symbol(),0,AlertValidated,Histo1,Histo2,Histo3,0,0,0,1,0); }
These are the indicator inputs if that helps
I meant this:
double ArrowUP=iCustom(Symbol(), 0, "AlertArrow", Step1, Step2, Step3, 0, 0, 0, 0, 1); double ArrowDN=iCustom(Symbol(), 0, "AlertArrow", Step1, Step2, Step3, 0, 0, 0, 1, 1); double HistoUP=iCustom(Symbol(), 0, "AlertValidated", Histo1, Histo2, Histo3, 0, 0, 0, 0, 1); double HistoDN=iCustom(Symbol(), 0, "AlertValidated", Histo1, Histo2, Histo3, 0, 0, 0, 1, 1);
And verify whether these indicators return EMTPY_VALUE...
Ok, perhaps it's my interpretation of what the indicator writer gave me (I don't have the source code)
All i have from them is:
These are the indicator inputs if that helps
I don't see how your 4 iCustom() lines matches the inputs of the indicators.
Perhaps you can try out default values, by simplifying your iCustom() to these:
double ArrowUP=iCustom(Symbol(), 0, "AlertArrow", 0, 1); double ArrowDN=iCustom(Symbol(), 0, "AlertArrow", 1, 1); double HistoUP=iCustom(Symbol(), 0, "AlertValidated", 0, 1); double HistoDN=iCustom(Symbol(), 0, "AlertValidated", 1, 1);
See what happens first...
Yeah i think they sent me the wrong buffer code to use. But looks like they say to use shift value of 0?
Ok still not working and i have tried the following combinations:
double ArrowUP=iCustom(Symbol(),0,"AlertArrow", Ma1, Ma2, Ma3, Ma4, 0, 0, 0, 0, 0); double ArrowDN=iCustom(Symbol(),0,"AlertArrow", Ma1, Ma2, Ma3, Ma4, 0, 0, 0, 1, 0); double HistoUP=iCustom(Symbol(),0,"AlertValidated", Histogram, Method_Type, 0, 0, 0, 0, 0); double HistoDN=iCustom(Symbol(),0,"AlertValidated", Histogram, Method_Type, 0, 0, 0, 1, 0);
double ArrowUP=iCustom(Symbol(),0,"AlertArrow", Ma1, Ma2, Ma3, Ma4, 0, 0, 0, 0, 1); double ArrowDN=iCustom(Symbol(),0,"AlertArrow", Ma1, Ma2, Ma3, Ma4, 0, 0, 0, 1, 1); double HistoUP=iCustom(Symbol(),0,"AlertValidated", Histogram, Method_Type, 0, 0, 0, 0, 1); double HistoDN=iCustom(Symbol(),0,"AlertValidated", Histogram, Method_Type, 0, 0, 0, 1, 1);
double ArrowUP=iCustom(Symbol(),0,"AlertArrow", 0, 1); double ArrowDN=iCustom(Symbol(),0,"AlertArrow", 1, 1); double HistoUP=iCustom(Symbol(),0,"AlertValidated", 0, 1); double HistoDN=iCustom(Symbol(),0,"AlertValidated", 1, 1);
Yeah i think they sent me the wrong buffer code to use. But looks like they say to use shift value of 0?
Ok still not working and i have tried the following combinations:
Look at my earlier post - check return values, verify if they are EMTPY_VALUE. Also, follow what they said and use 0 IF the arrows appear at bar 0.

- 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,
New to MQL and trying to automate my trades from an indicator that I have. I've been reading up on the various threads here and been able to get some code together but it keeps firing everybar. Would appreciate if someone could point me in the right direction in order for me to fix.
Code:
When I add this to my chart, it fires immediately (the correct direction) and adds the time when added to the chart. And then you see the time keep updating which indicates that if I had an orderopen instead of comments, that it would be opening an order each candle.