Backtesting Traps: Overfitting and Walk-Forward, Explained

The best rule in hindsight often fails on new data. Here is why, and how a walk-forward test gives a more honest answer.

A backtest is a simple idea. You take a trading rule, run it on past prices, and see what would have happened. The trap is that the past is a fixed set of data, and with enough effort you can find a rule that fits it almost perfectly. That rule often fails once it meets prices it has never seen.

This article explains why that happens, how to spot it, and how a walk-forward test reduces the problem. The example uses invented numbers to show the mechanics. It is not a result from any real strategy, and nothing here says a method will make money.

What overfitting means

Overfitting means tuning a rule so closely to past data that it describes the noise as well as the pattern. Markets contain real structure and a lot of random movement. A rule that is too flexible will memorise both, and the random part does not repeat.

A simple picture helps. Imagine drawing a line through a cloud of dots. A straight line captures the general direction. A line that wiggles through every dot touches all of them, and it looks perfect on that page. Add a new dot and the wiggly line is usually far off, because its curves were shaped by chance.

How the trap is built, one setting at a time

Nobody decides to overfit. It happens through small, reasonable steps:

Each step looks sensible alone. Together they make a rule with many adjustable settings, tuned until the history looks good. The more settings you try, the more likely it is that one combination works by luck. The final curve says little about the future, because you chose the combination after seeing the answer.

Warning signs in a backtest

You cannot prove overfitting from one chart, but some signs should slow you down.

The second sign is the most useful. A sound idea usually works across a neighbourhood of settings. If length 14 is great and lengths 13 and 15 are poor, the 14 is probably an accident.

Out-of-sample testing, the first defence

The basic remedy is to split your data. You build and tune the rule on one part, called in-sample. Then you test it once on a part you did not touch, called out-of-sample. If it holds up on data it never saw, that is better evidence than a good in-sample curve.

This method has a weakness. If you look at the out-of-sample result, dislike it, change the rule and test again, the out-of-sample data stops being unseen. You have turned it into training data without noticing. The discipline is to look rarely, and to count how many times you looked.

Walk-forward testing in plain words

A walk-forward test repeats the in-sample and out-of-sample split many times, moving forward through history. It imitates what you would have done in real life: tune on what you know, then trade the next stretch with those settings, then repeat.

The steps are straightforward:

  1. Choose a tuning window, for example twelve months, and a test window, for example three months.
  2. Tune the rule on the first tuning window and pick the best settings.
  3. Apply those settings to the next test window without changes and record the result.
  4. Slide both windows forward by the length of the test window and repeat.
  5. Join all the test windows into one record. That record is the walk-forward result.

The joined record contains only trades made with settings chosen before the trades happened. It is a more honest picture than one curve tuned on the full history.

A worked example with invented numbers

These figures are made up to show the mechanics. A trader has 24 months of data. Tuned on all 24 months, the best settings show a total gain of 100 units. This looks impressive.

The trader then runs a walk-forward test with a 12-month tuning window and a 3-month test window. Four test windows result. In each one, the rule is tuned on the preceding 12 months and then run on the next 3 months.

Test windowResult with tuned settings (in-sample)Result on the next 3 months (out-of-sample)
Window 1+60 units+8 units
Window 2+55 units-12 units
Window 3+70 units+3 units
Window 4+65 units-9 units
Totaln/a-10 units

Every in-sample figure looks good, since the settings were picked to make it so. The out-of-sample results are the ones that count, and here they total a small loss. The invented rule looked strong in hindsight and had no edge going forward. A real test will not match this table. The point is the gap between the two columns.

A small gap, with out-of-sample results that stay positive in most windows, is a better sign. Even then it is a sign, not a proof.

Other traps worth knowing

Ignoring costs

Commissions, fees and the difference between the price you expect and the fill you get all reduce results. A rule that makes many small trades can look good before costs and poor after them. Include realistic costs from the start.

Look-ahead and hidden knowledge

If a rule uses information that was not available at the moment of the trade, such as the high of a candle that had not finished, the backtest is cheating without anyone meaning to. Check the timing of every input.

Too few trades

A result from twenty trades can come from luck alone. More trades across different conditions give you more confidence, though never certainty.

What a backtest cannot test

A backtest assumes the trader follows the rule on every trade. Live trading breaks that assumption. A trader who skips a signal after two losses, or doubles size after a win, is no longer running the tested rule. For a prop firm account, that gap matters even more, because a loss limit ends the account.

So a backtest answers one question: does this rule have any merit? It does not answer whether you will execute it. Your own record decides that, which is why we suggest reviewing live trades, as in bad days, not bad methods, and keeping a journal. To see how a daily loss limit relates to your drawdown, use the evaluation survival calculator. If you are weighing prop firm plans, our list what each one publishes about its rules.

PropGod is not for sale yet

PropGod is a discipline and journaling tool for futures prop firm traders. You write your own rules before the session and you keep them yourself. PropGod never places, changes, closes or cancels an order, and it never locks you out of your account. PropGod is not for sale at the moment; you can join the waitlist.

Join the waitlist ↗

A short checklist before you trust a backtest

  1. Count the settings you tuned and compare that with the number of trades.
  2. Change each setting slightly and see whether the result survives.
  3. Reserve data you do not touch until the rule is final.
  4. Run a walk-forward test and read the out-of-sample column first.
  5. Include costs and check the timing of every input.
  6. Start live with small size and compare your results with the test.

The takeaway

The best rule in hindsight is often the one most fitted to noise. Walk-forward testing gives you a more honest record because each test period uses settings chosen before it happened. Treat any backtest as a reason to look closer, not as a promise, and remember that following the rule live is a separate skill.

This article is educational and is not financial or trading advice. Trading futures involves risk of loss. Prop firm rules differ and change, so check the firm's official rules page and the CME calendar on the day you read this. PropGod is not affiliated with any prop firm or exchange.

Free: Prop firm rules cheat sheet 2026. Drawdown, daily loss, consistency, payout and automation rules of six firms on three pages, with sources, checked Nov 4, 2026. No email required. Open or download.