How to Flatten NinjaTrader Positions with an AI Agent
Flatten realizes P&L immediately. It is one of the most destructive write actions an agent can take. This tutorial walks the confirmation-gated pattern, the difference between single-instrument and account-wide flatten, and the verification step.
Direct answer
- Authenticate with
mcp:trade. - Ask the agent to list positions and propose a flatten plan.
- Review the plan.
- Confirm.
- The agent calls
Flatten(single instrument) orFlattenEverything(account-wide) only after your confirmation. - The agent re-lists positions to verify the account is actually flat.
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 first tests |
Flatten converts open paper losses into realized losses. On a funded account it can lock the day or violate trailing drawdown immediately. Treat every flatten as a deliberate decision, never as a default reaction to discomfort.
Step 1: Authenticate with mcp:trade
See Use mcp:read vs mcp:trade.
Step 2: Propose a flatten plan
For a single instrument:
ListPositions for <account>. Propose a Flatten plan for <instrument>. Tell me
the current side, quantity, average price, and unrealized P&L. Do not flatten
yet.
For everything in the account:
ListPositions for <account>. Propose a FlattenEverything plan. List every
position that will be closed with current quantities and unrealized P&L. Do
not flatten yet.
Step 3: Review
Read the plan. Make sure:
- The account is the one you intend.
- The instrument list is what you expect.
- The quantities match positions you actually want to close.
Step 4: Confirm
Flatten only <instrument> on <account>. Wait for "go" before calling.
Or:
FlattenEverything on <account>. Wait for "go" before calling.
The agent restates and pauses. Type "go".
Step 5: Verify
After the flatten, ListPositions for <account>. Confirm everything is flat. If
anything is still open, tell me.
FlattenEverything does not always close instantly; a fast market or partial-fill scenario can leave residual quantity. The verification step is non-optional.
Emergency flatten
Even an emergency should not be silent. Use this prompt:
Emergency: flatten <instrument> on <account> as soon as possible. Restate the
action first; I will confirm with "go" within 10 seconds.
The pause is brief but real. A "default to yes" pattern is a recipe for closing the wrong position.
Funded futures notes
- A flatten on a funded account is the agent acting on your behalf. Some firms count this as automation regardless of intent. Verify the firm's automation policy.
- Some firms have EOD-flatten requirements; the agent can remind you and propose, but you should still confirm.
- Trailing-drawdown accounts get hit hard by a flatten at the wrong moment. The agent should report remaining drawdown room as part of the proposal.
Troubleshooting
| Symptom | Fix |
|---|---|
403 insufficient_scope | Reauthorize at mcp:trade |
account_disconnected | Reconnect the account in NT8 |
| Residual position after flatten | Re-list positions; manual cleanup may be needed |
Related
- Docs: FlattenEverything and Flatten
- Learn: Cancel Orders with AI
- Learn: Trade-Enabled AI Agent Workflows
- Learn: Prop Firm Risk Checklist with AI