I have created following script, that works fine for me, but only if I use MaximumBarsLookBack.TwoHundredFiftySix and not MaximumBarsLookBack.Infinite.
There are following steps in the script:
1. read the data from an external DB
2. store the date in myDateTimeDataSeries
3. store the close in myValueDataSeries
4. check for every bar the date in myDateTimeDataSeries
5. if there is a match for the date plot the value from myDateTimeDataSeries
After changing the Maximum Bars Look Back setting from 256 to infinite, I got the following error under the referral to line 107, where I assign the value close to myValueDataSeries.
It would be great if you could help me, to solve the error.
Thanks and best regards
Andi
28.08.2023 20:00:00 System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
at System.ThrowHelper.ThrowArgumentOutOfRangeExceptio n(ExceptionArgument argument, ExceptionResource resource)
at NinjaTrader.NinjaScript.Series`1.set_Item(Int32 barsAgo, T value)
at NinjaTrader.NinjaScript.Indicators.AA.AFMYSQL3.OnS tateChange() in C:\Users\AF\Documents\NinjaTrader 8\bin\Custom\Indicators\AA\AFMYSQL3.cs:line 107
Indicator 'AFMYSQL3': 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.
Comment