Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Execute Strategy Once and disable in NT8

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

    Execute Strategy Once and disable in NT8

    Is it possible to setup a strategy in NT8 so that it executes only once and stops executing Until I enable it again. for example I want to implement a strategy that enters an order at a certain price then disables after that order is placed and triggers.
    Regards
    G Hastings

    #2
    Welcome to the forums g_hastings!

    Yes, this would be possible. A strategy can check for the execution of an order in OnExecutionUpdate and then call CloseStrategy() to disable the strategy.

    OnExecutionUpdate - https://ninjatrader.com/support/help...tionupdate.htm

    CloseStrategy - https://ninjatrader.com/support/help...sestrategy.htm

    Also note, if you want the strategy to only work with realtime data, and skip historical processing, you can add the following to the top of the OnBarUpdate() method.

    if (State == State.Historical) return;

    We look forward to assisting.

    Comment


      #3
      From Strategy wizard? or I have to enter the code.

      Comment


        #4
        Hello g_hastings,

        In the Strategy Builder, You could use a bool to control actions so they only happen once, but we cannot programmatically disable the strategy.

        You could, for example, create a bool in Inputs and Variables that is initialized as true. You can then check if that bool is true, Misc > Current State is State.Realtime, and then your entry condition. When all are true, call EnterLong/EnterShort to enter, and also set the bool to false.

        The condition to enter will no longer become true until the strategy is disabled and re-enabled.

        We look forward to assisting.

        Comment


          #5
          Thank you! I believe the second approach where one uses a bool to evaluate a true/ false to stop the strategy would be more than sufficient. So if you could point me to a sample of such a setup would be highly appreciated.

          Comment


            #6
            Hello g_hastings,

            To visualize a bool in use, I have attached a strategy that uses a bool to control when an initial stop loss should be used or if the stop loss should be moved to breakeven. The stop loss is controlled with ExitLongStopMarket in Conditions and Actions so the strategy logic can control where the order gets placed.

            You would need to set up a condition as described in post #4 to accomplish your goal.

            We look forward to assisting.
            Attached Files

            Comment

            Latest Posts

            Collapse

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