Skip to content
Daytraders.nl
Tutorial
Intermediate Technical analysis

Backtesting a Trading Strategy

Learn how to test a trading strategy on historical prices, which numbers to look at and which mistakes distort the result.

Read 12 min Published January 15, 2026 Updated October 10, 2026

TL;DR: Backtesting means running your rules on old prices to see what would have happened. It helps you find weak spots before you risk real money. A good backtest is no guarantee, but a bad backtest gives a false sense of security.

Step-by-step guide

  1. Write your rules so precisely that someone else could follow them: entry, stop-loss, target, position size.
  2. Choose your data and tool: a spreadsheet, a replay function in your charting platform, or a script.
  3. Choose a period with rising, falling and sideways markets.
  4. Keep part of the data aside and only test on it once your rules are fixed.
  5. Take every trade your rules give. Do not skip trades because they ‘feel wrong’.
  6. Record entry and exit prices, profit or loss, and costs for each trade.
  7. Calculate the numbers: win rate, average win and loss, profit factor and maximum drawdown.
  8. Then practise on a demo account before you risk real money.

Why backtest?

An idea that sounds good in your head can lose money on paper. A backtest checks that idea against old prices without costing you anything. It teaches you three things:

  • Does the strategy have a positive expectancy? In other words: do you earn something per trade on average, after costs?
  • How deep can a losing streak go? That decides whether you can stick with the strategy.
  • In which market conditions does the strategy fail?

Worked example: a strategy that turns out to lose money

Suppose you design a breakout strategy: you buy a stock that closes above its highest price of the last 20 days. You test it on 100 past trades:

  • 42 winning trades averaging €180 profit: €7,560
  • 58 losing trades averaging €220 loss: €12,760
  • Net result: €7,560 - €12,760 = -€5,200, or -€52 per trade
  • Profit factor: €7,560 / €12,760 = 0.59

This is a made-up example, but it shows what a backtest does: you see the problem on paper before it costs you money. You calculate expectancy per trade like this: (win probability × average win) - (loss probability × average loss). A second example: 40% wins averaging €300 and 60% losses averaging €100 gives 0.4 × €300 - 0.6 × €100 = €60 per trade. The profit factor is then 2.0.

The process

Step 1: Write rules with no room for interpretation

Your rules must be clear enough for someone else to follow without calling you.

  • Too vague: ‘Buy when the RSI is low and the stock looks good.’
  • Clear: ‘Buy at the next day’s open if the RSI (14) closes above 30 and the price is above its 50-day average. Put the stop-loss 8% below your entry. Sell when the RSI rises above 70 or after 14 days.’

Also fix your position size, for example with the position size calculator and the guide to risk management.

Step 2: Choose a period with different markets

A strategy that only works in a rising market is not a strategy but a bet on that market. Take a period with rising, falling and sideways stretches. A long enough period includes crises and recoveries. The longer the period, the less the result depends on a single event.

Step 3: Apply the rules without picking

This is where many people cheat, often without noticing. You see a trade in the test and think: ‘I would never have taken that one in real life.’ Yet it belongs in the test if your rules produced it. If you skip trades you dislike, you are testing your opinion, not your strategy.

Step 4: Record everything and calculate the numbers

Put every trade in a spreadsheet: entry date and price, exit date and price, profit or loss in euros and percent, and costs. Then calculate:

  • Win rate: the share of winning trades
  • Average win and average loss
  • Profit factor: total profit divided by total loss
  • Maximum drawdown: the deepest fall of your account from peak to trough
  • Expectancy per trade

Pitfalls that distort the result

A backtest tests a simplified world. The bigger the gap with the real market, the less the result is worth.

Curve fitting (over-optimising)

You try many settings and pick the best one. That best one mostly fits random swings in the past. Test 200 combinations and one will always look good by chance alone. So limit the number of settings, choose them before you test, and keep part of the data (for example 30%) for a check on data you have not used yet.

Survivorship bias (only the survivors)

If you test on the stocks that are in an index today, you miss the companies that went bankrupt or were dropped from the index. Your result looks better than it should. If possible, use data that also includes delisted stocks.

Look-ahead bias (peeking into the future)

You use information you did not have at that moment. Example: you buy at a day’s closing price, while your signal only becomes known after the close. Only use data that was available when the decision was made.

Forgetting costs and slippage

A backtest often assumes perfect execution with no costs. In real life you pay commission, the spread and sometimes a worse price than expected (slippage). Example: suppose these costs add up to €20 per trade on a €10,000 position (0.2%). With 50 trades a year that is €1,000 a year. For a strategy with a small profit per trade, that can be the difference between profit and loss. See also the break-even calculator.

Reading the results

No single number says: ‘your strategy is now good.’ These are the questions you can ask.

Profit factor. Below 1.0 the strategy loses. Just above 1.0, costs and slippage can eat the profit. A higher factor gives more room, but always look at the number of trades too.

Number of trades. A result from 10 trades says little. With 100 or more trades, luck fades somewhat, though that is no guarantee either.

Maximum drawdown. This is the deepest fall of your account. Use the drawdown calculator: after a 25% fall you need +33.3% to get back to your starting amount, and after a 50% fall you need +100%. Ask yourself honestly whether you could sit through such a fall without dropping your rules. Real drawdowns are often bigger than in the backtest.

Win rate and reward-to-risk. They belong together. With a reward-to-risk ratio of 2 to 1 (the average win is twice the average loss), you only need to win 1 trade in 3 (33.3%) to break even before costs. At 1 to 1 it is 50%. Use the risk/reward calculator to work this out for your rules. Also read about balancing risk and reward.

After the backtest: practise and start small

A good backtest is a first filter, not proof. Next, practise on a demo account (see paper trading) and compare your results with the backtest. If they differ a lot, find out why. Only then trade, and only with money you can afford to lose.

Trading involves risk: you can lose all or part of your money. Past performance is no guarantee of future results. This tutorial is information, not investment advice.

Work it out yourself

Open the full calculator →

Test yourself

Practice questions to check your understanding, not advice.

  1. A backtest shows €6,000 total profit and €4,000 total loss. What is the profit factor?

    • 2.0
    • €2,000
    • 0.67
    • 1.5
    Show answer

    Answer:D. 1.5

    The profit factor is total profit divided by total loss: 6,000 / 4,000 = 1.5. That is €1.50 profit for every €1.00 lost.

  2. A strategy wins 50% of trades with an average of €200 and loses 50% with an average of €100. What is the expected value per trade?

    • €50
    • €25
    • €100
    Show answer

    Answer:A. €50

    The formula is (win rate × average win) - (loss rate × average loss): 0.5 × €200 - 0.5 × €100 = €50 per trade, before costs.

  3. You test 200 combinations of settings and pick the one with the nicest result. What is the risk?

    • The profit factor automatically becomes too low
    • You use too few old prices
    • The result mostly fits random fluctuations from the past (curve-fitting)
    • The backtest counts too many costs
    Show answer

    Answer:C. The result mostly fits random fluctuations from the past (curve-fitting)

    With 200 combinations, one always looks good by chance. That is why you limit the number of settings and keep part of the data (for example 30%) for a check.

  4. During the test you skip trades that 'don't feel right'. What are you actually testing?

    • The strategy itself
    • Your own opinion instead of your rules
    • The effect of costs
    • The drawdown
    Show answer

    Answer:B. Your own opinion instead of your rules

    Trades that your rules produced belong in the test. If you skip them, you test your opinion and not your strategy.

  5. With a reward-to-risk ratio of 2 to 1, what percentage of trades must you win to break even, without costs?

    • 33.3%
    • 66.7%
    • 50%
    • 25%
    Show answer

    Answer:A. 33.3%

    At 2 to 1, winning 1 trade out of 3 (33.3%) is enough. At 1 to 1 it is 50%. Costs push the threshold higher.

Frequently asked questions

What is a profit factor?
Profit factor is your total profit divided by your total loss. A profit factor of 1.5 means €1.50 of profit for every €1.00 of loss. Below 1.0 the strategy loses money. There is no fixed level that counts as 'good enough': the closer the factor is to 1.0, the more easily costs and bad luck turn the result negative.
How many trades do I need before the result means anything?
The more trades, the more reliable the result. With 10 or 20 trades, luck decides the outcome. Many people use at least 100 trades as a rule of thumb, spread over rising, falling and sideways markets. It is not a guarantee, but it gives a fairer picture than a handful of trades.
What can a beginner use to backtest?
You can start with a spreadsheet and a chart from your broker. Manual backtesting means you scroll the chart back and move forward bar by bar, noting every trade. Many charting platforms have a replay function for this, for example TradingView's Bar Replay. Check what your own plan includes.
What is curve fitting and how do I avoid it?
Curve fitting means you adjust a strategy until it fits the old prices perfectly, but it does not fit new ones. Keep part of the data aside, for example 30%, and only test on it once your rules are fixed. Use few parameters and also test on other stocks or periods. If the strategy only works on one stock or in one period, treat that as a warning.
Does a good backtest mean the strategy will work live?
No. A backtest shows what could have happened in the past, not what will happen. Live, costs, delays and your own behaviour all play a part. Practise on a demo account first, and only trade with an amount you can afford to lose.