I have a multi-instrument indicator, and at some point in the code I have a call that occurs when BarsInProgress==0
This code tries to look at the series of other instruments and is looking for a matching timestamp. Skipping some code, here's the context of the problem:
//...
ITimeSeries time = Times[instrumentIndex];
//...
for (int i = 0; i < time.Count; i++)
{
Print("i=" + i+", time.Count = "+time.Count); // debugging
DateTime t = time[i];
Print(" time = " + t); // debugging
// do stuff with t....
This works for some bars, but at some point it throws an exception. The output window shows the following:
i=390, time.Count = 1556
time = 6/6/2012 6:32:00 AM
i=391, time.Count = 1556
time = 6/6/2012 6:31:00 AM
i=392, time.Count = 1556
Exception in MyGroupWatchListVsIndex.OnBarUpdate(): System.ArgumentException: Bar index needs to be greater/equal 0
at NinjaTrader.Data.Bars.GetTime(Int32 barIndex)
at NinjaTrader.Data.Bars.GetTimeEnd(Int32 barIndex)
at NinjaTrader.Indicator.TimeSeriesHelper.get_Item(In t32 barsAgo)
at NinjaTrader.Indicator.MyGroupWatchListVsIndex.Find OffsetByTimestamp(DateTime syncTimeStamp, Int32 instrumentIndex, Boolean roundToDate, Boolean useExactMatch, Int32 guess) in c:\Users\Admin\Documents\NinjaTrader 7\bin\Custom\Indicator\MyGroupWatchListVsIndex.cs: line 327
...
What gives?
Comment