20-Day Momentum + Trailing Stop on XLY
Consumer Discretionary Select Sector SPDR Fund: consumer discretionary stocks, a cyclical read on the US consumer. Backtest 2021-01-04 to 2026-10-02, $10,000 starting capital, computed by the same engine that runs live DeployQuant strategies.
XLY is the Consumer Discretionary Select Sector SPDR Fund. The 20-day momentum breakout turned $10,000 into $12,405.85 on it, a CAGR of 3.83%. Buy-and-hold on XLY returned 6.27% a year and ended at $14,177.03. Return was lower than holding, and the maximum drawdown was much shallower, 18.35% against 39.06%, over 9 round trips from 2021-01-04 to 2026-10-02.
A 20-day return above 10% triggers a 98% buy. After that a trailing stop follows 10% under the highest close since entry, and no profit target exists. Five of the 9 trades won, so the win rate was 56%. Winners averaged 9.87% and losers -5.94%. The profit factor was 1.88 and the Sharpe ratio 0.33, against 0.39 for holding. The rule was invested on 60.7% of days.
This fund was a middling fit. The rule ranks 5th of 12 templates on XLY, and XLY ranks 21st of 59 for the rule. Across all 59 funds the median CAGR for this rule is 0%, a sign of how many funds never produced a 10% burst in 20 sessions. The category median among sector funds is 6.99%. Per-fund results sit on the momentum breakout strategy page, while the XLY fund page sets the 12 templates side by side.
Fees and slippage are zero in the headline figures. The cost runs, parameter variants and the fund's own behaviour come after the year-by-year view, and the test covers one 5.74-year window.
Year by year
| Year | momentum breakout | buy & hold |
|---|---|---|
| 2021 | 11.1% | 28.5% |
| 2022 | −5.2% | −35.7% |
| 2023 | 1.4% | 38.7% |
| 2024 | 17.4% | 26.0% |
| 2025 | 14.5% | 7.3% |
| 2026 | −13.6% | −7.2% |
Six calendar years against a fund that swung both ways
The rule returned 11.1% in 2021, -5.2% in 2022, 1.4% in 2023, 17.4% in 2024, 14.5% in 2025 and -13.6% in 2026. Holding the fund returned 28.5%, -35.7%, 38.7%, 26%, 7.3% and -7.2%. The rule won two years, 2022 by 30.5 points and 2025 by 7.2 points, and behind in the other four, by 17.4, 37.3, 8.6 and 6.4 points. Data for 2026 ends on 2026-10-02.
In 2021 the first trade began on 2021-04-06 at an adjusted $82.76, so the first three months were spent in cash. It then held for 258 days to 2021-12-20, exiting at $92.14 for a gain of 11.33%. The monthly results from April to November were mostly positive, led by October at 11.74%. December lost 5.87%, because the trail triggered after the fund's peak on 2021-11-19.
The bear market of 2022 is where the rule paid off. XLY lost 35.7%, and the rule lost 5.2%. The rule made two entries in that year. The first, on 2022-04-05 at $90.69, lost 9.6% in 21 days and was the poorest trade of the run, and April's -9.41% was the rule's weakest month. The second, on 2022-07-20 at $72.34, caught the summer rebound, with July at 8.33% and an exit on 2022-08-30 at $75.816 for 4.81%. The rest of the year went by in cash while XLY slid to its low on 2022-12-28.
2023 is the year the rule missed. XLY gained 38.7% and the rule made 1.4%. Two entries, on 2023-01-27 and 2023-06-13, were stopped out for losses of 2.48% and 3.01%, and the third began on 2023-11-20 at $81.48. A trend-following exit with a 10% trail has difficulty in a year when strength arrives in brief spurts that reverse. September 2023 cost 6.13% and December made 6.04%.
2024 and 2025 were the strong stretch. The 2023-11-20 trade ran to 2024-08-02 and made 5.57%. A new entry on 2024-09-06 at $92.31 held for 172 days to 2025-02-25 and made 15.19%, the best trade of the run. November 2024 returned 12.6%, the best month. The 2025-05-08 entry at $99.45 held for 299 days to 2026-03-03 at $111.816 and made 12.43%. The result in 2025 was 14.5% against 7.3% for holding, partly because the rule sat out the April 2025 low, after a stop in February.
In 2026 the last trade was a buy on 2026-04-21 at $119.93 and a sale on 2026-07-23 at $109.512, a loss of 8.69% over 93 days. The year ended at -13.6% against -7.2% for holding, the other year in which the rule did worse than the fund by a margin driven by one entry near the high.
Month by month
| Year | Jan | Feb | Mar | Apr | May | Jun | Jul | Aug | Sep | Oct | Nov | Dec |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2021 | 0.0% | 0.0% | 0.0% | 3.2% | −3.3% | 3.4% | 1.0% | 1.8% | −2.1% | 11.7% | 1.6% | −5.9% |
| 2022 | 0.0% | 0.0% | 0.0% | −9.4% | 0.0% | 0.0% | 8.3% | −3.4% | 0.0% | 0.0% | 0.0% | 0.0% |
| 2023 | 2.5% | −2.1% | −2.8% | 0.0% | 0.0% | 2.9% | 2.3% | −1.7% | −6.1% | 0.0% | 1.0% | 6.0% |
| 2024 | −4.4% | 7.7% | −0.1% | −4.4% | 0.2% | 3.8% | 2.8% | −6.4% | 6.6% | −1.7% | 12.6% | 1.1% |
| 2025 | 3.4% | −6.9% | 0.0% | 0.0% | 6.1% | 1.8% | 1.9% | 4.6% | 3.5% | 0.1% | −1.4% | 1.1% |
| 2026 | 1.5% | −3.5% | −3.7% | −1.7% | 2.1% | −2.7% | −6.2% | 0.0% | 0.0% | 0.0% | – | – |
Months in and out of the fund
Months with zeros are the ones spent in cash. No position was held from January to March 2022, in May and June 2022, from September to December 2022, in April and May 2023, or in March and April 2025.
The best months for the rule were November 2024 at 12.6%, October 2021 at 11.74%, July 2022 at 8.33%, February 2024 at 7.74% and September 2024 at 6.58%. The worst were April 2022 at -9.41%, February 2025 at -6.87%, August 2024 at -6.39%, July 2026 at -6.23% and September 2023 at -6.13%. Holding peaked in July 2022 at 17.99% and bottomed in April 2022 at -11.72%. The rule took only part of the July 2022 rebound, because the entry came on 2022-07-20, after the fund was already well off its low.
XLY's calendar-month averages in the window were 5.12% in November and 4.24% in July, against -1.9% in September, -1.56% in February and -0.57% in December. Since 5 or 6 observations stand behind each average, they fit this window alone, and the rule's results echo them in places: it made 12.6% in November 2024 and lost 6.13% in September 2023 and 6.87% in February 2025.
A trailing stop produces a particular monthly signature. Gains come in clusters during a run, followed by a single large loss when the stop is hit. The sequence from January to April 2024 shows it: -4.36%, 7.74%, -0.05% and -4.43%. The fund was choppy and the position was held through it, with the trail reset higher after each new close.
Every trade
momentum breakout on XLY made 9 closed round trips, an average hold of 142 days, an average winner of 9.87%, an average loser of −5.94%, a profit factor of 1.88, a longest losing streak of 2. It held a position at the close on 60.7% of trading days.
| Entry | Entry price | Exit | Exit price | Return | Days held |
|---|---|---|---|---|---|
| 2021-04-06 | $82.76 | 2021-12-20 | $92.14 | 11.3% | 258 |
| 2022-04-05 | $90.69 | 2022-04-26 | $81.98 | −9.6% | 21 |
| 2022-07-20 | $72.34 | 2022-08-30 | $75.82 | 4.8% | 41 |
| 2023-01-27 | $70.24 | 2023-03-02 | $68.50 | −2.5% | 34 |
| 2023-06-13 | $80.32 | 2023-09-26 | $77.90 | −3.0% | 105 |
| 2023-11-20 | $81.48 | 2024-08-02 | $86.02 | 5.6% | 256 |
| 2024-09-06 | $92.31 | 2025-02-25 | $106.33 | 15.2% | 172 |
| 2025-05-08 | $99.45 | 2026-03-03 | $111.82 | 12.4% | 299 |
| 2026-04-21 | $119.93 | 2026-07-23 | $109.51 | −8.7% | 93 |
Prices are adjusted for splits and dividends, so they sit below the quotes printed at the time. An open position is marked at the last close.
Nine trades in detail
The trade list reads as follows. A buy on 2021-04-06 at $82.76 and a sale on 2021-12-20 at $92.14 made 11.33% over 258 days. A buy on 2022-04-05 at $90.69 and a sale on 2022-04-26 at $81.981 lost 9.6% over 21 days. A buy on 2022-07-20 at $72.34 and a sale on 2022-08-30 at $75.816 made 4.81% over 41 days. A buy on 2023-01-27 at $70.24 and a sale on 2023-03-02 at $68.5 lost 2.48% over 34 days. A buy on 2023-06-13 at $80.32 and a sale on 2023-09-26 at $77.904 lost 3.01% over 105 days. A buy on 2023-11-20 at $81.48 and a sale on 2024-08-02 at $86.022 made 5.57% over 256 days. A buy on 2024-09-06 at $92.31 and a sale on 2025-02-25 at $106.335 made 15.19% over 172 days. A buy on 2025-05-08 at $99.45 and a sale on 2026-03-03 at $111.816 made 12.43% over 299 days. A buy on 2026-04-21 at $119.93 and a sale on 2026-07-23 at $109.512 lost 8.69% over 93 days. Prices are adjusted for splits and dividends.
The median return was 4.81% and the median hold was 105 days. The average hold was 142.1 days, the longest was 299 and the shortest was 21. Three wins in a row was the best streak and two losses in a row the worst. Counted by exit year, 2021 had 1 trade and 1 win, 2022 had 2 and 1, 2023 had 2 and 0, 2024 had 1 and 1, 2025 had 1 and 1, and 2026 had 2 and 1.
The pattern is a few large winners and several small losers, which is the shape a trailing stop is meant to give. The three trades of 11.33%, 15.19% and 12.43% carry the profit. The two largest losses, 9.6% and 8.69%, are close to the 10% trail, and both were entries that reversed soon after the 20-day burst. The template's own caveat covers the second pattern, since a reversal right after the burst makes the trail exit about 10% under the entry.
The entry on 2022-04-05 is the clearest example. The rule bought a 20-day gain above 10% during a bear market and gave it back inside three weeks. A momentum entry has no way to tell a rebound inside a downtrend from the start of a trend, and the 2022 loss on this trade stands for every trade of that type in the window.
Nine trades are a small sample. One different trade would move the win rate several points and the CAGR by a point or more, so the profit factor of 1.88 is an estimate with wide error.
Largest drawdowns
| Peak | Low point | Depth | Days to low | Recovered | Days to recover |
|---|---|---|---|---|---|
| 2021-11-19 | 2022-07-26 | −18.4% | 249 | 2024-11-11 | 839 |
| 2026-01-12 | 2026-07-23 | −17.1% | 192 | not yet | – |
| 2024-12-17 | 2025-02-25 | −9.5% | 70 | 2025-07-21 | 146 |
Buy-and-hold's deepest drawdown ran from 2021-11-19 to 2022-12-28 and reached −39.1%.
Drawdowns for the rule and for holding
The rule's worst drawdown was 18.35%. It began at the 2021-11-19 peak, bottomed on 2022-07-26 after 249 days, and recovered on 2024-11-11, 839 days later. A 17.13% drawdown followed from 2026-01-12 to 2026-07-23, 192 days, with no recovery in the data. The third was 9.49%, from 2024-12-17 to 2025-02-25 in 70 days, with recovery on 2025-07-21 after 146 days.
Holding fell 39.06% from that same November 2021 peak to the 2022-12-28 low, 404 days, and recovered on 2024-11-06 after 679 days. A 25.64% drop ran from 2024-12-17 to 2025-04-08 and healed by 2025-09-12. A further 14.79% drop from 2026-01-12 to 2026-03-30 remained open. The fund's own deepest figure was 39.67% and its longest drawdown lasted 743 sessions.
The two runs share peak dates in November 2021, December 2024 and January 2026. In 2022 the trail kept the loss far below the fund's, because the account was in cash when most of the decline arrived. In early 2025 the rule's drawdown of 9.49% compares with 25.64% for holding, because the stop on 2025-02-25 came before the April low. In 2026 the rule's 17.13% is deeper than holding's 14.79%, because the position entered on 2026-04-21 at $119.93 and was stopped out at $109.512 after the fund's March low.
That last comparison is the limit of a trailing stop. It protected in the two big declines and did worse than holding in the third, which started after a partial recovery and caught the rule with a fresh entry near the high. The 2026 drawdown had not recovered by the end of the data, so that loss is still open.
The drawdown that began in November 2021 left the account below its high for a long stretch, though the fund itself spent 743 sessions below its own high.
With trading costs
The headline run fills at the bar price. These runs charge slippage on every fill.
| Slippage per fill | CAGR | Max drawdown | Final value | Sharpe |
|---|---|---|---|---|
| None (headline) | 3.8% | −18.4% | $12,406 | 0.33 |
| 5 basis points | 3.7% | −18.5% | $12,311 | 0.32 |
| 10 basis points | 3.5% | −18.9% | $12,184 | 0.31 |
What slippage did to 18 fills
Eighteen fills carry the slippage charge. With 5 basis points on each, the CAGR slipped from 3.83% to 3.69%, the maximum drawdown moved from 18.35% to 18.47% and the final value went from $12,405.85 to $12,311.42. At 10 basis points the CAGR was 3.5%, the maximum drawdown 18.86% and the final value $12,183.67. The Sharpe ratio went from 0.33 to 0.324 and then 0.312.
The effect is small because the trade count is low and the holds are long. A hold averaging 142.1 days spreads the cost of one entry and one exit over a large price move. A rule that trades daily would lose far more of its return to the same assumption.
Liquidity is deep, with $892,144,651 of average daily dollar volume and a median of 15,102 shares per minute. A 98% allocation of a $10,000 sleeve is small against that. Actual spreads were not measured, so the 10 basis point run is best read as a stress case, and the CAGR of 3.5% shows the result survives it.
The gap to buy-and-hold does not close with lower costs. Even at no slippage the rule trails holding by a wide margin in the headline figures, and it is the trade-off in drawdown, not execution, that separates them.
Changing the parameters
| Version | CAGR | Max drawdown | Round trips | Win rate | Final value |
|---|---|---|---|---|---|
| Published rules | 3.8% | −18.4% | 9 | 56% | $12,406 |
| 5% trailing stop | 4.2% | −11.4% | 15 | 47% | $12,672 |
| 15% trailing stop | 2.0% | −29.9% | 6 | 67% | $11,208 |
| 20% return entry | 0.7% | −9.5% | 1 | 100% | $10,385 |
Tighter and looser versions
Three variants were tested. A 5% trailing stop made 4.21% a year with an 11.41% drawdown, 15 trades and 7 wins, ending at $12,672.49 with a Sharpe ratio of 0.492. A 15% trailing stop made 2.01% with a 29.89% drawdown, 6 trades and 4 wins, ending at $11,208.48. A 20% return entry made 0.66% with a 9.46% drawdown, 1 trade and 1 win, ending at $10,384.57.
The published rule made 3.83% with an 18.35% drawdown and 9 trades. The tighter stop did better on both counts here, at the price of more trades, 15 against 9. The wider stop did worse on both, since a 15% trail gives back more before it exits. The variant with the 20% entry waited for a burst that arrived once in the window and made one trade.
The results form a clean sequence for the stop width: 5% gave 4.21%, 10% gave 3.83% and 15% gave 2.01%, with drawdowns of 11.41%, 18.35% and 29.89%. A tighter stop cuts losses sooner, and on a fund that gave back its gains during brief declines that helped. This ordering describes this window. In a fund with deeper pullbacks inside a trend, a 5% stop would exit and re-enter repeatedly, and the extra trades would meet higher costs.
The 20% entry result is a caution about trade count. One trade, which won, produced a CAGR of 0.66%, and the account was invested for a small share of the window. A rule with one trade has a drawdown of 9.46% because it was rarely exposed.
The same variants are run for every fund and were not tuned to XLY. The momentum breakout page shows the published settings across funds.
How XLY behaved
| Measure | XLY |
|---|---|
| Data in this test | 2021-01-04 to 2026-10-02 (1444 sessions) |
| Total return, buy and hold | 44.7% |
| Annualized volatility | 23.3% |
| Deepest drawdown | −39.7% (2021-11-19 to 2022-12-28) |
| Up days | 53.0% |
| Average daily range | 1.68% |
| Average overnight gap | 0.63% |
| Correlation to SPY | 0.87 |
| Correlation to QQQ | 0.86 |
| Correlation to TLT | 0.11 |
| Sessions above the 200-day average | 65.1% |
| Crossings of the 200-day average | 59 |
| Falls of 10% or more from a 20-day high | 24 |
What XLY's behaviour meant for a momentum rule
XLY returned 44.67% over the window, a CAGR of 6.64%, with annualized volatility of 23.32%. Its maximum drawdown was 39.67%, from 2021-11-19 to 2022-12-28, with recovery on 2024-11-06. Calendar-year returns ran 29.05%, -36.28%, 39.68%, 26.51%, 7.36% and -7.26%, the last year being partial.
The fund's beta was 1.24 to SPY, 0.89 to QQQ and 0.16 to TLT, with correlations of 0.87, 0.86 and 0.11. The funds in the library most like it were VV at 0.88, SSO, SPY, VOO and SPUU at 0.87. The least like it were SDS, SH and SPDN at -0.87, PSQ at -0.86 and SQQQ at -0.86. XLY behaved as a high-beta slice of the US market, and a 10% gain in 20 sessions is a move that a fund with 23.32% volatility makes several times in a rally.
The fund closed above its 200-day average on 65.06% of sessions and crossed that line 59 times. That is a lot of crossings for a fund that was in an uptrend most of the time, and it describes a market that kept reversing within the trend. The fund had 24 falls of 10% or more from a 20-day high, over 98 days in total, which is the kind of event a trailing stop is meant to handle.
The fund went up on 53.01% of days, with an average up day of 1.06% and an average down day of -1.13%. The average intraday range was 1.68% and the average overnight gap was 0.63%. The overnight log return was 31.78% and the intraday log return was 3.65%, so 89.7% of the fund's return came overnight and 10.3% during the day. A rule that buys at the open and sells on a stop through the day holds across that overnight gain only while invested.
RSI(14) fell below 30 on 27 sessions, with a median 5-day return of -0.17% and a median 20-day return of -0.78%, against baselines of 0.22% and 0.77%. RSI(14) rose above 70 on 92 sessions. RSI(2) fell below 10 on 152 sessions, with a median 5-day return of 0.74% and a 20-day return of 1.8%. Deep oversold readings on XLY were followed by gains, which favours dip rules over a momentum rule on this fund, and the ranking shows it.
The worst days were -6.54% on 2022-05-18, -5.97% on 2025-04-03, -5.49% on 2022-05-05, -5.14% on 2022-09-13 and -5.12% on 2022-04-26. The best days were 10.79% on 2025-04-09, 7.27% on 2022-11-10, 5.07% on 2025-05-12, 4.9% on 2022-05-26 and 4.07% on 2022-10-17. The best day of the window, 2025-04-09, came one day after the low of the April 2025 drawdown, and the rule was out of the fund for it. It re-entered on 2025-05-08, after the first part of the rebound.
The lag-1 autocorrelation of daily returns was -0.02, which is close to zero. There was no day-to-day momentum in XLY returns, so the rule depends on the 20-day horizon, not on streaks of daily gains.
The rules
Buy after a +10% four-week burst and let a 10% trailing stop manage the exit.
- WHEN the market opens · IF not invested AND the 20-day return > +10% · THEN buy with 98% of the sleeve
- WHILE invested · a managed trailing stop follows 10% below the position's high-water mark
Momentum entry, trailing-stop exit. A +10% gain over 20 sessions marks a burst of momentum. The template buys the strength and exits on a 10% trailing stop that ratchets up beneath the highest close and never moves down. There is no profit target, so winners run until the trail is hit.
Good for: high-momentum assets where trends extend, such as semiconductor and leveraged tech ETFs.
Watch out: buying strength means buying high; when a burst immediately reverses, the trail exits about 10% below the entry.
The other templates on XLY, and sector peers
The weekly 7% target led on XLY with 10.19% and a 24.73% drawdown. RSI(2) snapback made 8.2% with 16.62% and RSI mean reversion 7% with 20.65%. The dip buyer made 4.01% with 32.73%, just ahead of the momentum breakout at 3.83% with 18.35%. The monthly cycle made 3.67% with 43.81%, EMA 12/26 2.36% with 21.26% and golden cross 1.35% with 25.65%. SMA 10/50 made 0.35%, the 200-day filter -2.16%, 3-month momentum -3.94% and trend plus trailing stop -4.4%.
The mean-reversion rules beat the trend and momentum rules on XLY. The momentum breakout had the shallowest drawdown among the top five except for RSI(2) snapback, at 18.35% against 24.73% for the leader. The drawdown is the reason to look at this rule here, not the return.
Among sector funds, the same rule made 16.73% on SOXX with a 30.23% drawdown on 18 round trips, and 11.62% on XLK with 26.14% on 9. It made 6.99% on XLF, 2.19% on VOX and -1.87% on XLP. The rule did best on the semiconductor and technology funds, which matches the template's own description of good targets: high-momentum assets where trends extend. XLY, a consumer sector fund, sits in the middle.
What was measured: one fund, one window of 5.74 years, daily decisions and 9 trades. More bursts over a longer window would sharpen the estimate. All figures are hypothetical and not advice.
Build it from blocks (or type it in English), backtest it on 5.7 years of minute data in seconds, tweak any parameter, then paper trade it on live data. No card, no broker needed to start.
Frequently asked questions
Did momentum breakout beat buy-and-hold on XLY?
Over 2021-01-04 to 2026-10-02, momentum breakout on XLY returned 3.8% annualized vs 6.3% for buy-and-hold: it trailed buy-and-hold by 2.4% per year, with a maximum drawdown 20.7 points shallower than holding (18.4% vs 39.1%).
How many trades did it make?
9 completed round trips over 5.7 years (18 fills), with 56% of round trips closing profitably.
How does the trailing stop work in the backtest?
The stop sits 10% below the highest price since entry and only ratchets up. When a bar trades through it, the position sells at the stop, or at the open if the price gaps below it. Trailing-stop exits can be backtested now; deploying them live is not available yet.
Did the momentum breakout beat buy-and-hold on XLY?
No on return and yes on drawdown. The rule made 3.83% a year and ended at $12,405.85, while buy-and-hold made 6.27% and ended at $14,177.03. The rule's maximum drawdown was 18.35% against 39.06%. It was ahead in 2022 and 2025 and behind in the other four years.
How many trades did it make on XLY?
9 closed round trips and 18 fills, with 5 winners and a win rate of 56%. The average winner was 9.87% and the average loser was -5.94%. The rule was invested on 60.7% of days with an average hold of 142.1 days.
Does the rule still work after trading costs?
Yes, with a small reduction. At 5 basis points per fill the CAGR was 3.69% and the final value $12,311.42. At 10 basis points the CAGR was 3.5% and the final value $12,183.67. XLY averaged $892,144,651 in daily dollar volume, so costs of that size are likely above actual spreads.
Would a different trailing stop do better on XLY?
In this window a tighter one did. A 5% stop made 4.21% with an 11.41% drawdown and 15 trades, a 10% stop made 3.83%, and a 15% stop made 2.01% with a 29.89% drawdown. The ordering describes these dates and 6 to 15 trades.
What was the worst trade?
The entry on 2022-04-05 at $90.69, which was sold on 2022-04-26 at $81.981 for a loss of 9.6% in 21 days. It bought a 20-day gain during the 2022 decline, and the trail exited close to its 10% limit.
Why did the rule lag buy-and-hold in 2023?
XLY gained 38.7% that year and the rule made 1.4%. Two entries were stopped out for losses of 2.48% and 3.01%, and the next did not begin until 2023-11-20. A 10% burst followed by a reversal is the weakness named in the template's caveats.
How does XLY compare with other sector funds for this rule?
XLY made 3.83%. SOXX made 16.73%, XLK 11.62%, XLF 6.99% and VOX 2.19%, while XLP lost 1.87%. The category median for the rule is 6.99%.
Related
Backtests are hypothetical, computed by DeployQuant's engine on minute-resolution consolidated US market data (2021-01-04 to 2026-10-02, $10,000 starting capital, no margin, no fees or slippage in the headline run; buy-and-hold puts 98% of the account in at the first open, as the templates do) and do not guarantee future results. Nothing on this page is investment advice. Live trading involves risk of loss.