BACKTEST RESULTS

Moving average strategy backtest results

SPY daily data, 2016 to 2026: the 50-day EMA rule, long and short, lost 19.5% after costs over 191 trades, winning 31.4% of them, against +277.8% for holding SPY. Long only it made 91.1%. The best of 7 runs was 50-day EMA on SPY, long only: +91.1%, held-out survived. Every run, every trade and the script are on this page.

SPY · daily data · 50-day EMA · long and short
Net after costs
-19.5%
Holding SPY
+277.8%
Trades
191
Win rate
31.4%
Profit factor
1.01
Max drawdown
40.5%
Held out, last third: survived
Long only: +91.1% on 95 trades, held-out survived
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
  • 7 runs, 894 trades
  • Updated 1 November 2026

The short answer

Answers here: Does trading the 200-day moving average work? · Which average is best? · What is the win rate? · Long only, or both ways?

SPY daily data, 4 January 2016 to 23 October 2026, long and short: 191 trades, lost 19.5% after costs, 31.4% of trades won, profit factor 1.01, worst drawdown 40.5%, 97% 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 17.1% on 62 trades: the rule survived its held-out period.

Long only, the same rule made 91.1% on 95 trades (45.3% won, profit factor 1.92, held-out survived): the short side cost 110.6 points of return in a period when SPY rose 277.8%.

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

The best run was 50-day EMA on SPY, long only: +91.1% net on 95 trades, profit factor 1.92, worst drawdown 19.1%, 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

Price / Moving Average Cross Strategy, from the strategy library.

Price crossing one moving average: goes long when the close crosses above the average and goes short when it crosses below; the opposite cross closes the trade, and a stop sits 2 ATR away. Four averages were run: the 50-day EMA, the 200-day SMA, the 20-day EMA, and long-only versions of the 200-day SMA and the 50-day EMA.

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
SPYdaily50-day EMAlong and short19131.4%-19.5%+277.8%1.0140.5%survived
SPYdaily200-day SMAlong and short5825.9%+4.4%+277.8%1.3742.2%survived
QQQdaily50-day EMAlong and short18324.6%-21.5%+542.3%1.0853.6%survived
SPYdaily20-day EMAlong and short32129.0%-50.0%+277.8%0.8562.0%did not survive
SPYdaily200-day SMAlong only2931.0%+91.0%+277.8%3.1023.2%survived
QQQdaily200-day SMAlong only1735.3%+235.8%+542.3%6.6323.3%too few trades to judge
SPYdaily50-day EMAlong only9545.3%+91.1%+277.8%1.9219.1%survived

Year by year

50-day EMA 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.

Year50-day EMA, long and short50-day EMA, long onlyHolding SPY
2016-7.8%+0.4%+11.2%
2017+8.1%+13.2%+18.5%
2018-20.4%-13.0%-6.9%
2019-8.1%+9.1%+28.6%
2020+4.1%+14.6%+15.1%
2021+6.2%+17.0%+28.8%
2022-13.3%-15.0%-19.9%
2023+4.3%+14.5%+24.8%
2024-3.6%+9.8%+24.0%
2025+16.5%+18.0%+16.6%
2026-3.9%+3.6%+11.2%

Every trade

The 191 trades of 50-day EMA 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
short2016-05-202016-05-23204.86205.56-0.4%
long2016-05-232016-06-20205.56208.76+1.5%
short2016-06-202016-06-21208.76208.35+0.1%
long2016-06-212016-06-27208.35201.53-3.4%
short2016-06-272016-07-01201.53209.42-4.0%
long2016-07-012016-09-12209.42212.33+1.3%
short2016-09-122016-09-13212.33214.90-1.3%
long2016-09-132016-09-14214.90213.23-0.9%
short2016-09-142016-09-22213.23217.06-1.9%
long2016-09-222016-09-27217.06213.99-1.5%
short2016-09-272016-09-28213.99215.89-1.0%
long2016-09-282016-09-30215.89215.59-0.2%
short2016-09-302016-10-03215.59215.88-0.2%
long2016-10-032016-10-05215.88215.35-0.3%
short2016-10-052016-10-06215.35215.43-0.1%
long2016-10-062016-10-10215.43216.09+0.2%
short2016-10-102016-10-11216.09215.72+0.1%
long2016-10-112016-10-12215.72213.53-1.1%
short2016-10-122016-11-09213.53212.43+0.4%
long2016-11-092017-04-17212.43233.04+9.6%
short2017-04-172017-04-18233.04233.78-0.4%
long2017-04-182017-04-19233.78234.45+0.2%
short2017-04-192017-04-21234.45235.32-0.5%
long2017-04-212017-05-18235.32235.63+0.0%
short2017-05-182017-05-19235.63237.40-0.8%
long2017-05-192017-07-07237.40241.14+1.5%
short2017-07-072017-07-10241.14242.02-0.5%
long2017-07-102017-08-11242.02243.95+0.7%
short2017-08-112017-08-15243.95247.05-1.4%
long2017-08-152017-08-18247.05242.83-1.8%
short2017-08-182017-08-23242.83244.42-0.8%
long2017-08-232017-08-25244.42244.83+0.1%
short2017-08-252017-08-28244.83245.20-0.3%
long2017-08-282018-02-06245.20259.92+5.9%
short2018-02-062018-02-16259.92272.39-4.9%
long2018-02-162018-02-22272.39271.01-0.6%
short2018-02-222018-02-26271.01276.01-1.9%
long2018-02-262018-03-02276.01265.72-3.8%
short2018-03-022018-03-06265.72273.35-3.0%
long2018-03-062018-03-20273.35270.85-1.0%
short2018-03-202018-04-18270.85270.77-0.1%
long2018-04-182018-04-23270.77267.18-1.4%
short2018-04-232018-05-08267.18266.58+0.1%
long2018-05-082018-06-26266.58271.56+1.8%
short2018-06-262018-07-06271.56273.22-0.7%
long2018-07-062018-10-11273.22277.00+1.3%
short2018-10-112018-11-08277.00280.22-1.3%
long2018-11-082018-11-12280.22277.07-1.2%
short2018-11-122018-12-03277.07280.34-1.3%
long2018-12-032018-12-06280.34265.84-5.3%
short2018-12-062019-01-18265.84265.06+0.2%
long2019-01-182019-05-14265.06281.94+6.3%
short2019-05-142019-05-17281.94285.22-1.3%
long2019-05-172019-05-21285.22285.75+0.1%
short2019-05-212019-05-22285.75285.530.0%
long2019-05-222019-05-24285.53283.66-0.8%
short2019-05-242019-06-07283.66286.01-0.9%
long2019-06-072019-08-05286.01288.01+0.6%
short2019-08-052019-08-09288.01292.66-1.7%
long2019-08-092019-08-12292.66289.88-1.1%
short2019-08-122019-08-20289.88291.85-0.8%
long2019-08-202019-08-21291.85292.39+0.1%
short2019-08-212019-08-22292.39293.31-0.4%
long2019-08-222019-08-26293.31287.19-2.2%
short2019-08-262019-08-30287.19294.30-2.6%
long2019-08-302019-09-04294.30293.06-0.5%
short2019-09-042019-09-05293.06296.87-1.4%
long2019-09-052019-10-02296.87291.43-1.9%
short2019-10-022019-10-14291.43296.00-1.7%
long2019-10-142020-02-25296.00323.84+9.3%
short2020-02-252020-04-15323.84277.64+14.2%
long2020-04-152020-04-16277.64279.07+0.4%
short2020-04-162020-04-20279.07282.69-1.4%
long2020-04-202020-04-22282.69278.27-1.7%
short2020-04-222020-04-27278.27285.20-2.6%
long2020-04-272020-05-14285.20278.86-2.3%
short2020-05-142020-05-15278.86282.45-1.4%
long2020-05-152020-06-29282.45301.33+6.6%
short2020-06-292020-06-30301.33304.07-1.0%
long2020-06-302020-09-21304.07325.61+7.0%
short2020-09-212020-09-29325.61334.06-2.7%
long2020-09-292020-10-29334.06326.82-2.3%
short2020-10-292020-11-05326.82349.34-7.0%
long2020-11-052021-03-05349.34380.31+8.8%
short2021-03-052021-03-08380.31384.77-1.3%
long2021-03-082021-05-13384.77406.96+5.7%
short2021-05-132021-05-14406.96413.31-1.7%
long2021-05-142021-09-20413.31434.76+5.1%
short2021-09-202021-09-24434.76441.56-1.7%
long2021-09-242021-09-29441.56435.07-1.6%
short2021-09-292021-10-15435.07444.88-2.4%
long2021-10-152021-12-01444.88461.51+3.6%
short2021-12-012021-12-03461.51459.29+0.4%
long2021-12-032021-12-06459.29456.02-0.8%
short2021-12-062021-12-07456.02464.54-2.0%
long2021-12-072021-12-21464.54458.45-1.4%
short2021-12-212021-12-22458.45462.92-1.1%
long2021-12-222022-01-14462.92461.06-0.5%
short2022-01-142022-02-03461.06451.07+2.1%
long2022-02-032022-02-04451.07446.23-1.2%
short2022-02-042022-02-10446.23451.46-1.3%
long2022-02-102022-02-11451.46449.29-0.6%
short2022-02-112022-03-18449.29438.12+2.4%
long2022-03-182022-04-12438.12442.96+1.0%
short2022-04-122022-04-20442.96447.03-1.0%
long2022-04-202022-04-22447.03436.78-2.4%
short2022-04-222022-07-21436.78394.27+9.6%
long2022-07-212022-07-27394.27394.25-0.1%
short2022-07-272022-07-28394.25402.00-2.1%
long2022-07-282022-08-29402.00402.09-0.1%
short2022-08-292022-09-12402.09408.89-1.8%
long2022-09-122022-09-14408.89394.35-3.7%
short2022-09-142022-10-26394.35381.72+3.1%
long2022-10-262022-10-28381.72379.77-0.6%
short2022-10-282022-10-31379.77386.55-1.9%
long2022-10-312022-11-03386.55371.37-4.0%
short2022-11-032022-11-09371.37379.95-2.4%
long2022-11-092022-11-10379.95387.92+2.0%
short2022-11-102022-11-11387.92395.70-2.1%
long2022-11-112022-12-16395.70385.08-2.8%
short2022-12-162023-01-09385.08390.48-1.5%
long2023-01-092023-01-20390.48389.98-0.2%
short2023-01-202023-01-23389.98396.83-1.9%
long2023-01-232023-02-22396.83399.40+0.5%
short2023-02-222023-02-24399.40395.52+0.9%
long2023-02-242023-02-27395.52399.75+1.0%
short2023-02-272023-03-06399.75405.15-1.5%
long2023-03-062023-03-08405.15398.28-1.8%
short2023-03-082023-03-22398.28398.84-0.2%
long2023-03-222023-03-23398.84394.96-1.1%
short2023-03-232023-03-30394.96404.20-2.4%
long2023-03-302023-05-05404.20408.80+1.0%
short2023-05-052023-05-08408.80413.07-1.1%
long2023-05-082023-08-17413.07441.04+6.7%
short2023-08-172023-08-24441.04444.81-1.0%
long2023-08-242023-08-25444.81438.56-1.5%
short2023-08-252023-08-29438.56442.77-1.1%
long2023-08-292023-09-18442.77442.93-0.1%
short2023-09-182023-11-03442.93433.23+2.1%
long2023-11-032024-04-16433.23504.80+16.4%
short2024-04-162024-04-29504.80510.22-1.2%
long2024-04-292024-05-01510.22501.24-1.9%
short2024-05-012024-05-06501.24513.89-2.6%
long2024-05-062024-07-25513.89541.20+5.2%
short2024-07-252024-07-29541.20546.17-1.0%
long2024-07-292024-07-31546.17548.83+0.4%
short2024-07-312024-08-01548.83552.72-0.8%
long2024-08-012024-08-05552.72511.50-7.6%
short2024-08-052024-08-14511.50543.02-6.3%
long2024-08-142024-09-09543.02544.50+0.2%
short2024-09-092024-09-11544.50548.85-0.9%
long2024-09-112024-11-01548.85571.17+4.0%
short2024-11-012024-11-04571.17571.33-0.1%
long2024-11-042024-12-19571.33591.20+3.4%
short2024-12-192024-12-23591.20591.05-0.1%
long2024-12-232024-12-31591.05589.74-0.3%
short2024-12-312025-01-06589.74596.43-1.2%
long2025-01-062025-01-08596.43588.54-1.4%
short2025-01-082025-01-16588.54594.34-1.1%
long2025-01-162025-02-25594.34597.00+0.3%
short2025-02-252025-05-02597.00564.84+5.3%
long2025-05-022025-11-18564.84661.91+17.1%
short2025-11-182025-11-25661.91668.81-1.1%
long2025-11-252025-12-18668.81677.42+1.2%
short2025-12-182025-12-19677.42676.780.0%
long2025-12-192026-01-21676.78679.47+0.3%
short2026-01-212026-01-22679.47690.03-1.7%
long2026-01-222026-02-06690.03681.28-1.4%
short2026-02-062026-02-09681.28689.60-1.3%
long2026-02-092026-02-13689.60681.50-1.3%
short2026-02-132026-02-19681.50684.04-0.5%
long2026-02-192026-02-20684.04682.14-0.4%
short2026-02-202026-02-23682.14688.00-1.0%
long2026-02-232026-02-24688.00681.72-1.0%
short2026-02-242026-02-25681.72690.37-1.4%
long2026-02-252026-03-04690.37681.45-1.4%
short2026-03-042026-04-09681.45675.02+0.8%
long2026-04-092026-06-29675.02736.37+9.0%
short2026-06-292026-06-30736.37741.49-0.8%
long2026-06-302026-07-24741.49738.35-0.5%
short2026-07-242026-07-28738.35739.43-0.2%
long2026-07-282026-07-30739.43735.86-0.6%
short2026-07-302026-07-31735.86744.88-1.3%
long2026-07-312026-09-11744.88764.49+2.5%
short2026-09-112026-09-14764.49759.19+0.6%
long2026-09-142026-09-16759.19759.30-0.1%
short2026-09-162026-09-18759.30761.51-0.4%
long2026-09-182026-10-19761.51767.03+0.6%
short2026-10-192026-10-20767.03766.07+0.0%
long2026-10-202026-10-23766.07759.70-0.9%
short2026-10-232026-10-23759.70760.10-0.2%

The script

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

//@version=6
strategy("Price / MA 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="Setup")
len      = input.int(50, "MA length", minval=1, group="Setup")
maType   = input.string("EMA", "MA type", options=["EMA", "SMA"], group="Setup")
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(0, "Stop (ATR multiples, 0 = off)", minval=0, step=0.5, group="Risk")

// both averages computed every bar, the setting picks one
maE = ta.ema(src, len)
maS = ta.sma(src, len)
ma  = maType == "EMA" ? maE : maS
atr = ta.atr(atrLen)

longSig  = ta.crossover(close, ma) and barstate.isconfirmed
shortSig = ta.crossunder(close, ma) and barstate.isconfirmed

plot(ma, "Moving average", color=close > ma ? color.new(#16A56A, 0) : color.new(#E5484D, 0), linewidth=2)

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

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 Moving average 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: Golden cross strategy, EMA crossover strategy, Trailing stop strategy.

Questions

Does the Moving average strategy work?

SPY, daily data, 2016 to 2026, long and short: 50-day EMA lost 19.5% after costs over 191 trades (31.4% won, profit factor 1.01) against +277.8% for holding SPY, and the held-out third survived. Long only it made 91.1%. Across all 7 runs on the page, 4 made money after costs, 5 survived their held-out third and 0 beat holding the stock.

What is the win rate of the Moving average strategy?

From 24.6% to 45.3% across the 7 runs. The classic setting, 50-day EMA on SPY long and short, won 31.4% of 191 trades. The win rate alone does not decide the result: that run's profit factor was 1.01, so its winners outweighed its losers, and the net return was -19.5%.

What are the best Moving average settings?

Of the 3 settings tested, 50-day EMA on SPY (long only) did best: +91.1% net, profit factor 1.92, held-out survived. That is the best of 7 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 Moving average strategy beat holding the stock?

0 of the 7 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 40.5% with 97% of the time in the market.

Did the Moving average 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: 5 of 7 runs survived, 0 decayed, 1 did not survive and 1 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.