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 Brevo, Today, 01:45 AM
      0 responses
      3 views
      0 likes
      Last Post Brevo
      by Brevo
       
      Started by aussugardefender, Today, 01:07 AM
      0 responses
      3 views
      0 likes
      Last Post aussugardefender  
      Started by pvincent, 06-23-2022, 12:53 PM
      14 responses
      240 views
      0 likes
      Last Post Nyman
      by Nyman
       
      Started by TraderG23, 12-08-2023, 07:56 AM
      9 responses
      384 views
      1 like
      Last Post Gavini
      by Gavini
       
      Started by oviejo, Today, 12:28 AM
      0 responses
      6 views
      0 likes
      Last Post oviejo
      by oviejo
       
      Working...
      X