Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 CortexZenUSA, Today, 12:53 AM
      0 responses
      1 view
      0 likes
      Last Post CortexZenUSA  
      Started by CortexZenUSA, Today, 12:46 AM
      0 responses
      1 view
      0 likes
      Last Post CortexZenUSA  
      Started by usazencortex, Today, 12:43 AM
      0 responses
      5 views
      0 likes
      Last Post usazencortex  
      Started by sidlercom80, 10-28-2023, 08:49 AM
      168 responses
      2,265 views
      0 likes
      Last Post sidlercom80  
      Started by Barry Milan, Yesterday, 10:35 PM
      3 responses
      11 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Working...
      X