Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

NinjaScript cancel targets of an ATM strategy

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

    NinjaScript cancel targets of an ATM strategy

    Is there any way to cancel the stop/target orders of an atm strategy in NinjaScript?

    I am trying to implement a reversing strategy using atm's. I created an atm with twice the share amount of the currently active trade, and when the market hits my stop/limit order on the reversing ATM order, it will reverse my position by entering the market with 2 times the shares in the opposite direction thereby reversing my trade.

    The problem is, once the reversal trade happens, I have left over stop/target orders from the previous trade that cannot be canceled within NinjaScript. ATMStrategyClose() does not help because it does not realize that the original position shares have been exited, and it tries to close the original order by moving the original target to get executed at market, which now erroneously doubles my position in the opposite direction.

    Once my order is reversed, I would like to simply cancel the stop/target orders of the original position. Is there any way to cancel the stop/target orders of an atm strategy in NinjaScript?
    Last edited by monpere; 01-21-2012, 09:39 AM.

    #2
    monpere,

    I am happy to assist you.

    You can use OnExectution() and OnOrderUpdate() to get the IOrder object for stop loss and profit target orders, then you can manage them as you see fit.

    For more information, please see the following links.







    Please let me know if I may assist further.
    Adam P.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_AdamP View Post
      monpere,

      I am happy to assist you.

      You can use OnExectution() and OnOrderUpdate() to get the IOrder object for stop loss and profit target orders, then you can manage them as you see fit.

      For more information, please see the following links.







      Please let me know if I may assist further.
      I was under the impression that OnExectution() and OnOrderUpdate() only came into play for orders triggered by EnterLong(), EnterShort() family of standard order methods. Are OnExectution(), OnOrderUpdate(), OnPosistionUpdate() triggered from orders initiated by AtmStrategyCreate() family of ATM methods as well?

      Comment


        #4
        Monpere,

        Yes, you are correct. Apologies for overlooking your ATM strategy portion. Do you have your strategy to post so I may replicate this?

        I look forward to helping you resolve your issues.
        Adam P.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_AdamP View Post
          Monpere,

          Yes, you are correct. Apologies for overlooking your ATM strategy portion. Do you have your strategy to post so I may replicate this?

          I look forward to helping you resolve your issues.
          I can't share my strategy. All you have to do is create 2 ATM strategies, and use AtmStrategyCreate() to enter long with one ATM, and use AtmStrategyCreate() again to reverse with the other strategy. You sill see that the original stop/targets remain, and they can only be canceled manually.

          Comment


            #6
            Monpere,

            I will attempt to replicate and see if I can explain, or find a work around.

            I will get back to you as soon as possible.
            Adam P.NinjaTrader Customer Service

            Comment


              #7
              Monpere,

              Are you using market orders?

              When I use AtmStrategyClose() I can get it to open the correct ATM strategy in the opposite direction. The issue is you need to wait until after you verify that the ATM strategy is indeed no longer active.
              Last edited by NinjaTrader_AdamP; 01-23-2012, 09:44 AM.
              Adam P.NinjaTrader Customer Service

              Comment


                #8
                Originally posted by NinjaTrader_AdamP View Post
                Monpere,

                Are you using market orders?

                When I use AtmStrategyClose() I can get it to open the correct ATM strategy in the opposite direction. The issue is you need to wait until after you verify that the ATM strategy is indeed no longer active.
                I am using stop/limit orders. I do not want to use market orders. AtmStrategyClose() closes a position by moving the target to become a market order, so I cannot use AtmStrategyClose(). I want to reverse the position at an exact price, so I reverse it with a stop/limit order with 2 times the share/contract size.

                Both ATM strategies open properly in both directions. The issue is with the stop and target orders of the original ATM strategy that remain working in the market after the position is reversed, and the only way to cancel those original stop/target orders is to cancel them manually. I need to be able to cancel them using NinjaScript.
                Last edited by monpere; 01-23-2012, 09:57 AM.

                Comment


                  #9
                  Monpere,

                  Are you submitting a limit/stop for a sell and buy simultaneously?

                  When you use AtmStrategyClose() it will cancel the entire ATM strategy. You mentioned before you are having your position doubled doing so, however if you are careful and wait to verify that the ATM strategy has completed its closing method, you should be able to submit a new ATM strategy order in the opposite direction.

                  Please let me know if I may assist further.
                  Last edited by NinjaTrader_AdamP; 01-23-2012, 11:14 AM.
                  Adam P.NinjaTrader Customer Service

                  Comment


                    #10
                    Originally posted by NinjaTrader_AdamP View Post
                    Monpere,

                    Are you submitting a limit/stop for a sell and buy simultaneously?

                    When you use AtmStrategyCancel() it will cancel the entire ATM strategy. You mentioned before you are having your position doubled doing so, however if you are careful and wait to verify that the ATM strategy has completed its closing method, you should be able to submit a new ATM strategy order in the opposite direction.

                    Please let me know if I may assist further.
                    I don't know of an AtmStrategyCancel() method, I know about the AtmStrategyCancelEntryOrder() which does not do anything, because after the order is reversed for the original trade, there is no more entry order for that original ATM in the market, there is only the original stop order and the original target order left, and they cannot be canceled with ninjascript.

                    Here's the other of events:
                    1. Create ATM stopLimit order A, Long 100 shares, it gets filled, and stopA, targetA are placed
                    2. Create ATM stopLimit order B, Short 200 shares, it gets filled, and stopB, targetB are placed
                    3. Now we are short 100 shares as a result of order B
                    4. Also at this point we have the following orders in the market: entryB (100 shares), stopB, targetB, as well as stopA and targetA.

                    What I want to do now, is get rid of stopA, and targetA left over from the original long position.
                    Last edited by monpere; 01-23-2012, 11:03 AM.

                    Comment


                      #11
                      Monpere,

                      Apologies, I am referring to AtmStrategyClose(),



                      I would suggest incorporating this.

                      If you simply create an ATM strategy with a long position, then create a ATM strategy with a short position, you will have 2 separate ATM strategies working. As such the behavior you describe is to be expected. You need to close the prior ATM strategy if you want to open another one.

                      Please let me know if I may assist further.
                      Last edited by NinjaTrader_AdamP; 01-23-2012, 11:38 AM.
                      Adam P.NinjaTrader Customer Service

                      Comment


                        #12
                        If I have a stop limit in and I close my control panel, is that "stop limit" held at the exchange, other words if I want a stop in overnight because I have a position on, do I have to leave my control panel up and live and conneceted to my broker in order for the stop to be "live" ?

                        Thanks

                        Comment


                          #13
                          mcorbett,

                          This depends on your data provider.

                          Please see the following link : http://www.ninjatrader.com/support/f...ead.php?t=5349

                          Please let me know if I may assist further.
                          Adam P.NinjaTrader Customer Service

                          Comment


                            #14
                            Originally posted by NinjaTrader_AdamP View Post
                            Monpere,

                            Apologies, I am referring to AtmStrategyClose(),



                            I would suggest incorporating this.

                            If you simply create an ATM strategy with a long position, then create a ATM strategy with a short position, you will have 2 separate ATM strategies working. As such the behavior you describe is to be expected. You need to close the prior ATM strategy if you want to open another one.

                            Please let me know if I may assist further.
                            I guess the only alternative to do what I want is to use Unmanaged orders.

                            Comment


                              #15
                              monpere,

                              You can also cancel the ATM strategy, then wait for verification its closed. After, resubmit an opposite order.

                              Please let me know if I may assist further.
                              Adam P.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by WHICKED, Today, 12:45 PM
                              2 responses
                              18 views
                              0 likes
                              Last Post WHICKED
                              by WHICKED
                               
                              Started by GussJ, 03-04-2020, 03:11 PM
                              15 responses
                              3,276 views
                              0 likes
                              Last Post xiinteractive  
                              Started by Tim-c, Today, 02:10 PM
                              1 response
                              8 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by Taddypole, Today, 02:47 PM
                              0 responses
                              4 views
                              0 likes
                              Last Post Taddypole  
                              Started by chbruno, 04-24-2024, 04:10 PM
                              4 responses
                              51 views
                              0 likes
                              Last Post chbruno
                              by chbruno
                               
                              Working...
                              X