Backtesting in NinjaTrader
NinjaTrader's Strategy Analyzer is its built-in backtester — the NinjaTrader equivalent of the MT5 Strategy Tester. This guide shows how to point it at a compiled NinjaScript strategy, set the instrument and date range, run the test, and read the results.
1) Open the Strategy Analyzer
From the Control Center, go to New → Strategy Analyzer. The Strategy Analyzer window opens.
2) Select your strategy
- In the left-hand panel, make sure the mode is set to Backtest (rather than Optimization or Walk Forward).
- Under the strategy selector, choose your compiled strategy by name from the list.
- Click the Parameters (…) control if you want to adjust the strategy's inputs (lot/contract size, indicator lengths, and so on).
3) Set the instrument and data series
In the Data Series section:
- Instrument — pick the market you want to test (for futures, choose the specific contract, e.g.
ES 03-26, or a continuous@ESseries for tests spanning expirations). - Type / Value — set the bar type and size for your data series (for example a 5-minute or daily series).
- Start date / End date — set the historical period to test over.
- Trading hours — apply a session template if your strategy is session-sensitive.
4) Set capital, commission, and slippage
For realistic results, adjust the account and cost settings before running:
- Starting capital — set it to something like your intended account size.
- Commission — NinjaTrader defaults to
$0; set it to your broker's real commission. - Slippage — add a tick or two of slippage, especially for strategies that use market orders.
5) Run the backtest
Click Run. When it finishes, review the result tabs:
- Overview / Performance — summary stats: net profit, profit factor, max drawdown, win rate.
- Trades — every trade the strategy took.
- Chart — the equity curve and trades over the test period.
Next steps
- Iterate the strategy's inputs and re-run to compare reports.
- Once you're happy, apply the strategy to a chart on your simulation account to watch it trade in real time (see Using the NinjaScript Editor).
Understanding your results
- Backtesting Metrics Explained — Profit factor, drawdown, Sharpe, and more
- How to Backtest a Trading Strategy — Best practices for validation
- Common Backtesting Mistakes to Avoid — Traps that make backtests lie
Related Guides
- Running NinjaScript on NinjaTrader 8 — The full HorizonAI → NinjaTrader overview
- Setting up NinjaTrader 8 — Install and create a sim account
- Using the NinjaScript Editor — Compile your strategy first
- Getting Started with HorizonAI — Generate NinjaScript with AI