To check whether the data series is valid, I use the call IsValidDataPoint. This works for the correct data series, but it also returns true for the one data series that failed to load.
It looks for me (naively), like IsValidDataPoint is returning true when it should not.
(I have searched this forum and also read the sentences about MaximumBarsLookBack.TwoHundredFiftySix, but dont think this is valid, as it works for the other data series.)
Here is the sample code. First I load three extra data series. The last series ^RUI fails to load, but that is exactly what I want to test.
if (State == State.Configure) { AddDataSeries("^NDX", Data.BarsPeriodType.Day, 1, Data.MarketDataType.Last); AddDataSeries("^OEX", Data.BarsPeriodType.Day, 1, Data.MarketDataType.Last); AddDataSeries("^RUI", Data.BarsPeriodType.Day, 1, Data.MarketDataType.Last); }
protected override void OnBarUpdate() { if (CurrentBar <= 20 || BarsInProgress != 0) return; for(int idx=0; idx<Closes.Length; idx++) if (Closes[idx].IsValidDataPoint(0)) Print(Closes[idx][0]); }
1304.27 1581.95 602.82 Indicator 'TEST_IsValidDataPoint': Error on calling 'OnBarUpdate' method on bar 21: 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.
Am I overseeing anything obvious?
Thanks, Brian
Comment