TradeReign
Back to HomeEducation HubCompatibilityAboutDisclosures
NinjaTrader Desktop

NinjaTrader Walk Forward Optimization Read the Test Windows in Order

The example uses three fictional test windows to show how to check the dates, settings, trade counts and net results. The numbers illustrate how to read the report.

Quick Answer

In Control Center, open New → Strategy Analyzer and set Backtest type to Walk Forward Optimization. Choose the parameter ranges, optimization fitness, optimization period and test period. Read the results by test window. Each test uses values selected using the earlier optimization window.

Start 7-Day TrialMore Guides

Three passes across a fictional 60-day sample

Each numbered block is ten days. Amber shows the optimization window and teal shows the subsequent test window.

When each set was chosen and what happened in the next test
Optimize daysTest daysFast / SlowTradesNet
1–3031–4012 / 2812$180
11–4041–5014 / 2411-$220
21–5051–6010 / 327$90
All test windows30$50

Choose in-sample days

NinjaTrader compares parameter values inside the optimization window.

Freeze values during each test

Each forward test uses the combination from its preceding optimization window.

Read all windows

Keep the losing period and flag the low-trade period when you review the total.

Set up Walk Forward Optimization in Strategy Analyzer

Open New → Strategy Analyzer from Control Center. Select Walk Forward Optimization as the Backtest type and choose a strategy with optimizable inputs. Use a sample strategy to learn the report. Confirm the dated instrument, series, Trading Hours template, and availability of historical data before you start.

For a small practice grid, use a strategy with Fast and Slow inputs, such as Sample MA Crossover. Set Fast to Min 10, Max 14 and Increment 2. Set Slow to Min 24, Max 32 and Increment 4. That is three Fast values times three Slow values, or nine combinations with the Default optimizer across each complete optimization window. Set Optimize on to Max. net profit for the exercise.

Set Optimization period (days) to 30, Test period (days) to 10, and Keep best # results to three. Enter a Start and End date spanning enough history for several windows. Set your commission, slippage and fill assumptions before running. Check the actual Start date and End date shown in each result, especially if the sample includes weekends, holidays or missing history.

Read the forward results and the parameter choices

In the first fictional pass, days 1–30 choose 12 / 28. Those values are fixed for days 31–40, which show 12 trades and $180 net. In the second pass, the optimizer uses days 11–40. Days 31–40 can now be training history for the next decision. The next test runs on days 41–50 with its own frozen 14 / 24 values.

The test windows themselves are distinct. The middle window loses $220 and the last makes $90, giving $50 net across 30 trades after modeled costs. If your review requires ten trades per window, flag the last window with seven. Keep its count and result in the record. A small positive aggregate and a short sample leave performance uncertain.

In the Optimization Results Grid, compare each test row’s dates, inputs and figures. Right-click a walk-forward result and select View Optimization Results to see the retained in-sample candidates for that pass. Use those records to inspect nearby settings. NinjaTrader notes that optimization can omit historical Trade objects by default. Check IncludeTradeHistoryInBacktest if your strategy reads past trades, and confirm what evidence was saved before analyzing the output.

Keep the next test independent

Write down the parameter ranges, fitness, window lengths and costs before running the comparison. Walk-forward lets you test a process that reselects parameters at set intervals. If you tune the grid or window lengths after looking at the forward results, keep a later date range untouched for a separate check.

Compare the next unseen test with a fixed-parameter baseline over the same dates and assumptions. Record net P&L, trade count and maximum drawdown, and inspect losing windows and missing data. To calculate drawdown across all test windows, use the ordered equity or trade series. The individual window drawdowns alone leave the cross-window peak and trough unknown.

Sources

Official References

Platform details on this page were checked against these official resources.

NinjaTrader Walk Forward OptimizationFind Backtest type, window controls and the Optimization Results Grid.NinjaTrader Strategy Analyzer OptimizationCheck optimizer, fitness and parameter settings.NinjaScript TestPeriod referenceWhat the test period setting means for out-of-sample data.
Related Guides

Keep Building the Rule System

Backtest a NinjaTrader strategy

Match fill settings, commissions and available historical trade data.

Verify NinjaTrader historical data

Check contracts, dates, data coverage and session boundaries.

Compare mechanical and discretionary trading

Write trading criteria that can be applied consistently.

FAQ

Common Questions

What is the difference between NinjaTrader Optimization and Walk Forward Optimization?

Optimization compares inputs on the selected historical segment. Walk Forward Optimization repeats that selection and tests the chosen values on the following segment.

What do Optimization period and Test period mean?

The optimization period is the historical window used to select inputs. The test period is the next window used to evaluate those inputs before advancing.

Can an earlier test period become part of the next optimization period?

Yes. In a rolling walk-forward process, an earlier window can be historical data by the next selection time. Check that the test for each pass comes after that pass’s selection window.

Risk Disclosure

Futures trading contains substantial risk and is not suitable for every investor. TradeReign is a trading-discipline and rule-enforcement application. It does not provide trading advice, trade signals, investment recommendations, or performance guarantees.

TradeReign is not a broker-dealer, futures commission merchant, or investment advisor.

Futures trading contains substantial risk and is not for every investor. An investor could potentially lose all or more than the initial investment. Only risk capital - money that can be lost without jeopardizing financial security or lifestyle - should be used for trading. Past performance is not necessarily indicative of future results.