Hi, I'm new to mt4 but not to programming, I'm working on a EA and one thing I've noticed is that the value for ATR from the EA is different to the ATR on the chart window, see attached screenshot
This is my code in the EA
In the attached screenshot on the 19th October at 03:00 you will see
- ATR on the chart shows "0.0014"
- ATR in the terminal shows "0.00131929"
Now if the value in the chart is using the "NormalizeDouble" function then surely it would round down and show "0.0013"
It depends when you call iATR() in your EA. E.G. if you call it at the beginning of the candle you get a different result comparing to the chart value (there are values for finished candles). The ATR is changing during the candle lasting.
It depends when you call iATR() in your EA. E.G. if you call it at the beginning of the candle you get a different result comparing to the chart value (there are values for finished candles). The ATR is changing during the candle lasting.
Thanks for your response, I'm calling the code inside the EA "OnTick()" function. How am I meant to know whether the code I execute in the EA is at the beginning or end of a candle?
Without your code, I can't help you. But I guess (from your log), the code is executed at the beginning of a candle. You should execute iATR() for the last finished candle.
double atr = iATR(_Symbol, _Period, 14, 1); Print("ATR[1] FROM EA = ",NormalizeDouble(atr,8));
Don't forget your log will be shifted. At 2018.10.19 04:00:00 you will get the ATR for 1-Hour candle 2018.10.19 03:00:00 .
Without your code, I can't help you. But I guess (from your log), the code is executed at the beginning of a candle. You should execute iATR() for the last finished candle.
Don't forget your log will be shifted. At 2018.10.19 04:00:00 you will get the ATR for 1-Hour candle 2018.10.19 03:00:00 .
- 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, I'm new to mt4 but not to programming, I'm working on a EA and one thing I've noticed is that the value for ATR from the EA is different to the ATR on the chart window, see attached screenshot
This is my code in the EA
In the attached screenshot on the 19th October at 03:00 you will see
Now if the value in the chart is using the "NormalizeDouble" function then surely it would round down and show "0.0013"
The issue is the same when I compare the ATR values for other hours, any help or suggestions would be greatly appreciated.