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