Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

What are the side effects of manually using "Close" while a strategy is running?

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

    What are the side effects of manually using "Close" while a strategy is running?

    Hi,

    If I have a strategy running that is trading autonomously and I manually flatten my position what happens under the hood with my strategy? I know it continues to run, but the execution isn't firing now when it should.

    Just curious what really happens underneath and can I work around it programmatically?


    Thanks.

    #2
    Hello DogEars,

    Thanks for your question.

    Hitting the Close button to close a position on an instrument in which a strategy is running will close the position and disable the strategy.

    Strategies are intended to operate on their own positions which are separate from the actual account position. This would mean that the strategy is intended to stay in sync with the account, and manual order submissions will desync the strategy from the account.

    However, strategies can be built to manage manual entries in a couple ways:
    1. Using AdoptAccountPosition to capture the account position and have the strategy manage that adopted position
    2. Writing a strategy that uses the Unmanaged Approach, and keeps track of the Account Position with PositionAccount
    Strategy vs. Account Position — https://ninjatrader.com/support/help..._account_p.htm

    Start Behaviors — https://ninjatrader.com/support/help..._positions.htm

    PositionAccount - https://ninjatrader.com/support/help...ionaccount.htm

    Unmanaged Approach - https://ninjatrader.com/support/help...d_approach.htm

    Let us know if there is anything else we can do to help.
    Attached Files

    Comment


      #3
      Thank you very much, incredibly helpful. You guys are the best.

      Comment


        #4
        Hi DogEars,

        That is a nice strong reply from Jim.


        To extend on Jim's reply ...


        If you want to "have your cake and eat it too" ....

        Strategies will keep running if it is the Strategy rather than buttons in the ChartTrader UI that initiate the Close or Flatten.

        Here in this forum and in the NT ecosystem free app share there are a number of examples of Indicators using on-Chart buttons.

        I think you could create an indicator that is called by and used by the strategy that hosts two buttons that appear on the chart. One button titled Close and another titled Flatten.

        Click on one of those puppies and your well thought out and tested strategy will shut that position and keep happily spinning along.

        The first example is a good starting place to see the concepts play out.
        https://ninjatraderecosystem.com/use...olbar-buttons/

        The second is much more complicated but also, if you dig hard has code to leverage to either close or flatten in response to a click of the button. This core great but will ask you to bring pretty strong C# skills.
        https://ninjatraderecosystem.com/use...bot-indicator/

        A "mothership" type post on creating buttons.
        Hello All, Moving forward this will be maintained in the help guide reference samples and no longer maintained on the forum. Creating Chart WPF (UI) Modifications from an Indicator - https://ninjatrader.com/support/help...ui)-modifi.htm (https://ninjatrader.com/support/helpGuides/nt8/creating-chart-wpf-(ui)-modifi.htm) I've



        You can drive the buttons from a strategy or addon as well if you have C# skills.


        HedgePlay
        Last edited by hedgeplay; 07-23-2021, 12:12 PM.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Today, 05:17 AM
        0 responses
        50 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        126 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        69 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        42 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        46 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X