AI trading agents for NinjaTrader 8.
Point Claude, ChatGPT, Cursor, or any MCP client at NinjaTrader 8 and let it act as a trading agent. Your agent writes the NinjaScript, compiles it, backtests through NT8's actual Strategy Analyzer engine, sweeps parameters, deploys the winner, and monitors the live state — all in one conversation. No C# experience required.
CrossTrade owns the entire agent loop: inspect → write → compile → backtest → optimize → deploy → verify. Every step is one typed MCP tool call. You set the gates. The agent does the work.
You shouldn't have to learn C# to backtest a hypothesis
NinjaScript is a great execution environment for live trading. It is a terrible place to iterate on ideas by hand. You have to compile, attach to a chart, configure Strategy Analyzer, click around for parameters, wait, read a results panel that's locked inside the desktop app, then translate everything back into a hypothesis you can adjust. An AI trading agent on the MCP Trading API collapses that loop into a chat session.
Write a simple ATR-trailing-stop strategy on MES that goes long when the 9-EMA crosses above the 21-EMA. Backtest April 2026, 5-minute bars. Sweep ATR from 1.5 to 3.0 in 0.25 steps. Tell me the best parameters by NetProfit, then run a full backtest with those and show me every trade.
I'll inspect NT8's actual EMA / ATR signatures first, compile in memory, write the strategy, run the sweep, then drill into the winner.
→ GetNinjaScriptHelp · LookupNinjaScriptSymbol(EMA) · CompileNinjaScript(in_memory:true) · WriteNinjaScriptFile
→ RunStrategyBacktest with optimization.parameters_sweep: [{name:"AtrStop", min:1.5, max:3.0, step:0.25}]
→ 7 iterations completed in 2.1s. Best: AtrStop=2.25, NetProfit $1,420, ProfitFactor 1.34, 89 trades.
→ Full single-backtest with AtrStop=2.25, returning every trade.
What your trading agent can do
Every tool here is exposed through the Model Context Protocol. Any MCP-compatible AI client (Claude, ChatGPT, Cursor, Continue, Cline) can call them with the user's permission.
Write NinjaScript with AI
Your agent pulls the real signatures from your NT8 install (not stale training data) and writes C# that compiles on the first or second try. Pre-flight syntax checks happen in memory before anything lands on disk.
AGENTICBacktest 1:1 with NT8
RunStrategyBacktest drives Strategy.RunBacktest() through NT8's actual Strategy
Analyzer engine. The trades and metrics are bit-identical to what you'd see in NT8's UI.
Verified against SampleMACrossOver on MES: $800 NetProfit, profit factor 1.14, 264 trades.
AI parameter sweeps
Pass an optimization.parameters_sweep argument and your agent cartesian-enumerates
every combination. Results return ranked best-first with the winning parameters in a top-level
best callout. 41 NT8 fitness functions resolve by name.
Deploy + monitor
The same parameters your agent backtested with go straight into DeployStrategy. The MCP
deployment registry tracks every strategy your agent has launched, and GetDeployedStrategyState
returns the live NT8 state (trading? active orders? bar count?) on demand.
See your real risk
Account balances, open positions, working orders, executions, daily watermarks, and quote snapshots are all available as MCP tools. Build prompts that refuse to deploy if drawdown is too deep or the position would breach a prop-firm limit.
SAFETYAlert through your channels
EmitMcpAlert routes agent-generated alerts through your in-app notifications,
email, Discord, or Telegram. Build prompts that ping you when a backtest finishes, a sweep
identifies a winner, or a deployed strategy reaches a threshold.
The full idea → live agent loop
Every step is one MCP tool call. The AI sequences them. You approve the gates.
Inspect
GetMcpCapabilities, LookupNinjaScriptSymbol,
SearchNinjaScriptSymbols, GetNinjaScriptHelp.
Your agent reads the actual NinjaTrader surface available in your install.
Write
The agent encodes your hypothesis as NinjaScript. Idiomatic C#, sized for the NT8 version it just inspected. No copy-pasted templates from training data.
Compile
CompileNinjaScript(in_memory:true) validates syntax against the running
NT8 AppDomain. Fully isolated until you approve writing the file.
Backtest
RunStrategyBacktest runs the strategy through NT8's Strategy Analyzer engine.
Same trades, same metrics, same fills as the desktop UI.
Optimize
Pass optimization.parameters_sweep to enumerate every parameter combination.
Results sorted best-first by NetProfit with a best callout.
Deploy
DeployStrategy launches the compiled strategy headlessly or attaches it to a
chart. GetDeployedStrategyState verifies it actually reached active state.
We verified the engine
You shouldn't trust an AI trading agent (or its backtest engine) just because a marketing page says so. Here are the actual numbers — same configuration run through NT8's UI and through MCP — that prove parity.
Reference run: SampleMACrossOver (ships with NT8) on MES 06-26, 5-minute bars, April 1–30, 2026, Fast=10, Slow=25, Sim101 account, no commission, 0 slippage. Same configuration in both places.
What the wire actually looks like
You probably won't write these by hand. Your trading agent does. But here's what your agent is sending.
{
"method": "tools/call",
"params": {
"name": "RunStrategyBacktest",
"arguments": {
"strategy_class": "MyEma20Reversal",
"instrument": "MES 06-26",
"bars_period": {"period_type": "Minute", "value": 5},
"from": "2026-04-01T00:00:00Z",
"to": "2026-04-30T00:00:00Z",
"parameters": {"Quantity": 1, "StopAtrMultiplier": 2.25},
"fill": {"slippage_ticks": 0}
}
}
} {
"method": "tools/call",
"params": {
"name": "RunStrategyBacktest",
"arguments": {
"strategy_class": "MyEma20Reversal",
"instrument": "MES 06-26",
"bars_period": {"period_type": "Minute", "value": 5},
"from": "2026-04-01T00:00:00Z",
"to": "2026-04-30T00:00:00Z",
"optimization": {
"fitness": "MaxNetProfit",
"parameters_sweep": [
{"name": "StopAtrMultiplier", "min": 1.5, "max": 3.0, "step": 0.25},
{"name": "TargetRatio", "min": 1.0, "max": 2.0, "step": 0.25}
]
}
}
}
} A real agent prompt
You don't issue tool calls one at a time. You write one prompt and let the agent sequence dozens of calls inside your guardrails. Drop this into Claude Desktop, Claude Code, Cursor, or any MCP client connected to CrossTrade and watch the full loop run.
I'm in an Apex $50k evaluation on APEX1234 with about $200 of daily loss room left. Defensive ideas only.
1. Inspect the account first. If current risk is already too high, stop.
2. Research a one-contract MES morning scalper. Time filter, no averaging, ATR stop, target ≤ 1.5R, max two trades per session, hard daily lockout.
3. Write the NinjaScript. Compile in memory. Only write the file when compile is green.
4. Backtest 60 days. Gate: PF > 1.25, MaxDD < $350, trades > 40. If any gate fails, stop.
5. Sweep stop multiplier and target ratio. Show top three. Re-run a single full-detail backtest on the winner.
6. Ask me to confirm before DeployStrategy. After deploy, GetDeployedStrategyState. Confirm is_trading.
7. EmitMcpAlert(deployment_started) so I get a notification.
See the full prompt library for account-risk agents, market-research agents, NinjaScript authoring agents, and operational shutdown agents.
Honest limitations
Most "AI for trading" marketing pages would skip this section. We won't. Here are the constraints you'll actually run into building trading agents on CrossTrade MCP.
- Optimization is cartesian. Pass
optimizationand the agent enumerates every combination.GeneticOptimizerandStrategyGeneratornames are accepted but the iteration loop is exhaustive. You get every point in the grid, ranked by NetProfit. Fitness-specific ranking and genuine genetic search are on the roadmap. - Sweep parameter types. Only int / long / double / float / decimal are sweepable.
Boolean and enum strategy inputs can still be fixed via the
parametersargument. - NT8 must be running. The MCP server is hosted, but it talks to your NT8 desktop over the CrossTrade add-on. If NT8 is offline, agent tools return a clear error instead of inventing fake data.
- Elite + Add-On v1.13.0+. The Elite gate is enforced at token issuance. REST and WebSocket access remain on Pro, but trading agents on MCP need Elite.
- Async jobs. Backtests and compiles return a
job_idand complete asynchronously. Your agent pollsGetMcpJobfor progress. Jobs auto-expire after 30 minutes. - Live trades are real. MCP tools can submit orders and deploy strategies. Use
mcp:tradescope only with agents you trust, and always start your prompts with a safety frame that asks the agent to confirm account, instrument, and risk before any write.
Ready to deploy your first trading agent?
MCP Trading is included with the CrossTrade Elite plan. Plug Claude, ChatGPT, Cursor, or any MCP-capable AI client into NinjaTrader 8 and start running real agents against your real install — write, backtest, optimize, deploy, monitor.