Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to cancel limit orders that don't fill

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

    How to cancel limit orders that don't fill

    I did the "Enter Long Limit @ Ask" / "Exit Long Limit @ Bid" in the strategy wizard...

    is there something to add to cancel limit orders that don't fill? Maybe cancel them in x second after the order?

    #2
    Hello crimsonite,
    Thanks for writing in and I am happy to assist you.

    Unfortunately you cannot cancel an order via the Strategy Wizard.

    To cancel an order you have to unlock the code and edit the code via the NinjaScript editor.

    To cancel any order you can use the CancelOrder function http://www.ninjatrader.com/support/h...ancelorder.htm

    Please let me know if I can assist you any further.
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      Unlocking the code is fine. Thanks for the pointer -

      is it possible to enter a piece of code that will allow the order to cancel or fill immediately?

      Comment


        #4
        Hello crimsonite,
        Yes, you can custom code to cancel the order as per your requirement. For example in the help file sample code the limit order is cancelled if it is not filled within the next 5 bars.

        Code:
        private IOrder myEntryOrder = null;
        private int barNumberOfOrder = 0;
         
        protected override void OnBarUpdate()
        {
            // Submit an entry order at the low of a bar
            if (myEntryOrder == null)
            {
                 myEntryOrder = EnterLongLimit(0, true, 1, Low[0], "Long Entry");
                 barNumberOfOrder = CurrentBar;
            }
         
            // If more than 5 bars has elapsed, cancel the entry order
            if (CurrentBar > barNumberOfOrder + 5)
                 CancelOrder(myEntryOrder);
        }



        Please let me know if I can assist you any further.
        JoydeepNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by CarlTrading, 03-31-2026, 09:41 PM
        1 response
        152 views
        1 like
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        89 views
        1 like
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        131 views
        2 likes
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        127 views
        1 like
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        107 views
        0 likes
        Last Post CarlTrading  
        Working...
        X