BACKTEST RESULTS

EMA crossover strategy backtest results

SPY daily data, 2016 to 2026: the 9/21 rule, long and short, made 11.7% after costs over 94 trades, winning 40.4% of them, against +277.8% for holding SPY. Long only it made 58.2%. The best of 8 runs was 9/21 on SPY, long only: +58.2%, held-out survived. Every run, every trade and the script are on this page.

SPY · daily data · 9/21 · long and short
Net after costs
+11.7%
Holding SPY
+277.8%
Trades
94
Win rate
40.4%
Profit factor
1.14
Max drawdown
19.4%
Held out, last third: decayed
Long only: +58.2% on 47 trades, held-out survived
4 January 2016 to 23 October 2026
  • Checked 25 October 2026
  • Alpaca daily data since 2016, and 5-minute data from the last 600 sessions
  • 0.05% commission + 0.025% slippage per fill
  • last third of the history held out
  • 8 runs, 2431 trades
  • Updated 1 November 2026

The short answer

Answers here: Does the EMA crossover strategy work? · What is its win rate? · 9/21 or 20/50? · Long only, or both ways?

SPY daily data, 4 January 2016 to 23 October 2026, long and short: 94 trades, made 11.7% after costs, 40.4% of trades won, profit factor 1.14, worst drawdown 19.4%, 39% of the time in the market. Holding SPY returned +277.8% over the same period.

Held out on its own, the last third (16 March 2023 to 23 October 2026) made 1.5% on 32 trades, with a weaker Sharpe ratio than the fitted period: decayed.

Long only, the same rule made 58.2% on 47 trades (53.2% won, profit factor 2.02, held-out survived): the short side cost 46.5 points of return in a period when SPY rose 277.8%.

On 5-minute data the same rule traded 1968 times in 2.4 years on SPY and lost 95.4%: at 0.15% a round trip, costs alone came to roughly 295% of the account over the period, which is where a daily rule moved to minute charts usually dies.

Across all 8 runs on this page, 6 made money after costs, 4 survived the held-out third, and 0 beat holding the symbol (1 had too few trades to judge).

The best run was 9/21 on SPY, long only: +58.2% net on 47 trades, profit factor 2.02, worst drawdown 13.6%, held-out survived. The tester's verdict on it reads "real edge so far · check the test period".

One symbol's past after modelled costs is not a forecast. Prices are split-adjusted and not dividend-adjusted, so every return here is a price return; the period includes a long rise with two sharp falls, and a rule that is often long did well for that reason as much as any other. These are research results, not investment advice.

What the script does

EMA Cross Strategy, from the strategy library.

Goes long when the 9-period EMA crosses above the 21-period EMA and goes short when it crosses below; the opposite cross closes the trade. A stop 2 ATR away and a target 3 ATR away are attached to every trade. A slower 20/50 pair was run on SPY, the 9/21 on QQQ and NVDA, and long-only versions of both pairs.

The indicator itself, with its Pine code drawn on real market data: Moving Average Crossover.

The numbers, run by run

Net and holding the symbol are after costs over the same period. Held-out is the verdict on the last third of the history judged alone: survived, decayed, did not survive, or too few trades to judge.

SymbolTimeframeSettingsDirectionTradesWin rateNetHoldingProfit factorMax drawdownHeld-out
SPYdaily9/21long and short9440.4%+11.7%+277.8%1.1419.4%decayed
SPYdaily20/50long and short3652.8%+14.7%+277.8%1.2824.7%survived
QQQdaily9/21long and short10837.0%+23.6%+542.3%1.1828.8%decayed
NVDAdaily9/21long and short10633.0%-74.3%+25955.3%0.8381.5%did not survive
SPYdaily9/21long only4753.2%+58.2%+277.8%2.0213.6%survived
QQQdaily9/21long only5444.4%+61.4%+542.3%1.6719.9%survived
SPYdaily20/50long only1866.7%+28.6%+277.8%2.2616.7%survived
SPY5-minute9/21long and short196829.5%-95.4%+44.4%0.3295.4%did not survive

Year by year

9/21 on SPY, long and short, the same rule long only, and SPY itself, each calendar year after costs. A partial first or last year counts the sessions it has.

Year9/21, long and short9/21, long onlyHolding SPY
2016-0.2%+10.9%+11.2%
2017-0.5%+3.2%+18.5%
2018-4.2%-9.1%-6.9%
2019+7.3%+10.9%+28.6%
2020+11.1%+12.4%+15.1%
2021-1.9%+5.1%+28.8%
2022-5.3%-5.5%-19.9%
2023+9.4%+9.6%+24.8%
2024-7.2%+4.3%+24.0%
2025+8.3%+7.7%+16.6%
2026-4.7%-1.0%+11.2%

Every trade

The 94 trades of 9/21 on SPY, long and short, oldest first: side, entry and exit days, fill prices after slippage, and the return after both commissions. The other runs' trades open below.

SideInOutEntryExitReturn
long2016-02-232016-03-30194.05206.24+6.2%
short2016-05-062016-05-11204.00207.97-2.0%
long2016-05-112016-05-13207.97204.53-1.8%
short2016-05-162016-05-25204.90208.78-2.0%
long2016-05-262016-06-20209.51208.76-0.5%
short2016-06-202016-06-23208.76210.45-0.9%
long2016-06-242016-06-24203.68203.56-0.2%
short2016-06-272016-06-30201.53208.09-3.4%
long2016-07-072016-08-01209.93217.50+3.5%
short2016-09-122016-09-12212.33216.64-2.1%
long2016-11-112016-12-07216.17223.63+3.4%
short2017-03-242017-04-05234.31237.29-1.4%
long2017-04-262017-06-02238.60243.82+2.1%
short2017-07-032017-07-13242.84244.09-0.6%
long2017-07-132017-08-18244.09242.83-0.6%
short2017-08-182017-08-30242.83246.34-1.5%
long2017-09-012017-10-03247.99252.40+1.7%
short2018-02-072018-02-08268.42258.14+3.7%
long2018-02-272018-03-01278.19269.10-3.4%
short2018-03-022018-03-09265.72275.78-3.9%
long2018-03-092018-03-22275.78267.83-3.0%
short2018-03-222018-03-23267.83259.57+3.0%
long2018-04-192018-04-24269.73261.69-3.1%
short2018-04-252018-05-10262.83270.43-3.0%
long2018-05-102018-06-27270.43272.18+0.5%
short2018-06-272018-07-09272.18276.63-1.7%
long2018-07-102018-08-07278.49285.93+2.6%
short2018-10-092018-10-10287.31281.28+2.0%
long2018-12-042018-12-04278.45270.40-3.0%
short2018-12-072018-12-17269.38255.10+5.2%
long2019-01-152019-02-05257.89273.18+5.8%
short2019-05-132019-05-29282.34278.66+1.2%
long2019-06-122019-07-10288.72299.29+3.6%
short2019-08-062019-08-08285.83290.98-1.9%
long2019-09-062019-10-02298.25291.43-2.4%
short2019-10-022019-10-16291.43298.43-2.5%
long2019-10-162019-11-12298.43309.63+3.7%
short2020-02-262020-02-27314.11299.48+4.6%
long2020-04-142020-06-03281.02312.61+11.1%
short2020-09-142020-10-08337.40342.95-1.7%
long2020-10-082020-10-28342.95328.36-4.4%
short2020-10-292020-11-03326.82338.32-3.6%
long2020-11-062020-12-08350.03370.37+5.7%
short2021-03-052021-03-09380.31388.87-2.3%
long2021-03-112021-04-09392.33408.61+4.1%
short2021-09-202021-09-20434.76430.13+1.0%
long2021-10-192021-11-03449.04462.97+3.0%
short2021-12-022021-12-07450.60464.54-3.2%
long2021-12-092021-12-20468.28454.32-3.1%
short2021-12-212021-12-23458.45468.88-2.4%
long2021-12-232022-01-14468.88461.06-1.8%
short2022-01-142022-01-20461.06446.21+3.1%
long2022-03-222022-04-18445.98436.69-2.2%
short2022-04-182022-04-27436.69416.12+4.6%
long2022-06-062022-06-10414.89390.74-5.9%
short2022-06-132022-07-21379.75394.27-3.9%
long2022-07-212022-08-10394.27418.77+6.1%
short2022-08-312022-09-12399.82411.53-3.0%
long2022-10-262022-12-19381.72383.36+0.3%
short2022-12-192023-01-12383.36396.78-3.6%
long2023-01-122023-02-02396.78415.18+4.5%
short2023-02-242023-03-13395.30381.91+3.3%
long2023-03-312023-05-30404.76422.13+4.2%
short2023-08-142023-09-01444.58453.29-2.1%
long2023-09-012023-09-19453.29440.81-2.9%
short2023-09-202023-09-22443.89430.41+2.9%
long2023-11-072023-11-20435.81452.03+3.6%
short2024-04-162024-05-06504.80516.36-2.4%
long2024-05-082024-06-06515.40534.89+3.7%
short2024-07-262024-07-31542.13550.53-1.6%
long2024-08-192024-09-10554.88548.21-1.3%
short2024-09-102024-09-12548.21555.16-1.4%
long2024-09-122024-10-11555.16578.49+4.1%
short2024-11-052024-11-06570.58589.36-3.4%
long2024-11-072024-12-20593.24581.61-2.1%
short2024-12-202024-12-24581.61597.48-2.8%
long2025-01-222025-02-26606.08595.75-1.8%
short2025-02-262025-03-04595.75575.11+3.4%
long2025-04-302025-06-06547.74599.06+9.3%
short2025-11-192025-11-26660.60677.78-2.7%
long2025-12-012026-02-06678.98681.28+0.2%
short2026-02-062026-02-09681.28692.42-1.7%
long2026-02-102026-02-13695.13681.50-2.1%
short2026-02-132026-02-27681.50683.24-0.4%
long2026-02-272026-03-02683.24678.52-0.8%
short2026-03-022026-03-13678.52662.32+2.3%
long2026-04-102026-04-17681.48710.94+4.2%
short2026-06-252026-07-02738.70747.60-1.3%
long2026-07-022026-07-27747.60744.67-0.5%
short2026-07-272026-08-03744.67755.34-1.5%
long2026-08-042026-09-11760.82764.49+0.4%
short2026-09-112026-09-21764.49770.11-0.8%
long2026-09-232026-10-01772.99759.66-1.8%
short2026-10-232026-10-23759.70760.10-0.2%

The script

Pine v6, exactly as it ran for 9/21 on SPY, long and short. The variants change only the inputs listed in the table.

//@version=6
strategy("EMA Cross Strategy", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=100, initial_capital=100000, commission_type=strategy.commission.percent, commission_value=0.05, slippage=1, margin_long=0, margin_short=0)

src      = input.source(close, "Source", group="Lengths")
fastLen  = input.int(9, "Fast EMA", minval=1, group="Lengths")
slowLen  = input.int(21, "Slow EMA", minval=2, group="Lengths")
useLong  = input.bool(true, "Trade longs", group="Direction")
useShort = input.bool(true, "Trade shorts", group="Direction")
atrLen   = input.int(14, "ATR length", minval=1, group="Risk")
stopMult = input.float(2, "Stop (ATR multiples)", minval=0, step=0.5, group="Risk")
tpMult   = input.float(3, "Target (ATR multiples, 0 = off)", minval=0, step=0.5, group="Risk")

fast = ta.ema(src, fastLen)
slow = ta.ema(src, slowLen)
atr  = ta.atr(atrLen)

longSig  = ta.crossover(fast, slow) and barstate.isconfirmed
shortSig = ta.crossunder(fast, slow) and barstate.isconfirmed

pFast = plot(fast, "Fast EMA", color=color.new(#16A56A, 0), linewidth=2)
pSlow = plot(slow, "Slow EMA", color=color.new(#E5484D, 0), linewidth=2)
fill(pFast, pSlow, color=fast > slow ? color.new(#16A56A, 90) : color.new(#E5484D, 90), title="Trend fill")

if longSig
    strategy.close("Short")
    if useLong
        strategy.entry("Long", strategy.long)
        strategy.exit("Long exit", "Long", stop=stopMult > 0 ? close - stopMult * atr : na, limit=tpMult > 0 ? close + tpMult * atr : na)
if shortSig
    strategy.close("Long")
    if useShort
        strategy.entry("Short", strategy.short)
        strategy.exit("Short exit", "Short", stop=stopMult > 0 ? close + stopMult * atr : na, limit=tpMult > 0 ? close - tpMult * atr : na)

How it was tested

Alpaca daily data since 2016, and 5-minute data from the last 600 sessions, 0.05% commission and 0.025% slippage on every fill, the last third of the history held out, textbook settings and nothing tuned. The engine, fills and what it does not model are written out once, in data and methodology.

Run the EMA crossover strategy on your own symbol, free

Describe the rule in your own words or paste the script. The Free plan writes the Pine v6 script with the AI, runs it on any US stock or ETF with the same costs and the same held-out check, and shows every trade on the chart. No card.

Every strategy tested

Seventeen popular rules through the same engine, the same costs and the same held-out check, with every trade listed. Next: Trailing stop strategy, Golden cross strategy, MACD strategy, Moving average strategy.

Questions

Does the EMA crossover strategy work?

SPY, daily data, 2016 to 2026, long and short: 9/21 made 11.7% after costs over 94 trades (40.4% won, profit factor 1.14) against +277.8% for holding SPY, and the held-out third decayed. Long only it made 58.2%. Across all 8 runs on the page, 6 made money after costs, 4 survived their held-out third and 0 beat holding the stock.

What is the win rate of the EMA crossover strategy?

From 29.5% to 66.7% across the 8 runs. The classic setting, 9/21 on SPY long and short, won 40.4% of 94 trades. The win rate alone does not decide the result: that run's profit factor was 1.14, so its winners outweighed its losers, and the net return was +11.7%.

What are the best EMA crossover settings?

Of the 2 settings tested, 9/21 on SPY (long only) did best: +58.2% net, profit factor 2.02, held-out survived. That is the best of 8 tries on 10.8 years of daily data of one symbol, which is already a fitted number. A setting that works on one symbol or one period only is a coincidence, not a setting; run it on your own symbol and timeframe before trusting it.

Does the EMA crossover strategy beat holding the stock?

0 of the 8 runs did. SPY itself returned +277.8% between 4 January 2016 and 23 October 2026, so a rule that is out of the market part of the time has a lot to make up; what a timing rule usually gets you is a smaller drawdown, not a bigger return. The classic run's worst drawdown was 19.4% with 39% of the time in the market.

Did the EMA crossover strategy hold up out of sample?

The last third of every run's history (16 March 2023 to 23 October 2026 for the lead run) was judged on its own, with no fitting on it: 4 of 8 runs survived, 2 decayed, 2 did not survive and 0 had too few trades there to judge. Survived means a positive Sharpe ratio on the held-out part at least half the fitted period's; it is a check on one later stretch, not a forecast.

How was this tested?

With the free Alpha Charts tester's own engine: the Pine v6 scripts on this page, run on Alpaca daily data since 2016, and 5-minute data from the last 600 sessions, split-adjusted and not dividend-adjusted, one position at a time with the whole account, fills at the next candle's open, a commission of 0.05% and slippage of 0.025% on every fill, the last third of the history held out. The settings are the textbook ones and every variant is stated; nothing was tuned to make the page look better.

Every number on this page is the output of the Alpha Charts backtest engine on 25 October 2026, on Alpaca market data; the scripts are the strategy library's templates, shown as they ran. Symbols are US-listed ETFs and stocks; results are price returns after the costs stated. Past results are not a forecast and nothing here is investment advice. TradingView and Pine Script belong to TradingView, Inc.; Alpha Charts is not affiliated with it.