Skip to main content

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

  1. Authenticate with mcp:trade.
  2. Ask the agent to list working orders and identify cancel candidates.
  3. Review the proposed list.
  4. Confirm.
  5. The agent calls Cancel (or CancelOrders / CancelAllOrders) only after your confirmation.
  6. The agent re-lists orders to verify.

Prerequisites

RequirementDetail
CrossTrade subscriptionElite
CrossTrade Add-Onv1.13.0 or higher
MCP clientAny client supporting mcp:trade
Scopemcp:trade
AccountSim101 for the first test
Cancel can leave a position unprotected

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

SymptomFix
403 insufficient_scopeToken is mcp:read; reauthorize at mcp:trade
order_not_foundThe order already filled, rejected, or expired; re-list orders
Partial cancelSome IDs no longer exist; re-list and decide whether to retry