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:
![](images/image(143).png)
1
|
Parameters
|
Check both parameters.
|
2
|
Mode
|
Set to "Combinatorial"
|
4
|
Score
|
Set to NetProfit, or any other Results Window item (statistical formula) you want to optimize for. This is your "Fitness Function".
|
5
|
Clear Results
|
Check this so any prior tests will be deleted, and/or open a new results window.
|
6
|
Sort After Each Test
|
Check this whenever generating a Walk-Forward test.
|
7
|
Keep Best
|
Set to 1 for Walk-Forward.
|
8
|
By Date
|
Check this (it will become enabled after the next step if it isn't already).
|
9
|
Daily Interval
|
Set Time Unit to Days (or a longer unit if desired).
|
10
|
Test Length
|
Specifies how many days (since that's the Time Unit) to include in each backtest (252 days is one year).
|
11
|
Test Interval
|
Specifies how often to re-optimize (63 days is one quarter).
|
12
|
Walk-Forward
|
Check this.
|
13
|
Test Count
|
This will show how many tests need to be run. (The current version of the example script has different parameters so the count will be different.)
|
Now you are ready to press and let RealTest generate your walk-forward model.
Though there are about 5,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 the overall date range
for each of the 40 possible combinations of the 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:
![](images/image(146).png)
The Results window shows the best "in-sample" test for each interval. The final two tests run are the in-sample (1480) and out-of-sample (1481) results for the entire date range.
The script window shows the new WalkForward section that was generated. These three rows extend far to the right. The first row contains the start date of each interval and the subsequent rows contain the best value found for each parameter in each interval.
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 in Test mode.
|