Navigation: Running Tests >

Walk-Forward Tests

 

 

 

 

To introduce Walk Forward testing, let's return to the sample2.rts script used in Tutorial 2.

Open that script again and click on .

Now make all of the following selections in the Optimizer dialog:

Parameters

Check both parameters.

Mode

Set to "Combinatorial"

Iterations

Set to 1.

Score

Set to NetProfit, or any other Results Window item (statistical formula) you want to optimize for. This is your "Fitness Function".

Clear Results

Check this so any prior tests will be deleted, and/or open a new results window.

Sort After Each Test

Check this whenever generating a Walk-Forward test.

Keep Best

Set to 1 for Walk-Forward.

By Date

Check this (it will become enabled after the next step if it isn't already).

Daily Interval

Set Time Unit to Days (or a longer unit if desired).

Test Length

Specifies how many days (since that's the Time Unit) to include in each backtest (252 days is one year).

Test Interval

Specifies how often to re-optimize (63 days is one quarter).

Walk-Forward

Check this.

Test Count

This will show how many tests need to be run.

 

Now you are ready to press  and let RealTest generate your walk-forward model.

Though there are more than 10,000 tests to run, it will probably take less than one minute to finish, depending on the speed of your computer.

As the tests run, you will see the Results window being updated continually. To help the process finish faster, minimize the Results window until all tests are finished, then restore it again.

Here is what is going on under the hood:

          for each 63-bar interval of your overall date range

                    for each of the 110 possible combinations of your two parameters

                              run a 252-bar test and keep the result if it is better than the prior best result

                    record the start date and parameter values that produced the best result

Once the above is complete, a new WalkForward section is automatically added to your script. This section contains an item called "Dates", and an item for each of your parameters. These things together serve to define how to run the final Walk-Forward test, in which the best parameters from the previous interval are used for each 63-bar interval. In effect, this becomes a test of the effectiveness of the process of periodic re-optimization.

Here is a snippet of how the results and script windows will look at the end of the run:

To run the walk-forward test again (without re-generating all the parameter values), simply press the Test button or select Run Test from the Run Menu:

When a script includes a WalkForward section (and it's not commented out), RealTest will always use it when running that script as a single backtest.

Now for (an unfair) comparison, let's do the following:

1. Change the date range in Settings to match the dates of the Walk-Forward row in your results window.

In my case this will be:

(The start date is 252 bars after the earliest data date, and the end date is 252 bars after the last multiple of 63 bars that would not push it past the last data date.)

2. Add default values for each of the two parameters to select 10 and 70, which were among the best results found in the overall optimization done in Tutorial 2.

3. Comment out the WalkForward section, so that the test will run with constant parameter values.

4. Run a regular single test by pressing .

5. Look at the new line at the top of the results window:

(Ignore the parameter values for the Walk-Forward line - they should really be blank or say "various".)

In this case it appears that the walk-forward process produced results that were roughly equivalent to the most optimal overall result.

See also spy_tlt_uis.rts in the Examples folder for an example that uses walk-forward optimization to implement a strategy from an article.

 

 

 

 

Copyright © 2020-2024 Systematic Solutions, LLC