Skip to content
← All guides

Guide · 8 min read · Updated 17 November 2026

How to backtest a trading strategy without fooling yourself

A backtest runs a set of trading rules over past prices to see how they would have done. Done carefully, it is the cheapest way to throw out a bad idea before it costs you money. Done carelessly, it produces a beautiful equity curve that means nothing. This guide covers the steps that separate the two.

1. Write rules a computer could follow

A strategy can only be tested if every decision is mechanical. "Buy when RSI(14) closes below 30, sell when it closes above 50" is testable. "Buy when momentum looks strong" is not, because two people would trade it differently.

For each rule, write down:

  • What triggers an entry, and on which price (close, open, high, low).
  • What triggers an exit: a signal, a stop loss, a target or a time limit.
  • Which market and which bar size (daily, hourly, 5-minute).
  • How much you put into each trade.

If you cannot fill in all four, the strategy is not ready to test. Most strategies shared online leave at least one of them out.

2. Use only information you would have had

Look-ahead bias is the most common way a backtest lies. It happens when a rule uses a price that was not yet known when the decision was made, such as entering at today's close based on a signal that needs today's close to be calculated.

A simple guard: compute signals on one bar's close and fill the order at the next bar's open. That is how our engine works, as described on the methodology page.

3. Charge costs on every trade

Brokerage, exchange fees, taxes and slippage (the gap between the price you wanted and the price you got) are charged on every entry and exit. A strategy that trades often can look excellent before costs and lose money after them.

Read why costs and slippage kill most backtests for the arithmetic.

4. Keep a period the rules never saw

Split the history by time. Develop or describe the strategy on the earlier part and judge it on the later part. If the strategy only works on the period it was built on, it was fitted to noise. This is called out-of-sample testing, and it is the single best defence against overfitting.

We split every test 70/30 by time and show both periods side by side. See overfitting and out-of-sample testing.

5. Compare with doing nothing

Always put the result next to buy-and-hold on the same instrument over the same dates. A strategy that makes 40% while the market made 90% has not added anything except work and costs.

6. Read more than the return

The headline return is the least informative number. Look at:

  • Number of trades: fewer than about 30 and the win rate is mostly noise.
  • Max drawdown: the worst fall from a peak. Could you sit through it with real money?
  • Longest losing streak: expect at least that many losses in a row again.
  • Dependence on a few trades: remove the best one or three trades and see what is left.
  • Whether random entries would have done as well. See the random-entry test.

7. Treat a good result as a hypothesis

A backtest that survives all of the above is a reason to keep watching, not proof of an edge. Markets change, and real fills are messier than simulated ones. The honest next step is to track the rules forward on new data before risking money.

Do it without code

If you have a strategy from a video, article or post, send us the link. We turn the rules into a test, run it on real price history with costs and an out-of-sample period, and email you the result with every trade. Today the engine tests long-only strategies on daily bars for a fixed list of markets.

Common questions

How many years of data do I need for a backtest?
Enough to include different market conditions and at least 30 trades. For a daily strategy that usually means several years. A strategy that trades rarely needs a longer history to produce enough trades to judge.
What is a good win rate?
There is no good win rate on its own. A 35% win rate can be profitable if winners are much larger than losers, and a 90% win rate can lose money if the rare losers are huge. Look at win rate together with average win, average loss and the number of trades.
Can a backtest prove a strategy works?
No. A backtest can show that a strategy would have worked on past data under stated assumptions. It cannot show that it will keep working. Its real value is finding flaws cheaply.

Research, not advice. This guide is general education. It does not recommend buying or selling anything. Read the risk disclosure.