Download MetaTrader 5

ATR formula used in MT4 indicator is not original

To add comments, please log in or register
Rasoul Mojtahedzadeh
29807
Rasoul Mojtahedzadeh  

I was studying Average True Range indicator that I realized the calculation used in standard MT4 indicator is different than original formula. The calculation of ATR in MT4 is based on following formula:

ATR[i] = ATR[i-1] + ( TR[i] - TR[i-n] ) / n; // n is the ATR period

But the original formula as described in the book New Concepts in Technical Trading Systems is:

ATR[i] = ( ATR[i-1] * (n-1) + TR[i] ) / n; // n is the ATR period
Does anybody know what the rationale behind this different calculation of ATR is?
graziani
2007
graziani  

many of implemented indicators are different compared to original.

in case of Wilders indicator, one of the reason would be optimization: Welles was calculating practically everything manually, so he was optimising calculations in favour of calculation speed on the cost of precision. 

whroeder1
15581
whroeder1  
ATR[i] = ATR[i-1] + ( TR[i] - TR[i-n] ) / n; // n is the ATR period
This is the SMA(n, TR) that mt4 uses.
ATR[i] = ( ATR[i-1] * (n-1) + TR[i] )  / n; // n is the ATR period
This is the MMA(N, TR) which equals EMA(2N-1, TR) original.
ATR[i] = ATR[i-1] + (TR[i] - ATR[i-1]) / n; // n is the ATR period
Same but without magnifying round off errors.
ATR[i] = ATR[i-1]  + (TR[i] - ATR[i-1] ) * 2/(N+1);
This is EMA(N, TR) that some other platforms use.
Rasoul Mojtahedzadeh
29807
Rasoul Mojtahedzadeh  
WHRoeder:
This is the SMA(n, TR) that mt4 uses.
This is the MMA(N, TR) which equals EMA(2N-1, TR) original.
Same but without magnifying round off errors.
This is EMA(N, TR) that some other platforms use.

Thanks for your explanation! It is now clear for me why the formula that MT4 uses is different than the original formula.
To add comments, please log in or register