Maetis™
← Strategy & Backtesting

Strategy Backtest Lab

A simple rule, run against real prices.What the win rate hides, and what changes when you nudge one number.

Sign in to unlock Level 6.

Sign in

This Lab runs a simple, transparent rule against real daily prices: buy when price breaks above its recent high, hold for a fixed number of days, then exit. It is not a strategy to copy. It is a way to see what a backtest actually tells you, and what it does not. You choose a stock or all four pooled, the length of the breakout window and the holding period, and you can add trading costs and require volume to confirm a breakout.

How to use this Lab

  1. Choose a stock (TCS, Reliance, HDFC Bank or Infosys), or all four pooled.
  2. Set the breakout window, from 5 to 40 days. A breakout is a close above the highest price in that window.
  3. Set the holding period, from 3 to 30 days.
  4. Optionally include trading costs of about 0.2 percent per round trip, and count only breakouts confirmed by volume.
  5. Read the win rate, the average win and average loss, the total trades, the expected value per trade and the compounded return.

What to notice

Win rate alone misleads
Expected value is the win rate times the average win, plus the loss rate times the average loss. A rule can win most of the time and still lose money if its losses are larger than its wins.
Small changes swing the result
Nudge the breakout window or the holding period by a little and watch how much the numbers move. That swing is the overfitting warning: a rule tuned tightly to one setting on one stretch of history is memorising that stretch.
Costs matter
Switch on the cost option and see how much each trade's result falls. Small costs matter more when the average gain per trade is small.

Win rate against expected value (hypothetical arithmetic)

Suppose a rule wins 40 percent of the time, with an average win of 6 percent and an average loss of 2 percent. The expected value per trade is 0.4 x 6 plus 0.6 x (minus 2), which is 2.4 minus 1.2, or plus 1.2 percent.

Suppose another rule wins 70 percent of the time, with an average win of 1 percent and an average loss of 3 percent. Its expected value is 0.7 x 1 plus 0.3 x (minus 3), which is 0.7 minus 0.9, or minus 0.2 percent. The second rule wins more often and still loses money.

Costs of about 0.2 percent a trade would take the first result from 1.2 to about 1.0 percent, and the second from minus 0.2 to minus 0.4 percent.

What this Lab does not show

  • The Lab uses four large companies that are still listed today. Companies that did not survive are missing, which is survivorship bias, and it flatters any rule tested this way.
  • The cost toggle is a rough retail estimate, not your broker's fees or the real slippage on any day.
  • About three years of real history is a short sample. A result here says little about how the rule would behave in another period.
  • It is a simulated result of a made-up rule against real prices, not a claim about these companies, and not investment advice.

Common questions

What is backtesting?
Running a rule against past prices to see what it would have done. It shows what happened in that history, not what will happen next.
What is expected value in trading?
The average result per trade: win rate times average win plus loss rate times average loss. It matters more than the win rate on its own.
What is overfitting?
Tuning a rule so closely to one stretch of history that it only fits that stretch, and then fails on new data.
What is survivorship bias?
Testing only on companies that still exist today, which leaves out the ones that failed and makes a rule look better than it was.

Learn the idea

Related terms

Try next