Home
About
Courses
Plans
Mentorship
Blog
Tools
Support
Strategy

Backtesting without fooling yourself

A backtest can prove almost anything if you let it. Here is how curve fitting happens, why out of sample data matters, and the habits that keep a backtest honest.

Backtesting without fooling yourself

Backtesting means applying a set of trading rules to historical data to see how they would have performed. Done honestly, it is one of the most valuable tools a trader has. Done carelessly, it is a machine for producing confidence in strategies that do not work.

The problem: curve fitting

With enough adjustments, any set of rules can be made to look profitable on past data. Change the moving average from 20 to 23, add a filter for Tuesdays, tighten the stop by three pips, and the historical results improve. Each change is fitted to the particular noise of that particular data. The result describes the past perfectly and predicts the future poorly.

An equity curve that rises in sample and falls on unseen, out of sample data
An equity curve that rises in sample and falls on unseen, out of sample data

This is called curve fitting or overfitting, and it is the most common reason a strategy that looked brilliant in testing fails the moment it is traded.

Out of sample data

The main defence is to divide your data before you start:

  • In sample: the data you use to design and adjust the rules.
  • Out of sample: data you set aside and do not look at until the rules are final.

If a strategy performs well in sample and much worse out of sample, it was fitted to noise. If it performs similarly on both, you have evidence, not proof, that it captures something real.

Every adjustment you make after seeing the out of sample results turns it back into in sample data.

Habits that keep a backtest honest

  • Write the rules before you test. Precisely enough that there is no judgement in applying them.
  • Use few parameters. A strategy with three adjustable settings is much harder to overfit than one with twelve.
  • Include costs. Spreads, commissions and realistic slippage. Many short-term strategies are profitable only when costs are ignored.
  • Test enough trades. At least a hundred, across different market conditions: trending, ranging and volatile periods.
  • Be suspicious of smooth curves. Real strategies have drawdowns and losing streaks. A backtest with neither is usually a warning sign.

Manual backtesting first

Before using any automated tools, backtest by hand: scroll back through a chart, hide the future, and apply your rules bar by bar, recording every trade in a spreadsheet. It is slow, and that is the point. It teaches you what your setup actually looks like, including all the ambiguous cases that a description glosses over.

From backtest to forward test

A good backtest earns a strategy the right to be forward tested: traded in the simulator in real time, under the same rules, for weeks. Only if its forward results resemble its backtest should it be considered for real money, and even then with small risk.

Practise it

Pick one setup from your trading plan. Write its rules in five lines or fewer. Backtest it by hand on the first two-thirds of a year of data, then, without changing anything, on the final third. Compare the expectancy of the two. The academy's Strategy Development and Backtesting programme takes this process much further, but this one exercise will teach you more than most videos on the subject.

Education only. Nothing here is investment advice; practise in the simulator before risking real money.

Keep reading

Strategy

Risk to reward: what the ratio really tells you

3 min read
Strategy

A trading plan you will actually follow

3 min read
Fundamentals

Reading a forex quote: bid, ask, spread and pips

3 min read