Advanced

Walk forward instead of one split

One train test split measures one moment. A strategy that works only in that moment is a strategy that was fitted to it, and a single split cannot tell the difference between fitted and real.

What you will see

refuse. A rule that loses in any fold is a rule that was fitted to the others.

About 1 min of reading

Try It

Run three folds and keep the spread

1

Write the fold results

printf 'fold1 0.04\nfold2 -0.02\nfold3 0.09\n' > /tmp/folds.txt; wc -l < /tmp/folds.txt

Before you run it, say out loud what it will print. Then open the answer.

What it prints
Three folds. Each is one independent measurement.
2

Print the mean and the worst

awk '{s+=$2; n++; if(m==""||$2

Before you run it, say out loud what it will print. Then open the answer.

What it prints
mean 0.037 worst -0.020. The worst fold is the decision input, not the mean.
3

Refuse on the worst fold

awk '{if(m==""||$20) ? "ship" : "refuse"}' /tmp/folds.txt

Before you run it, say out loud what it will print. Then open the answer.

What it prints
refuse. A rule that loses in any fold is a rule that was fitted to the others.

Data Flow

A rule to a distribution of folds
1 The first window is fitted
↓
2 The next window is traded
↓
3 Both windows move forward
↓
4 Every fold result is kept, not averaged away
Why this works
Why the fit never sees its own trade

A fold where the fit window overlaps the trade window is a leak, and it is the leak that makes every backtest look better than it is.

The number of folds as a budget

Folds cost the same as data. The count is chosen so the whole run fits in one change cycle, the same rule an eval set follows.

Examples

The fold is the unit

Fit on a window, trade the next window, move both. Each fold is one independent measurement of the same rule.

Why the out of sample window is short

A long out of sample window is a window that contains several markets. The fold is sized to the market, not to the data.

The folds that disagree

Five folds with three wins and two losses is a distribution. That distribution is the result, and a mean alone hides it.

Words this lesson uses

Each one is defined here on this site. Open the entry for the full definition and the other words it points at.

← Calibrating the error, not the value
Previous Lesson
Calibrating the error, not the value
Next Lesson
The paper trade log
The paper trade log →