Because what you see on the chart is calculated at close of the candle, but what you printed is at open.
In 'Open prices only', your EA receives 1 tick at open of each bar, but there are 2 ticks generated (and used to draw candles and indicators).
Example: EURUSD,H1: 768 ticks, 384 bars generated. Environment synchronized in 0:00:00.125. Test passed in 0:00:00.687 (including ticks preprocessing 0:00:00.016).
Use the debugger and place a breakpoint on your last "return", and check the values.
Because what you see on the chart is calculated at close of the candle, but what you printed is at open.
In 'Open prices only', your EA receives 1 tick at open of each bar, but there are 2 ticks generated (and used to draw candles and indicators).
Example: EURUSD,H1: 768 ticks, 384 bars generated. Environment synchronized in 0:00:00.125. Test passed in 0:00:00.687 (including ticks preprocessing 0:00:00.016).
Use the debugger and place a breakpoint on your last "return", and check the values.
Thank you so much Alain.
I fixed the issue by modifying the following lines :
CopyBuffer(handle,0,0,2,bufferOpen); CopyBuffer(handle,1,0,2,bufferHigh); CopyBuffer(handle,2,0,2,bufferLow); CopyBuffer(handle,3,0,2,bufferClose);
If I understand correctly, in backtest mode "open price only", for each new candle, 1 tick event is sent to the EA, but 2 ticks are actually registered by the indicator : one for the current candle open, one for the last candle close. Is that correct?
Thank you so much Alain.
I fixed the issue by modifying the following lines :
If I understand correctly, in backtest mode "open price only", for each new candle, 1 tick event is sent to the EA, but 2 ticks are actually registered by the indicator : one for the current candle open, one for the last candle close. Is that correct?
Not exactly, see this article
- 2011.05.18
- MetaQuotes Software Corp.
- www.mql5.com
Not exactly, see this article
Thanks for the reference!
- 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 all.
I am getting crazy with this issue.
I have a MT5 EA using the native MT5 Heiken Ashi indicator. It just displays the values of open, high, low, close of the current Heiken Ashi candle.
When applying the EA to a graph which has the indicator applied, values printed by the EA do match the one I see on the graph, in real time.
When launching the EA in back test mode, with option "open price only", displayed values do not match the Heiken Ashi candles I can see on the graph.
Anybody has a clue why and how I can fix that?
Here is the EA code:
Thanks in advance for your help!