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 traderqz, Today, 12:06 AM
        10 responses
        18 views
        0 likes
        Last Post traderqz  
        Started by algospoke, 04-17-2024, 06:40 PM
        5 responses
        46 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by arvidvanstaey, Today, 02:19 PM
        1 response
        6 views
        0 likes
        Last Post NinjaTrader_Zachary  
        Started by mmckinnm, Today, 01:34 PM
        3 responses
        5 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by f.saeidi, Today, 01:32 PM
        2 responses
        9 views
        0 likes
        Last Post f.saeidi  
        Working...
        X