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

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.
    Paul H.NinjaTrader Customer Service

    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.
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Wooo - Hooo! Thank you Paul!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by inanazsocial, Today, 01:15 AM
          0 responses
          2 views
          0 likes
          Last Post inanazsocial  
          Started by trilliantrader, 04-18-2024, 08:16 AM
          5 responses
          22 views
          0 likes
          Last Post trilliantrader  
          Started by Davidtowleii, Today, 12:15 AM
          0 responses
          3 views
          0 likes
          Last Post Davidtowleii  
          Started by guillembm, Yesterday, 11:25 AM
          2 responses
          9 views
          0 likes
          Last Post guillembm  
          Started by junkone, 04-21-2024, 07:17 AM
          9 responses
          70 views
          0 likes
          Last Post jeronymite  
          Working...
          X