⚠ Trading involves significant risk of loss. Everything on this site is for education only and is not financial advice.
Lesson 10 of 10 · Free

Backtesting and Forward-Testing a Setup

Test a setup with written rules, record results in R and avoid curve-fitting and look-ahead bias.

Author: Moustafa HijaziContent reviewed: 2026-10-304 min readSelf-study course

What you will learn

  • How to write rules precise enough to test.
  • How to record results in R and calculate expectancy and profit factor.
  • Why sample size matters and how a few trades can change everything.
  • How to avoid curve-fitting and look-ahead bias, and how forward-testing helps.

Explanation

Backtesting means applying fixed rules to past data and recording what would have happened. Forward-testing means applying the same rules to new data as it happens, in a demo account or with very small size. A good backtest is evidence about the past, not a promise about the future.

Testable rules

Every rule must be answerable with yes or no. "Strong trend" is not testable. "Daily close above the 50-day SMA and the last daily swing low unbroken" is testable. Write down: market, timeframes, setup conditions, entry trigger, stop, target or exit, and the maximum risk per trade.

Recording in R

Record each result as a multiple of the planned risk. From the list you calculate:

  • Win rate = winning trades ÷ all trades
  • Expectancy = total R ÷ number of trades
  • Profit factor = sum of winning R ÷ sum of losing R (as a positive number)
  • Longest losing streak and largest drawdown (biggest fall from a peak in your running total)

Include estimated costs (spreads, fees, slippage) as a deduction in R per trade.

Sample size

A small sample is noisy. The fewer trades, the more one or two lucky trades decide the result. Collect as many trades as you reasonably can, from different market conditions (trends, ranges, high and low volatility), before you trust a number.

Curve-fitting and look-ahead bias

Curve-fitting (over-optimisation) means adjusting rules and settings until the past looks perfect. The rules then describe the past noise, not a repeatable behaviour. Protection: keep rules simple, fix them before testing, and test on a separate period you did not use while building the rules.

Look-ahead bias means using information that was not available at the time of the decision. Examples: using a swing point before it was confirmed, or using the day's close to decide an entry during that day. When testing by hand, scroll the chart forward one candle at a time.

Worked example

Hypothetical example: 40 recorded backtest trades of one setup. Planned risk €100 per trade (1R).

  1. Wins: 16 trades, total +33.6R (average +2.1R). Losses: 24 trades, total −24.0R.
  2. Win rate: 16 ÷ 40 = 40%
  3. Net result: 33.6R − 24.0R = +9.6R. Expectancy: 9.6R ÷ 40 = +0.24R per trade
  4. Profit factor: 33.6 ÷ 24.0 = 1.4
  5. Estimated costs 0.1R per trade: 40 × 0.1R = 4.0R. Net after costs: 9.6R − 4.0R = +5.6R, or 0.14R per trade (about €14 per trade at €100 risk). Taxes are excluded.

Sensitivity check, before costs: remove the two best trades (+4.5R and +4.0R, total +8.5R). Then 9.6R − 8.5R = +1.1R over 38 trades ≈ +0.03R per trade. The edge almost disappears. This sample is far too small to trust, so the next step is more backtest data and a forward-test.

Common mistake

Optimising after every losing streakChanging a rule after five losses and testing again until the result looks good is curve-fitting in small steps. Decide in advance how many trades you will collect before reviewing, and change only one rule at a time, then retest on new data.

Practice activity

Hypothetical results in R of 10 trades: +2, −1, −1, +3, −1, +1.5, −1, −1, +2, −1. Calculate win rate, net R, expectancy and profit factor. Then write one reason why 10 trades are not enough.

Show solution

Wins: 4 (2 + 3 + 1.5 + 2 = +8.5R). Losses: 6 (−6.0R). Win rate: 4 ÷ 10 = 40%. Net: 8.5R − 6.0R = +2.5R. Expectancy: 2.5R ÷ 10 = +0.25R. Profit factor: 8.5 ÷ 6.0 ≈ 1.42.

Ten trades are not enough because one trade (the +3R) changes the result strongly; without it expectancy falls to −0.5R ÷ 9 ≈ −0.06R.

Limitations: costs are excluded here; real results would be lower.

Key takeaways

  • Only yes/no rules can be tested honestly.
  • Record every trade in R, including costs, and calculate expectancy, profit factor and drawdown.
  • Small samples mislead; check how much a few trades drive the result.
  • Avoid curve-fitting and look-ahead bias; confirm with a forward-test on new data.

Next step

You have finished this course; continue with "Risk & Trade Management" to turn a tested setup into a complete plan for position sizing, drawdowns and trade handling.

Self-check

Answer the questions, then check your answers. You can retry as often as you like.

1. Hypothetical: 50 trades, total winning R = +30, total losing R = −25. What are the expectancy and profit factor?

2. While backtesting by hand, a trader enters at a swing low that only became confirmed two candles later. What is this error?

3. A trader tests 20 combinations of moving average periods and keeps the one with the best past result. What is the main risk?

Automatic self-check for your own revision. Your answers are checked in your browser and are not seen or assessed by us. It is not an exam and not a qualification.

Your progress

“Complete” only means you marked the lesson as done. It is not a test of your understanding. Progress and notes are saved only in this browser on this device — not in an account.