Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 inanazsocial, Today, 01:15 AM
        0 responses
        2 views
        0 likes
        Last Post inanazsocial  
        Started by trilliantrader, 04-18-2024, 08:16 AM
        5 responses
        22 views
        0 likes
        Last Post trilliantrader  
        Started by Davidtowleii, Today, 12:15 AM
        0 responses
        3 views
        0 likes
        Last Post Davidtowleii  
        Started by guillembm, Yesterday, 11:25 AM
        2 responses
        9 views
        0 likes
        Last Post guillembm  
        Started by junkone, 04-21-2024, 07:17 AM
        9 responses
        71 views
        0 likes
        Last Post jeronymite  
        Working...
        X