Backtesting

How to Build a Reliable Backtesting Workflow (Step-by-Step Guide)

A repeatable research process from hypothesis to go-live: written rules, data split, baseline test, robustness checks, out-of-sample decision, forward test and a research log.

By AlgoXP4 min readUpdated

Backtesting workflow from hypothesis and clean data to backtest, out-of-sample check and forward test

Good strategies are rarely the result of one brilliant backtest. They come from a process that makes it hard to fool yourself: decisions are written down before results are known, data is split so that the final verdict comes from untouched history, and every promising idea is attacked before it gets real money.

This guide describes a workflow you can repeat for every idea.

Step 1: write the hypothesis

Start with a sentence that explains why the strategy should work, not only what it does:

“Gold tends to continue in the direction of a breakout from the Asian session range during the London session, because new liquidity arrives and stops cluster at the range edges.”

A hypothesis with a reason behind it is easier to test honestly and easier to abandon when the evidence is against it.

Step 2: turn it into exact rules

Write rules a program can follow without interpretation:

  • Market and timeframe: XAUUSD, M15.
  • Setup: Asian range = high and low from 00:00 to 06:00 server time.
  • Entry: buy stop one spread above the range high, sell stop one spread below the low, valid 07:00-11:00.
  • Exit: stop at the opposite side of the range, target 1.5 × range height, close all at 16:00.
  • Risk: 1% of equity per trade, one trade per day.
  • Filters: skip if the range is wider than 2 × ATR(14, D1).

If you cannot write a rule, the backtest will silently replace it with something else.

Step 3: prepare and split the data

Collect data from the broker you will trade with, check it for gaps and spikes, and record its source - see collecting quality historical data.

Then split it before the first test:

Part Share Use
Development ~60-70% Build and debug rules, explore parameters
Validation ~15-20% Choose between a few finalists
Final test ~15-20%, most recent One verdict, used once

Never move data from the final test back into development after you have seen it.

Step 4: run a baseline with realistic costs

Run the rules once with sensible default parameters and realistic spread, commission and swap. Check the trades visually on the chart: are entries and exits where the rules say? Fix logic errors now; they are much harder to find later.

Record the baseline metrics: number of trades, expectancy, maximum equity drawdown, profit factor, results by year.

Step 5: explore parameters carefully

If the baseline shows promise, look at how results change across parameter values:

  • Test a coarse grid first (for example range filter 1.5, 2.0, 2.5, 3.0 × ATR).
  • Prefer regions where neighbouring values work similarly over single peaks.
  • Limit the number of optimised parameters to the few that matter.

The goal is to understand the strategy’s behaviour, not to find the maximum. See parameter stability analysis.

Step 6: stress the survivors

Attack every candidate before you trust it:

  • Costs: spread and commission +50% or +100%.
  • Delay: enter one bar later.
  • Remove the best trades: drop the top 5 winners.
  • Monte Carlo: reshuffle trade order a few thousand times to see the range of drawdowns.
  • Related markets: if the logic is general, does it work at least reasonably on a similar instrument?

Robust strategies get worse under stress; fragile ones collapse.

Step 7: decide on validation, confirm once on the final test

Compare the few finalists on the validation period and pick one, using criteria you wrote down in advance, for example: expectancy above 0.1R, maximum equity drawdown below 15%, at least 150 trades.

Then run the chosen version once on the final test period. If it fails, the honest conclusion is that the idea did not hold - not that you need another round of tweaks on the same data.

For a more thorough version of steps 5-7, use walk-forward analysis.

Step 8: forward test

Run the strategy on a demo account or with very small size, unchanged, for a predefined period or number of trades. Compare:

  • trade frequency with the backtest;
  • average slippage and spread with what you assumed;
  • win rate and average R within the range the backtest suggested.

See why forward testing matters.

Step 9: go live with limits

Start with reduced size and explicit limits: maximum daily loss, maximum drawdown before the strategy is paused, and conditions for reviewing it. Treat the first months as continued testing.

Keep a research log

A simple table per strategy is enough:

Date Version Change Data Trades Expectancy Max eq. DD Decision
05-12 v1 Baseline Dev 2018-2022 412 0.12R 14% Continue
06-12 v2 ATR range filter Dev 2018-2022 356 0.17R 11% Finalist

The log shows how many variants you tried, stops you from repeating work, and makes it easy to explain later why a strategy exists.

In cTrader

The workflow maps directly to cTrader Algo: the Backtesting tab for baseline and stress tests (data source, commission and spread are set in its settings), the Optimisation tab for parameter exploration, and a separate cBot instance on a demo account for the forward test. The cTrader Algo guide shows where each step lives.

Key takeaways

  • Write the hypothesis, the rules and the success criteria before testing.
  • Split the data first and keep the final test untouched until the end.
  • Stress candidates instead of polishing them.
  • A research log turns trial and error into a process you can trust.

FAQ

How should I split my data?

A common split is roughly 60-70% for development, 15-20% for validation while you choose between variants, and the most recent 15-20% as a final out-of-sample test that you use once. Walk-forward analysis is a more thorough alternative.

What should go into a research log?

Date, strategy version, hypothesis, data period and source, cost settings, parameters tested, key metrics, and the decision you made. It prevents you from repeating tests and makes the number of variants you tried visible.

When is a strategy ready for live trading?

When it passed the out-of-sample test you defined in advance, survived robustness checks, and ran in a forward test long enough to collect a meaningful number of trades with behaviour close to the backtest.

Sources and further reading

  1. Bailey, Borwein, López de Prado, Zhu: The Probability of Backtest Overfitting - papers.ssrn.com
  2. cTrader Help: Backtest a cBot - help.ctrader.com
  3. cTrader Help: Optimise a cBot - help.ctrader.com