
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, am not an expert, thus I need to seek your support, I know I am wrong but:
According to the definition/formula of ATR, it looks to me that the ATR code in MT4 is wrong.
See, the formula to calculate ATR is : TR=max[(high-low), abs(high-close_prev), abs (low-close_prev)] according to wikipedia.
But in MT4's ATR code , it code the looping as :
----qte----
//--- the main loop of calculations
for(i=limit; i<rates_total; i++)
{
ExtTRBuffer[i]=MathMax(high[i],close[i-1])-MathMin(low[i],close[i-1]);
ExtATRBuffer[i]=ExtATRBuffer[i-1]+(ExtTRBuffer[i]-ExtTRBuffer[i-InpAtrPeriod])/InpAtrPeriod;
}
//--- return value of prev_calculated for next call
return(rates_total);
------- unqte ----
My question is : if we need close value of the previous bar, then we need to say close[i+1], instead of [i-1], doesn't it ?
Many thanks friends.