BACKTEST RESULTS

EMA pullback strategy backtest results

SPY daily data, 2016 to 2026: the 20/50 rule, long and short, made 1.9% after costs over 109 trades, winning 36.7% of them, against +277.8% for holding SPY. Long only it lost 7.4%. The best of 5 runs was 20/50 on QQQ, long only: +13.6%, held-out survived. Every run, every trade and the script are on this page.

SPY · daily data · 20/50 · long and short
Net after costs
+1.9%
Holding SPY
+277.8%
Trades
109
Win rate
36.7%
Profit factor
1.05
Max drawdown
13.7%
Held out, last third: survived
Long only: -7.4% on 89 trades, held-out did not survive
4 January 2016 to 23 October 2026
  • Checked 25 October 2026
  • Alpaca daily data since 2016
  • 0.05% commission + 0.025% slippage per fill
  • last third of the history held out
  • 5 runs, 465 trades
  • Updated 1 November 2026

The short answer

Answers here: Does the pullback to the 20 EMA work? · What is the win rate? · Long only, or both ways?

SPY daily data, 4 January 2016 to 23 October 2026, long and short: 109 trades, made 1.9% after costs, 36.7% of trades won, profit factor 1.05, worst drawdown 13.7%, 32% 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 2.6% on 36 trades: the rule survived its held-out period.

Long only, the same rule lost 7.4% on 89 trades (36.0% won, profit factor 0.95, held-out did not survive): the short side added 9.3 points of return in a period when SPY rose 277.8%.

Across all 5 runs on this page, 3 made money after costs, 4 survived the held-out third, and 0 beat holding the symbol.

The best run was 20/50 on QQQ, long only: +13.6% net on 69 trades, profit factor 1.18, worst drawdown 32.5%, held-out survived. The tester's verdict on it reads "made money, but could be luck".

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 Pullback Strategy, from the strategy library.

Goes long on a pullback in an uptrend: when the 20 EMA is above the 50 EMA and the close is above the 50, and the close comes back above the 20 after a close below it; the mirror image shorts a bounce in a downtrend. The trade closes when the close crosses the 50 EMA, with a stop 2 ATR away and a target 3 ATR away. Long-only versions were run on SPY and QQQ.

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

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
SPYdaily20/50long and short10936.7%+1.9%+277.8%1.0513.7%survived
QQQdaily20/50long and short9242.4%+10.5%+542.3%1.1231.1%survived
NVDAdaily20/50long and short10636.8%-52.1%+25955.3%0.9283.7%survived
SPYdaily20/50long only8936.0%-7.4%+277.8%0.9516.9%did not survive
QQQdaily20/50long only6944.9%+13.6%+542.3%1.1832.5%survived

Year by year

20/50 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.

Year20/50, long and short20/50, long onlyHolding SPY
2016-3.4%-5.2%+11.2%
2017+2.7%+2.7%+18.5%
2018-4.1%-0.8%-6.9%
2019+0.2%+3.3%+28.6%
2020+2.9%+2.9%+15.1%
2021-0.9%+1.0%+28.8%
2022-0.9%-10.0%-19.9%
2023+4.3%+2.2%+24.8%
2024+5.0%+5.0%+24.0%
2025+7.5%+2.9%+16.6%
2026-10.7%-10.7%+11.2%

Every trade

The 109 trades of 20/50 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-05-032016-05-06206.58204.00-1.3%
long2016-05-112016-05-13207.97204.53-1.8%
long2016-05-172016-05-20206.52204.86-0.9%
long2016-05-252016-06-20208.73208.76-0.1%
long2016-06-242016-06-24203.68203.56-0.2%
long2016-07-012016-08-05209.42217.65+3.8%
long2016-08-302016-09-09218.32215.39-1.4%
long2016-09-222016-09-27217.06213.99-1.5%
long2016-09-292016-09-30216.47215.59-0.5%
long2016-10-032016-10-05215.88215.35-0.3%
long2016-10-062016-10-10215.43216.09+0.2%
long2016-10-112016-10-12215.72213.53-1.1%
short2016-10-262016-11-03213.15209.04+1.8%
long2017-01-042017-02-09225.69229.86+1.8%
long2017-03-302017-04-17235.56233.04-1.2%
long2017-04-212017-05-18235.32235.63+0.0%
long2017-05-222017-06-01238.97243.15+1.6%
long2017-06-292017-06-29243.73240.32-1.5%
long2017-07-062017-07-07241.95241.14-0.4%
long2017-07-112017-08-11242.24243.95+0.6%
long2017-08-152017-08-17247.05243.52-1.5%
long2017-08-232017-08-25244.42244.83+0.1%
long2017-08-312017-09-29246.80250.87+1.5%
long2017-11-172017-11-29258.29262.95+1.7%
long2018-02-162018-02-22272.39271.01-0.6%
long2018-02-262018-03-02276.01265.72-3.8%
long2018-03-062018-03-20273.35270.85-1.0%
short2018-04-122018-04-18265.18270.77-2.2%
short2018-04-252018-05-08262.83266.58-1.5%
long2018-05-312018-06-26272.24271.56-0.3%
long2018-07-062018-07-18273.22281.06+2.8%
long2018-08-172018-08-29283.91290.77+2.3%
short2018-11-132018-12-03272.98280.34-2.8%
short2018-12-062018-12-17265.84256.37+3.5%
long2019-03-122019-04-12279.12289.93+3.8%
short2019-08-212019-08-22292.39293.31-0.4%
short2019-08-262019-08-30287.19294.30-2.6%
long2019-09-262019-10-02297.71291.43-2.2%
long2019-12-052019-12-13312.33318.19+1.8%
long2020-01-292020-01-31328.47321.42-2.2%
long2020-02-052020-02-24332.36322.26-3.1%
long2020-05-152020-06-03282.45310.15+9.7%
long2020-06-162020-06-29315.56301.33-4.6%
long2020-07-012020-08-03309.65328.54+6.0%
long2020-09-162020-09-18341.63328.57-3.9%
long2020-09-292020-10-28334.06327.71-2.0%
long2020-11-052020-11-09349.34363.88+4.1%
long2021-02-032021-03-04382.55378.10-1.3%
long2021-03-102021-04-05389.79406.37+4.2%
long2021-05-172021-05-19415.50406.34-2.3%
long2021-05-212021-07-02416.98432.33+3.6%
long2021-07-212021-08-11432.46443.69+2.5%
long2021-08-232021-09-02445.28453.90+1.8%
long2021-09-162021-09-20447.44434.76-2.9%
long2021-09-272021-09-28442.93434.45-2.0%
short2021-10-112021-10-15437.04444.88-1.9%
long2021-11-302021-12-01462.13461.51-0.2%
long2021-12-082021-12-20468.83454.32-3.2%
long2021-12-232022-01-14468.88461.06-1.8%
short2022-02-042022-02-10446.23451.46-1.3%
short2022-02-112022-02-23449.29423.14+5.7%
long2022-04-082022-04-12448.09442.96-1.2%
short2022-04-222022-04-27436.78416.10+4.6%
short2022-06-102022-06-13394.77373.63+5.3%
short2022-06-292022-07-21381.12394.27-3.5%
long2022-08-262022-08-26419.50407.34-3.0%
short2022-09-142022-09-23394.35370.13+6.0%
short2022-10-202022-10-26367.91381.72-3.9%
short2022-11-032022-11-09371.37379.95-2.4%
short2022-11-102022-11-10387.92390.47-0.8%
long2022-12-092022-12-16395.05385.08-2.6%
long2023-01-232023-02-02396.83414.90+4.5%
long2023-03-062023-03-08405.15398.28-1.8%
short2023-03-232023-03-30394.96404.20-2.4%
long2023-04-282023-05-05411.60408.80-0.8%
long2023-05-082023-06-02413.07427.79+3.5%
long2023-08-082023-08-15448.20442.33-1.4%
long2023-08-302023-09-18449.65442.93-1.6%
short2023-10-162023-10-26433.69413.90+4.5%
long2024-01-092024-01-24472.00487.69+3.2%
long2024-04-082024-04-15519.29507.64-2.3%
long2024-04-292024-05-01510.22501.24-1.9%
long2024-05-062024-05-16513.89530.07+3.0%
long2024-06-032024-06-12529.16542.00+2.3%
long2024-07-232024-07-24554.69544.00-2.0%
long2024-08-012024-08-02552.72535.57-3.2%
long2024-09-122024-10-11555.16578.49+4.1%
long2024-11-062024-11-07589.36593.63+0.6%
long2024-11-192024-12-04584.87605.58+3.4%
long2024-12-262024-12-30599.62587.80-2.1%
long2025-01-072025-01-08597.59588.54-1.6%
long2025-01-162025-02-25594.34597.00+0.3%
short2025-03-272025-04-03567.05541.37+4.4%
long2025-08-052025-09-15631.98659.60+4.3%
long2025-10-162025-10-28667.00686.90+2.9%
long2025-11-112025-11-14680.12665.22-2.3%
long2025-11-262025-12-18677.78677.42-0.2%
long2025-12-222026-01-21684.11679.47-0.8%
long2026-01-232026-02-06688.33681.28-1.1%
long2026-02-092026-02-13689.60681.50-1.3%
long2026-02-232026-02-24688.00681.72-1.0%
long2026-02-252026-03-03690.37670.97-2.9%
long2026-06-152026-06-26752.05726.98-3.4%
long2026-06-302026-07-24741.49738.35-0.5%
long2026-08-032026-08-05749.64775.65+3.4%
long2026-08-242026-09-11764.96764.49-0.2%
long2026-09-222026-10-01774.23759.18-2.0%
long2026-10-052026-10-19769.88767.03-0.5%
long2026-10-222026-10-23766.57759.70-1.0%

The script

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

//@version=6
strategy("EMA Pullback 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(20, "Pullback EMA", minval=1, group="Lengths")
slowLen  = input.int(50, "Trend 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, 0 = off)", 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)

upTrend = fast > slow and close > slow
dnTrend = fast < slow and close < slow
// the pullback: the previous bar closed on the wrong side of the fast EMA, this one closed back on the trend's side
longSig   = upTrend and close[1] < fast[1] and close > fast and barstate.isconfirmed
shortSig  = dnTrend and close[1] > fast[1] and close < fast and barstate.isconfirmed
exitLong  = ta.crossunder(close, slow) and barstate.isconfirmed
exitShort = ta.crossover(close, slow) and barstate.isconfirmed

pFast = plot(fast, "Pullback EMA", color=color.new(#A3A39E, 0), linewidth=1)
pSlow = plot(slow, "Trend EMA", color=upTrend ? color.new(#16A56A, 0) : dnTrend ? color.new(#E5484D, 0) : color.new(#A3A39E, 0), linewidth=2)
fill(pFast, pSlow, color=upTrend ? color.new(#16A56A, 90) : dnTrend ? color.new(#E5484D, 90) : color.new(#A3A39E, 94), title="Trend fill")

if longSig and 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 and 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)
if exitLong
    strategy.close("Long")
if exitShort
    strategy.close("Short")

How it was tested

Alpaca daily data since 2016, 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 pullback 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: EMA crossover strategy, Moving average strategy, RSI strategy.

Questions

Does the EMA pullback strategy work?

SPY, daily data, 2016 to 2026, long and short: 20/50 made 1.9% after costs over 109 trades (36.7% won, profit factor 1.05) against +277.8% for holding SPY, and the held-out third survived. Long only it lost 7.4%. Across all 5 runs on the page, 3 made money after costs, 4 survived their held-out third and 0 beat holding the stock.

What is the win rate of the EMA pullback strategy?

From 36.0% to 44.9% across the 5 runs. The classic setting, 20/50 on SPY long and short, won 36.7% of 109 trades. The win rate alone does not decide the result: that run's profit factor was 1.05, so its winners outweighed its losers, and the net return was +1.9%.

Is the EMA pullback strategy better long only?

On SPY it was: long only lost 7.4% against made 1.9% traded both ways, with held-out verdicts of did not survive and survived. In a period when SPY returned +277.8%, shorting the pullbacks of an index that kept rising is where the money went; a different period could reverse that.

Does the EMA pullback strategy beat holding the stock?

0 of the 5 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 13.7% with 32% of the time in the market.

Did the EMA pullback 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 5 runs survived, 0 decayed, 1 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, 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.