BACKTEST RESULTS

Trailing stop strategy backtest results

SPY daily data, 2016 to 2026: the 9/21 cross, 3 ATR trail rule, long and short, made 79.8% after costs over 94 trades, winning 39.4% of them, against +277.8% for holding SPY. Long only it made 147.4%. The best of 6 runs was 9/21 cross, 3 ATR trail on QQQ, long only: +239.0%, held-out survived. Every run, every trade and the script are on this page.

SPY · daily data · 9/21 cross, 3 ATR trail · long and short
Net after costs
+79.8%
Holding SPY
+277.8%
Trades
94
Win rate
39.4%
Profit factor
1.61
Max drawdown
24.0%
Held out, last third: survived
Long only: +147.4% on 47 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
  • 6 runs, 462 trades
  • Updated 1 November 2026

The short answer

Answers here: Does a trailing stop improve a trend strategy? · What does the ATR trail do to the win rate? · Long only, or both ways?

SPY daily data, 4 January 2016 to 23 October 2026, long and short: 94 trades, made 79.8% after costs, 39.4% of trades won, profit factor 1.61, worst drawdown 24.0%, 80% 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 48.7% on 32 trades: the rule survived its held-out period.

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

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

The best run was 9/21 cross, 3 ATR trail on QQQ, long only: +239.0% net on 54 trades, profit factor 2.77, worst drawdown 24.9%, 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 with Trailing Stop, from the strategy library.

The 9/21 EMA cross with an ATR trailing stop in place of a fixed stop and target: the trail switches on once a trade is 1 ATR in profit and closes it when price gives back 3 ATR from its best level; the opposite cross closes the trade as well. The plain 9/21 cross, with its fixed 2 ATR stop and 3 ATR target, is on the EMA crossover page for comparison. Long-only versions were run on all three names.

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

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/21 cross, 3 ATR traillong and short9439.4%+79.8%+277.8%1.6124.0%survived
QQQdaily9/21 cross, 3 ATR traillong and short10834.3%+79.8%+542.3%1.4930.8%survived
NVDAdaily9/21 cross, 3 ATR traillong and short10633.0%-32.1%+25955.3%1.2072.3%did not survive
SPYdaily9/21 cross, 3 ATR traillong only4753.2%+147.4%+277.8%3.0417.3%survived
QQQdaily9/21 cross, 3 ATR traillong only5440.7%+239.0%+542.3%2.7724.9%survived
NVDAdaily9/21 cross, 3 ATR traillong only5343.4%+551.4%+25955.3%2.4742.7%survived

Year by year

9/21 cross, 3 ATR trail 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 cross, 3 ATR trail, long and short9/21 cross, 3 ATR trail, long onlyHolding SPY
20160.0%+4.9%+11.2%
2017+6.3%+10.6%+18.5%
2018-6.1%-10.2%-6.9%
2019+11.7%+16.2%+28.6%
2020+20.6%+24.0%+15.1%
2021+1.6%+13.0%+28.8%
2022-10.2%-10.7%-19.9%
2023+13.2%+17.4%+24.8%
2024+8.4%+14.7%+24.0%
2025+19.1%+18.8%+16.6%
2026-0.7%+1.7%+11.2%

Every trade

The 94 trades of 9/21 cross, 3 ATR trail 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-05-06194.05204.00+5.0%
short2016-05-062016-05-11204.00207.97-2.0%
long2016-05-112016-05-16207.97204.90-1.6%
short2016-05-162016-05-25204.90208.77-2.0%
long2016-05-262016-06-16209.51206.26-1.7%
short2016-06-202016-06-24208.76203.68+2.3%
long2016-06-242016-06-27203.68201.53-1.2%
short2016-06-272016-06-29201.53205.91-2.3%
long2016-07-072016-09-12209.93212.33+1.0%
short2016-09-122016-11-08212.33213.38-0.6%
long2016-11-112017-03-22216.17233.44+7.9%
short2017-03-242017-03-30234.31236.49-1.0%
long2017-04-262017-07-03238.60242.84+1.7%
short2017-07-032017-07-13242.84244.09-0.6%
long2017-07-132017-08-10244.09243.81-0.2%
short2017-08-182017-09-01242.83247.99-2.2%
long2017-09-012017-12-01247.99261.06+5.2%
short2018-02-072018-02-12268.42264.09+1.5%
long2018-02-272018-03-02278.19265.72-4.6%
short2018-03-022018-03-09265.72275.78-3.9%
long2018-03-092018-03-22275.78267.83-3.0%
short2018-03-222018-04-05267.83265.66+0.7%
long2018-04-192018-04-25269.73262.83-2.7%
short2018-04-252018-05-10262.83270.43-3.0%
long2018-05-102018-06-27270.43272.18+0.5%
short2018-06-272018-07-06272.18275.85-1.4%
long2018-07-102018-10-08278.49285.76+2.5%
short2018-10-092018-10-12287.31277.02+3.5%
long2018-12-042018-12-07278.45269.38-3.4%
short2018-12-072018-12-27269.38247.56+8.0%
long2019-01-152019-05-13257.89282.34+9.4%
short2019-05-132019-06-05282.34282.59-0.2%
long2019-06-122019-08-02288.72291.69+0.9%
short2019-08-062019-08-08285.83292.39-2.4%
long2019-09-062019-10-02298.25291.43-2.4%
short2019-10-022019-10-07291.43294.72-1.2%
long2019-10-162020-01-31298.43322.06+7.8%
short2020-02-262020-03-02314.11298.90+4.7%
long2020-04-142020-09-14281.02337.40+20.0%
short2020-09-142020-09-30337.40337.52-0.1%
long2020-10-082020-10-26342.95335.53-2.3%
short2020-10-292020-11-06326.82350.03-7.2%
long2020-11-062021-03-04350.03373.83+6.7%
short2021-03-052021-03-10380.31390.78-2.9%
long2021-03-112021-09-20392.33434.76+10.7%
short2021-09-202021-09-23434.76440.37-1.4%
long2021-10-192021-11-26449.04457.56+1.8%
short2021-12-022021-12-09450.60468.28-4.0%
long2021-12-092021-12-21468.28458.45-2.2%
short2021-12-212021-12-23458.45468.88-2.4%
long2021-12-232022-01-10468.88459.69-2.1%
short2022-01-142022-01-24461.06439.31+4.6%
long2022-03-222022-04-18445.98436.69-2.2%
short2022-04-182022-05-04436.69426.98+2.1%
long2022-06-062022-06-13414.89379.75-8.6%
short2022-06-132022-06-27379.75391.16-3.1%
long2022-07-212022-08-26394.27407.55+3.3%
short2022-08-312022-09-12399.82408.89-2.4%
long2022-10-262022-12-16381.72383.93+0.5%
short2022-12-192023-01-12383.36396.78-3.6%
long2023-01-122023-02-22396.78398.43+0.3%
short2023-02-242023-03-21395.30398.76-1.0%
long2023-03-312023-08-14404.76444.58+9.7%
short2023-08-142023-08-29444.58446.15-0.5%
long2023-09-012023-09-20453.29443.89-2.2%
short2023-09-202023-10-09443.89432.74+2.4%
long2023-11-072024-04-15435.81507.99+16.5%
short2024-04-162024-05-03504.80511.57-1.4%
long2024-05-082024-07-24515.40547.20+6.1%
short2024-07-262024-08-06542.13528.46+2.4%
long2024-08-192024-09-10554.88548.21-1.3%
short2024-09-102024-09-12548.21555.16-1.4%
long2024-09-122024-11-05555.16570.58+2.7%
short2024-11-052024-11-07570.58593.24-4.1%
long2024-11-072024-12-18593.24589.77-0.7%
short2024-12-202025-01-15581.61592.30-1.9%
long2025-01-222025-02-26606.08595.75-1.8%
short2025-02-262025-03-17595.75569.06+4.4%
long2025-04-302025-11-19547.74660.60+20.5%
short2025-11-192025-11-25660.60675.84-2.4%
long2025-12-012026-02-06678.98681.28+0.2%
short2026-02-062026-02-10681.28695.13-2.1%
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-04-01678.52654.05+3.5%
long2026-04-102026-06-09681.48728.97+6.9%
short2026-06-252026-06-30738.70745.71-1.0%
long2026-07-022026-07-27747.60744.67-0.5%
short2026-07-272026-08-03744.67753.72-1.3%
long2026-08-042026-09-11760.82764.49+0.4%
short2026-09-112026-09-21764.49767.90-0.5%
long2026-09-232026-10-16772.99761.18-1.6%
short2026-10-232026-10-23759.70760.10-0.2%

The script

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

//@version=6
strategy("EMA Cross with Trailing Stop", 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")
trailMul = input.float(3, "Trail distance (ATR multiples)", minval=0.5, step=0.5, group="Risk")
actMul   = input.float(1, "Activation profit (ATR multiples)", 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

// strategy.exit works in ticks: convert the ATR distances
trailTicks = trailMul * atr / syminfo.mintick
actTicks   = actMul * atr / syminfo.mintick

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 trail", "Long", trail_points=actTicks, trail_offset=trailTicks)
if shortSig
    strategy.close("Long")
    if useShort
        strategy.entry("Short", strategy.short)
        strategy.exit("Short trail", "Short", trail_points=actTicks, trail_offset=trailTicks)

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 Trailing stop 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, SuperTrend strategy, Parabolic SAR strategy.

Questions

Does the Trailing stop strategy work?

SPY, daily data, 2016 to 2026, long and short: 9/21 cross, 3 ATR trail made 79.8% after costs over 94 trades (39.4% won, profit factor 1.61) against +277.8% for holding SPY, and the held-out third survived. Long only it made 147.4%. Across all 6 runs on the page, 5 made money after costs, 5 survived their held-out third and 0 beat holding the stock.

What is the win rate of the Trailing stop strategy?

From 33.0% to 53.2% across the 6 runs. The classic setting, 9/21 cross, 3 ATR trail on SPY long and short, won 39.4% of 94 trades. The win rate alone does not decide the result: that run's profit factor was 1.61, so its winners outweighed its losers, and the net return was +79.8%.

Is the Trailing stop strategy better long only?

On SPY it was: long only made 147.4% against made 79.8% traded both ways, with held-out verdicts of survived 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 Trailing stop strategy beat holding the stock?

0 of the 6 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 24.0% with 80% of the time in the market.

Did the Trailing stop 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 6 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.