• 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

Errors showing up in log even when catching all exceptions in OnBarUpdate

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

    Errors showing up in log even when catching all exceptions in OnBarUpdate

    I have an indicator in which I am catching all exceptions as follows:

    Code:
            protected override void OnBarUpdate()
            {
                try
                {
                ...code
                }
                catch(Exception e) { Print(e.ToString()); }            
            }
    However in the log I am still getting this error:

    Error on setting indicator plot for indicator 'MyIndicator'. Value outside of valid range.
    I would have expected the try/catch to prevent all errors in the indicator from reaching NT. How can I catch everything and examine the exception traces and never allow anything to get all the way back to NT?

    #2
    Hello meinl,

    Thank you for your post.

    Exceptions generally don't catch incorrect inputs. That would be why the error occurs without the catch. I would break the code down into smaller Try-Catch blocks rather than one large block. And I would recommend printing out the inputs you are using to ensure they are valid before use.

    You can find more information on debugging your script at the following link: http://ninjatrader.com/support/forum...ead.php?t=3418

    Please let me know if you have any questions.
    Patrick H.NinjaTrader Customer Service

    Comment


      #3
      Thanks for your help, how would I find which line is causing this if try/catch blocks don't handle the error? Even if I had every line in its own try/catch it would still just get printed to the NT log.

      Edit:

      I could of course also log debug messages to a file before and after I update anything. The bug only happens when I have about a month of 1 range data on the chart so it would be a huge debug file.

      I am hoping there is a way to use more modern programming features like try/catch to trace the error rather than having to resort to the log everything in sight approach?
      Last edited by meinl; 05-09-2016, 12:13 PM.

      Comment


        #4
        Hello meinl,

        Thank you for your response.

        If you use any variables to set CurrentBar or BarsAgo ints in your code, I would start here. An example would be the period of an indicator.
        Patrick H.NinjaTrader Customer Service

        Comment


          #5
          For the error:

          Error on setting indicator plot for indicator 'MyIndicator'. Value outside of valid range.
          Can you post what is the C# code for the test that NT uses to produce this error, so that I can test for it before setting values in my indicator?

          Comment


            #6
            Hello meinl,

            Thank you for your response.

            I would not be able to post that code as it is proprietary.

            The error message occurs when a value being set to the plot series is not valid or is trying to set outside the available size of the series. Example, setting an item to 300 when we only have 299.

            Try setting MaximumBarsLookBack to Infinite: http://ninjatrader.com/support/helpG...rslookback.htm
            Patrick H.NinjaTrader Customer Service

            Comment


              #7
              I've noticed that one of the ways this error can happen is if NT gets a data glitch and drops a sections of bars from the chart.

              Just recently I loaded a chart and scrolled back a few days and noticed a section where it showed a bunch of trade arrows all in a vertical line. As soon as that happened my indicators disappeared from the screen and the error message appeared in the log.

              The vertical line of trade arrows must be a day where I was trading, but NT has corrupted its database, as it does very often. My indicator tries to set values for those bars and gets shut down.

              I suspect that if I send a support email about it that the reply will be to send my log and trace files, they'll see the error and think that caused it, when in fact it's the other way around, that the corrupted data caused it.

              I am hoping that when 8 comes out of beta its database is more stable than the one in 7. I am not really interested in any of the other changes but having a stable database is critical for me.

              Comment


                #8
                Originally posted by meinl View Post
                I've noticed that one of the ways this error can happen is if NT gets a data glitch and drops a sections of bars from the chart.

                I am hoping that when 8 comes out of beta its database is more stable than the one in 7. I am not really interested in any of the other changes but having a stable database is critical for me.

                How old is your system? Have you checked for disk errors? How old is the drive?

                Are you recording data for market replay? Are you sure historical data source isn't the issue?

                I had issues with my original laptop's 5400 rpm drive.... things got funky.

                Comment


                  #9
                  Originally posted by sledge View Post
                  How old is your system? Have you checked for disk errors? How old is the drive?

                  Are you recording data for market replay? Are you sure historical data source isn't the issue?

                  I had issues with my original laptop's 5400 rpm drive.... things got funky.
                  It's about 3 years old, it's well within warranty. I'll run a test on the hard drive and see if it finds anything.

                  I am saving the data for market replay. I have found that there are often differences between the data I get when recording with the Gom recorder vs ninjatrader's database. The gom flat files seem to be a lot more reliable to what actually happened vs what I get if I have to restart NT.

                  The data NT shows as it's streamed off the network and has in memory always seems good, but when it comes to backtesting I would really prefer if there was a way to have it read the gom flat files rather than the NT database.

                  I've attached a screenshot of the part of my chart that causes the error.

                  Edit: I ran a disk test overnight to find errors on the drive and it came up clean
                  Attached Files
                  Last edited by meinl; 05-15-2016, 06:34 AM.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by motog4, Today, 11:42 AM
                  0 responses
                  2 views
                  0 likes
                  Last Post motog4
                  by motog4
                   
                  Started by motog4, Today, 11:41 AM
                  1 response
                  3 views
                  0 likes
                  Last Post motog4
                  by motog4
                   
                  Started by derivtrader, Today, 11:20 AM
                  1 response
                  8 views
                  0 likes
                  Last Post NinjaTrader_PaulH  
                  Started by TAJTrades, Today, 10:34 AM
                  1 response
                  7 views
                  0 likes
                  Last Post NinjaTrader_ChrisL  
                  Started by timcjpfx, Today, 10:20 AM
                  1 response
                  5 views
                  0 likes
                  Last Post NinjaTrader_ChelseaB  
                  Working...
                  X