• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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:
      http://ninjatrader.com/support/helpG...tatechange.htm

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

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by epitoma, Today, 05:21 PM
      1 response
      10 views
      0 likes
      Last Post NinjaTrader_ShawnB  
      Started by BatBart, Today, 01:24 PM
      1 response
      22 views
      0 likes
      Last Post NinjaTrader_Melissa  
      Started by ezrakoper, Today, 03:05 PM
      1 response
      7 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by asmmbillah, Today, 02:23 PM
      1 response
      17 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by steveg, Today, 02:44 PM
      1 response
      9 views
      0 likes
      Last Post NinjaTrader_Heath  
      Working...
      X