Rule backtest — every trade, the equity curve and the drawdown
A trading rule is replayed bar by bar over daily bars. Output: each trade, the equity curve, win rate, average R (average win ÷ average loss), profit factor and maximum drawdown. The rule shown is a 20-day moving-average crossover (long when the close is above its 20-day average, exit when it closes below, 8% stop). Fills happen at the bar close, so there is no look-ahead, replayed on daily history covering 2021-10-11 → 2026-10-12 (1256 daily bars). Results are gross of costs — no commission, spread or slippage is deducted.
Measured over 2021-10-11 → 2026-10-12 (1256 daily bars) · one symbol, one rule, 54 trades. A dash marks a figure this sample cannot measure.
- Period
- 2021-10-11 – 2026-10-12
- Out-of-sample from
- none — whole period in sample
- Trades
- 54
- Costs charged
- 0 bps per side 0 bps commission + 0 bps slippage, charged on every position change
Hypothetical, backtested results — not the record of a traded account. Past results do not predict future returns; the strategy set was chosen with knowledge of the history it is measured on, and no financing, borrow, tax or capacity constraints are modelled. One name’s result does not generalise. There is no out-of-sample split: every bar behind these figures was already available when the rule was chosen.
Equity curve — the rule's running NAV
| Sharpe | 0.93 | Sortino | 1.36 |
| Calmar | 0.74 | Annualized (extrapolated from 1256 bars) | +16.75% |
| Avg win | +7.26% | Avg loss | -2.30% |
Fills at the close of the signal bar (no look-ahead). Profit factor = gross gains ÷ gross losses; average R = average win ÷ average loss; maximum drawdown = deepest peak-to-trough decline of the equity curve. A dash marks a figure this sample cannot measure: with no losing trade there is no profit factor, and with no drawdown there is no Calmar.
The rule under test
Backtest glossary
- Backtest
- Replaying a fixed set of trading rules over historical prices to estimate how they would have performed.
- Sharpe ratio
- Annualised return divided by the volatility of returns — reward per unit of total risk.
- Sortino ratio
- Like Sharpe but only counts downside volatility in the denominator.
- Calmar ratio
- Annualised return divided by the maximum drawdown — reward per unit of worst-case pain.
- Max drawdown
- The largest drop from a peak in the equity curve to a subsequent trough.
- Profit factor
- Gross profit divided by gross loss; above 1 means the strategy is net profitable.
- Exposure
- The fraction of bars the strategy was actually in a position (capital at work).
- Stress test
- Re-running the strategy on a deliberately worse price path to see if it survives bad conditions.
- Sim-to-live promotion
- The gate that decides whether a paper-traded rule-set is trustworthy enough to run with real consequences.
Trade ledger — 54 trades
| 1 | 19 @ 151.28 | 22 @ 147.92 | 3 bars | -2.22% | rule |
| 2 | 24 @ 149.99 | 60 @ 174.92 | 36 bars | +16.62% | rule |
| 3 | 76 @ 170.33 | 86 @ 168.64 | 10 bars | -0.99% | rule |
| 4 | 87 @ 168.88 | 90 @ 168.88 | 3 bars | +0.00% | rule |
| 5 | 110 @ 163.98 | 126 @ 165.75 | 16 bars | +1.08% | rule |
| 6 | 142 @ 166.02 | 143 @ 156.77 | 1 bars | -5.57% | rule |
| 7 | 159 @ 149.64 | 163 @ 145.38 | 4 bars | -2.85% | rule |
| 8 | 164 @ 146.14 | 167 @ 142.64 | 3 bars | -2.39% | rule |
| 9 | 177 @ 141.66 | 179 @ 137.44 | 2 bars | -2.98% | rule |
| 10 | 182 @ 138.93 | 221 @ 163.62 | 39 bars | +17.77% | rule |
| 11 | 260 @ 147.27 | 268 @ 145.03 | 8 bars | -1.52% | rule |
| 12 | 274 @ 146.87 | 285 @ 144.22 | 11 bars | -1.80% | rule |
| 13 | 287 @ 148.03 | 291 @ 142.91 | 4 bars | -3.46% | rule |
| 14 | 315 @ 133.49 | 342 @ 148.48 | 27 bars | +11.23% | rule |
| 15 | 350 @ 151.03 | 355 @ 148.50 | 5 bars | -1.68% | rule |
| 16 | 356 @ 150.47 | 377 @ 160.10 | 21 bars | +6.40% | rule |
| 17 | 378 @ 165.56 | 386 @ 163.77 | 8 bars | -1.08% | rule |
| 18 | 388 @ 168.41 | 454 @ 192.58 | 66 bars | +14.35% | rule |
| 19 | 473 @ 184.12 | 479 @ 177.56 | 6 bars | -3.56% | rule |
| 20 | 499 @ 174.91 | 509 @ 175.46 | 10 bars | +0.31% | rule |
| 21 | 519 @ 177.57 | 554 @ 193.60 | 35 bars | +9.03% | rule |
| 22 | 570 @ 188.63 | 579 @ 184.40 | 9 bars | -2.24% | rule |
| 23 | 583 @ 189.30 | 585 @ 188.32 | 2 bars | -0.52% | rule |
| 24 | 612 @ 176.08 | 614 @ 171.37 | 2 bars | -2.67% | rule |
| 25 | 618 @ 173.31 | 619 @ 171.48 | 1 bars | -1.06% | rule |
| 26 | 628 @ 175.04 | 631 @ 169.38 | 3 bars | -3.23% | rule |
| 27 | 638 @ 169.89 | 639 @ 169.30 | 1 bars | -0.35% | rule |
| 28 | 640 @ 173.50 | 642 @ 169.30 | 2 bars | -2.42% | rule |
| 29 | 643 @ 173.03 | 699 @ 218.54 | 56 bars | +26.30% | rule |
| 30 | 713 @ 221.27 | 728 @ 220.85 | 15 bars | -0.19% | rule |
| 31 | 739 @ 228.87 | 751 @ 221.69 | 12 bars | -3.14% | rule |
| 32 | 752 @ 225.77 | 768 @ 230.10 | 16 bars | +1.92% | rule |
| 33 | 781 @ 228.02 | 811 @ 243.85 | 30 bars | +6.94% | rule |
| 34 | 827 @ 238.26 | 831 @ 228.01 | 4 bars | -4.30% | rule |
| 35 | 834 @ 233.22 | 835 @ 227.63 | 1 bars | -2.40% | rule |
| 36 | 837 @ 232.62 | 848 @ 237.30 | 11 bars | +2.01% | rule |
| 37 | 849 @ 241.84 | 850 @ 238.03 | 1 bars | -1.58% | rule |
| 38 | 870 @ 222.13 | 873 @ 204.36 | 3 bars | -8.00% | stop |
| 39 | 886 @ 204.60 | 894 @ 198.89 | 8 bars | -2.79% | rule |
| 40 | 899 @ 210.79 | 905 @ 206.86 | 6 bars | -1.86% | rule |
| 41 | 926 @ 201.00 | 952 @ 211.27 | 26 bars | +5.11% | rule |
| 42 | 958 @ 213.25 | 982 @ 226.79 | 24 bars | +6.35% | rule |
| 43 | 984 @ 234.07 | 1004 @ 245.27 | 20 bars | +4.78% | rule |
| 44 | 1010 @ 262.24 | 1030 @ 267.46 | 20 bars | +1.99% | rule |
| 45 | 1034 @ 271.49 | 1049 @ 274.11 | 15 bars | +0.97% | rule |
| 46 | 1079 @ 258.28 | 1089 @ 261.73 | 10 bars | +1.34% | rule |
| 47 | 1091 @ 263.88 | 1093 @ 260.58 | 2 bars | -1.25% | rule |
| 48 | 1095 @ 266.18 | 1099 @ 264.18 | 4 bars | -0.75% | rule |
| 49 | 1122 @ 255.63 | 1168 @ 301.54 | 46 bars | +17.96% | rule |
| 50 | 1185 @ 308.63 | 1205 @ 308.91 | 20 bars | +0.09% | rule |
| 51 | 1218 @ 316.83 | 1219 @ 311.30 | 1 bars | -1.75% | rule |
| 52 | 1223 @ 313.45 | 1246 @ 329.40 | 23 bars | +5.09% | rule |
| 53 | 1247 @ 333.02 | 1248 @ 330.32 | 1 bars | -0.81% | rule |
| 54 | 1249 @ 333.69 | 1255 @ 340.97 | 6 bars | +2.18% | eod |
Exit reasons: rule = the exit predicate fired; stop = the protective stop was hit; target = the take-profit was hit; eod = closed at the last bar. Bar index = position in the price path, not a calendar date.