> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.ninjatrader.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.ninjatrader.com/_mcp/server.

# Using CancelOrder() method to cancel orders

When using NinjaTrader's Entry and Exit methods, the default behavior is to automatically expire them at the end of a bar unless they are resubmitted to keep them alive. Sometimes you may want more flexibility in this behavior and wish to submit orders as live-until-cancelled. When orders are submitted as live-until-cancelled, the way to cancel them is by using the [CancelOrder()](/developer/desktop-sdk/references/strategy/order-methods/managed-approach/cancelorder) method.

## Key concepts in this example

* Submitting live-until-cancelled entry orders
* Manually cancelling orders

## Important related documentation

* [CancelOrder()](/developer/desktop-sdk/references/strategy/order-methods/managed-approach/cancelorder)
* [Order](/developer/desktop-sdk/references/strategy/order)
* [OnOrderUpdate()](/developer/desktop-sdk/references/strategy/onorderupdate)
* [OnExecutionUpdate()](/developer/desktop-sdk/references/strategy/onexecutionupdate)
* [EnterLongLimit()](/developer/desktop-sdk/references/strategy/order-methods/managed-approach/enterlonglimit)

## Import instructions

1. Download the file contained in this Help Guide topic to your PC desktop
2. From the Control Center window, select the menu Tools > Import > NinjaScript
3. Select the downloaded file

[SampleCancelOrder\_NT8.zip](https://ninjatrader.com/support/helpGuides/nt8/samples/SampleCancelOrder_NT8.zip)