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

Close atm strategy

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

    Close atm strategy

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

    #2
    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() - https://ninjatrader.com/support/help...ategyclose.htm

    Also, here is a Help Guide link about ATM Strategy close behavior - https://ninjatrader.com/support/help...r_atm_stra.htm

    Please let us know if we may further assist.

    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      Thanks for your reply. from the guide I can see you suggest to use
      AtmStrategyClose("idValue");

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

      Comment


        #4
        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 - https://ninjatrader.com/support/help...gyuniqueid.htm

        Also, here is a Help Guide link about manually closing an ATM Strategy using the Close button - https://ninjatrader.com/support/help...strategies.htm

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

        Comment


          #5
          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.

          Comment


            #6
            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 - https://ninjatrader.com/support/help...tegycreate.htm

            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 - https://ninjatrader.com/support/foru...ategyid-needed

            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

            Comment


              #7
              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.

              Comment


                #8
                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 - https://ninjatrader.com/support/help...rs_account.htm

                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

                Comment


                  #9
                  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.

                  Comment


                    #10
                    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(). - https://ninjatrader.com/support/help...tegycreate.htm

                    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 - https://ninjatrader.com/support/help...nt8/?order.htm

                    I look forward to further assisting.

                    Brandon H.NinjaTrader Customer Service

                    Comment


                      #11
                      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?

                      Comment


                        #12
                        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

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by jclose, Today, 09:37 PM
                        0 responses
                        5 views
                        0 likes
                        Last Post jclose
                        by jclose
                         
                        Started by WeyldFalcon, 08-07-2020, 06:13 AM
                        10 responses
                        1,414 views
                        0 likes
                        Last Post Traderontheroad  
                        Started by firefoxforum12, Today, 08:53 PM
                        0 responses
                        11 views
                        0 likes
                        Last Post firefoxforum12  
                        Started by stafe, Today, 08:34 PM
                        0 responses
                        11 views
                        0 likes
                        Last Post stafe
                        by stafe
                         
                        Started by sastrades, 01-31-2024, 10:19 PM
                        11 responses
                        169 views
                        0 likes
                        Last Post NinjaTrader_Manfred  
                        Working...
                        X