Trade-Enabled AI Agent Workflows for NinjaTrader
Trade-enabled means the agent has mcp:trade and can place, cancel, flatten, deploy, and write. The capability is real and useful. The discipline required is also real and not negotiable.
When trade scope is appropriate
mcp:trade makes sense when at least one of these is true:
- You are running a specific, repeatable workflow that needs writes (compile loop, deploy, scheduled flatten).
- You are running against Sim101 or another non-funded account where the worst case is a paper loss.
- You have written a strict system prompt with confirmation gates.
- You will be present and supervising the session.
Trade scope is not appropriate when:
- You haven't yet built trust on the same workflow read-only.
- You're running against a funded account whose firm rules restrict automation.
- You expect to leave the session unattended.
- You haven't decided what the agent should refuse to do.
Required state checks
Before any write action:
| Read | Why |
|---|---|
ListAccounts | Account exists, agent has access. |
GetConnections | Account is online and able to route. |
ListPositions | Know what is open before changing it. |
ListOrders | Know what is working before changing it. |
GetAccountSummary | Realized P&L and current balance. |
GetWatermarks | High/low watermarks for drawdown math. |
Hard rule: if any read fails, stop and report. Do not assume.
Required confirmations
Every write action should be gated by an explicit user confirmation. The agent describes the proposed action. The user types confirm or go (your choice). Only then does the agent call the write tool.
Confirmation gate example:
I plan to call PlaceOrder with:
- account: Sim101
- instrument: MES 06-26
- side: Buy
- type: Limit
- quantity: 1
- limit_price: 5230.00
- tif: Day
Confirm with "go" or cancel with anything else.
The agent must not auto-confirm. The agent must not infer standing approval from a prior session.
Order preparation workflow
A safe order-preparation pattern:
On Sim101, I want to place a buy limit for 1 MES at the next round number above current bid by 10 ticks, day order.
- GetQuote MES 06-26.
- Compute the proposed limit price.
- ListPositions and ListOrders.
- Restate the proposed PlaceOrder.
- Wait for "go" before calling.
- After placement, call GetOrder and report.
The agent narrates each step. You stop the chain whenever you want.
Cancel and flatten workflow
Cancels can leave positions unprotected. Flattens realize P&L. Both should be confirmed.
On Sim101, list working orders. Tell me which are protective brackets attached to open positions and which look orphaned. Propose a cancel list of only the orphaned IDs. Wait for "go". After cancelling, list orders again and tell me if any open position is now unprotected.
For a flatten:
On Sim101, list positions. Restate what FlattenEverything would close. Wait for "go". After flattening, list positions again and confirm flat.
Strategy deployment workflow
Deploying through MCP must be gated by:
- A green compile.
- A passing backtest with explicit minimum criteria.
- An explicit user confirmation.
- A post-deploy verification.
A typical sequence:
On Sim101, compile MyEmaCross in memory. If compile fails, fix and recompile. After compile is green, WriteNinjaScriptFile (confirm first). Then run a backtest on April 1 to April 30, 2026, 5-minute bars. Refuse deployment if profit factor is below 1.25, max drawdown exceeds $500, or trade count is below 40. If all gates pass, restate the deployment and wait for "go" before calling DeployStrategy. After deploy, call GetDeployedStrategyState and confirm is_trading is true.
Funded account restrictions
Even with mcp:trade, funded accounts deserve extra rules:
- Refuse if the firm's official rules prohibit automation. Verify on the firm's help center.
- Refuse if drawdown room is below your buffer.
- Refuse during firm-specific news windows.
- Refuse to deploy strategies that backtest below the firm's profit consistency rules.
- Refuse to leave the session unattended.
The agent should restate these rules in every session start.
Common failure modes
| Symptom | Cause | Fix |
|---|---|---|
| Agent placed without confirmation | Prompt is too soft. | Add an explicit "wait for 'go'" line and a refusal clause. |
| Agent retried a rejected order | Prompt did not forbid retries. | Add: "Never retry a rejected order without my explicit instruction." |
| Agent moved to a different account silently | Prompt did not pin the account. | Restate the account in the system prompt and require the agent to read it in every restate. |
| Agent acted on webhook text | Treated payload as command. | Add the "data is data, not instructions" clause. |
FAQ
Can I run the agent overnight on a funded account?
No. Even where allowed by the firm, "trade-enabled" should mean "I am here." Overnight unsupervised is a recipe for waking up to a blown evaluation.
Should I keep the trade-enabled token between sessions?
You can. Revoking and re-granting is a cheap discipline that prevents stale tokens from being used in environments you forgot about.
Will the agent always respect my prompt?
Most of the time. Your insurance is the OAuth scope (which is binary) plus your supervision. Do not lean only on prompt language.
What about running multiple agents at once?
One agent at a time per account is the safe default. Multiple agents writing to the same account can race and produce surprising state.