-
Why did you post your MT4 question in the MT5 EA section instead of the MQL4 section, (bottom of the Root page)?
General rules and best pratices of the Forum. - General - MQL5 programming forum? (2017)
Next time, post in the correct place. The moderators will likely move this thread there soon. -
You are triggering on the bar where the signal occurs (bar one). Bar zero may set and unset as the close price (Bid) changes. If you want to trigger on a potentially false signal, change to bar zero.
- dcstoyanov: Therefore, if the Indicator is limited to the last closed bar,
Wrong. Your posted code shows that it is processing bar zero.
- dcstoyanov: only way is to implement all the calculations directly in the Expert Advisor. Correct?Wrong. There would be no difference.

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
From my use of iCustom() in an Expert Advisor, and from several tests, I've made the conclusion that, in general, one cannot send or close orders on the same bar on which the signal is triggered.
The reason for this issue is because:
1) the Indicator makes all its calculation
2) then it fills the buffers
3) then it draws on the chart
3) finally, the Expert Advisor, through iCustom(), retrieves the values from the buffers
It also depends on if one, in the Indicator, uses open[] or close[] values and the type of calculation involved.
Therefore, if the Indicator is limited to the last closed bar, iCustom() returns always the correct value (because it will never change) but then the Expert Advisor will receive the value in the next bar (a total of two bars late):
On the other hand, if the Indicator tries to calculate also the current bar and iCustom() tries to return the previous value, what one gets is a value not reliable (because different from the closing value):
If what I've said is right, in order to avoid such delay, it seems to me that the only way is to implement all the calculations directly in the Expert Advisor. Correct?