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 argusthome, 03-08-2026, 10:06 AM
        0 responses
        88 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        48 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        30 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        34 views
        0 likes
        Last Post TheRealMorford  
        Started by Mindset, 02-28-2026, 06:16 AM
        0 responses
        68 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Working...
        X