Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to make strategy ready to enter orders at start

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

    How to make strategy ready to enter orders at start

    I have noticed that in my strategy, if I enable the strategy it will show a bunch of simulated historical trades on my chart, right up until the first live bar. If the strategy theoretically would have opened a trade just before the first live bar, then my strategy does not open any trades - it waits fro that simulated trade to close. But that simulated trade never seems to close - even if it hits what would have been my stoploss or take profit, the strategy stays in this untradeable state - not simulated exit ever occurs.

    What I want the strategy to do is ignore any simulated past trades and just start trading from a flat state. I'm sure there is some NT setting to make this happen. Please tell me what to do here.

    #2
    Hello westofpluto,

    Thanks for your post.

    You can "skip" historical processing with if (State == State.Historical) return;

    Reference: (second example): https://ninjatrader.com/support/help...nt8/?state.htm

    If you intend to run your strategy in the strategy analyzer then you would need to comment that line of code out or create a user input bool that you can change when you apply the strategy to enable or disable the use of historical data/trades.

    Comment


      #3
      Paul, is there any way to do this using the Strategy Builder? I like the builder but once the code is unlocked then I can't use it anymore. I tried several things in the builder to say if (State==State.Historical) but no success. State is in the builder menu, but the only options for State on the left side is Historical, Transition, and Real time.
      Suggestions??

      Comment


        #4
        Hello JoeF1953,

        Thanks for your post and welcome to the NinjaTrader forums!

        Yes, you can and you are on the right track!

        In each set, add the condition Misc>Current State equals Misc>state Real Time.

        This condition means that it will only execute the set when the bars are Real time, so there would be no execution on historical bars.

        Comment


          #5
          Wooo - Hooo! Thank you Paul!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by CarlTrading, 03-31-2026, 09:41 PM
          1 response
          80 views
          1 like
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 04-01-2026, 02:41 AM
          0 responses
          40 views
          0 likes
          Last Post CarlTrading  
          Started by CaptainJack, 03-31-2026, 11:44 PM
          0 responses
          63 views
          2 likes
          Last Post CaptainJack  
          Started by CarlTrading, 03-30-2026, 11:51 AM
          0 responses
          63 views
          0 likes
          Last Post CarlTrading  
          Started by CarlTrading, 03-30-2026, 11:48 AM
          0 responses
          54 views
          0 likes
          Last Post CarlTrading  
          Working...
          X