How to backtest a trading strategy without fooling yourself.

Ten steps, from writing the test down first to asking why the survivors survived, each shown on Finertia’s own runs of the Nifty 50 and Apple.

The short answer

A backtest fools you when the same data both choose the rule and grade it. Every step below takes one of those chances away. Together they are how Finertia ran its study of the Nifty 50: 129 strategy-and-stock pairs over 2011–2025, of which 50 looked better than holding the stock on the years they were tuned on, and 4 were still standing after every check.

Most of what looked good at the start did not hold up. That is the normal outcome of an honest backtest, not a sign it went wrong.

1. Write the test down before you run it

Decide the strategy, its settings to try, the years, the costs and what counts as a pass before the first run. Afterwards it is too easy to move the bar to where the result landed. The Nifty study wrote its passing rules down first and reported how many pairs fell at each step, not only the 4 that passed.

2. Use the stock list as it stood at the start

Today’s index holds the companies that did well enough to stay in. Testing on it quietly picks the winners in advance. Holding the typical stock from today’s Nifty 50 gave a Sharpe ratio of 0.51 over the tuning years; holding the typical stock from the list as it stood in 2011 gave 0.28. Same years, different list. Survivorship bias on the Nifty 50 has the full comparison.

3. Trade on the next day, not the same one

A signal worked out from today’s close can only be traded tomorrow. A backtest that trades it today gets a price no one could have had, and nothing in the code warns you. See lookahead bias.

4. Charge costs, then change them

Every trade costs brokerage, taxes and the spread. The Nifty study charged 0.1% per trade, then re-ran everything at half and at double that. The number of surviving pairs went from 4 at half cost to 4 at the default and 3 at double. A result that only exists at one cost is a result about the cost.

5. Tune on the early years, score on the later ones

Pick the settings on the first part of the history and score them, unchanged, on the rest. Only the second number is evidence. In the Nifty study the typical pair had a Sharpe of 0.09 on the tuning years and −0.18 on the later ones, and of the 50 pairs ahead of holding at first, 7 were still ahead afterwards. Walk-forward validation explains the method.

6. Count every setting you tried

The more settings you try, the better the best one looks by luck. On Reliance Industries the study tried 70 Bollinger-band settings. The best on the tuning years scored 0.342; on the later years it scored −0.463 and ranked 623 of 834 combinations tried on the stock. Searching harder made the tuning number better and the later number worse.

7. Move the split and run it again

One split is one draw. On Apple from 2018, momentum’s pick scored 0.949 on the tuning years and −0.303 on the later ones: failed. Ending the test one year later, the same strategy held up at 0.547. Bollinger bands went the other way, from held up to failed. If the verdict flips when the dates move, the dates were doing the work.

8. Compare against holding the same stock

Making money is not the bar; beating the plain alternative is. On the later years the typical Nifty pair scored −0.18, while holding the typical stock scored 0.59. Only 15 of 129 pairs did better than holding. The Sharpe ratio explains how to compare the two fairly.

9. Check whether luck explains it

Permutation test

Would the same time in the market, at random moments, have done as well? Bollinger bands on Apple came out at p 0.164: their timing could not be told apart from shuffled timing. How it works.

Deflated Sharpe ratio

Is the best Sharpe higher than the best of that many random tries would reach?

Probability of backtest overfitting

When the history is cut up many ways, how often does the tuning winner land in the bottom half on the other part? The overfitting checks.

10. Ask why the survivors survived

A result that passes every check still needs a reason. All 4 Nifty survivors were on companies of one business group that fell apart over the decade. The rules beat holding by sitting in cash through a long fall, not by timing good moments to buy, and one of the stocks had long stretches with no trading at all. That is something to know, but it is not a skill a rule can be expected to repeat.

The list on one page

StepThe question it asks
Write it down firstWas the bar set before the result was known?
Stock list as it wasWere the losers in the test too?
Next-day tradingCould anyone have traded at that price?
Costs, changedDoes it survive realistic and harsher costs?
Unseen yearsDoes it work on years it was not tuned on?
Count the settingsHow many tries did the winner beat?
Move the splitDoes the verdict hold on other dates?
Against holdingDid it beat simply owning the stock?
Luck checksCould chance alone have produced it?
Why it workedIs there a reason, or only a number?

Which steps Finertia does for you

The workspace trades every signal on the next day, charges costs on every trade and shows how far they could rise before the result goes, tunes on the first 70% and scores on the rest, slides the split through the period, compares against holding the same stock and runs the luck checks. Steps 1, 2 and 10 are yours: what to test, on which stocks, and what to make of what passes. To see a full result on past data first, open the demo.

What this list does not do

Passing all ten steps means a backtest has fewer ways to fool you. It does not mean the rule has an edge, or that what it did on past prices says anything about later ones. The two studies these figures come from: Of 129 Nifty strategies, four survived honest testing and the best-looking one was the worst on new data.

On real stocks

Each stock page runs the same three rules on one stock, 2019–2024, against holding it. 14 of them are Indian large caps.

All the stocks

See it on a real strategy.

Finertia runs these checks on any stock you pick. The free plan runs the backtest; Pro adds the validation.