Quick answer
NinjaTrader walk-forward optimization selects parameters on an earlier data segment, then evaluates them on the following segment. The windows advance and repeat. Judge the later test results separately from the results used to select parameters.
Set the training and test windows
Open New > Strategy Analyzer from the Control Center. Choose your strategy, instrument, bar interval and historical date range. Data for that range must be available from your provider or local storage.
Set Backtest type to Walk Forward Optimization. The two period fields use days:
| Setting | Role |
|---|---|
| Optimization period (days) | Earlier, in-sample window used to choose parameters. |
| Test period (days) | Following, out-of-sample window evaluated with those parameters. |
Define the parameter search separately
Expand each strategy input to set its minimum, maximum and increment. For example, values 8 through 12 in steps of 2 give three choices: 8, 10 and 12. A second input with four choices makes 12 combinations for a full search of the pair. This is arithmetic, not a tested strategy or recommended configuration.
Optimize on defines the scoring criterion. A winning net-profit result and a winning drawdown result need not use the same inputs. Record the criterion alongside the parameter values when comparing runs.
The Default optimizer examines all combinations. The Genetic optimizer searches a subset through successive generations; NinjaTrader describes its solutions as approximate, so its selected result is not guaranteed to be the best possible combination.
Read each test period’s result
The results grid lists each test interval’s dates and selected parameter combination. Right-click a row and choose View Optimization Results to inspect its earlier search. Keep best # results controls how many optimization candidates are retained.
Check strategy code that depends on trade history
NinjaTrader’s optimization documentation says historical Trade-object storage is disabled by default in this context to save memory. Code that reads SystemPerformance.AllTrades.Count therefore needs attention: without retained Trade objects, that count cannot supply the expected history.
When the strategy requires those objects, its developer can enable IncludeTradeHistoryInBacktest in OnStateChange() during State.Configure. Retaining detailed history increases memory use. This setting is separate from the number of top optimization results displayed.
Out-of-sample is still historical testing
The later window still uses historical data and simulated fills. It does not become a live brokerage execution or a Playback session merely because its data was excluded from parameter selection.
NinjaTrader documents different fill processes for historical backtests, simulation with incoming data, and live orders. Check fill assumptions separately; changing the training window does not resolve those differences.
Official sources
Platform monitoring
Keep platform health in view
Ninja Watchdog monitors NinjaTrader and supports recovery after platform interruptions. Email alerts are available today; SMS and WhatsApp alerts are coming soon.
