Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Index out of range error in auto-trading but not in backtesting

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

    Index out of range error in auto-trading but not in backtesting

    I'm getting the following error in several of my strategies when I attempt to run them live: "Error in calling 'OnBarUpdate' method for strategy 'XYZ'. Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index."

    Comments:
    1) This error is occurring in several existing strategies and I've made no recent changes to the strategies. The strategies were working fine until I attempted to start them up again on Sunday evening.
    2) The error does not occur in backtesting w/Strategy Analyzer, it only occurs when I'm trying to load each strategy.
    3) I've tried simple steps like exiting Ninja and restarting the computer to no avail. Please help.

    -Lou
    Last edited by bluelou; 05-18-2009, 09:03 PM.

    #2
    bluelou, unfortunately you will have to debug the code to trace where the issue originates from - Print statement are helpful in this regard - http://www.ninjatrader-support2.com/...ead.php?t=3418
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Bertrand,
      After 2 days w/o strategy automation my strategies somehow healed themselves and the OnBarUpdate error went away w/o changing a single line of code. This spontaneous error cost me almost 300 bps in performance.

      Please explain how a bug appears out of nowhere, shuts me down for 2 days, and then suddenly disappears again. There's nothing for me to fix and this concerns me b/c the problem can just as easily come back again.

      This is a platform problem, not a strategy code problem. There's no other explanation for my code to suddenly run error-free when I've done nothing to fix it. Please tell me what needs to be done to understand why the problem appeared and why it went away. Having an intermittent bug in the auto-trading portion of the NinjaTrader platform is unacceptable.

      -Lou

      Comment


        #4
        Hi Lou, just because you most times do not see any issues, it does not automatically mean your code applied is error free. You would still need to debug this step by step and check where the offending values stem from. Try and catch statements can be helpful for this, more info is compiled in here - http://www.ninjatrader-support2.com/...ead.php?t=9825
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Bertrand,
          I'm quite certain that this is a NinjaTrader issue with strategy automation and not a bug in my code. There are no "offending values". Here is the sequence of events that lead me to this conclusion:

          1) On 4/15 all strategies ran normally as they had for weeks.
          2) On 4/17 2 strategies received the OnBarUpdate - "index out of range error" though the code had not been altered. Also, the print log that I use for each strategy stopped working for the remaining strategies that I was still able to run.
          3) On 4/18 I used both try...catch statements and the MSVS debugger to try to identify the problem. No problems were identified in Strategy Analyzer and the code ran properly in backtesting. However, an exception was thrown when launching a strategy in live mode. The source of the exception was not found.
          4) On 4/20 I was able to reload all strategies in live mode successfully, no exceptions were thrown, the print logger worked properly, and not a single line of code was changed. So, now I'm up and running again after being down for 2 days.
          5) FWIW, this problem has occurred in the past and I've resolved it by opening, closing, and reopening NinjaTrader about a 1/2 dozen times until I got the strategies to run properly. This time was different in that I had to restart Ninja about 12 times to get it to run properly.

          The fact that this is a recurring, intermittent problem, that cannot be resolved w/exception handling or the MSVS debugger, that can only be resolved by restarting NinjaTrader several times, leads me to believe that this is a platform issue.

          If the platform issue continues unresolved then this means that I should regard NinjaTrader as a tool for hobbyists and not for active traders.

          Please let me know how I can help Ninja resolve this platform issue.

          -Lou

          Comment


            #6
            Lou, thanks for the detailed reply.

            Backtesting with the strategy analyzer is to be treated separate from live trading as new paramters are introduced. The stopping of the Print outputs after your exception was thrown in expected.

            Many customers are using NinjaTrader everyday for autotrading strategies without issues, the error you report in is originating from your code and you need to debug what is causing this exception to address it.

            Please work with the suggested try and catch blocks to trace this down and debug.

            BertrandNinjaTrader Customer Service

            Comment


              #7
              Just because you don't see it every day does not mean your code is error free. It just means you have not run into the exact scenario that breaks your code.

              The error message states you are trying to access index values outside of the allowable range. You should go through your code and try and isolate out each and ever single one of your [] indexes to find which one has run into an issue. The error occurred inside your OnBarUpdate() method.

              If you feel it is intermittent I suggest you always run with your Output Window open and leave tracer prints throughout your code so you at least get an idea of how far your code goes before it runs into the error. That will help you isolate out the area of interest.
              Josh P.NinjaTrader Customer Service

              Comment


                #8
                Josh,
                Fair enough I guess. I always run w/a print log as you've suggested. I guess its possible that the bug is caused by a specific sequence of events that can't be found using exception handling, debugging in MSVS, or print log statements - that means that the bug is untraceable. Either way, it's my problem.

                -Lou
                Last edited by bluelou; 05-21-2009, 11:21 AM.

                Comment


                  #9
                  Lou,

                  The message also mentions Parameter: index. Please give special care in checking any variable you may have named "index".
                  Josh P.NinjaTrader Customer Service

                  Comment


                    #10
                    Josh,
                    That's another question to be resolved. The word "index" appears nowhere in my strategy or indicator code. I have no idea what "index" is. I thought it was some NinjaTrader secret code.

                    -Lou

                    Comment


                      #11
                      Lou,

                      Then we are back to trying to isolate where exactly it broke. The way to do this is to print tracers throughout the code and see which is the last tracer to be print before the error.
                      Josh P.NinjaTrader Customer Service

                      Comment


                        #12
                        Josh,
                        What exactly do you mean by "tracer"? Are you referring to putting print statements throughout the code? If so, I don't think that's going to work since the error occurs b/f the strategy loads. If not, please explain further.

                        Thx,
                        Lou

                        Comment


                          #13
                          Place it throughout your code and print statements that you can clearly identify where in your code this print out actually came from.

                          It will print. For instance place one line in the very beginning of OnBarUpdate(). You might as well even place some prints in Initialize() bearing in mind that the Initialize() prints will print several times when trying to start up your strategy.
                          Josh P.NinjaTrader Customer Service

                          Comment


                            #14
                            Josh,
                            Thanks for this advice. I'll prepare the tracers in advance so I'm ready the next time this happens.

                            -Lou

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by chbruno, 04-24-2024, 04:10 PM
                            3 responses
                            47 views
                            0 likes
                            Last Post NinjaTrader_Gaby  
                            Started by samish18, Today, 01:01 PM
                            1 response
                            6 views
                            0 likes
                            Last Post NinjaTrader_LuisH  
                            Started by WHICKED, Today, 12:56 PM
                            1 response
                            8 views
                            0 likes
                            Last Post NinjaTrader_Gaby  
                            Started by cre8able, Today, 01:16 PM
                            1 response
                            3 views
                            0 likes
                            Last Post NinjaTrader_Gaby  
                            Started by WHICKED, Today, 12:45 PM
                            1 response
                            11 views
                            0 likes
                            Last Post NinjaTrader_Gaby  
                            Working...
                            X