Announcement

Collapse
No announcement yet.

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.
      <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

      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.​
            <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

            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.​​
                  <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

                  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
                        <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

                        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.
                            <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

                            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 NinjaTrader_Brett, Yesterday, 03:19 PM
                              0 responses
                              145 views
                              0 likes
                              Last Post NinjaTrader_Brett  
                              Started by domjabs, Yesterday, 01:55 PM
                              2 responses
                              31 views
                              0 likes
                              Last Post domjabs
                              by domjabs
                               
                              Started by Morning Cup Of Trades, Yesterday, 11:50 AM
                              1 response
                              33 views
                              0 likes
                              Last Post NinjaTrader_ChristopherJ  
                              Started by imjustkaze, Yesterday, 12:20 PM
                              2 responses
                              68 views
                              0 likes
                              Last Post imjustkaze  
                              Started by IanS00, Yesterday, 11:57 AM
                              3 responses
                              22 views
                              0 likes
                              Last Post NinjaTrader_LuisH  
                              Working...
                              X