Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Skip past index data errors

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

    Skip past index data errors

    Hi,

    I want to skip any invalid values that are out of range?

    if(Closes[SymbolCount][0]!=null)

    SymbolCount is on a loop.

    I just want to loop the whle lot and then see whats left to check errors

    Thanks

    #2
    Tinkerz,

    Is it a for loop? Is there a maximum number for the loop here?

    You could use a Try/Catch here to gracefully handle any invalid index exceptions.

    try
    {
    // the code here
    }
    catch ( Exception e )
    {
    Print(e.ToString());
    // or do something else here like exit the for loop
    }

    Please let me know if I may assist further.
    Adam P.NinjaTrader Customer Service

    Comment


      #3
      Thats great, that prints the whole data for me, as this is printing to excel I would like to print some text into the spreadsheet when an error happen, then I can find the errors easy.

      So how do I identify the System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. error ? then I can use "if else" to achieve the result

      Thanks

      Tinkerz

      Comment


        #4
        Hello,

        You would need to change where the try/catch block is running to see if you can isolate it to a specific section or your code.

        For example if you're trying/catching the entire OnBarUpdate() method, you can try a smaller section to try an encapsulate exactly where the error is coming from.
        MatthewNinjaTrader Product Management

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        595 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        343 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        103 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        556 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        554 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X