Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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:	103
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.
    Chris L.NinjaTrader Customer Service

    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
        Chris L.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by cls71, Today, 04:45 AM
        0 responses
        1 view
        0 likes
        Last Post cls71
        by cls71
         
        Started by mjairg, 07-20-2023, 11:57 PM
        3 responses
        213 views
        1 like
        Last Post PaulMohn  
        Started by TheWhiteDragon, 01-21-2019, 12:44 PM
        4 responses
        544 views
        0 likes
        Last Post PaulMohn  
        Started by GLFX005, Today, 03:23 AM
        0 responses
        3 views
        0 likes
        Last Post GLFX005
        by GLFX005
         
        Started by XXtrader, Yesterday, 11:30 PM
        2 responses
        12 views
        0 likes
        Last Post XXtrader  
        Working...
        X