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.
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".
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.
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.
| Symbol | Timeframe | Settings | Direction | Trades | Win rate | Net | Holding | Profit factor | Max drawdown | Held-out |
|---|---|---|---|---|---|---|---|---|---|---|
| SPY | daily | 9/21 cross, 3 ATR trail | long and short | 94 | 39.4% | +79.8% | +277.8% | 1.61 | 24.0% | survived |
| QQQ | daily | 9/21 cross, 3 ATR trail | long and short | 108 | 34.3% | +79.8% | +542.3% | 1.49 | 30.8% | survived |
| NVDA | daily | 9/21 cross, 3 ATR trail | long and short | 106 | 33.0% | -32.1% | +25955.3% | 1.20 | 72.3% | did not survive |
| SPY | daily | 9/21 cross, 3 ATR trail | long only | 47 | 53.2% | +147.4% | +277.8% | 3.04 | 17.3% | survived |
| QQQ | daily | 9/21 cross, 3 ATR trail | long only | 54 | 40.7% | +239.0% | +542.3% | 2.77 | 24.9% | survived |
| NVDA | daily | 9/21 cross, 3 ATR trail | long only | 53 | 43.4% | +551.4% | +25955.3% | 2.47 | 42.7% | survived |
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.
| Year | 9/21 cross, 3 ATR trail, long and short | 9/21 cross, 3 ATR trail, long only | Holding SPY |
|---|---|---|---|
| 2016 | 0.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% |
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.
| Side | In | Out | Entry | Exit | Return |
|---|---|---|---|---|---|
| long | 2016-02-23 | 2016-05-06 | 194.05 | 204.00 | +5.0% |
| short | 2016-05-06 | 2016-05-11 | 204.00 | 207.97 | -2.0% |
| long | 2016-05-11 | 2016-05-16 | 207.97 | 204.90 | -1.6% |
| short | 2016-05-16 | 2016-05-25 | 204.90 | 208.77 | -2.0% |
| long | 2016-05-26 | 2016-06-16 | 209.51 | 206.26 | -1.7% |
| short | 2016-06-20 | 2016-06-24 | 208.76 | 203.68 | +2.3% |
| long | 2016-06-24 | 2016-06-27 | 203.68 | 201.53 | -1.2% |
| short | 2016-06-27 | 2016-06-29 | 201.53 | 205.91 | -2.3% |
| long | 2016-07-07 | 2016-09-12 | 209.93 | 212.33 | +1.0% |
| short | 2016-09-12 | 2016-11-08 | 212.33 | 213.38 | -0.6% |
| long | 2016-11-11 | 2017-03-22 | 216.17 | 233.44 | +7.9% |
| short | 2017-03-24 | 2017-03-30 | 234.31 | 236.49 | -1.0% |
| long | 2017-04-26 | 2017-07-03 | 238.60 | 242.84 | +1.7% |
| short | 2017-07-03 | 2017-07-13 | 242.84 | 244.09 | -0.6% |
| long | 2017-07-13 | 2017-08-10 | 244.09 | 243.81 | -0.2% |
| short | 2017-08-18 | 2017-09-01 | 242.83 | 247.99 | -2.2% |
| long | 2017-09-01 | 2017-12-01 | 247.99 | 261.06 | +5.2% |
| short | 2018-02-07 | 2018-02-12 | 268.42 | 264.09 | +1.5% |
| long | 2018-02-27 | 2018-03-02 | 278.19 | 265.72 | -4.6% |
| short | 2018-03-02 | 2018-03-09 | 265.72 | 275.78 | -3.9% |
| long | 2018-03-09 | 2018-03-22 | 275.78 | 267.83 | -3.0% |
| short | 2018-03-22 | 2018-04-05 | 267.83 | 265.66 | +0.7% |
| long | 2018-04-19 | 2018-04-25 | 269.73 | 262.83 | -2.7% |
| short | 2018-04-25 | 2018-05-10 | 262.83 | 270.43 | -3.0% |
| long | 2018-05-10 | 2018-06-27 | 270.43 | 272.18 | +0.5% |
| short | 2018-06-27 | 2018-07-06 | 272.18 | 275.85 | -1.4% |
| long | 2018-07-10 | 2018-10-08 | 278.49 | 285.76 | +2.5% |
| short | 2018-10-09 | 2018-10-12 | 287.31 | 277.02 | +3.5% |
| long | 2018-12-04 | 2018-12-07 | 278.45 | 269.38 | -3.4% |
| short | 2018-12-07 | 2018-12-27 | 269.38 | 247.56 | +8.0% |
| long | 2019-01-15 | 2019-05-13 | 257.89 | 282.34 | +9.4% |
| short | 2019-05-13 | 2019-06-05 | 282.34 | 282.59 | -0.2% |
| long | 2019-06-12 | 2019-08-02 | 288.72 | 291.69 | +0.9% |
| short | 2019-08-06 | 2019-08-08 | 285.83 | 292.39 | -2.4% |
| long | 2019-09-06 | 2019-10-02 | 298.25 | 291.43 | -2.4% |
| short | 2019-10-02 | 2019-10-07 | 291.43 | 294.72 | -1.2% |
| long | 2019-10-16 | 2020-01-31 | 298.43 | 322.06 | +7.8% |
| short | 2020-02-26 | 2020-03-02 | 314.11 | 298.90 | +4.7% |
| long | 2020-04-14 | 2020-09-14 | 281.02 | 337.40 | +20.0% |
| short | 2020-09-14 | 2020-09-30 | 337.40 | 337.52 | -0.1% |
| long | 2020-10-08 | 2020-10-26 | 342.95 | 335.53 | -2.3% |
| short | 2020-10-29 | 2020-11-06 | 326.82 | 350.03 | -7.2% |
| long | 2020-11-06 | 2021-03-04 | 350.03 | 373.83 | +6.7% |
| short | 2021-03-05 | 2021-03-10 | 380.31 | 390.78 | -2.9% |
| long | 2021-03-11 | 2021-09-20 | 392.33 | 434.76 | +10.7% |
| short | 2021-09-20 | 2021-09-23 | 434.76 | 440.37 | -1.4% |
| long | 2021-10-19 | 2021-11-26 | 449.04 | 457.56 | +1.8% |
| short | 2021-12-02 | 2021-12-09 | 450.60 | 468.28 | -4.0% |
| long | 2021-12-09 | 2021-12-21 | 468.28 | 458.45 | -2.2% |
| short | 2021-12-21 | 2021-12-23 | 458.45 | 468.88 | -2.4% |
| long | 2021-12-23 | 2022-01-10 | 468.88 | 459.69 | -2.1% |
| short | 2022-01-14 | 2022-01-24 | 461.06 | 439.31 | +4.6% |
| long | 2022-03-22 | 2022-04-18 | 445.98 | 436.69 | -2.2% |
| short | 2022-04-18 | 2022-05-04 | 436.69 | 426.98 | +2.1% |
| long | 2022-06-06 | 2022-06-13 | 414.89 | 379.75 | -8.6% |
| short | 2022-06-13 | 2022-06-27 | 379.75 | 391.16 | -3.1% |
| long | 2022-07-21 | 2022-08-26 | 394.27 | 407.55 | +3.3% |
| short | 2022-08-31 | 2022-09-12 | 399.82 | 408.89 | -2.4% |
| long | 2022-10-26 | 2022-12-16 | 381.72 | 383.93 | +0.5% |
| short | 2022-12-19 | 2023-01-12 | 383.36 | 396.78 | -3.6% |
| long | 2023-01-12 | 2023-02-22 | 396.78 | 398.43 | +0.3% |
| short | 2023-02-24 | 2023-03-21 | 395.30 | 398.76 | -1.0% |
| long | 2023-03-31 | 2023-08-14 | 404.76 | 444.58 | +9.7% |
| short | 2023-08-14 | 2023-08-29 | 444.58 | 446.15 | -0.5% |
| long | 2023-09-01 | 2023-09-20 | 453.29 | 443.89 | -2.2% |
| short | 2023-09-20 | 2023-10-09 | 443.89 | 432.74 | +2.4% |
| long | 2023-11-07 | 2024-04-15 | 435.81 | 507.99 | +16.5% |
| short | 2024-04-16 | 2024-05-03 | 504.80 | 511.57 | -1.4% |
| long | 2024-05-08 | 2024-07-24 | 515.40 | 547.20 | +6.1% |
| short | 2024-07-26 | 2024-08-06 | 542.13 | 528.46 | +2.4% |
| long | 2024-08-19 | 2024-09-10 | 554.88 | 548.21 | -1.3% |
| short | 2024-09-10 | 2024-09-12 | 548.21 | 555.16 | -1.4% |
| long | 2024-09-12 | 2024-11-05 | 555.16 | 570.58 | +2.7% |
| short | 2024-11-05 | 2024-11-07 | 570.58 | 593.24 | -4.1% |
| long | 2024-11-07 | 2024-12-18 | 593.24 | 589.77 | -0.7% |
| short | 2024-12-20 | 2025-01-15 | 581.61 | 592.30 | -1.9% |
| long | 2025-01-22 | 2025-02-26 | 606.08 | 595.75 | -1.8% |
| short | 2025-02-26 | 2025-03-17 | 595.75 | 569.06 | +4.4% |
| long | 2025-04-30 | 2025-11-19 | 547.74 | 660.60 | +20.5% |
| short | 2025-11-19 | 2025-11-25 | 660.60 | 675.84 | -2.4% |
| long | 2025-12-01 | 2026-02-06 | 678.98 | 681.28 | +0.2% |
| short | 2026-02-06 | 2026-02-10 | 681.28 | 695.13 | -2.1% |
| long | 2026-02-10 | 2026-02-13 | 695.13 | 681.50 | -2.1% |
| short | 2026-02-13 | 2026-02-27 | 681.50 | 683.24 | -0.4% |
| long | 2026-02-27 | 2026-03-02 | 683.24 | 678.52 | -0.8% |
| short | 2026-03-02 | 2026-04-01 | 678.52 | 654.05 | +3.5% |
| long | 2026-04-10 | 2026-06-09 | 681.48 | 728.97 | +6.9% |
| short | 2026-06-25 | 2026-06-30 | 738.70 | 745.71 | -1.0% |
| long | 2026-07-02 | 2026-07-27 | 747.60 | 744.67 | -0.5% |
| short | 2026-07-27 | 2026-08-03 | 744.67 | 753.72 | -1.3% |
| long | 2026-08-04 | 2026-09-11 | 760.82 | 764.49 | +0.4% |
| short | 2026-09-11 | 2026-09-21 | 764.49 | 767.90 | -0.5% |
| long | 2026-09-23 | 2026-10-16 | 772.99 | 761.18 | -1.6% |
| short | 2026-10-23 | 2026-10-23 | 759.70 | 760.10 | -0.2% |
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)
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.
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.
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.
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.
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%.
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.
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.
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.
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.