Guide · Risk and process

How to backtest a trading strategy: a manual, step-by-step method

Backtesting is checking how a set of rules would have behaved on past charts before you risk money on them. Done honestly it is the cheapest education in trading. Done carelessly it produces beautiful numbers that fall apart the week you go live.

Last reviewed by the MarketPro research desk · Editorial policy

Short answer

To backtest a trading strategy, write its rules down exactly, pick one market and timeframe, scroll the chart back and step forward one candle at a time, and log every trade the rules would have taken: date, direction, entry, stop, target, exit and result in R (multiples of the risk). Include the spread and swap, collect at least 50 trades across different market conditions, then study the average win against the average loss, the longest losing streak and the deepest drawdown. Finish with a month of forward testing on a demo account.

Key takeaways

  • Rules first. If a rule needs judgement you cannot repeat, the backtest measures your mood, not the strategy.
  • Hide the future. Step forward one candle at a time and decide before the next one appears.
  • Record in R, not money. Results as multiples of the risk let you compare trades and test any position size later.
  • Fifty trades is a floor, not a target. Include trends, ranges and quiet weeks, and count every cost.
  • Forward test before going live. A month on demo shows whether you can follow the rules in real time.

What backtesting is, and what it is not

A backtest applies a fixed set of rules to historical price data and records what would have happened. It answers a narrow question: if I had followed these exact rules over this period, what would the trades have looked like? It shows how often the setup appears, the typical win and loss, and how long and deep the bad runs get.

It does not tell you what will happen next. Markets change, and the past period may have suited the rules better than the next one will. What a good backtest does is remove bad ideas cheaply and show you what a normal bad stretch looks like, so you recognise it later instead of abandoning the strategy at the worst moment.

This guide covers manual backtesting: stepping through a chart by eye, ideally with the bar replay mode most charting platforms offer, and logging trades in a spreadsheet. Automated testing in code comes later; doing it by hand first teaches you how the strategy actually behaves.

Manual backtesting, step by step

Set aside a few focused sessions. Rushing a backtest is how hindsight creeps in.

  1. Write the rules so a stranger could follow them

    Setup, entry, stop, exit, skip

    Before opening a chart, write the strategy on one page: the market condition it needs, the exact entry trigger, where the stop goes, how you exit, and when you skip a trade. Replace vague words with testable ones. "Uptrend" becomes "price above a rising 50-period EMA on the daily chart"; "rejection" becomes "a candle that closes back above the level with a lower wick at least twice its body". How to check you are done: would someone else, given the page, mark the same trades? If not, the rules still contain judgement.

  2. Choose one market, one timeframe and a fixed period

    Decide before you look

    Pick the market and timeframe you intend to trade, for example EUR/USD on the 4-hour chart, and a period long enough to include different conditions: a trend up, a trend down and at least one long range. For a 4-hour strategy, one to two years is a reasonable start. Choose the dates before you look at the chart, so you do not unconsciously pick a stretch where the strategy obviously worked. How to use it: note the start and end dates at the top of your spreadsheet, and keep a later period untouched to test any changes on afterwards.

  3. Hide the future and step forward

    Bar replay or scrolling one candle at a time

    Scroll back to the start date so that no later candles are visible, or use your platform's bar replay mode. Move forward one candle at a time. At each close, ask only one question: do the rules say to act now? If yes, write down the entry, stop and target before revealing the next candle. How to use it well: work in sessions of an hour or so, because tiredness makes you skip setups or bend rules, and if you catch yourself pausing to "see what happens", decide first.

  4. Log every trade, including the ugly ones

    One row per trade

    Record each trade in the spreadsheet as soon as its outcome is known: date, direction, entry, stop, target, exit, the reason for the exit, and the result in R. A trade that hit its stop for a full loss is -1R; one that reached a 2:1 target is +2R. Take a screenshot of each one. How to stay honest: log the trades you would rather skip, the ones that triggered just before a news release or looked messy. If you would not take them live, add a written rule that excludes them and apply it to every trade from the start, not just the losers.

  5. Count the costs on every trade

    Spread, commission, swap, slippage

    Subtract the cost of each trade from its result. Use the typical spread for that market and session, any commission per lot, swap for each night the trade was open, and a small allowance for slippage on stop exits. Converting costs into R keeps everything comparable: a 1.2-pip cost on a 20-pip stop is 0.06R per trade. How to use it: add a costs column and a net R column, and judge the strategy on the net figure only. Short-term strategies often look strong before costs and flat after them.

  6. Reach a meaningful sample

    50 trades minimum, 100 or more is better

    Luck dominates small samples. Keep going until you have at least 50 trades, more if results are close to break-even, drawn from different conditions rather than one strong trend. How to use it: if the setup appears too rarely on one market to reach 50 trades in two years, add a second, less correlated market with the same rules (gold alongside EUR/USD, for example) rather than loosening the rules to create more trades.

  7. Review the numbers that decide whether you can trade it

    Expectancy, streaks, drawdown

    Once the sample is complete, calculate the average net result per trade in R (the expectancy), the average win and loss, the longest losing streak and the deepest drawdown in R. Then split the results by market condition: trending against ranging, and by session if relevant. How to use it: a positive expectancy is the starting requirement, but the streak and drawdown decide whether you will keep following the rules. If ten losses in a row is normal for this strategy, ask yourself honestly whether you would still be trading it after the eighth, and size accordingly.

  8. Forward test on demo before risking money

    At least a month, in real time

    Trade the strategy on a demo account in real time, with the position size you would use live, and keep logging in the same spreadsheet. The goal is to see whether the rules can be followed when the next candle is genuinely unknown, and whether live spreads and fills match your assumptions. How to use it: compare forward-test results with the backtest after 20 to 30 trades. If the shape is similar, move to a small live account. If it is much worse, check for execution mistakes first, then suspect hindsight in the backtest.

EUR/USD 4-hour chart in an uptrend above a rising 50-period EMA with three logged backtest trades: a first pullback entry that reaches its target, a second that is stopped out, and a third that is still open, each marked with its entry.
Each setup that met the rules is marked and written down before the next candle is revealed, including the one that lost. Illustrative chart, not live market data.

The chart shows what a test looks like part way through: each setup that met the rules is marked and logged, the losing trade included. Skipping the loss because "I would not have taken that one" is the most common way a backtest lies.

What to record for every trade

A spreadsheet with one row per trade is enough. These columns cover what you need to analyse the results later:

ColumnExampleWhy
Date and time2025-03-12 08:00Lets you check sessions, news days and seasonality
Market and directionEUR/USD, longCompare markets and longs against shorts
Entry, stop, target1.0866 / 1.0838 / 1.0922The plan, written before the outcome
Exit price and reason1.0922, targetTarget, stop, time exit or rule exit
Result in R+2.0Comparable across all trades and sizes
Costs in R-0.05Spread, commission and swap
Market conditionTrendingShows where the rules work and where they do not

From those columns a few formulas give you everything that matters: the number of trades, the share that won, the average win and average loss in R, the expectancy (the average result per trade in R, after costs), the longest losing streak, and the largest peak-to-trough fall in a running total of R, which is the drawdown.

A useful sanity check is break-even arithmetic: winning 2R and losing 1R breaks even if about a third of trades win, before costs. Results close to break-even will be decided by costs and execution.

The traps that make a backtest lie

  • Look-ahead bias. Using information that was not available at the time, such as knowing a level held before deciding to buy it. Bar replay and a strict "decide, then reveal" habit are the cure.
  • Curve fitting. Tweaking settings until the past looks perfect: an 18-period average instead of 20 because it caught two extra trades. Every tweak fits the noise of that period more closely and makes the future less like it. Keep rules simple, change one thing at a time, and test the change on a period you have not looked at.
  • Survivorship and selection bias. Testing only the market or period where you know the strategy did well. Pick the market and dates before you look, and include the difficult stretches.
  • Ignoring costs. A strategy with small targets can look fine before costs and lose money after them. Include the typical spread, commission, and swap for every night held, and add a little slippage on stops.
  • Too few trades. Twenty trades can look excellent or terrible purely by luck. Treat anything under 50 as a first impression, and prefer 100 or more across different conditions.

Forward testing, and reading the results

A backtest shows how rules behaved with the future hidden by discipline. A forward test shows how they behave with the future truly unknown, and how you behave while following them. Trade the strategy on a demo account for at least a month, at the size you would use for real, and log every trade in the same spreadsheet.

Then compare three things across backtest and forward test: the average win against the average loss, the longest losing streak, and the deepest drawdown. If forward results are much worse, look first at execution (late entries, skipped trades, moved stops) and costs, then at whether the market has changed character.

Finally, turn the numbers into a risk decision. Put your losing-streak and drawdown figures into the drawdown calculator to see what they would do to your account at different risk levels, and use the risk of ruin calculator to check that a bad run would not take the account below the point where you would stop.

Written and reviewed by the MarketPro research desk

MarketPro is a trading-signal and trading-education app operated by Harajuku Holdings LTD (Cyprus). Our signal desk publishes and tracks every trade idea in-app, and every page here is checked against the app's live behaviour before publishing. Last reviewed . How we produce signals and content · About MarketPro

FAQ

Frequently asked questions

How many trades do you need to backtest a strategy?
At least 50, and 100 or more if you can. Small samples are dominated by luck: twenty trades can make a weak strategy look strong or a sound one look broken. The sample should also cover different conditions, such as trends, ranges and quiet periods, rather than one favourable stretch.
Can I backtest a trading strategy for free?
Yes. Most charting platforms let you scroll back through historical charts at no cost, and many include a bar replay mode on free plans with some limits. A free spreadsheet is enough to log trades and calculate the results.
What is the difference between backtesting and forward testing?
Backtesting applies your rules to past data with the future hidden by discipline. Forward testing applies them in real time on a demo account, where the future is genuinely unknown. Forward testing catches hindsight that slipped into the backtest, and shows whether you can follow the rules at live speed.
Why do strategies perform worse live than in the backtest?
The usual causes are hindsight in the backtest, costs and slippage that were underestimated, settings tuned too closely to past data, and execution mistakes such as late entries or moved stops. Markets also change. A month of forward testing on demo usually reveals which one applies.
Trade · Learn · Earn

See strategies on live charts

Every MarketPro signal names its setup and timeframe, with the entry, stop and targets drawn on the chart. Free signals every week, and 320 lessons in the academy.

Same account as the app · No install · Free to start

Not investment advice. Past performance is not indicative of future results.