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

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
    JimNinjaTrader Customer Service

    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 traderqz, Today, 12:06 AM
        2 responses
        3 views
        0 likes
        Last Post traderqz  
        Started by RideMe, 04-07-2024, 04:54 PM
        5 responses
        28 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Started by f.saeidi, Today, 08:13 AM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by DavidHP, Today, 07:56 AM
        1 response
        6 views
        0 likes
        Last Post NinjaTrader_Erick  
        Started by kujista, Today, 06:23 AM
        3 responses
        11 views
        0 likes
        Last Post kujista
        by kujista
         
        Working...
        X