Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to Fully Terminate a Strategy when conditions are met

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

    How to Fully Terminate a Strategy when conditions are met

    I'm aware that there are methods to prevent a running strategy from executing (such as a bool), however is there a method for terminating a strategy altogether? For example, when certain conditions are met, the strategy purposefully throws an error that shuts down the strategy and stops it running is one method that comes to mind - just wondering if there is a correct or clean way of doing this please?

    The scenario I'm thinking of is:
    I run a strategy against 1000 symbols (which is too many to compute properly), and then discard ~900 that don't meet certain conditions, leaving 100 symbols running (which is fine to compute).

    Many thanks in advance

    ChainsawDR

    #2
    Hello

    You can use CloseStrategy for that purpose: https://ninjatrader.com/support/help...=closestrategy

    Comment


      #3
      Thank you Jesse!

      Comment


        #4
        Hi Jesse,

        Please could you let me know if it is possible to close the strategy without exiting any open positions? I've looked through the documentation but struggling to find info regarding the options (the 'base implementation of CloseStrategy()' mentioned in the documentation).

        Many thanks in advance

        ChainsawDR

        Comment


          #5
          Hello ChainsawDR,

          You can override CloseStrategy like shown in the help guide page. It mentions if you don't want the default logic called then you need to not call the base method or base.CloseStrategy(signalName);

          This would leave the strategy enabled still because you are not calling the base logic. The only way to leave the position open would be to have the strategy manually disabled. Your strategy logic can stop working based on some criteria so it stays enabled but does not do anything and at that point you could manually disable it.
          Last edited by NinjaTrader_Jesse; 11-29-2022, 09:52 AM.

          Comment


            #6
            Thanks Jesse. TBH I haven't fully understood - by overriding and not calling base.CloseStrategy(signalName) then I presumed it would do nothing (that by 'taking over' the function, only the rules written in the override would apply.

            I did manage to find on another post the option of SetState(State.Terminated) which looks to have solved the issue.

            Thanks again for your help

            ChainsawDR

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by NullPointStrategies, Yesterday, 05:17 AM
            0 responses
            59 views
            0 likes
            Last Post NullPointStrategies  
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            134 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            75 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            45 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            50 views
            0 likes
            Last Post TheRealMorford  
            Working...
            X