I'm using a timer to trigger an event that displays 5 minute volume on my range chart, and I am getting errors in my trace log on startup (below)
I am fairly sure that I have the timer events setup correctly, its probably what I am doing in the timer event that is the problem. The timer and the events are created in OnStartup() and in my Initialize() I do this -
Add(PeriodType.Minute, 5);
volTimer.Start();
In the timer event I refer to the array VOL(BarsArray[1])[0] which I suspect is the cause of the error, as if the array is not created before the first timer event is triggered?
Do I need to check the array size or something else first?
Thanks,
Will.
Error Log
--------------
at NinjaTrader.Data.DataSeries.get_Item(Int32 barsAgo)
at NinjaTrader.Indicator.IndicatorBase.get_Item(Int32 barsAgo)
at NinjaTrader.Indicator.Wills5MinuteVolume.displayVo lume()
at System.Windows.Forms.Timer.OnTick(EventArgs e)
at System.Windows.Forms.Timer.TimerNativeWindow.WndPr oc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
2014-03-31 19:08:43:625 in OnUnhandledThreadException
2014-03-31 19:08:43:625 *************** unhandled exception trapped ***************
2014-03-31 19:08:43:625 Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
2014-03-31 19:08:43:625 at System.Collections.ArrayList.get_Item(Int32 index)
at NinjaTrader.Data.DataSeries.get_Item(Int32 barsAgo)
at NinjaTrader.Indicator.IndicatorBase.get_Item(Int32 barsAgo)
at NinjaTrader.Indicator.Wills5MinuteVolume.displayVo lume()
at System.Windows.Forms.Timer.OnTick(EventArgs e)
at System.Windows.Forms.Timer.TimerNativeWindow.WndPr oc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Comment