Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Times[][] error

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

    Times[][] error

    I'm getting a Times[1][index] error when the index is within range of Times[1].Count - 1 for awhile then it works about 15 mins later (put in try..catch) until it does work. The debugger watch window is attached here with my hardcoding the index value that eventually works.

    Click image for larger version

Name:	error.PNG
Views:	136
Size:	15.6 KB
ID:	1145504

    #2
    Hello jalley, thanks for writing in.

    You must reduce your code to find the issue. There is no problem using a contrived example to access the secondary time stamps e.g.

    if(CurrentBars[0] < 10 || CurrentBars[1] < 10) return;

    if(BarsInProgress == 1)
    {
    Print(Times[1][10]);
    }

    At some point in your script, it is accessing a Times[1] index that has not been created yet.

    Please let me know if I can assist any further.

    Comment


      #3
      Hi Chris,

      The Times[1].Count was equal to 2123 and the index I was trying to get at was 127 at the time it had the 2123 count. That was the confusion because it said it already had 2123 bars in the series and I was trying to get one within it but it got the error shown in the debug window. CurrentBars are also way past 127 as shown in the debugger watch window.

      Comment


        #4
        Hello jalley, thanks for your reply.

        The code must be reduced down to see where the barsago error is coming from. I reccomend right clicking the script>Save As> save under a new name and make a copy so you can remove code down to just the problem area. The script you are using is accessing an index that does not yet exist or is not initialized. If you run my attached test script it should work fine on your end, please run this to confirm.

        Kind regards.
        Attached Files

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by CarlTrading, 03-31-2026, 09:41 PM
        1 response
        77 views
        1 like
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        40 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