Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Using a Timer on Second Bar Series - Startup Errors

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Using a Timer on Second Bar Series - Startup Errors

    Hi,

    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)

    #2
    Will, would the outcome change if you're not starting the timer in Initialize() but OnStartUp(), so after the bars array is added and ready?

    Comment


      #3
      No, Bertrand, unfortunately.

      That was where I had it originally and that seems to be worse. It doesnt seem to happen on every chart, but when its in OnStartup() it seems to happen more.

      Either way, its still happening.

      Thanks...

      Comment


        #4
        Hi Will with Initialize() getting called multiple times I would not start the timer there. You update the volume with the timer for realtime only, correct? Would you mind sending me the script to support at ninjatrader dot com so I could give this a quick run here?

        Comment


          #5
          Yes, no problem, I will do that shortly.

          Comment


            #6
            Hi, Its sent now,
            Thanks,
            Will.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            579 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            334 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            101 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            554 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            551 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X