Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Help with Exception Logic

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

    Help with Exception Logic

    Friday, 11 minutes after the open, an hour after starting my indicator, my indicator got an exception message in the Log tab. No unusual events preceeded this exception.
    Here is the exact exception message:
    "
    Error on calling 'OnBarUpdate' method for indicator 'aaMyIndicator' on bar 4685: Index was out of range.
    Must be non-negative and less than the size of the collection. Parameter name: index
    "

    My indictor has CalculateOnBarClose=false (tick-by-tick updating in OnBarUpdate()).

    I've structured my OnBarUpdate() code with a try/catch which surrounds all the code in OnBarUpdate(). This is the only try/catch in OnBarUpdate().

    Code:
    protected override void OnBarUpdate()
    {
      try
      {
    
        //A bunch of code but no other try/catch statements.
    
      }
      catch(Exception e)
      {
        Print("My Exception Handler.");
        Print(e.Message);
      }
    }
    The above exception was not caught by my try/catch inside OnBarUpdate().

    So can I conclude the code that caused the above exception was not inside OnBarUpdate()? And if this is correct, then what could cause this exception? I do call Update() in another area of the code. I assume Update() eventually causes an OnBarUpdate() event.

    If the call to Update() is possibly a contributor to the above exception, are there some conditions that should be checked for before calling Update()?

    thanks,
    shawnj
    Last edited by shawnj; 12-06-2008, 12:55 PM.

    #2
    I will forward this to development for review. By chance can you reproduce this?
    RayNinjaTrader Customer Service

    Comment


      #3
      >> If the call to Update() is possibly a contributor to the above exception, ...?
      Potentially. Unfortunately we are not aware of any details related to the issue you experienced. We would need a reproducible scenario in order to analyze what's going on.

      Comment


        #4
        Unfortunately I have not been able to reproduce this error. It has been very intermittent. If I play it back with Market Replay there are no errors. This indicator has lots of "moving parts" .

        This has proven to be one of the hardest bugs I've every tried to track down. It would be helpful if from the previously provided information I could be sure that none of the code in the OnBarUpdate() was a contributor to the exception error. It is my understanding that only unhandled exceptions will appear in the Log tab.

        For next week's testing, I've wrapped the Update() call with a try/catch. The Update() call is coming from another thread. I'm guessing this has something to do with it.

        thanks,
        shawnj
        Last edited by shawnj; 12-07-2008, 07:55 AM.

        Comment


          #5
          >> The Update() call is coming from another thread.
          Unfortunately multi-threading is not supported. It may or may not work. You would need to try on your own.

          Comment


            #6
            The exception that I originally documented seems to be coming from withing NT and therefore out of my reach. I also can't duplicate it so I realize I'm on my own.

            I was calling Update() to just force a screen update (Paint). So far, my attempts to draw on a chart from another thread, either directly with calls to DrawXX() or indirectly with Update() have been problematic.

            Studying the BarTime indicator code, I see another way to force a Paint may be to call ChartControl.ChartPanel.Invalidate(). I think I'll try to rig up something with a timer, which should be on the chart thread, and a signaling variable to indicate if Invalidate shoud be called. This will probably be safer than calling Update() from other than the chart's thread.

            thanks,
            shawnj

            Comment


              #7
              >> This will probably be safer than calling Update() from other than the chart's thread
              Definitely

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              558 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              324 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              101 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              545 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              547 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X