Walk-forward analysis explained with a real crypto test

Walk-forward testing checks a method one step at a time, using only past data. Rolling vs anchored windows, and a Bitcoin test scored year by year.

Walk-forward testing (also called walk-forward analysis) checks a trading method on history one step at a time, using only the data that existed at each step. In our walk-forward test on Binance Bitcoin, chart look-alikes called the next 24 hours right 55.56% of the time in 2020 but 44.44% in 2022. They beat "always guessing up" in some years and lost in others, and never beat the better of always up or always down in any year.

The test was built so nothing from the future could slip in. With that guard in place, the look-alikes did no better than a simple guess. These are past cases, not a forecast.

For the full 12-market result, see Do chart patterns predict crypto prices?.

What is walk-forward testing?

A backtest checks how a method would have done on past prices. Walk-forward is a careful way to run one:

  1. Pick a moment in the past, called the decision time.
  2. Use only data from before it.
  3. Write down what your method says.
  4. Look at what happened after the decision time.
  5. Move to the next decision time and repeat.

You end up with many scored decisions, spread across years, each made with only what was known at the time. Two details are easy to miss. The "data from before" must include only things that were finished. And you must fix your settings before you look at any result, or you are using the test to tune the method.

What are rolling and anchored windows?

Many traders use walk-forward to re-tune a rule over time. You tune it on one stretch of dates (the training window), test it on the next stretch, then slide both forward and repeat. In a rolling window the training stretch keeps the same length and drops old dates. In an anchored window it always starts on the same first date and grows. Our look-alike test below is the simplest form: the method was fixed in advance and never re-tuned.

How is it different from a train and test split?

A train and test split picks a rule on early dates (train), then tests it once on later dates (test). Our random-rules test did exactly that: 1,000 random rules for hourly Bitcoin on Binance, the best one picked on September 2019 to 2022, then tested unchanged on 2023 to September 2026.

How is it different from a train and test split?
Training, Sep 2019 to 2022 Test, 2023 to Sep 2026
Hours 29,046 32,856
Sharpe score 0.75 -0.19
Return before fees +544.51% +42.96%
Return after fees +155.22% -51.72%
Worst drop from a peak -60.22% -76.83%

Sharpe is the average result divided by how much results swing, scaled to a year (see our Sharpe ratio guide). Zero or below means no reward for the swings. Note the fee rows: in the test years the rule made +42.96% before fees and lost 51.72% after, because it traded so often.

A split gives you one score, and you cannot tell whether it was luck. Here, 24.50% of the 1,000 rules had a positive Sharpe in training and only 1.00% in the test period. Our overfitting article walks through it.

A walk-forward test gives you a score per step. Here is the same frozen rule, year by year. We never re-picked it, but the table shows how much a single number hides.

How is it different from a train and test split?
Year Hours Return after fees
2019 (from Sep 8) 2,742 -5.89%
2020 8,784 +135.72%
2021 8,760 +4.80%
2022 8,760 +9.44%
2023 8,760 +2.37%
2024 8,784 -18.26%
2025 8,760 -50.57%
2026 (to Sep) 6,552 +16.38%

Most of the training gain came from 2020 alone. We did not run a version that re-picked the rule each year.

One frozen random trading rule's return after fees, by calendar yearLine chart of one rule's yearly return after fees, 2020 to 2026. The training years (to 2022) are shaded and the test years are not. The rule was not changed between years. 2020: +135.72% over 8,784 hours; 2021: +4.80% over 8,760 hours; 2022: +9.44% over 8,760 hours; 2023: +2.37% over 8,760 hours; 2024: -18.26% over 8,784 hours; 2025: -50.57% over 8,760 hours; 2026: +16.38% over 6,552 hours.ONE RULE / EACH YEAR+135.72%One frozen rule, 2020 return after fees.No later year beat +16.38%.TRAIN to 2022TEST 2023 to Sep 2026-50%0%50%100%150%2020+135.722021+4.802022+9.442023+2.372024-18.262025-50.572026*+16.38Return after fees, %, one calendar year each.* 2026 runs to Sep 30. The train period alsoincludes Sep 8 to Dec 31 2019: -5.89%.Source: Binance BTCUSDT perpetual hourly bars,Comparand archive. Best of 1,000 random rules,picked on training years, then frozen. Fees0.05% per side.comparand.xyz
One frozen random trading rule's return after fees, by calendar year

What did a real walk-forward test of chart look-alikes find?

We asked: when a coin's last 48 hourly closes look like a past stretch of the same coin on the same exchange, does that past say whether the next hours went up or down?

For each of 12 markets, we picked 300 evenly spaced decision times from January 2020 to September 2026. At each one, we used only the 48 closes before it, found the ten closest earlier stretches with no overlap among them, and called the direction from the middle (median) of what followed those ten. Then we checked what actually happened.

The 12 markets were 10 Binance perps (futures that never expire) plus Coinbase BTC-USD and ETH-USD spot. Each market was tested alone.

What did a real walk-forward test of chart look-alikes find?
Time ahead Tests Look-alikes right on direction Always guessing up Mean trade after fees
12 hours 3,600 50.44% 51.67% -0.05%
24 hours 3,600 50.22% 50.92% -0.07%
48 hours 3,600 50.25% 51.39% -0.08%

"Always guessing up" is a base rate: how often price was higher at that horizon after the same decision times. Look-alikes were below it at all three horizons. Trading the call lost a little per trade after a 0.10% round-trip fee (0.05% per side), before funding, spread or slippage. Our look-alike article shows the coins one by one.

Why do the past cases have to finish first?

Because you could not have known them yet. At each decision time, every past case had to end before the query chart began, and its 48-hour outcome had to be finished by the decision time. A past case from 10 hours ago has no known 48-hour outcome, so we could not use it. Breaking this rule is called look-ahead bias. In one of our tests it turned a losing Bitcoin rule into an impossible winner (see our look-ahead example). Decision times in each market were also more than 48 hours apart, so no two scored windows overlapped.

Do the scores stay the same from year to year?

No, and a walk-forward test shows it. Here is Binance BTCUSDT on the 24-hour call, split by year.

Do the scores stay the same from year to year?
Year Tests Look-alikes right Always guessing up Better of up or down (hindsight)
2020 45 55.56% 42.22% 57.78%
2021 44 52.27% 59.09% 59.09%
2022 45 44.44% 46.67% 53.33%
2023 44 52.27% 47.73% 52.27%
2024 44 54.55% 54.55% 54.55%
2025 45 48.89% 35.56% 64.44%
2026 (to Sep) 33 45.45% 63.64% 63.64%

Look-alikes beat "always up" in some years and lost in others. They never beat the better of "always up" or "always down" in any year, though they tied it in 2023 and 2024. (That last column uses hindsight: you only know which guess was better after the year ends.) With about 45 tests a year, a swing of several points is normal noise (our sample size article shows why). Over all 300 Binance Bitcoin tests, look-alikes were right 50.67% of the time, against 49.33% for always up. But always guessing "down" would also have scored 50.67%, so they only tied the better simple guess.

What does this not show?

  • The tests are not independent. The same past stretch can match several decision times, and coins move together. Treat 3,600 tests as fewer independent facts.
  • Only coins that still trade. Coins that faded away are missing.
  • Complete data only. A decision time was used only if the 48 hours after it were fully recorded. A live system cannot know that in advance.
  • One setting. We used 48 closes and ten matches. Other settings could differ.

How we measured this

We used hourly bars for the 12 markets, with 300 decision times each from January 2020 to September 2026 (newer coins start later). Each decision used 48 earlier closes, ranked past stretches by shape, kept the ten closest without overlap, and scored their middle outcome against what happened. Fees were 0.05% per side. For the random rules, we made 1,000 rules with a fixed random seed, picked the best on 2019 to 2022, and froze it for the later dates.

Try this in Comparand

Walk-forward needs many decision times. Ask your connected AI agent: "For these 100 past times, find the closest past cases for Bitcoin on Hyperliquid and what happened over the next hour. Keep the source record for each."

  • hl_analogs_batch runs up to 100 searches in one call. Each compares a coin only with its own Hyperliquid past, with the outcome over the next 1 hour or 4 hours. It costs $0.01 per search that runs, paid from credits. Refused searches are not charged.
  • The prov block comes with every answer. It lists the days, digests (codes that identify the exact data) and code versions behind it, so you can see which data each search used.

Comparand returns the past cases and what followed each, with no average or hit rate. Scoring is your step, so fix your rules first. Our test used the chart-shape search on Binance and Coinbase, so its numbers do not apply to this Hyperliquid call.

See the docs, or try 3 coins free. Past cases, not a forecast.

The short version

  • Walk-forward testing steps through history and uses only data that existed at each moment.
  • In 3,600 crypto tests, look-alikes called 24-hour direction right 50.22% of the time, below 50.92% for always guessing up.
  • The best of 1,000 random rules fell from a Sharpe of 0.75 in training to -0.19 in the test, and fees turned its +42.96% test-period gain into a loss.
  • A single score hides swings. Per-year scores showed Bitcoin look-alikes ranging from 44.44% to 55.56%.

Questions people ask

What is walk-forward testing?

Walk-forward testing means going through history one step at a time. At each step you use only data from before that moment, record what your method says, and then compare it with what happened next. Then you move to the next step.

How is walk-forward different from a single train and test split?

A single split picks a rule on early dates and tests it once on later dates. Walk-forward repeats the pick-then-test step many times as the date moves forward, so you get a series of scores instead of one.

What did your walk-forward test of chart look-alikes find?

In 3,600 tests across 12 crypto markets, the ten closest past charts called the next 24 hours' direction right 50.22% of the time. Always guessing up was right 50.92% of the time. This is past data, not a forecast.

Why do past cases need to finish before the decision time?

If a past case's outcome had not finished yet at your decision time, you could not have known it then. Using it would leak the future into the test and make the result look better than it was.

How many tests do I need for a walk-forward test?

There is no single number. Our test used 300 decision times per market, and a year of those (about 45 tests) swung from 44.44% to 55.56% right on Binance Bitcoin. Small groups of tests are noisy.

Read next