Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Cancel Limit Order at particular time

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

    Cancel Limit Order at particular time

    Trying to cancel a limit order by 9am. From what I see it doesn't know what to cancel...

    if (orderId.Length == 0 && atmStrategyId.Length == 0 && Close[0] > Open[0])
    {
    atmStrategyId = GetAtmStrategyUniqueId();
    orderId = GetAtmStrategyUniqueId();
    AtmStrategyCreate(Action.Buy, OrderType.Limit, Low[0], 0, TimeInForce.Day, orderId, "AtmStrategyTemplate", atmStrategyId);
    }

    // If 9:00AM and the order has not been filled, cancel the entry order
    if (CurrentBar == ToTime(09, 00, 00))
    {
    CancelOrder(Limit);
    }

    #2
    Please use AtmStrategyCancelEntryOrder() for this - http://www.ninjatrader-support.com/H...egyActive.html

    Comment


      #3
      Originally posted by NinjaTrader_Bertrand View Post
      Please use AtmStrategyCancelEntryOrder() for this - http://www.ninjatrader-support.com/H...egyActive.html

      So if the ordered was filled will it cancel that? I only want it canceled if it was never filled.

      Comment


        #4
        Not sure I follow - if the order was filled, then there's nothing to cancel, only to 'close'. This will cancel placed entry orders generated by the AtmStrategyCreate().

        Comment


          #5
          Originally posted by NinjaTrader_Bertrand View Post
          Not sure I follow - if the order was filled, then there's nothing to cancel, only to 'close'. This will cancel placed entry orders generated by the AtmStrategyCreate().

          Ahh got it thanks Bertrand.

          Comment


            #6
            Originally posted by NinjaTrader_Bertrand View Post
            Please use AtmStrategyCancelEntryOrder() for this - http://www.ninjatrader-support.com/H...egyActive.html

            Tried it but would not cancel the order...

            // If 9:00AM and the order has not been filled, cancel the entry order
            if (CurrentBar == ToTime(09, 00, 00))
            {
            AtmStrategyCancelEntryOrder("orderId");
            }

            Comment


              #7
              CurrentBar represents the bar count, so unfortunately it would not work comparing to time stamp values this way, please try this -
              Code:
               
              if (ToTime(Time[0]) == 090000)
              AtmStrategyCancelEntryOrder("orderId");

              Comment


                #8
                Originally posted by NinjaTrader_Bertrand View Post
                CurrentBar represents the bar count, so unfortunately it would not work comparing to time stamp values this way, please try this -
                Code:
                 
                if (ToTime(Time[0]) == 090000)
                AtmStrategyCancelEntryOrder("orderId");

                Nope didn't work... Does it not know how to find orderId?

                I made sure I recompiled.
                Last edited by m3power222; 06-25-2009, 09:05 AM. Reason: Additional info

                Comment


                  #9
                  Don't use the quotes. Your string is the orderId variable.
                  Josh P.NinjaTrader Customer Service

                  Comment


                    #10
                    Originally posted by NinjaTrader_Josh View Post
                    Don't use the quotes. Your string is the orderId variable.
                    Thank you that worked.

                    Comment


                      #11
                      How would I get the bool's to go to false only if there was a ATMStratCancelEntryOrder?

                      If the trade wasn't filled by 9am it cancels and I don't want to take any more trades.

                      But if there was nothing to cancel at 9am I'd still want to take a trade so wouldn't want the bool's to go to false as entry logic is looking for true to place a trade.


                      private bool entrylong = true;
                      private bool entryshort = true;

                      // If 9:00AM and the order has not been filled, cancel the entry order
                      if (ToTime(Time[0]) == 090000)
                      {
                      AtmStrategyCancelEntryOrder(orderId);
                      entrylong = false;
                      entryshort = false;
                      }
                      Last edited by m3power222; 06-25-2009, 11:29 AM. Reason: Add info

                      Comment


                        #12
                        Hi, you can check the ATM Entry order state with GetAtmStrategyEntryOrderStatus() - http://www.ninjatrader-support.com/H...derStatus.html

                        Then set your bools according to if an order is placed and potentially cancelled or not and you want to take a trade after 9:00

                        Comment


                          #13
                          Originally posted by NinjaTrader_Bertrand View Post
                          Hi, you can check the ATM Entry order state with GetAtmStrategyEntryOrderStatus() - http://www.ninjatrader-support.com/H...derStatus.html

                          Then set your bools according to if an order is placed and potentially cancelled or not and you want to take a trade after 9:00
                          Getting an error with:

                          // If 9:00AM and the order has not been filled, cancel the entry order
                          if (ToTime(Time[0]) == 090000
                          && GetAtmStrategyEntryOrderStatus("orderId") > 0)
                          {
                          AtmStrategyCancelEntryOrder(orderId);
                          entrylong = false;
                          entryshort = false;
                          }

                          Comment


                            #14
                            Please retry again without the quotes for your first orderId.

                            Comment


                              #15
                              Originally posted by NinjaTrader_Bertrand View Post
                              Please retry again without the quotes for your first orderId.

                              Now the error is: Operator > cannot be applied to operands of type string and int.

                              What about this?

                              // If 9:00AM and the order has not been filled, cancel the entry order
                              if (ToTime(Time[0]) == 090000
                              && orderId.Length > 0)
                              {
                              AtmStrategyCancelEntryOrder(orderId);
                              entrylong = false;
                              entryshort = false;
                              }
                              Last edited by m3power222; 06-25-2009, 12:54 PM. Reason: add

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              648 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              369 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              108 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              572 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              573 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X