How do you backtest: chart replay, spreadsheets or code?

Backtesting ranges from scrolling back through charts and writing down every setup, to replay tools that hide future candles, to coded tests across years of data.

How do you do it?

How do you backtest: chart replay, spreadsheets or code? — bid-ask spread diagram
The bid-ask spread on a currency pair
  • which method or tool you use (describe it; no links to paid products)
  • how many trades you collect before trusting the results
  • how you account for spread, commission, swap and slippage
  • how you avoid tuning the rules until the past looks perfect
How do you backtest: chart replay, spreadsheets or code? — support and resistance diagram
Price bouncing between support and resistance

That last point is where most backtests go wrong. Rules adjusted to fit one stretch of data often fall apart on the next. If you keep part of your data back to test the finished rules, explain how you split it.

Background: Bid, ask and slippage: why your order fills at a different price

Why buy trades open at one price and close at another, why a stop can trigger when the chart never touched it, and how slippage happens.

Why did my stop-loss trigger when the price on the chart didn't reach it?

Charts usually show the bid price, but a sell position's stop is triggered by the ask. If the spread widened, the ask could have touched your stop while the bid line stayed away from it.

What is slippage?

The difference between the price you expected and the price your order was filled at. It is most common in fast or thin markets, such as around news releases.

Read the full guide

Comments

Log in to join the discussion. Comments follow the community guidelines.

Log in to comment

Loading comments…

  1. FTC Community Team1 mo ago

    A checklist that catches the most common backtesting mistakes, whichever method you use.

    1. Write the rules before testing. Entry, stop, exit and position size, in enough detail that someone else would take the same trades.
    2. Collect enough trades. Results from 20 trades can be pure luck. Many traders want at least 100 before drawing conclusions.
    3. Include costs: spread, commission, swap for trades held overnight, and some slippage around releases (trading costs).
    4. Split the data. Develop the rules on one period, then test the finished rules once on a later period you haven't looked at.
    5. Check the drawdown, not just the total. Would you really have kept trading through the worst stretch?

    If the results on the untouched period are much worse, the rules were probably fitted to the first one. The next step after a backtest is usually a period of forward testing on demo or at small size.

    Background: drawdown and recovery maths.

    0