Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Empty backtesting results due to historical state

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

    Empty backtesting results due to historical state

    My strategy checks this in OnBarUpdate()

    if (State == State.Realtime && BarsInProgress == 0)

    It seems when I do back testing using the strategy analyzer, it never goes inside this if statement to actually run any of my strategy's logic. What do I have to do in order to back-test properly?

    #2
    Originally posted by jiminssy View Post
    My strategy checks this in OnBarUpdate()

    if (State == State.Realtime && BarsInProgress == 0)

    It seems when I do back testing using the strategy analyzer, it never goes inside this if statement to actually run any of my strategy's logic. What do I have to do in order to back-test properly?
    Documentation for 'State.Realtime' says 'Begins to process realtime data.'

    During backtesting, you never process realtime data, only historical data.

    When backtesting, try using 'State == State.Historical'.

    When running live, use something like 'State == State.Realtime' or 'State != State.Historical'.

    Comment


      #3
      Hello,

      Thank you for your note.

      Bltdavid is correct. Since a backtesting uses historical data rather than real time data, the code inside (State ==State.Realtime && BarsInProgress ==0) will not be processed during backtesting. I’d suggest making another State.Historical section before State.Realtime section so that you can backtest.

      Something like this,

      if (State == State.Historical && BarsInProgress == 0)
      {
      // your code here
      }
      if (State == State.Realtime && BarsInProgress == 0)
      {
      // your code here
      }

      I’ve provided a link to our helpguide on OnStateChange:


      Please let us know if you need further assistance.
      Alan P.NinjaTrader Customer Service

      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