Price crosses its 21-day EMA: does it work after costs?
On SPY, holding did better: +289.4% vs +114.3% for the rule after costs.
Over the last 10 years on SPY (2016-11-30 to 2026-11-30), this rule made +114.3% after modelled costs, against +289.4% for simply holding SPY, across 142 trades. It ended ahead of holding on 2 of the 30 tickers in the table. Run on 2026-12-01 with the estockes strategy test; a historical simulation, not advice.
Test this rule on SPYThe rule on 30 liquid tickers, closest to holding first
Across the 30 tickers with a result, the rule came closest to holding on BA (+145.3% against +22.5%, 122.8 pts ahead) and furthest from it on NVDA (+576.9% against +6,634%, 6,057 pts behind). It made 4613 trades in all; 0 of the 30 runs had fewer than 30 trades, too few to judge on their own. Luck Test: could be luck on 3, looks like luck on 24, random timing did better on 3.
| Ticker | Verdict | Trades | After costs | Holding | Luck Test |
|---|---|---|---|---|---|
| BA | Passed basic checks | 141 | +145.3% | +22.5% | could be luck, beat 86% |
| NFLX | Passed basic checks | 142 | +535.8% | +426.3% | could be luck, beat 89% |
| DIS | Holding did better | 159 | +30.5% | +40.8% | looks like luck, beat 67% |
| TLT | Lost money | 174 | -21.0% | -9.5% | looks like luck, beat 31% |
| INTC | Holding did better | 160 | +81.1% | +109.0% | looks like luck, beat 72% |
| GLD | Holding did better | 161 | +86.6% | +197.2% | looks like luck, beat 62% |
| XOM | Only in the past | 162 | +67.7% | +186.8% | looks like luck, beat 27% |
| XLE | Holding did better | 158 | +147.5% | +267.9% | looks like luck, beat 63% |
| IWM | Only in the past | 182 | +9.1% | +135.6% | looks like luck, beat 9% |
| DIA | Holding did better | 138 | +74.9% | +220.6% | looks like luck, beat 38% |
| KO | Holding did better | 153 | +74.3% | +221.5% | looks like luck, beat 24% |
| XLF | Holding did better | 149 | +43.3% | +203.6% | looks like luck, beat 17% |
| XLV | Holding did better | 155 | +50.7% | +215.2% | looks like luck, beat 6% |
| SPY | Holding did better | 142 | +114.3% | +289.4% | looks like luck, beat 21% |
| QQQ | Holding did better | 143 | +202.5% | +500.3% | looks like luck, beat 72% |
| JPM | Holding did better | 161 | +34.6% | +421.7% | random timing did better, beat 4% |
| COST | Holding did better | 144 | +370.7% | +774.0% | looks like luck, beat 41% |
| V | Holding did better | 161 | +89.6% | +494.9% | looks like luck, beat 17% |
| GOOGL | Holding did better | 134 | +255.2% | +668.1% | looks like luck, beat 31% |
| META | Only in the past | 157 | +5.3% | +440.1% | looks like luck, beat 34% |
| XLK | Holding did better | 139 | +274.7% | +732.0% | looks like luck, beat 75% |
| WMT | Only in the past | 165 | +39.2% | +554.5% | random timing did better, beat 1% |
| AMZN | Only in the past | 162 | +36.3% | +589.5% | looks like luck, beat 14% |
| AAPL | Holding did better | 124 | +681.5% | +1,295% | looks like luck, beat 73% |
| MSFT | Holding did better | 159 | +140.9% | +806.1% | looks like luck, beat 18% |
| SMH | Holding did better | 153 | +349.0% | +1,288% | looks like luck, beat 73% |
| TSLA | Only in the past | 161 | +1,265% | +3,177% | could be luck, beat 84% |
| AVGO | Holding did better | 165 | +76.2% | +2,344% | random timing did better, beat 1% |
| AMD | Holding did better | 155 | +480.1% | +4,701% | looks like luck, beat 62% |
| NVDA | Only in the past | 154 | +576.9% | +6,634% | looks like luck, beat 69% |
How the rule works
The test enters at the next open after the close crosses above its 21-day exponential moving average and exits after the close crosses back below. The 21-day EMA is a common short-term trend line on daily charts.
Why costs matter
Price-and-average rules are in while the close is above the line. A short average is crossed often, so whipsaws and their costs add up; a long one is crossed rarely, and the rule then gives up part of each rise while it waits to come back in.
Every result here is after modelled costs: the engine charges commission and slippage on each entry and exit, set by the ticker's liquidity (on SPY: 0 bp commission, 2 bp slippage per side), and fills at the next session's open, never at the signal's close. Holding is measured on the same total-return prices with no costs.
Limits of this test
- It is a historical simulation of 10 years of daily data, not a forecast and not advice. A rule that did well in this window can do badly in the next.
- Survivorship: only tickers listed today can be tested, so companies that failed or were delisted are missing, which flatters any rule tested on stocks.
- The recent window matters: ten years that include one long rally favour holding, and a different decade could rank the rule differently. Run the test on another window to see.
- Fixed settings for every ticker. Changing the period or the exit changes the result, and trying many settings until one looks good is how false results are made. That is also why the Luck Test bar rises with the number of results shown.
Related rules
- Exit at the death cross
- Price crosses its 20-day average
- Price crosses its 50-day average
- Price crosses its 200-day average
- All tested rules
- The scoreboard: 90 of 1,260 tests ended ahead of holding, and why
- Strategies we tested
Every rule on one ticker
Questions
Price crosses its 21-day EMA: does this rule work?
Over the last 10 years on SPY (2016-11-30 to 2026-11-30), this rule made +114.3% after modelled costs, against +289.4% for simply holding SPY, across 142 trades. It ended ahead of holding on 2 of the 30 tickers in the table. Run on 2026-12-01 with the estockes strategy test; a historical simulation, not advice.
Price crosses its 21-day EMA: how does the rule work?
The test enters at the next open after the close crosses above its 21-day exponential moving average and exits after the close crosses back below. The 21-day EMA is a common short-term trend line on daily charts.
Why do trading costs matter here?
Price-and-average rules are in while the close is above the line. A short average is crossed often, so whipsaws and their costs add up; a long one is crossed rarely, and the rule then gives up part of each rise while it waits to come back in.
How was it tested?
Each number comes from one run of the estockes strategy test (public API), fetched on 2026-12-01: daily bars, signal on the close, fill at the next open, costs on every fill, idle cash earning the 3-month Treasury bill rate, compared with holding the same ticker over the same window.