Top

Strategy Analyzer Optimizations: Walk Forward and Multi-Objective

backtesting automated strategies ninjatrader

NinjaTrader’s Strategy Analyzer window is used to test automated trading strategies over historical trading data. This analysis can help traders improve their strategies for optimal performance in live market conditions.

Designed for use with strategies built using NinjaScript, NinjaTrader’s modern C# based trading framework, the Strategy Analyzer provides a robust solution for backtesting, optimizing and analyzing the performance of automated trading strategies.

Optimization of a trading strategy involves running multiple backtests to determine which combination of variables produces the best results. In addition to the standard trading strategy optimization, advanced optimization types included with the Strategy Analyzer are Walk Forward and Multi-Objective Optimization.

Walk Forward Optimization

Walk forward optimization is a technique used in finance to determine the best parameters for a trading strategy. The method first optimizes the input variables over one period of historical data, which are then walked forward over additional time segments for additional backtests.

One of the main reasons walk forward optimization is utilized is that a strategy’s good performance over historical data does not necessarily mean it will remain consistent in the future. Walk forward optimization can help traders keep their strategies current in dynamic markets.

Performing a Walk Forward Optimization

In order to run a walk forward optimization, the NinjaScript strategy used must have inputs to optimize. For example, inputs can be the period of a moving average, an overbought or oversold RSI threshold, or any other indicator parameter which can be predefined by the user.

  1. Within the Settings panel of the Strategy Analyzer window, under Backtest type select Walk Forward Optimization. Additional settings will appear in the Optimize section.
  2. Under Optimize, set the Optimization period to the number of days in the first segment to be optimized.
  3. Set the Test period to the total number of days to perform the walk forward optimization.
  4. Configure any other necessary strategy parameters for your walk forward optimization.
  5. Once all settings are configured as desired, click Run.

After running the optimization, the results will appear in the top left corner of the Strategy Analyzer window. The start date of the results will not match the start date in your settings, since the actual backtest does not start until the first optimization period is complete. More detailed results for each test can be viewed in the performance section below.

Multi-Objective Optimization

Multi-Objective Optimization takes standard optimization a step further by choosing multiple objectives to test for. This enables users to optimize input values for more than one performance metric in a single test.

For example, a strategy might have conflicting objectives: to maximize returns while minimizing risk. Multi-objective optimization tests for both objectives simultaneously and helps to determine the best possible combination of variables to balance risk and return.

Performing a Multi-Objective Optimization

Similar to a walk forward optimization, the NinjaScript strategy used in a multi-objective optimization must have inputs to optimize.

  1. Within the Settings panel of the Strategy Analyzer window, under Backtest type select Multi-Objective Optimization.
  2. Under Optimize, use the Optimize on menu to select multiple items to optimize your strategy for, as seen below.

  1. Configure any other necessary strategy parameters for your multi-objective optimization.
  2. Once all settings are configured as desired, click Run.

Rather than being presented in a list, multi-objective optimization test results are presented in a graph, allowing users to analyze and choose the input values which provide the best tradeoff between the different metrics.

Hovering your mouse over one of the results in the graph will display details such as what specific parameters created that outcome. Clicking on one of the result plots will highlight it red and also display the performance up to that point in the section below.

As past performance is not indicative of future results, traders should be aware of the risks involved in trading automated strategies in live markets.

The NinjaTrader open source trading platform is always FREE for backtesting, advanced charting and trade simulation. Get started with an award-winning trading platform – Download here!