That's to account for gaps in consecutive candles. No version is wrong, but they do slightly different things
However the original is more efficient since it avoids repeating calculations in the moving average (ATR buffer)
ironhak: I don't understand why it calculates like that, isn't it wrong??? I would use this one instead:
Both are wrong! They both generate the average of range ( Hi- Li ), not the average of True Range (max( Hi, Ci+1 )-min( Li, Ci+1 ).
The first uses SMMA. The second uses SMA.
The Smoothed Moving Average or SMMA - How to Avoid It - NinjaTrader Programming | futures.io (2019)

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
Hi everyone, my mt4 platform comes with ATR indicator that uses this calculation:
I don't understand why it calculates like that, isn't it wrong??? I would use this one instead:
Where index_forloop is just the index if the function is called inside a foor loop in order to get ATR of higher timeframes. This is how I would calculate it even on excel, is my version wrong or what? Why don't standard mt4 atr is like that?