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

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 pmachiraju, 11-01-2023, 04:46 AM
        8 responses
        149 views
        0 likes
        Last Post rehmans
        by rehmans
         
        Started by mattbsea, Today, 05:44 PM
        0 responses
        5 views
        0 likes
        Last Post mattbsea  
        Started by RideMe, 04-07-2024, 04:54 PM
        6 responses
        33 views
        0 likes
        Last Post RideMe
        by RideMe
         
        Started by tkaboris, Today, 05:13 PM
        0 responses
        5 views
        0 likes
        Last Post tkaboris  
        Started by GussJ, 03-04-2020, 03:11 PM
        16 responses
        3,283 views
        0 likes
        Last Post Leafcutter  
        Working...
        X