Can someone please advise how to retrieve values from previous bars of a Series<double> without getting the below error.
Indicator 'zzWIP': Error on calling 'OnBarUpdate' method on bar -1: 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.
Example code might be:
protected override void OnBarUpdate() { if (IsFirstTickOfBar) && CurrentBar > (61)) { //DECLARE SMA VARIABLES SMAs1t0 = SMA(BarsArray[1],SMA5mPeriod)[0]; SMAs1t1 = SMA(BarsArray[1],SMA5mPeriod)[1]; } }
Comment