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 CarlTrading, 03-31-2026, 09:41 PM
        1 response
        72 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        39 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        63 views
        2 likes
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        63 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        53 views
        0 likes
        Last Post CarlTrading  
        Working...
        X