What is backtesting? How to test a trading idea on history

A backtest replays a written rule on past prices to see how it would have behaved. Learn what it can show, what it cannot, and how to run a fair one.

हिन्दी में पढ़ें

Key takeaways

  • A backtest replays a rule on historical prices; it shows how the rule behaved, not what will happen.
  • A fair test needs a clear entry, an exit, a stop and estimated costs.
  • Judge a backtest by the number of trades and the worst dip, not one final number.
  • Tuning a rule until the past looks perfect usually fails on new data.
Reading an equity curve
Equity curve, illustrative example -- made-up numbersDrawdown
Illustrative example with made-up numbers, not a real backtest result.

What a backtest is

A backtest takes a rule written in plain steps, such as buy when a condition is true and exit on a stop or another condition, and replays it on past prices. It records every trade the rule would have made, so you can study how the idea behaved before risking any money.

What you need for a fair test

A clear entry rule, a clear exit, a stop, a position size, a period long enough to include different market conditions, and estimated trading costs. Leaving out costs or the stop makes a rule look better than it is.

What a backtest can tell you

How many trades the rule made, how long it held them, how big the worst losing stretch was, and how the result changed with different settings. These are the facts that help you decide whether the idea deserves more testing.

What it cannot tell you

It cannot tell you the future. It is built with hindsight, so a rule tuned on the past can fail on new data. Real markets also have slippage and gaps that a simple replay cannot fully capture.

Common mistakes

Judging a rule on a handful of trades. Tuning the settings again and again until the past looks perfect. Ignoring costs, which matter more for rules that trade often. Looking only at the final number and skipping the worst dip.

Run your first backtest

Pick one simple rule, choose a stock and a long period, add a stop, and run it. SmartPaperDesk backtests on historical, delayed daily data with estimated charges, and you can do it on the free plan. Then try a small change and see how much the result moves.

Questions people ask

Does a good backtest mean the rule will work?

No. It means the rule behaved well on that history. It may fail on new data, so check it on a period it was not tuned on and then paper trade it.

How long a period should I backtest?

Long enough to include several kinds of market, and to produce many trades. A rule judged on a few trades tells you very little.

Run your first backtest on the free plan

Keep reading

SmartPaperDesk is an educational paper-trading tool. Examples use a made-up Stock A.

For educational purposes only. This is not investment advice. Past performance does not guarantee future results.