Download MetaTrader 5

ATR formula used in MT4 indicator is not original

To add comments, please log in or register
What is a social trading? Read the article to find that out!
Rasoul Mojtahedzadeh
27563
Rasoul Mojtahedzadeh 2014.08.02 12:30 

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
1954
graziani 2014.08.02 12:45  

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
14486
whroeder1 2014.08.02 18:23  
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
27563
Rasoul Mojtahedzadeh 2014.08.03 15:05  
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