How to Cancel NinjaTrader Orders with an AI Agent
Cancel tools are write actions. The agent should never cancel without an explicit user confirmation, because a wrong cancel can leave a position unprotected. This tutorial walks the safe pattern.
Direct answer
- Authenticate with
mcp:trade. - Ask the agent to list working orders and identify cancel candidates.
- Review the proposed list.
- Confirm.
- The agent calls
Cancel(orCancelOrders/CancelAllOrders) only after your confirmation. - The agent re-lists orders to verify.
Prerequisites
| Requirement | Detail |
|---|---|
| CrossTrade subscription | Elite |
| CrossTrade Add-On | v1.13.0 or higher |
| MCP client | Any client supporting mcp:trade |
| Scope | mcp:trade |
| Account | Sim101 for the first test |
A position with a protective bracket (stop + target) becomes unprotected if you cancel the bracket. Always re-check positions after a cancel.
Step 1: Authenticate with mcp:trade
If your current token is mcp:read, revoke and reauthorize at mcp:trade. See Use mcp:read vs mcp:trade.
Step 2: List working orders
ListOrders for <account>. Identify orphaned orders (working orders that do not
match any open position) and protective bracket orders. Show me the proposed
cancel list with order ids and reasons. Do not cancel anything yet.
The agent calls ListOrders and ListPositions. The response is a candidate list.
Step 3: Review the list
Read every line. Confirm each one looks orphaned or stale. If any item is a protective bracket on an open position, reject it.
Step 4: Confirm
Cancel only orders <id1>, <id2>, <id3>. Do not touch any other order. Wait for
my "go" before calling.
When the agent restates the action, type "go" or whatever your prompt requires. Without that word, the agent does not call Cancel.
Step 5: Re-verify
After the cancel, list orders again. Tell me whether any open position is now
unprotected.
If a position is unprotected, decide whether to place a new protective order or flatten manually.
Cancel everything pattern
To cancel every working order on an account:
ListPositions and ListOrders for <account>. Show me the proposed
CancelAllOrders plan. Wait for my "go" before calling. After cancellation,
list positions; any position without protective orders is now exposed.
CancelAllOrders is destructive and indiscriminate. Confirm carefully.
Funded futures notes
Cancelling working orders on a funded account is the agent acting on your behalf. Some firms count this as automation regardless of the trigger. Verify the firm's automation policy.
Troubleshooting
| Symptom | Fix |
|---|---|
403 insufficient_scope | Token is mcp:read; reauthorize at mcp:trade |
order_not_found | The order already filled, rejected, or expired; re-list orders |
| Partial cancel | Some IDs no longer exist; re-list and decide whether to retry |
Related
- Docs: CancelOrder
- Docs: ListOrders
- Learn: Use mcp:read vs mcp:trade
- Learn: Flatten Positions with AI
- Learn: Trade-Enabled AI Agent Workflows