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 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
      22 views
      0 likes
      Last Post helpwanted  
      Started by cre8able, Today, 07:24 PM
      0 responses
      10 views
      0 likes
      Last Post cre8able  
      Working...
      X