How does the TS WFO calculate the in/out-of-sample windows?

Theory and Practice of Walk-Forward Analysis
User avatar
progster
Posts: 948
Joined: Thu Jul 26, 2007 7:20 pm
Contact:

How does the TS WFO calculate the in/out-of-sample windows?

Postby progster » Tue Jan 10, 2012 7:22 pm

From the TS WFO FAQ, via the TS Forum:

How does the WFO calculate the in/out-of-sample windows?

The WFO uses bars to calculate the walk-forward window lengths and not dates.
The number of bars per walk-forward run is calculated as follow:

TotalBarsPerRun = Total number of bars / (Walk-forward runs * Out-of-sample% + In-sample%)
InSampleBarsPerRun = TotalBarsPerRun * In-sample%
OutOfSampleBarsPerRun = TotalBarsPerRun * Out-of-sample%

For example, if all the data has 10000 bars and we apply an out-of-sample%=20% with 10 walk-forward runs, then for a Rolling walk-forward we get:

TotalBarsPerRun = 10000 / (10 * 0.2 + 0.8 ) = 3571 bars
InSampleBarsPerRun = 3571 * 0.8 = 2857 bars
OutOfSampleBarsPerRun = 3571 * 0.2 = 714 bars

Note: 10000 / 2.8 = 3571

Thus we get:

In-sample Out-of-Sample

StartBar EndBar StartBar EndBar

Run#1 1 2857 2858 3572
Run#2 715 3571 3572 4286
Run#3 142 4285 4286 5000
Run#4 2143 4999 5000 5714
Run#5 2857 5713 5714 6428
Run#6 3571 6427 6428 7142
Run#7 4285 7141 7142 7856
Run#8 4999 7855 7856 8570
Run#9 5713 8569 8570 9284
Run#10 6427 9283 9284 9998

The WFO also adds a rule to the calculation to enforce the last out-of-sample window always to continue until the last bar (bar no 10000 in this case) to compensate for cumulative rounding errors.
(resulting in missing out on the last 2 bars in this case, as can be seen from the above example)

For an anchored walk-forward, the in-sample startbar would simply have been fixed at 1.

Return to “Walk-Forward Analysis”

Who is online

Users browsing this forum: No registered users and 1 guest