use NormalizeDouble()
regardless wat's wrong with iATR()
The problem is that iHigh - iLow returns 0, so I can't see how rounding the value would help. I do round later in the code but did not want to round every iteration in order to keep the rounding error as small as possible.
Thanks for the tip regarding iATR. It is possible that I am inventing the wheel here but I don't know exactly what iATR does and the doc is pretty vague so this way at least i have full control (apart from the error at virgin installations). I think it has to do with the iHigh and iLow array not being populated all the way back, or something like that. So even if iATR would turn out to be an ideal replacement, I would still like to understand what is going wrong.
Anyone with any ideas?
Gosta
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I am running the following lines in my EA. When i run the EA for the first iHigh(Symbol(), PERIOD_D1, i)- iLow(Symbol(), PERIOD_D1, i) does not seem to return anything. The value of averageDailyRange after the call is 0. Then after that it seems to work fine, it's only the first time that it fails. Why does it fail? What can I do to prevent this?
for (int i=1; i<=ADRDays; i++) {
averageDailyRange = averageDailyRange + (iHigh(Symbol(), PERIOD_D1, i)- iLow(Symbol(), PERIOD_D1, i));
}
averageDailyRange = averageDailyRange / ADRDays;
The value of ADRDays is 30.
I use an M15 chart.
In my options the Max Bars In History and Max Bars In Chart is set to 50,000.
Thanks
Gosta