Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy showing up blank in backtest

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

    Strategy showing up blank in backtest

    Newbie here...been using NT for about 2 months...and have been backtesting, editing strategies, compiling, and backtesting again with no problems, using both the Wizard and the Editor. Today, all of a sudden, I started getting a very weird problem - after compiling, sometimes my strategy would show up in the Backtest blank - I mean completely blank. No way for me to adjust my settings, or to run the backtest. I could not create any new strategies that would work in the Backtest, they all kept coming up blank.

    I tried wiping out my NT 6.5 folder in My Docs completely, and restarting - that obviously puts all the standard NT generated Strategies back into that directory...and so I started AGAIN. I created a new strategy using the Wizard, tested it, no problem. Then I unlocked the code, changed nothing, saved and compiled and tested it no problem. Then I change one or two small lines of code, nothing crazy, saved, compiled and tested again. No problem. This went on for about 10 minutes, and I thought I had it licked. Then, out of the blue, I save and compile, go to run the Backtest and the Strategy is corrupted.

    I've been able to replicate this problem with several different (and very simple) strategies, so I do not feel like it is strategy specific. I get the same problem if I try to run the Strategy live vs. in a backtest. So I don't think it is a problem w/ my Backtest window.

    What could be causing my strategy files to get corrupted like this? I've upgraded to the most recent release of NT, I've rebooted NT countless times, rebooted Windows numerous times.

    I've edited, saved and compiled various strategies 3-4 hours per day for two months and have never had this issue. Any thoughts?

    thanks.

    #2
    Hello jeremytmartin,

    Deleting the My Documents-->NinjaTrader 6.5 folder will delete all saved settings and data.

    Do you list any error messages in the Log-tab when the backtest does not display results?

    Could you please provide me steps to reproduce the issue on my end.

    Comment


      #3
      error message from log files

      I went back through 2 days worth of log files...and the error I'm getting is always:

      3/31/2009 6:03:14 PM|3|128|Failed to call method 'Initialize' for strategy 'BBcounter': ATR[barsAgo]: barsAgo out of valid range 0 through -2, was 0.

      I have 4-5 different strategies that use a simple 13-period ATR...and its giving that same error message in the log files when I try to start one of those up. I'm using the syntax ATR(period)[current bar] to get that last value of the 13-period ATR.

      In the Initialize section I have ATR(ATRvalue)[0] where ATRvalue is an user provided variable that I set in the Backtest window so that I can change values for the ATR period (that was provided for me when I initially setup the Strategy using the Strategy Wizard - I haven't altered that).

      I can still run the Strategies provided by NinjaTrader, like the SimpleCrossover, etc. But when I got to select my strat from the drop down menu, it doesn't change the window to reflect my new strategy, the parameters, the description, etc - it just stays on the SimpleCrossover strategy even though I have my strategy selected from the drop down.

      Comment


        #4
        I suggest to review the information at the link below.


        It seems the indicator used in your strategy is referencing a bar that does not exist.

        Comment


          #5
          working

          OK - so I had this code snippet in the Initialize() method:

          SetStopLoss("", CalculationMode.Ticks, ATR(ATRperiod)[0] * 4 * ATRfactor, false);

          so all I did was move it out of the Initialize() method and into the OnBarUpdate() method and it started working.

          So question for you...why would it throw an exception in the Initialize method but not the OnBarUpdate method. On the first bar update it still does not have 13 bars worth of ATR data to set that StopLoss with (I did not put the code snippet in that says If Less than 13 Bars then Return) because I wanted to see what it did. I literally just moved it from Init to OnBarUpdate - cut and paste.

          Is it bad practice to call something like SetStopLoss from the Initialize method if the SetStopLoss uses some other indicator (like ATR) that needs a bunch of bars worth of data? I guess I need to make sure I only make those types of calls from the OnBarUpdate in the future.

          Thanks for the help - you guys do a great job w/ this forum.

          Comment


            #6
            Thanks for the kind words and great you got it working - please don't put any calculations in the Initialize(), like your ATR(ATRperiod)[0] * 4 * ATRfactor. It would be ok for a static stoploss though - http://www.ninjatrader-support.com/H...tStopLoss.html

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            110 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            59 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            37 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            41 views
            0 likes
            Last Post TheRealMorford  
            Started by Mindset, 02-28-2026, 06:16 AM
            0 responses
            78 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Working...
            X