I can call:
[INDENT]if(BarsInProgress > 20)[/INDENT][INDENT=2]return;[/INDENT][INDENT]{[/INDENT][INDENT=2]atrValue = ATR(10)[0];[/INDENT][INDENT]}[/INDENT]
[INDENT]
if(BarsInProgress > 20)[/INDENT][INDENT=2]return;[/INDENT][INDENT]{[/INDENT][INDENT=2]prevATR = ATR(10)[1];[/INDENT][INDENT]}[/INDENT]
Error on calling 'OnBarUpdate' method on bar 0: You are accessing an index with a value that is invalid since it is out-of-range.
I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.
I've tried many different methods to try to get the ATR's historical values including attempting to store the values in a Series<T>. In this attempt for example
else if (State == State.DataLoaded)[INDENT]{[/INDENT][INDENT=2]ATRdata = new Series<double>(this, MaximumBarsLookBack.Infinite);[/INDENT][INDENT]}[/INDENT]
protected override void OnBarUpdate()[INDENT]{[/INDENT][INDENT=2]if (BarsInProgress > 20)[/INDENT][INDENT=3]return;[/INDENT][INDENT=2]{[/INDENT][INDENT=3]ATRdata[0] = ATR(10)[0];[/INDENT][INDENT=3]Print("Current ATR is " ATRdata[0]);[/INDENT][INDENT=3]prevATR = ATRdata[1];[/INDENT][INDENT=3]Print("Previous ATR is " + prevATR);[/INDENT][INDENT=2]}[/INDENT][INDENT]}[/INDENT]
I'm rather new to NT8 coding.
Any help would be appreciated. Perhaps something I missed.

Comment