Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Is it possible to manually cancel some automated orders ?

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

    Is it possible to manually cancel some automated orders ?

    When I have my strategy running ( it only places limit orders with fixed stops and limits), sometimes I dont like some entry so I cancel the order. But when I do this, my strategy gets disabled, so i have to load and set all parameters again.
    Is there any solution for that ? May be some code I should add in OnOrderUpdate() ?

    Regards,
    pmaglio
    NinjaTrader Ecosystem Vendor - The Indicator Store

    #2
    Cancelling an order will not terminate a strategy (pressing CLOSE) could.
    RayNinjaTrader Customer Service

    Comment


      #3
      So, whats wrong ?

      When I cancel one order, my strategy cant place orders again...

      The part of code where i put my orders is :
      ================================================== =====
      if (mode == 1) {
      DrawDot(CurrentBar+"B",0,entrylong ,Color.Blue);
      entryOrder = EnterLongLimit(1, entrylong , "P1");}
      ================================================== =====
      If I cancel this order and mode is still = 1 I only see the dots but the order is not placed again.

      I have this code to monitor order changes
      ================================================== =====
      protected override void OnOrderUpdate(IOrder order)
      {
      if (entryOrder != null && entryOrder.Token == order.Token)
      {
      Print(order.ToString());
      Print(order.OrderState.ToString() );
      if (order.OrderState == OrderState.Filled )
      {entryOrder = null; }
      }
      }
      ================================================== =====
      These 2 print lines print the following when only seeing dots but not placing orders :
      Order='f314514648e14145ba42ee2d7f2a4044/Sim101' Name='P1' State=PendingCancel Instrument='ER2 06-08' Action=Buy Limit price=738.4 Stop price=0 Quantity=1' Type=Limit Tif=Gtc Oco='' Filled=0 Fill price=0 Token='f314514648e14145ba42ee2d7f2a4044' Gtd='01-01-0001 0:00:00'
      PendingCancel
      Order='f314514648e14145ba42ee2d7f2a4044/Sim101' Name='P1' State=Cancelled Instrument='ER2 06-08' Action=Buy Limit price=738.4 Stop price=0 Quantity=1' Type=Limit Tif=Gtc Oco='' Filled=0 Fill price=0 Token='f314514648e14145ba42ee2d7f2a4044' Gtd='01-01-0001 0:00:00'
      Cancelled

      Any idea of what I am doing wrong ?
      pmaglio
      NinjaTrader Ecosystem Vendor - The Indicator Store

      Comment


        #4
        You will have to debug it.

        I guarantee you that the code that creates orders is not being reached. I would speculate that you are NOT setting entryOrder to null if it reaches a cancelled state and you likely have some condition that checks for entryorder == null && ....
        RayNinjaTrader Customer Service

        Comment


          #5
          Cant found the bug !

          I removed almost all, now the entry is just :

          if (mode == 1) {
          DrawDot(CurrentBar+"B",0,entrylong ,Color.Blue);
          EnterLongLimit(1, entrylong , "P1");}


          ...and removed all OnOrderUpdate(IOrder order) section but if I cancel one order, in the next bars i only get dots without new orders.....

          Whats going on ?
          pmaglio
          NinjaTrader Ecosystem Vendor - The Indicator Store

          Comment


            #6
            Sorry, I would not know. You will even have to strip things back more to debug...I realize this is not fun but a necessary part of progamming
            RayNinjaTrader Customer Service

            Comment


              #7
              I found something

              I found that if you cancel a sell order, and at the next onbarupdate() the conditions are the same, so a sell order is submitted, it is ignored.
              It only places a new order if it is a buy or there is a bar without any order.
              Dont know if this is by design but if you have a burst of sell (or buy) orders and you cancel one, to place the next sell (or buy) you need to leave one onbarupdate() without issuing orders.

              Casually it is just the behaviour i was looking for ; if I cancel an order i dont want to do it again at the next bar, so I am only interested in the oposite order or just wait conditions flat ( no orders issued ) to reenter in the same direction.


              The first and real problem was trying to intercept the cancel order with the onorderupdate() when it was unnecessary.

              Regards, and thanks a lot !
              pmaglio
              NinjaTrader Ecosystem Vendor - The Indicator Store

              Comment


                #8
                Yes, by design. If you use orders with the paramter liveUntilCancelled = false, then orders are cancelled if not resubmitted on the following bar.
                RayNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by habeebft, Today, 07:27 AM
                1 response
                13 views
                0 likes
                Last Post NinjaTrader_ChristopherS  
                Started by AveryFlynn, Today, 04:57 AM
                1 response
                12 views
                0 likes
                Last Post NinjaTrader_Erick  
                Started by Max238, Today, 01:28 AM
                4 responses
                37 views
                0 likes
                Last Post Max238
                by Max238
                 
                Started by r68cervera, Today, 05:29 AM
                1 response
                10 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by geddyisodin, Today, 05:20 AM
                1 response
                14 views
                0 likes
                Last Post NinjaTrader_Gaby  
                Working...
                X