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

Strategy Historical Execution

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

    Strategy Historical Execution

    Forgive me for what I'm sure is a completely novice question, but I've been unable to find any information about this. When a strategy is enabled, why does it run retroactively through historical data first? As in, when I enable a strategy it appears to run through some number (I'm not sure how many) of bars on the chart before reaching the current "present" bar. Is there any way to disable this behavior?

    This causes problems because now all of my variables have been affected by historical data. For example, I have a variable that tracks my PnL and this causes it to have a value based on historical data, when it should be starting at 0. Now my strategy PnL is different from my account PnL. This is just one example, but it would be great if this could be disabled somehow.

    #2
    Hello,

    Thank you for the post.

    This is simply how the platform works, bars are evaluated from left to right starting at bar 0 in historical data. If you load X amount of data, all of that data would be processed. In the case you want to omit historical data from being used, you can.

    If you are manually coding, you would just need to check that the state is not equal to Historical:

    Code:
    protected override OnBarUpdate()
    {
       if(State == State.Historical) return;
    You can also do this using the Builder, in your conditions you can check Misc -> CurrentState != Misc -> State.Historical

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Fantastic, that's exactly what I needed.

      Thanks!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by alifarahani, Today, 09:40 AM
      6 responses
      31 views
      0 likes
      Last Post alifarahani  
      Started by Waxavi, Today, 02:10 AM
      1 response
      17 views
      0 likes
      Last Post NinjaTrader_LuisH  
      Started by Kaledus, Today, 01:29 PM
      5 responses
      13 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by Waxavi, Today, 02:00 AM
      1 response
      12 views
      0 likes
      Last Post NinjaTrader_LuisH  
      Started by gentlebenthebear, Today, 01:30 AM
      3 responses
      17 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Working...
      X