I have listed the simplified code below.
protected override void OnRender(ChartControl cc, ChartScale cs) { if( State != State.Realtime ) return; // Wait till we are real-time. for(int i = 0; i < Bars.Count; i++) { Print(string.Format("High [{0}] = {1}. Current Bar = {2}, Bars.Count = {3}", i, Instrument.MasterInstrument.FormatPrice(High[Bars.Count - i - 1]), CurrentBar, Bars.Count)); } }
High [0] = 177.92. Current Bar = 250, Bars.Count = 251
Indicator 'InsideOutsideBar': Error on calling 'OnRender' method on bar 250: You are accessing an index with a value that is invalid since it is out-of-range.
I notice that it fails from i = 1 onwards. However, the value of Bars.Count is 251, and the size of High <double> series is also 251.
Is my code correct ? What am I missing ?
Comment