The 9/21 EMA cross on 5-minute S&P 500 bars
Micro E-mini S&P 500 (MES) · 5-minute bars · 2016 to 2026 · Momentum · Widely taught
No edge after costs: profit factor 0.76 out of sample.
- Profit factor, out of sample
- 0.76
- Average trade, out of sample
- −0.14R
- Win rate, out of sample
- 30%
- Trades, 10 years
- 5,647
- Max drawdown
- $253,968
- Pass odds, median plan
- 2.9%
Hypothetical results. These results are based on simulated or hypothetical performance results that have certain inherent limitations. Unlike the results shown in an actual performance record, these results do not represent actual trading. Also, because these trades have not actually been executed, these results may have under- or over-compensated for the impact, if any, of certain market factors, such as lack of liquidity. Simulated or hypothetical trading programs in general are also subject to the fact that they are designed with the benefit of hindsight. No representation is being made that any account will or is likely to achieve profits or losses similar to these being shown.
Abstract
We backtested the 9/21 EMA cross rules on Micro E-mini S&P 500 (MES) 5-minute bars from 2016-01-11 to 2026-10-30: 5,647 trades, with commission and a tick of slippage on every market and stop fill. In sample (to 2023-08-03) it made −0.21R per trade with a profit factor of 0.69; out of sample (from 2023-08-04) −0.14R per trade and 0.76 over 1,660 trades. 0 of the 25 parameter settings we tried were profitable out of sample. Sized at $250 of risk a trade, simulated 50K evaluations passed 1% to 4% of the time across 36 tracked plans.
1Hypothesis
Buy when the 9-bar EMA crosses above the 21-bar EMA and sell when it crosses below, on 5-minute bars. The stop is 1.5 ATR away, the target twice that, and the opposite cross exits.
If short-term trends persist, crosses of a fast and a slow EMA should catch enough of them to beat the whipsaws and the costs.
2Data
- Instrument
- Micro E-mini S&P 500 (MES), traded on the ES price series (ES.c.0: front month, rolled on the calendar). CME Globex via Databento.
- Period
- 2016-01-11 to 2026-10-30: 2,746 sessions, 1,056,820 one-minute bars, built into 210,816 5-minute bars of the regular session (09:30 to 16:00 ET).
- Costs
- $0.75 commission a contract each way and 1 tick ($1.25) of slippage on every market and stop fill. Limit orders fill when price touches them; market orders fill at the next bar's open and stops at their price, each with one tick of slippage; when a bar touches both the stop and the target, the stop counts.
- Position size
- About $250 of risk a trade: micro contracts, rounded down, at least one. R is a trade's net P&L divided by its risk at entry.
- Out of sample
- The last 30% of weekdays: 2023-08-04 on (846 days), after 1,974 in-sample days. The rules were fixed before either side was run.
3Method
Our reading of the publicly described rules; the creator may trade it differently. The rules, exactly as the code runs them:
- EMAs of the 5-minute closes: fast (9) and slow (21) bars, regular-session bars only.
- Entry: when the 9 EMA closes above the 21 EMA after being at or below it, buy at the next bar's open; when it closes below, sell. New entries from 09:45 to 15:30 ET.
- Stop: stop_atr (1.5) times ATR(14) of the 5-minute bars from the fill.
- Target: target_r (2) times the stop distance.
- Exit: the stop, the target, the opposite cross (at the next bar's open), or flat at 15:55 ET.
- Size: about risk_usd dollars of risk a trade (micro contracts, rounded down, at least 1 and at most max_contracts).
"""9/21 EMA cross on MES 5-minute bars, regular session, long and short. Our reading of the commonly taught rules; traders who teach it may trade it differently. Rules: 1. EMAs of the 5-minute closes: `fast` (9) and `slow` (21) bars, regular-session bars only. 2. Entry: when the 9 EMA closes above the 21 EMA after being at or below it, buy at the next bar's open; when it closes below, sell. New entries from 09:45 to 15:30 ET. 3. Stop: `stop_atr` (1.5) times ATR(14) of the 5-minute bars from the fill. 4. Target: `target_r` (2) times the stop distance. 5. Exit: the stop, the target, the opposite cross (at the next bar's open), or flat at 15:55 ET. 6. Size: about `risk_usd` dollars of risk a trade (micro contracts, rounded down, at least 1 and at most `max_contracts`)."""import qy def ready(*values): """True when every value is a number (indicators have no value until they have enough data).""" return all(v is not None and v == v for v in values) class Bot(qy.Strategy): """EMA 9/21 cross with an ATR stop and a 2R target.""" symbol = "MES" timeframe = "5m" session = "rth" params = {"fast": 9, "slow": 21, "stop_atr": 1.5, "target_r": 2.0, "risk_usd": 250, "max_contracts": 50} max_position = 50 entry_window = ("09:45", "15:30") flatten_time = "15:55" overnight = False atr_period = 14 def setup(self): self.fast = self.ema(self.close, self.p.fast) self.slow = self.ema(self.close, self.p.slow) self.atr_line = self.atr(14) def _size(self, risk_points): per_contract = risk_points * self.point_value n = int(self.p.risk_usd // per_contract) if per_contract > 0 else 1 return max(1, min(self.p.max_contracts, n)) def on_bar(self, bar): if not ready(self.fast[0], self.slow[0], self.fast[1], self.slow[1], self.atr_line[0]): return up = self.crossed_above(self.fast, self.slow) down = self.crossed_below(self.fast, self.slow) if (self.position.is_long and down) or (self.position.is_short and up): self.close_position("opposite cross") return if not self.position.is_flat or self.orders: return t = bar.dt.hour * 60 + bar.dt.minute + 5 # the bar's close, when the order goes in if not 585 <= t < 930: return qty = self._size(self.p.stop_atr * self.atr_line[0]) if up: self.buy(qty, stop_atr=self.p.stop_atr, target_r=self.p.target_r, tag="EMA cross long") elif down: self.sell(qty, stop_atr=self.p.stop_atr, target_r=self.p.target_r, tag="EMA cross short")4Results
| Statistic | In sample | Out of sample | All |
|---|---|---|---|
| Trades | 3,987 | 1,660 | 5,647 |
| Net P&L | −$197,814 | −$54,796 | −$252,610 |
| Profit factor | 0.69 | 0.76 | 0.71 |
| Average trade | −0.21R | −0.14R | −0.19R |
| 95% interval of the average | −0.24 to −0.17 | −0.20 to −0.08 | −0.22 to −0.16 |
| t-statistic of trade R | −10.54 | −4.82 | −11.49 |
| Win rate | 29% | 30% | 30% |
| Average win / average loss | 1.65 | 1.79 | 1.69 |
| Max drawdown | $198,953 | $57,918 | $253,968 |
| Sharpe ratio (daily, annualized) | −3.83 | −2.77 | −3.53 |
| Longest losing streak | 24 | 17 | 24 |
| Long / short profit factor | 0.72 / 0.66 | 0.70 / 0.82 | 0.71 / 0.70 |
| Average holding time | 56 min | 56 min | 56 min |
| Commission paid | $76,425 | $14,387 | $90,812 |
Drag across the chart to zoom into a period, double-click to reset.
Averages: −0.21R in sample, −0.14R out of sample.
1,600 of 2,430 points drawn; the fit and the means use all of them. Drag a box to zoom, double-click to reset.
5Robustness
We reran the strategy on a grid of 25 settings of its two main parameters, each on the full history with the same split. 0 were profitable in sample and 0 out of sample.
Fast EMA (bars) across, slow EMA (bars) up. Solid outline: the defaults we tested; dashed: the in-sample best.
Hover a cell for both sides of the split.
Fast EMA (bars) 5.00 to 15.0 across · Slow EMA (bars) 18.0 to 50.0 in depth · Profit factor, out of sample 0.72 to 0.92 as height and shade. Drag or use the arrow keys to turn it.
Drag to rotate; ctrl or ⌘ and scroll to zoom.
What would change it
Nothing on the grid helps. Its in-sample best, fast EMA (bars) 15 and slow EMA (bars) 21, had profit factor 0.72 in sample but 0.84 out of sample, against 0.76 for the defaults.
6Prop-firm implications
The backtest's sessions run through the rules of 36 tracked 50K evaluations: 2,000 runs of up to 60 sessions each, with the drawdown and daily limits checked against each trade's intraday low. Intervals are Wilson 95% intervals of the simulation. A simulation of the past, not the chance that anyone passes.
| Plan | Pass odds, 95% interval | Pass | Fail | Out of time | Median sessions |
|---|---|---|---|---|---|
| FundedNext Futures Flex Challenge 50K | 4.2% | 96% | 0% | 17 | |
| Alpha Futures Zero 50K Evaluation | 3.0% | 96% | 0.7% | 23 | |
| Apex Trader Funding 50K EOD Evaluation | 3.0% | 96% | 0.7% | 23 | |
| Topstep 50K Trading Combine | 3.0% | 96% | 0.7% | 23 | |
| Bulenox 50K Qualification Account (Legacy, Option 2, EOD drawdown) | 3.0% | 96% | 1% | 23.5 | |
| Funded Futures Network Standard MAX 50K Evaluation | 3.0% | 96% | 0.6% | 23.5 | |
| Tradeify 50K GROWTH Evaluation | 3.0% | 96% | 0.6% | 23.5 | |
| Bulenox 50K Qualification Account (Legacy, Option 1, trailing drawdown) | 2.9% | 96% | 0.8% | 23 | |
| Lucid Trading LucidFlex 50K Evaluation | 2.9% | 97% | 0.5% | 23 | |
| Lucid Trading LucidPro 50K Evaluation | 2.9% | 97% | 0.5% | 23 |
7Limitations
- One market (MES) and one bar size.
- Every cross is taken: no trend or time-of-day filter.
- Frequent trading makes the result sensitive to the cost model.
- A backtest on the past, with fills simulated from one-minute bars; live fills, queues and outages differ.
8Conclusion
No edge after costs: profit factor 0.76 out of sample. Nothing on the grid helps. Its in-sample best, fast EMA (bars) 15 and slow EMA (bars) 21, had profit factor 0.72 in sample but 0.84 out of sample, against 0.76 for the defaults. On this reading of the rules, with these costs, the historical record gives no reason to expect a profit.
9References
- Brock, W., Lakonishok, J., and LeBaron, B. (1992). Simple Technical Trading Rules and the Stochastic Properties of Stock Returns. Journal of Finance, 47(5), 1731-1764.