• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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 memonolog, Today, 02:39 AM
        1 response
        17 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by memonolog, Today, 07:07 AM
        0 responses
        4 views
        0 likes
        Last Post memonolog  
        Started by juanram, Today, 06:01 AM
        1 response
        9 views
        0 likes
        Last Post NinjaTrader_PaulH  
        Started by dastaan, Today, 06:29 AM
        0 responses
        6 views
        0 likes
        Last Post dastaan
        by dastaan
         
        Started by random9570, Yesterday, 09:01 PM
        2 responses
        19 views
        0 likes
        Last Post Emma1
        by Emma1
         
        Working...
        X