Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Time[0] Not Available ?

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

    Time[0] Not Available ?

    I have added a toolbar to a strat of mine. The strat has a parameter for the start time but I wanted to add a button to manually start the thing if I wish. I am getting an error the big "NT has detected an error and needs to shutdown...". I have pasted some of the trace.

    After debugging a little I have pretty much narrowed it down to the reference ToTime(Time[0]). I use this all over the place in OnBarUpdate() but I assume I am doing something wrong in this subroutine.

    privatevoid tsbtnStart_Click(object sender, EventArgs e)
    {
    if (ToTime(Time[0]) < dStartTime)
    {
    dStartTime = ToTime(Time[
    0]);
    tsbtnStart.ForeColor = Color.Red;
    DrawTextFixed(
    "tag1","Manually Started at " + dStartTime, TextPosition.Center);
    }
    else
    {
    DrawTextFixed(
    "tag1","Strat already running", TextPosition.Center);
    }
    }

    2010-07-02 13:21:04:515 in OnUnhandledThreadException
    2010-07-02 13:21:04:515 ********* exception trapped *********
    2010-07-02 13:21:04:515 Index was out of range. Must be non-negative and less than the size of the collection.
    Parameter name: index

    #2
    Hi netjms,

    Can you perhaps post your entire script so I can see how the handler is being used.
    TimNinjaTrader Customer Service

    Comment


      #3
      The script is more characters then allowed by the forum. Is there a way to attach the cs file to a post reply?

      Comment


        #4
        Hi netjms,

        Yes, you can attach the cs file of a zip file created at "File>Utilities>Export NinjaScript"
        TimNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by DannyP96, 05-18-2026, 02:38 PM
        1 response
        29 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 05-11-2026, 05:56 AM
        0 responses
        117 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 05-10-2026, 08:12 PM
        0 responses
        69 views
        0 likes
        Last Post CarlTrading  
        Started by Hwop38, 05-04-2026, 07:02 PM
        0 responses
        227 views
        0 likes
        Last Post Hwop38
        by Hwop38
         
        Started by Mindset, 04-21-2026, 06:46 AM
        0 responses
        309 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Working...
        X