Question : if the ATR is the SMA of the TrueRange, then ATR(1) should be the TrueRange, correct ?
If that is true, then why SMA(10) of ATR(1) is not equal to ATR(10) ?
Is this the correct way to calculate ATR ?
protected override void OnBarUpdate()
{
if(CurrentBar < 1 ) return;
diff[0] = Math.Max(Math.Abs(Low[0] - Close[1]), Math.Max(High[0] - Low[0], Math.Abs(High[0] - Close[1]))); //High[0] - Low[0];
Value[0] = smaDiff[0];
}
assuming that
else if (State == State.DataLoaded)
{
diff = new Series<double>(this);
smaDiff = SMA(diff, Period);
}
This code shows a value similar but not equal to ATR
Which is the correct code please ?

Comment