NinjaScript > Language Reference > Strategy > Order Methods > Managed Approach >


Print this Topic Previous pageReturn to chapter overviewNext page

Cancels the specified order.


This method is made available for experienced programmers that fully understanding the concepts of advanced order handling
This method sends a cancel request to the broker and does not guarantee that an order is completely cancelled. Most of the time you can expect your order to come back 100% cancelled. An order can be completely filled or part filled in the time that you send the cancel request and the time the exchange receives the request. Check the OnOrderUpdate() method for the state of an order you attempted to cancelled.


CancelOrder(IOrder order)




An IOrder object representing the order you wish to cancel.




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)