NinjaTrader 8 · NinjaScript · CrossTrade MCP

Build a NinjaTrader 8 strategy with AI

Describe your entries, exits and position sizing. Your AI client uses CrossTrade MCP to inspect your NT8 installation, write NinjaScript, check compilation and run a Strategy Analyzer backtest. Keep the source and the results in view as you refine the rules.

Requires CrossTrade Elite and a supported, connected NT8 Add-On. This is CrossTrade’s AI-assisted workflow, separate from NinjaTrader’s native AI Strategy Builder beta.

From idea to testable rules

Your strategy needs more than a plausible code block

“Buy when momentum improves” is not a complete strategy specification. Define the instrument, bars, entry condition, exit condition, quantity and session behavior first. Ask the agent to restate ambiguous rules before it writes anything.

For example, a one-contract, long-only EMA crossover on five-minute MES bars is a small enough starting point to inspect. The goal of the first pass is to verify when it enters and exits, not to search until a performance number turns green. Prompt-to-NinjaScript guidance explains how to turn the idea into a precise specification.

The working loop

Inspect, compile, backtest, then verify in simulation

  1. Inspect your install. GetNinjaScriptHelp supplies authoring guidance. SearchNinjaScriptSymbols and LookupNinjaScriptSymbol resolve the types and method signatures available in your running NT8.
  2. Draft and compile. The agent generates a versioned strategy class and submits CompileNinjaScript(in_memory: true). It polls GetMcpJob, reads compiler diagnostics and repairs errors using the actual symbols.
  3. Save the approved source. WriteNinjaScriptFile writes the file. Read compile_engine: file_only means you still need F5 in the NinjaScript Editor before NT8 can use the class.
  4. Run a fixed backtest. Declare the full instrument contract, dates, trading-hours template, bar period, parameters, commission template and slippage. RunStrategyBacktest runs the supported configuration through NT8’s Strategy Analyzer engine on the isolated Backtest account.
  5. Review behavior before optimization. Inspect the trades and compare them with the written rules. If you sweep parameters, keep a separate evaluation period and read the returned ranking metadata.
  6. Forward-test separately. After approval, deploy to an available simulation account such as Sim101. GetDeployedStrategyState checks the live instance; a deploy-time response alone is not ongoing verification.

The walkthrough gives you prompts, a correctly shaped backtest request, expected checkpoints and a capture checklist. It separates historical testing from forward simulation so you can reproduce the process without mistaking one for the other.

Start here

A prompt that leaves a reviewable trail

Strategy-building prompt
Help me build a long-only EMA crossover strategy for NinjaTrader 8.
Use one contract, five-minute bars, FastPeriod=9 and SlowPeriod=21.
Enter on a completed-bar cross above; exit on a cross below.
No scaling in. Restate session-close behavior and the exact contract
before writing the strategy. Name the first class CrossTradeEmaDemo_v1.

Inspect capabilities and existing scripts. Read GetNinjaScriptHelp
for a strategy, then look up the required NT8 symbols. Show me the
rules and proposed source. After I approve compilation, compile in
memory and poll the job. Repair reported errors; stop after three
failed attempts and show the diagnostics.

Ask before saving the file. Use overwrite=false. Check compile_engine
and wait for F5 if NT8 has not rebuilt the class. Propose fixed backtest
settings, including available data, costs and dates, before starting it.
Show actual trades and metrics. Do not optimize, deploy, or place orders
unless I approve those steps separately.

Compiler success establishes that the code compiles. It does not establish that the rules are correct or that a strategy will make money. Keep each source version with its test settings and job results.

What the tools actually do

Know the build and backtest boundaries

The sandbox compile and NinjaTrader’s own Custom assembly are separate steps. A sandbox success does not make a class available to the Strategy Analyzer. The file writer attempts a rebuild, but its compile trigger is best-effort. Versioned class names also make iterative tests easier to distinguish.

RunStrategyBacktest uses NT8’s engine for the supported settings. Match data, dates, trading hours, inputs, fill settings and costs when comparing against the desktop UI. Tick Replay is not exposed through the current MCP interface. Tick bars and order-fill resolution are different settings.

Parameter sweeps enumerate a Cartesian grid. The requested fitness is applied where supported; read the returned ranking block for the actual fitness or fallback. Genetic optimizer names do not turn the sweep into genetic search. On older add-ons, fixed inputs in sweeps also have version-specific limitations; check capabilities and the tool reference first.

A running strategy is not necessarily a filled trade. Inspect live.state, live.is_trading, bar progress, positions and orders after deployment. If a strategy is still processing historical bars or has not received an entry signal, report that rather than claiming a live trade occurred.

Which AI route?

Use the builder that fits your workflow

CrossTrade works through your chosen MCP client, such as Claude, ChatGPT or Cursor, with tools connected to your own NT8 installation. It also exposes CrossTrade webhook, journal and operational evidence for reviewing what happens around the strategy.

NinjaTrader advertises its own desktop AI Strategy Builder in beta, alongside a separate MCP server and Nina insights. Our dated NinjaTrader AI comparison distinguishes those products. Compare current access and demonstrated workflows rather than assuming that either product’s feature list covers the other.

FAQ

AI strategy-building questions

Can I build a NinjaTrader 8 strategy with AI?

Yes. With CrossTrade MCP, an AI client can turn your rules into NinjaScript, inspect signatures from your NT8 installation, compile the draft, and run supported backtests through NT8 Strategy Analyzer. You need CrossTrade Elite, a supported NT8 Add-On and NinjaTrader running. Compile, file-write and backtest-job tools require mcp:trade.

Is this NinjaTrader’s own AI Strategy Builder?

No. CrossTrade is a separate service connecting your chosen AI client to your NT8 installation. NinjaTrader also advertises its own desktop AI Strategy Builder in beta as of October 10, 2026. Compare the workflow, account access and release requirements of each.

Does a successful sandbox compile make the strategy ready for NT8?

Not by itself. The sandbox checks the source. WriteNinjaScriptFile saves it and attempts to trigger the NT8 rebuild. If compile_engine is file_only, press F5 in the NinjaScript Editor before backtesting or deployment, and resolve any compilation errors.

Does the backtest place orders on Sim101?

No. RunStrategyBacktest uses NT8’s isolated Backtest simulation account. Sim101 is a separate account you can choose later for a confirmed forward-simulation deployment. Inspect available accounts before deploying.

Can I use Tick Replay or a genetic optimizer through MCP?

The current MCP backtest interface does not enable Tick Replay. Tick bars and High order-fill resolution are not Tick Replay. Parameter sweeps use exhaustive Cartesian combinations, even when a genetic optimizer name is supplied.

Test one clear idea end to end

Connect your client, define the rules, and keep the compile and test evidence beside the source.