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

ATM strategy called

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

    ATM strategy called

    hello

    I am calling an ATM strategy to place a limit order and it is working fine but i want it to cancel after no fill 1 bar and it is not doing it. I used AtmStrategyCancelEntryOrder("orderId");​and it is not cancelling it. attached is the code. any help is appreciated

    #2
    all i want is that it cancel after no fill.

    Comment


      #3
      Hello babouin77,

      Thanks for your note.

      When using Atm Strategy Methods to place orders, you could cancel a specified entry order by using AtmStrategyCancelEntryOrder().

      To see what the status of an entry order is, you could use GetAtmStrategyEntryOrderStatus(). A condition could be created that checks if the status is "Filled" and AtmStrategyCancelEntryOrder() can be called in that condition to cancel the entry order.

      You could view the SampleAtmStrategy script that comes default with NinjaTrader for an example of using Atm Strategy Methods in a NinjaScript.To view to script, open a New > NinjaScript Editor window, open the Strategies folder, and double-click on the SampleAtmStrategy file.

      See this help guide page for more information and sample code: https://ninjatrader.com/support/help...entryorder.htm

      And, see this help guide page also: https://ninjatrader.com/support/help...rderstatus.htm

      Ultimately, if the script is not behaving as expected, prints would need to be added to the script to see exactly how the strategy is behaving and handling orders.

      Below is a link to a forum post that demonstrates how to use prints to understand behavior.

      https://ninjatrader.com/support/foru...121#post791121

      Let me know if I may assist further.
      Last edited by NinjaTrader_BrandonH; 10-19-2022, 03:31 PM.
      Brandon H.NinjaTrader Customer Service

      Comment


        #4
        you mean i need to use AtmStrategyCancelEntryOrder() and not AtmStrategyCancelEntryOrder("orderId") as I did?

        Comment


          #5
          Wouldn’t that cancel all atms in NT if I don’t use an order id?

          Comment


            #6
            Hello babouin77,

            Thanks for your note.

            You would need to specify the orderId of the entry order when calling the AtmStrategyCancelEntryOrder() method.

            See the first help guide link in post # 2 for more information about using this method as well as sample code. The sample code demonstrates how to check if the entry order exists and the order state is not already cancelled/filled/rejected. I am also linking this help guide page below.

            https://ninjatrader.com/support/help...entryorder.htm

            Please let me know if I may assist further.​
            Brandon H.NinjaTrader Customer Service

            Comment


              #7
              ok i changed my code to this

              if (status.Length > 0 && status[2] == "Working")
              {
              // When entryOrder gets cancelled below in OnOrderUpdate(), it gets replaced with a Market Order via EnterLong()
              AtmStrategyCancelEntryOrder("orderId");
              //AtmStrategyCancelEntryOrder(orderId);
              }​

              i will let you know if it works or not

              Comment


                #8
                it is not working...
                Last edited by babouin77; 10-20-2022, 09:59 AM.

                Comment


                  #9
                  Hell babouin77,

                  Thanks for your note.

                  If a strategy is not behaving as you expect it to, you must add debugging prints to the strategy to determine exactly how the strategy is processing logic and placing trades or canceling trades.

                  In the strategy add prints (outside of any conditions) that print the values of every variable used in every condition that places an order along with the time of that bar.

                  Prints will appear in the NinjaScript Output window (New > NinjaScript Output window).

                  Also, enable TraceOrders which will let us know if any orders are being ignored and not being submitted when the condition to place the orders is evaluating as true.

                  I am happy to assist you with analyzing the output from the output window if you need.

                  Below is a link to a forum post that demonstrates how to use prints to understand behavior.

                  https://ninjatrader.com/support/foru...121#post791121

                  Note that in the support department at NinjaTrader it is against our policy to create, debug, or modify, code or logic for our clients. Further, we do not provide C# programming education services in our support. This is so that we can maintain a high level of service for all of our clients as well as our partners.

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

                  Comment


                    #10
                    yeah i have prints and i can see the output variable and it is just not cancelling the trades. thanks anyway for ur help and hope you guys maintain a high level of service for all your clients by not looking at the code.

                    Comment


                      #11
                      do you have a working example of canceling an ATM strategy in the code? a full code where an ATM strategy is called and then cancelled if no fill in one bar? the sampleatmstrategy provided by NT is helpful but it does not show how to cancel the order if no fill.

                      Comment


                        #12
                        Hello babouin77,

                        Thanks for your note.

                        I have modified and attached a copy of the SampleAtmStrategy script that comes default with NinjaTrader for you to view.

                        The script is modified to cancel the entry order if the order is in a Working state and BarsSinceEntryExecution() is >= 1.

                        See the help guide documentation linked below for more information.
                        GetAtmStrategyEntryOrderStatus(): https://ninjatrader.com/support/help...rderstatus.htm
                        AtmStrategyCancelEntryOrder(): https://ninjatrader.com/support/help...entryorder.htm
                        BarsSinceEntryExecution: https://ninjatrader.com/support/help...yexecution.htm

                        Please let me know if I may assist further.​
                        Attached Files
                        Brandon H.NinjaTrader Customer Service

                        Comment


                          #13
                          thank you for your help in this. i really appreciate it

                          Comment


                            #14
                            Hello babouin77,

                            Thanks for your note.

                            Please see the demonstration video below showing that the modified SampleAtmStrategy does cancel an entry order if the order is working and 1 bar has elapsed since the entry order was placed.

                            https://brandonh-ninjatrader.tinytak...Nl8yMDQyMTc4OQ

                            You could compare the modified SampleAtmStrategy script to your script to see where differences in your script might be.

                            Let me know if I may assist further.
                            Brandon H.NinjaTrader Customer Service

                            Comment


                              #15
                              thank you. yes the modified works great and you have been a great help. appreciate it.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by renner1984, 06-16-2024, 01:50 PM
                              6 responses
                              23 views
                              0 likes
                              Last Post renner1984  
                              Started by hardworkinguy, 02-07-2024, 09:19 PM
                              8 responses
                              413 views
                              0 likes
                              Last Post DavidHunter  
                              Started by ender_wiggum, Today, 07:56 AM
                              6 responses
                              20 views
                              0 likes
                              Last Post ender_wiggum  
                              Started by admiralpanda, 02-16-2024, 06:59 AM
                              2 responses
                              133 views
                              0 likes
                              Last Post pacpac
                              by pacpac
                               
                              Started by Vikuno1, 06-15-2024, 10:22 PM
                              16 responses
                              58 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Working...
                              X