BACKTEST RESULTS

MACD strategy backtest results

SPY daily data, 2016 to 2026: the 12/26/9 rule, long and short, lost 4.5% after costs over 231 trades, winning 39.8% of them, against +277.8% for holding SPY. Long only it made 46.4%. The best of 7 runs was 12/26/9 on SPY, long only: +46.4%, held-out decayed. Every run, every trade and the script are on this page.

SPY · daily data · 12/26/9 · long and short
Net after costs
-4.5%
Holding SPY
+277.8%
Trades
231
Win rate
39.8%
Profit factor
1.01
Max drawdown
23.4%
Held out, last third: did not survive
Long only: +46.4% on 115 trades, held-out decayed
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
  • 7 runs, 4602 trades
  • Updated 1 November 2026

The short answer

Answers here: Does the MACD crossover strategy work? · What is its win rate? · 12/26/9 or faster? · Long only, or both ways?

SPY daily data, 4 January 2016 to 23 October 2026, long and short: 231 trades, lost 4.5% after costs, 39.8% of trades won, profit factor 1.01, worst drawdown 23.4%, 64% 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) lost 17.8% on 84 trades: it did not survive its held-out period.

Long only, the same rule made 46.4% on 115 trades (46.1% won, profit factor 1.45, held-out decayed): the short side cost 50.9 points of return in a period when SPY rose 277.8%.

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

Across all 7 runs on this page, 2 made money after costs, 1 survived the held-out third, and 0 beat holding the symbol.

The best run was 12/26/9 on SPY, long only: +46.4% net on 115 trades, profit factor 1.45, worst drawdown 14.8%, held-out decayed. 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

MACD Cross Strategy, from the strategy library.

Goes long when the MACD line (12, 26) crosses above its 9-period signal line and goes short when it crosses below; the opposite cross closes the trade. Each trade carries a stop 2 ATR away and a target 3 ATR away. A faster 8/17/9 setting was run on SPY, and long-only versions on SPY and QQQ.

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

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
SPYdaily12/26/9long and short23139.8%-4.5%+277.8%1.0123.4%did not survive
QQQdaily12/26/9long and short20939.2%-34.3%+542.3%0.9152.7%did not survive
SPYdaily8/17/9long and short27838.1%-1.0%+277.8%1.0330.2%did not survive
NVDAdaily12/26/9long and short21733.6%-94.4%+25955.3%0.7595.3%did not survive
SPYdaily12/26/9long only11546.1%+46.4%+277.8%1.4514.8%decayed
QQQdaily12/26/9long only10449.0%+47.6%+542.3%1.3829.0%survived
SPY5-minute12/26/9long and short344824.0%-99.6%+44.4%0.2799.6%did not survive

Year by year

12/26/9 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.

Year12/26/9, long and short12/26/9, long onlyHolding SPY
2016+4.9%+2.8%+11.2%
2017-2.5%+2.2%+18.5%
2018-8.4%-9.8%-6.9%
2019+5.6%+9.3%+28.6%
2020+20.8%+32.8%+15.1%
2021-10.6%-1.1%+28.8%
2022+0.7%-2.7%-19.9%
2023+3.5%+8.1%+24.8%
2024-4.2%+7.8%+24.0%
2025-2.4%-3.3%+16.6%
2026-8.3%-3.2%+11.2%

Every trade

The 231 trades of 12/26/9 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-03-282016-04-13203.55207.78-2.2%
long2016-04-192016-04-26209.80208.98-0.5%
short2016-04-262016-05-19208.98203.02+2.8%
long2016-05-262016-06-14209.51207.94-0.9%
short2016-06-142016-06-24207.94203.24+2.2%
long2016-07-052016-08-02209.02216.59+3.5%
short2016-08-022016-09-26216.59215.11+0.6%
long2016-09-262016-09-27215.11213.99-0.6%
short2016-09-272016-09-28213.99215.89-1.0%
long2016-09-282016-10-12215.89213.53-1.2%
short2016-10-122016-10-25213.53214.75-0.7%
long2016-10-252016-10-31214.75212.87-1.0%
short2016-10-312016-11-09212.87212.43+0.1%
long2016-11-092016-11-21212.43220.06+3.5%
short2016-12-222017-01-25225.53229.09-1.7%
long2017-01-262017-01-30229.47226.38-1.4%
short2017-02-012017-02-09228.18230.60-1.2%
long2017-02-102017-02-15231.09234.75+1.5%
short2017-03-082017-03-27237.25231.99+2.1%
long2017-04-252017-05-18237.98235.63-1.1%
short2017-05-182017-05-19235.63238.97-1.5%
long2017-05-262017-06-16241.62242.70+0.3%
short2017-06-162017-07-14242.70244.50-0.8%
long2017-07-142017-08-04244.50247.45+1.1%
short2017-08-042017-08-17247.45243.31+1.6%
long2017-09-012017-09-27247.99249.81+0.6%
short2017-09-272017-10-02249.81251.56-0.8%
long2017-10-022017-10-10251.56254.85+1.2%
short2017-10-262017-10-27255.92257.64-0.8%
long2017-11-072017-11-09259.04256.38-1.1%
short2017-11-102017-11-28257.66260.84-1.3%
long2017-11-282017-11-30260.84263.95+1.1%
short2017-12-262018-01-03266.98270.60-1.5%
long2018-01-052018-01-11272.58275.97+1.1%
short2018-02-012018-02-02280.96275.66+1.8%
long2018-02-262018-03-02276.01265.72-3.8%
short2018-03-052018-03-06267.65273.35-2.2%
long2018-03-062018-03-20273.35270.85-1.0%
short2018-03-202018-03-23270.85259.00+4.3%
long2018-04-112018-05-03263.56262.18-0.6%
short2018-05-032018-05-08262.18266.58-1.8%
long2018-05-082018-05-30266.58270.45+1.4%
short2018-05-302018-06-04270.45274.85-1.7%
long2018-06-052018-06-19275.12273.92-0.5%
short2018-06-192018-06-25273.92269.67+1.5%
long2018-07-102018-08-01278.49281.48+1.0%
short2018-08-012018-08-06281.48283.64-0.9%
long2018-08-062018-08-14283.64282.84-0.4%
short2018-08-142018-08-21282.84286.32-1.3%
long2018-08-232018-08-24286.05286.36+0.0%
short2018-08-242018-08-27286.36288.94-1.0%
long2018-08-272018-09-07288.94286.90-0.8%
short2018-09-072018-09-20286.90292.72-2.1%
long2018-09-212018-09-25293.17291.45-0.7%
short2018-09-252018-10-10291.45285.55+1.9%
long2018-11-052018-11-21272.52265.78-2.6%
short2018-11-212018-11-28265.78274.03-3.2%
long2018-11-292018-12-06273.79265.26-3.2%
short2018-12-112018-12-20267.58248.19+7.1%
long2019-01-072019-02-05252.76272.40+7.7%
short2019-03-012019-03-19280.36283.88-1.4%
long2019-03-222019-03-22283.30279.19-1.6%
short2019-03-252019-04-01278.80285.13-2.4%
long2019-04-032019-04-23287.40290.60+1.0%
short2019-04-232019-04-24290.60292.85-0.9%
long2019-04-242019-05-02292.85291.60-0.5%
short2019-05-022019-05-09291.60285.31+2.1%
long2019-06-072019-06-20286.01295.97+3.4%
short2019-07-192019-08-02299.95292.16+2.5%
long2019-08-222019-08-23293.31284.12-3.2%
short2019-08-262019-08-30287.19294.30-2.6%
long2019-08-302019-09-25294.30295.88+0.4%
short2019-09-252019-10-03295.88286.58+3.0%
long2019-10-152019-11-04297.17307.77+3.5%
short2019-11-222019-11-27311.00314.70-1.3%
long2019-11-272019-12-03314.70308.56-2.0%
short2019-12-032019-12-12308.56315.82-2.5%
long2019-12-162020-01-02319.27323.45+1.2%
short2020-01-022020-01-03323.45321.23+0.6%
long2020-01-032020-01-06321.23320.40-0.4%
short2020-01-062020-01-09320.40326.64-2.0%
long2020-01-142020-01-27327.57322.94-1.5%
short2020-01-272020-01-31322.94321.95+0.2%
long2020-02-072020-02-24332.91323.05-3.1%
short2020-02-242020-02-25323.05323.22-0.2%
long2020-03-272020-05-14253.36278.86+10.0%
short2020-05-142020-05-18278.86296.78-6.5%
long2020-05-202020-06-05295.90317.19+7.1%
short2020-06-122020-06-16308.15315.56-2.5%
long2020-07-092020-07-29316.93322.03+1.5%
short2020-07-292020-08-04322.03327.95-1.9%
long2020-08-042020-08-21327.95337.83+2.9%
short2020-08-212020-08-25337.83343.64-1.8%
long2020-08-252020-09-02343.64354.58+3.1%
short2020-09-082020-09-21336.62325.78+3.1%
long2020-10-022020-10-23331.79345.83+4.1%
short2020-10-232020-10-28345.83328.65+4.9%
long2020-11-062020-12-08350.03370.37+5.7%
short2020-12-112020-12-21364.80375.57-3.1%
long2021-01-082021-01-19380.70378.24-0.7%
short2021-01-192021-01-20378.24384.75-1.8%
long2021-01-212021-01-27384.60374.68-2.7%
short2021-01-282021-02-04376.25384.04-2.2%
long2021-02-082021-02-23389.38384.54-1.3%
short2021-02-232021-03-04384.54374.75+2.4%
long2021-03-122021-03-24392.19390.89-0.4%
short2021-03-242021-03-30390.89394.51-1.0%
long2021-03-302021-04-13394.51412.37+4.4%
short2021-04-272021-05-12417.80405.44+2.9%
long2021-05-282021-06-18421.09416.97-1.1%
short2021-06-182021-06-28416.97427.29-2.6%
long2021-06-282021-07-12427.29437.05+2.2%
short2021-07-192021-07-23426.07438.57-3.0%
long2021-07-272021-08-03440.03438.32-0.5%
short2021-08-032021-08-04438.32439.89-0.5%
long2021-08-042021-08-05439.89440.10-0.1%
short2021-08-052021-08-09440.10442.57-0.7%
long2021-08-092021-08-19442.57436.15-1.6%
short2021-08-192021-08-23436.15446.15-2.4%
long2021-08-262021-08-27448.73447.00-0.5%
short2021-08-272021-08-30447.00451.11-1.0%
long2021-08-302021-09-09451.11450.58-0.2%
short2021-09-092021-09-17450.58442.30+1.7%
long2021-10-112021-10-22437.28454.36+3.8%
short2021-11-182021-11-26469.11457.60+2.4%
long2021-12-132021-12-17470.32458.37-2.6%
short2021-12-202021-12-27454.32472.16-4.0%
long2021-12-272022-01-07472.16467.82-1.0%
short2022-01-072022-01-20467.82450.99+3.5%
long2022-02-032022-02-11451.07439.04-2.8%
short2022-02-182022-02-24437.21411.12+5.9%
long2022-03-032022-03-08440.59419.59-4.9%
short2022-03-082022-03-17419.59433.71-3.5%
long2022-03-172022-04-08433.71447.85+3.2%
short2022-04-082022-04-22447.85426.76+4.6%
long2022-05-252022-06-14392.42376.75-4.1%
short2022-06-142022-06-28376.75390.33-3.7%
long2022-06-282022-08-08390.33416.93+6.7%
short2022-08-232022-09-01412.79392.99+4.7%
long2022-10-062022-10-10375.72359.76-4.3%
short2022-10-122022-10-14358.07368.63-3.0%
long2022-10-142022-11-10368.63392.67+6.4%
short2022-12-072022-12-13392.79410.32-4.6%
long2023-01-102023-02-01387.36408.46+5.3%
short2023-02-132023-02-14408.61411.35-0.8%
long2023-02-142023-02-15411.35410.25-0.4%
short2023-02-152023-02-24410.25394.01+3.9%
long2023-03-222023-04-26398.84406.61+1.8%
short2023-04-262023-04-28406.61415.27-2.2%
long2023-05-192023-05-24420.29410.09-2.5%
short2023-05-252023-05-26414.62419.95-1.4%
long2023-05-302023-06-12422.15433.51+2.6%
short2023-06-262023-06-30432.51441.90-2.3%
long2023-07-052023-07-07442.03438.51-0.9%
short2023-07-072023-07-13438.51448.02-2.3%
long2023-07-142023-07-28450.60455.76+1.0%
short2023-07-282023-08-16455.76440.96+3.1%
long2023-08-302023-09-19449.65442.56-1.7%
short2023-09-192023-09-22442.56431.19+2.5%
long2023-10-102023-10-20433.06421.51-2.8%
short2023-10-232023-11-03419.50433.23-3.4%
long2023-11-032023-11-14433.23447.88+3.3%
short2023-12-072023-12-12456.79462.82-1.4%
long2023-12-132023-12-20464.62475.62+2.3%
short2024-01-022024-01-22472.03484.14-2.7%
long2024-01-232024-02-07484.15496.17+2.4%
short2024-02-202024-02-22497.59508.33-2.3%
long2024-02-262024-03-06508.44510.41+0.3%
short2024-03-062024-03-08510.41515.60-1.1%
long2024-03-082024-03-11515.60510.34-1.1%
short2024-03-112024-03-21510.34523.52-2.7%
long2024-03-222024-03-26522.25521.09-0.3%
short2024-03-262024-04-15521.09506.72+2.7%
long2024-05-062024-05-16513.89530.07+3.0%
short2024-05-312024-06-05523.44531.98-1.7%
long2024-06-072024-06-20533.80549.30+2.8%
short2024-06-272024-07-05545.22554.47-1.8%
long2024-07-082024-07-19555.59552.27-0.7%
short2024-07-192024-08-02552.27535.84+2.9%
long2024-08-152024-09-05549.65550.74+0.1%
short2024-09-052024-09-16550.74561.89-2.1%
long2024-09-162024-10-04561.89572.20+1.7%
short2024-10-042024-10-11572.20576.20-0.8%
long2024-10-112024-10-24576.20579.83+0.5%
short2024-10-242024-11-06579.83589.36-1.7%
long2024-11-082024-11-19596.33584.55-2.1%
short2024-11-192024-11-25584.55600.03-2.7%
long2024-11-262024-12-11598.96605.62+1.0%
short2024-12-112024-12-18605.62589.68+2.5%
long2025-01-212025-02-24600.83601.86+0.1%
short2025-02-242025-03-03601.86581.42+3.3%
long2025-03-242025-04-03570.95544.90-4.7%
short2025-04-042025-04-07523.59489.31+6.4%
long2025-04-162025-04-22531.82519.98-2.3%
short2025-04-222025-04-23519.98540.58-4.1%
long2025-04-232025-05-12540.58581.34+7.4%
short2025-05-292025-06-24592.90606.88-2.5%
long2025-06-302025-07-16617.52623.59+0.9%
short2025-07-162025-07-23623.59633.21-1.6%
long2025-07-282025-07-30637.67635.79-0.4%
short2025-07-302025-08-01635.79621.68+2.1%
long2025-08-142025-08-20642.95639.23-0.7%
short2025-08-202025-08-29639.23647.63-1.4%
long2025-08-292025-09-02647.63637.33-1.7%
short2025-09-022025-09-11637.33654.35-2.8%
long2025-09-112025-09-26654.35659.34+0.7%
short2025-09-262025-10-01659.34668.37-1.5%
long2025-10-032025-10-10670.17671.96+0.2%
short2025-10-102025-10-13671.96656.93+2.1%
long2025-10-272025-11-06682.91676.29-1.1%
short2025-11-062025-11-18676.29656.78+2.8%
long2025-12-012025-12-17678.98679.71+0.0%
short2025-12-172025-12-26679.71690.82-1.7%
long2025-12-262026-01-02690.82685.53-0.9%
short2026-01-022026-01-07685.53692.38-1.1%
long2026-01-072026-01-20692.38679.65-1.9%
short2026-01-212026-01-22679.47690.36-1.7%
long2026-01-292026-02-04696.53690.17-1.0%
short2026-02-042026-02-26690.17693.46-0.6%
long2026-02-262026-03-03693.46674.87-2.8%
short2026-03-042026-03-20681.45653.99+3.9%
long2026-04-062026-04-14656.03687.76+4.7%
short2026-05-192026-05-28734.56754.24-2.8%
long2026-07-072026-07-20750.47746.86-0.6%
short2026-07-202026-08-04746.86760.82-2.0%
long2026-08-042026-08-21760.82765.84+0.6%
short2026-08-212026-09-23765.84772.99-1.0%
long2026-09-232026-10-01772.99764.15-1.2%
short2026-10-012026-10-05764.15775.86-1.6%
long2026-10-062026-10-16778.36773.04-0.8%
short2026-10-162026-10-23773.04760.10+1.6%

The script

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

//@version=6
strategy("MACD Cross Strategy", overlay=false, 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")
fastLen  = input.int(12, "Fast length", minval=1, group="Setup")
slowLen  = input.int(26, "Slow length", minval=2, group="Setup")
sigLen   = input.int(9, "Signal length", minval=1, 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(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")

[macd, signal, hist] = ta.macd(src, fastLen, slowLen, sigLen)
atr = ta.atr(atrLen)

longSig  = ta.crossover(macd, signal) and barstate.isconfirmed
shortSig = ta.crossunder(macd, signal) and barstate.isconfirmed

plot(hist, "Histogram", color=hist >= 0 ? color.new(#16A56A, 40) : color.new(#E5484D, 40), style=plot.style_columns)
plot(macd, "MACD", color=color.new(#A3A39E, 0), linewidth=2)
plot(signal, "Signal", color=color.new(#E3A008, 0), linewidth=1)
hline(0, "Zero", color=color.new(#A3A39E, 60), linestyle=hline.style_dotted)

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 MACD 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, Stochastic strategy, RSI strategy.

Questions

Does the MACD strategy work?

SPY, daily data, 2016 to 2026, long and short: 12/26/9 lost 4.5% after costs over 231 trades (39.8% won, profit factor 1.01) against +277.8% for holding SPY, and the held-out third did not survive. Long only it made 46.4%. Across all 7 runs on the page, 2 made money after costs, 1 survived their held-out third and 0 beat holding the stock.

What is the win rate of the MACD strategy?

From 24.0% to 49.0% across the 7 runs. The classic setting, 12/26/9 on SPY long and short, won 39.8% of 231 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 -4.5%.

What are the best MACD settings?

Of the 2 settings tested, 12/26/9 on SPY (long only) did best: +46.4% net, profit factor 1.45, held-out decayed. 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 MACD 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 23.4% with 64% of the time in the market.

Did the MACD 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: 1 of 7 runs survived, 1 decayed, 5 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.