No announcement yet.

Partner 728x90


Close atm strategy

  • Filter
  • Time
  • Show
Clear All
new posts

    Close atm strategy

    can you please say what should be the syntax for closing atm strategy? I am using button clicked for it.

    Hello asmmbillah,

    Thank you for your post.

    To close an ATM Strategy with syntax, you may use AtmStrategyClose(). This method cancels any working orders and closes any open position of a strategy using the default ATM Strategy close behavior. Please see the AtmStrategyClose() Help Guide page linked below for more information.

    AtmStrategyClose() -

    Also, here is a Help Guide link about ATM Strategy close behavior -

    Please let us know if we may further assist.

    Brandon H.NinjaTrader Customer Service


      Thanks for your reply. from the guide I can see you suggest to use

      Now while I have multiple positions running using the same atm strategy, how do I close all? And what is "idValue" here?


        Hello asmmbillah.

        Thank you for your reply.

        'idValue' in AtmStrategyClose() refers to the ATM Strategy's unique id generated from GetAtmStrategyUniqueId(). GetAtmStrategyUniqueId() would need to be used to create a unique id for each ATM Strategy you are running. Then AtmStrategyClose would be used to close out of each ATM Strategy using the strategy's unique id.

        Please clarify whether you are creating ATM Strategies using ATMStrategyCreate() or if you are wanting to close ATM Strategies from manually placed orders, like by clicking the Close button.

        More information may be found in the Help Guide link here -

        Also, here is a Help Guide link about manually closing an ATM Strategy using the Close button -

        Please let us know if we may assist further.
        Brandon H.NinjaTrader Customer Service


          Thanks for your reply. I am using AtmStrategy.StartAtmStrategy(atm.SelectedAtmStrate gy, entryOrder); for entering position. Now with a button click event, I may have multiple instance of the same atm strategy running. but with a separate button's click I am trying to close all open postions including any pending generated by the atm instances. I hope that clarifies.


            Hello asmmbillah,

            I see this post is in the strategy development section. Is this an AddOn or a Ninjascript strategy?

            For a strategy approach, you may use AtmStrategyCreate() for submitting an entry order that will execute a specified ATM Strategy.

            Here is a Help Guide link about how AtmStrategyCreate() may be used -

            Using an AddOn approach, you would need to loop through the account orders and change the limit to fill or submit an order to close the position.

            Additionally, you may also call atmStrategy.CloseStrategy() to close the ATM strategy once the target/stop reach an Accepted/Working OrderState. You could, for example, check if "Stop1" belongs to an ATM strategy taking the approach in the DetectAtmEntry example in the forum link below, and if the order is in an Accepted state, calling CloseStrategy from the AtmStrategy will close the ATM strategy.

            DetectAtmEntry Example -

            Also note that the ATM strategy will have a Strategy ID as we see with NinjaScript strategies, that can be used to uniquely identify the strategy. In the example, this strategy can be referenced as stratbase.Id or atmStrategy.Id. This Id is not the same as the Atm Strategy Id that is used in the NinjaScript strategy ATM Strategy Methods.

            I look forward to being of further assistance.
            Brandon H.NinjaTrader Customer Service


              You are seeing this post here as it is for strategy.
              I was advised by your colleague here to use StartAtmStrategy(atm.SelectedAtmStrate gy, entryOrder) for this purpose. I am not creating atm strategy within my script, I am simply grabing the existing atm template. I hope that gives you more clarification to review your reply above.


                Hello asmmbillah,

                Thank you for that information.

                If you are not submitting the ATM Strategy through code, it wouldn't be necessary to use StartAtmStrategy() as this method is used to start an ATM Strategy when submitting an entry order through the addon approach.

                If you want a list of working ATM Strategies from manually placed entry orders, these can be found from the Account.Orders. The previous DetectAtmEntry example demonstrates this by getting the ATM Strategy from the order.

                Here is a Help Guide link about using Account.Orders -

                Let me know if I may be of further assistance.
                Last edited by NinjaTrader_ChelseaB; 08-10-2020, 12:28 PM.
                Brandon H.NinjaTrader Customer Service


                  thanks for your info.
                  is AtmStrategyClose("idValue"); idValue and GetAtmStrategyMarketPosition("id") id is same? if no, please advice the difference. and it answer is yes, I am getting error saying it does not exists. Please advice.


                    Hello asmmbillah,

                    Thank you for your note.

                    Are these manually placed entries?
                    Or,.are they entries placed through ATM Strategy methods?
                    Or, are they entries placed using the AddOn approach?

                    AtmStrategyClose("idValue") and GetAtmStrategyMarketPosition("id") do utilize the same atmStrategyId value. It is likely that the message you are getting is due to not having generated a unique ID and used it with AtmStrategyCreate().

                    Please reference the AtmStrategyCreate() example to see how GetAtmStrategyUniqueId() generates a unique ID to be used in AtmStrategyCreate(). -

                    If they are manually placed orders, it could be that the correct ID isn't being fetched from the Account.Order Strategy.

                    More information about Account.Order may be found in the Help Guide link here -

                    I look forward to further assisting.

                    Brandon H.NinjaTrader Customer Service


                      thanks for that info. if I want to use AtmStrategyCreate(), I can see "AtmStrategyTemplate", can you please what it should be or how can I get that within my strategy script?


                        Hello asmmbillah,

                        Thank you for your post.

                        An ATM Strategy may be saved as a template that you can recall later to automatically populate all of the ATM Strategy parameters.

                        To save your current ATM Strategy parameters in a template:
                        • Open an order entry window and navigate to the ATM Strategy drop-down menu.
                        • Select the ATM Strategy you want to save from the drop-down menu and click 'edit'.
                        • Select the Save as Template button
                        • From the presented file dialog give the template a custom name, for example, AtmStrategyTemplate.
                        • Select Save.
                        • Select OK.
                        When using AtmStrategyCreate() you are able to specify an ATM Strategy template as a string for strategyTemplateName. "AtmStrategyTemplate" refers to the ATM Strategy template name that is to be used with the AtmStrategyCreate() example in the Help Guide.

                        Please note, the strategyTemplateName must match the name of the ATM Strategy template exactly in order to work.

                        Let us know if we may assist further.
                        Brandon H.NinjaTrader Customer Service


                        Latest Posts


                        Topics Statistics Last Post
                        Started by blar58, Today, 03:16 PM
                        1 response
                        Last Post NinjaTrader_Melissa  
                        Started by alcorr247, Today, 02:52 PM
                        2 responses
                        Last Post robforee2  
                        Started by Radano, Today, 02:30 PM
                        1 response
                        Last Post NinjaTrader_ChrisL  
                        Started by DrummerBoy, Today, 01:34 PM
                        3 responses
                        Last Post NinjaTrader_Clayton  
                        Started by kangethe, Today, 02:11 PM
                        1 response
                        Last Post NinjaTrader_BrandonH