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 judysamnt7, 03-13-2023, 09:11 AM
      4 responses
      59 views
      0 likes
      Last Post DynamicTest  
      Started by ScottWalsh, Today, 06:52 PM
      4 responses
      36 views
      0 likes
      Last Post ScottWalsh  
      Started by olisav57, Today, 07:39 PM
      0 responses
      7 views
      0 likes
      Last Post olisav57  
      Started by trilliantrader, Today, 03:01 PM
      2 responses
      21 views
      0 likes
      Last Post helpwanted  
      Started by cre8able, Today, 07:24 PM
      0 responses
      10 views
      0 likes
      Last Post cre8able  
      Working...
      X