ATR indicator
ATR indicator
12 Nov 2018, 08:17
Hi:
my code is this:
DonchianChannel mBreakIndicator;
AverageTrueRange mAtrIndicator;
protected override void OnStart()
{
mBreakIndicator = Indicators.DonchianChannel(mBreakPeriod);
mAtrIndicator = Indicators.AverageTrueRange(mAtrPeriod, MovingAverageType.Simple);
}
protected override void OnTick()
{
}
protected override void OnBar()
{
Print(mBreakIndicator.Bottom);
Print(mAtrIndicator.Result);
}
then I start backtest,
And I show the ATR in the chart,but I find that the print value is not same as the value shows in chart!!!
the ATR have same period 14,and same MovingAverageType.Simple,but value not same! why?
Replies
zhuyeaini
13 Nov 2018, 14:43
( Updated at: 21 Dec 2023, 09:20 )
RE:
Panagiotis Charalampous said:
Hi zhuyeaini,
I tried it and works fine for me. Can you share some screenshots with what you see?
Best Regards,
Panagiotis
See above screenshot.
@zhuyeaini
PanagiotisCharalampous
13 Nov 2018, 14:59
Hi zhuyeaini,
The reason you see this discrepancy is because you print the value of the bar at the opening of the bar but the indicator calculates the value when the bar closes and the data is finalized. If you want to print finalized calculations of the indicator values, you should print mAtrIndicator.Result.Last(1).
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
12 Nov 2018, 12:58
Hi zhuyeaini,
I tried it and works fine for me. Can you share some screenshots with what you see?
Best Regards,
Panagiotis
@PanagiotisCharalampous