> 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.

# CancelAllOrders()

## Definition

Cancels all orders for the specified instrument on the connection.

## Syntax

`\<connection\>.CancelAllOrders(Instrument instrument)`

| Name       | Description                                                                     |
| ---------- | ------------------------------------------------------------------------------- |
| instrument | An Instrument object used to identify the instrument for which to cancel orders |

## Examples

```csharp
private Account myAccount;

protected override void OnStateChange()
{
    if (State == State.SetDefaults)
    {
        // Initialize myAccount
    }
}

private void OnExecutionUpdate(object sender, ExecutionEventArgs e)
{
    // Cancel all orders if an execution is triggered after 9pm
    if (e.Time > new DateTime(now.Year, now.Month, now.Day, 21, 0, 0))
        myAccount.CancelAllOrders(e.Execution.Instrument);
}
```