20-Day Momentum + Trailing Stop on XLP
Consumer Staples Select Sector SPDR Fund: defensive consumer staples, a common risk-off equity sector. Backtest 2021-01-04 to 2026-10-02, $10,000 starting capital, computed by the same engine that runs live DeployQuant strategies.
The 20-day momentum breakout with a trailing stop buys when a fund has gained more than 10% over the last 20 sessions and exits when the price falls 10% below the highest close since entry. It was written for funds that make fast, large moves. XLP, the Consumer Staples Select Sector SPDR Fund, is a defensive sector fund with annualized volatility of 13.28%, and a 10% gain in four weeks is rare for it. The rule found 2 entries in 5.74 years, from 2021-01-04 to 2026-10-02. Both closed at a loss. The sleeve ended at $8,975 from $10,000, a CAGR of -1.87% and a total return of -10.25%.
Buy-and-hold on XLP made $13,819, a CAGR of 5.8%. The rule trailed it by 7.67 points of CAGR and ended $4,844.83 behind. The Sharpe ratio was -0.36 against 0.51. The maximum drawdown was 14.48%, against 15.99% for the fund, a difference of 1.51 points that comes from a sleeve that held a position on only 8.8% of days.
The rule ranked 12th of 12 strategies on XLP by CAGR, and XLP ranked 41st of 59 funds for the rule. The strategy's median CAGR across all 59 funds was 0%, which says something about how often the entry condition fires on a typical fund in this window. For a sector fund that moves about 1% a day, a 10% burst is an event. On XLP, the statistics page counts only one 20-day, 10% drawdown event on three days in the whole window, and the upside burst the rule needs was equally uncommon.
The two trades are the whole result. The year table is mostly zeros, the monthly table is zeros outside a handful of months, and the drawdown figure mostly reflects when the sleeve was invested.
Year by year
| Year | momentum breakout | buy & hold |
|---|---|---|
| 2021 | 0.1% | 18.1% |
| 2022 | −4.5% | −0.7% |
| 2023 | 0.0% | −0.9% |
| 2024 | 0.0% | 12.0% |
| 2025 | 0.0% | 1.5% |
| 2026 | −6.1% | 5.6% |
Year by year
The sleeve returned 0.1% in 2021, -4.5% in 2022, 0% in 2023, 0% in 2024, 0% in 2025 and -6.1% in 2026 to date. Buy-and-hold returned 18.1%, -0.7%, -0.9%, 12%, 1.5% and 5.6%. The rule beat the fund in one year, 2023, by 0.9 points, and it did so by staying in cash through a year when XLP lost 0.89%.
2021 is the year with the largest gap. XLP made 18.47% for the calendar year and the sleeve made 0.1%. The first entry did not come until 2021-12-30, so the sleeve missed the whole year's rise. The 20-day, 10% condition needs a sharp move, and XLP's 2021 gain was steady rather than sharp. The one month the sleeve was invested was December, which returned 0.09%, and the fund's own best month in the window was that same December at 10.36%. A single entry on the last trading day of the year caught none of it.
2022 is where the first trade lived and died. The sleeve entered at $67.94 and held through the first half of the year. January lost 1.42% and February 1.31%, March made 1.49% and April 2.45%, and then May lost 5.6%. The sleeve's 2022 total was -4.5%, against -0.7% for the fund, because the trailing stop took the sleeve out in May and the fund recovered some of its losses later in the year while the sleeve sat in cash.
2023, 2024 and 2025 show 0.0% in every month. Three full calendar years passed without the rule finding a 20-day, 10% gain. In 2024 the fund made 12.23% across the year, steadily, and the rule took none of it. That is the trade-off in the template's own description: it buys bursts and misses steady climbs.
2026 has the second trade. The sleeve entered on 2026-02-04, made 3.92% in February, then lost 9.64% in March and exited on 2026-03-20. The sleeve's 2026 return was -6.1% while XLP made 5.6% to 2026-10-02. The rule beat the fund in 2023 and trailed it in the other five years.
Month by month
| Year | Jan | Feb | Mar | Apr | May | Jun | Jul | Aug | Sep | Oct | Nov | Dec |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2021 | 0.0% | 0.0% | 0.0% | 0.0% | 0.0% | 0.0% | 0.0% | 0.0% | 0.0% | 0.0% | 0.0% | 0.1% |
| 2022 | −1.4% | −1.3% | 1.5% | 2.5% | −5.6% | 0.0% | 0.0% | 0.0% | 0.0% | 0.0% | 0.0% | 0.0% |
| 2023 | 0.0% | 0.0% | 0.0% | 0.0% | 0.0% | 0.0% | 0.0% | 0.0% | 0.0% | 0.0% | 0.0% | 0.0% |
| 2024 | 0.0% | 0.0% | 0.0% | 0.0% | 0.0% | 0.0% | 0.0% | 0.0% | 0.0% | 0.0% | 0.0% | 0.0% |
| 2025 | 0.0% | 0.0% | 0.0% | 0.0% | 0.0% | 0.0% | 0.0% | 0.0% | 0.0% | 0.0% | 0.0% | 0.0% |
| 2026 | 0.0% | 3.9% | −9.6% | 0.0% | 0.0% | 0.0% | 0.0% | 0.0% | 0.0% | 0.0% | – | – |
Months with a position
Only a handful of months in the window contain a position, and the monthly table is zero for every other one. The invested months are December 2021 (0.09%), January to May 2022 (-1.42%, -1.31%, 1.49%, 2.45%, -5.6%) and February and March 2026 (3.92%, -9.64%).
The best month was February 2026 at 3.92% and the worst was March 2026 at -9.64%. Buy-and-hold's worst month was also March 2026, at -8.31%. The sleeve lost more than the fund in that month, which is unusual for a rule that is in cash most of the time. It was fully invested in March 2026 after buying the burst in February, and the fund fell sharply from its high.
The month-of-year table on the fund's own history shows September as the weakest month on average at -3.79% and November as the strongest at 3.33%. Each is an average of five or six observations. The sleeve was never invested in either month, so those figures played no role in its result.
Every trade
momentum breakout on XLP made 2 closed round trips, an average hold of 92 days, an average loser of −5.38%, a longest losing streak of 2. It held a position at the close on 8.8% of trading days.
| Entry | Entry price | Exit | Exit price | Return | Days held |
|---|---|---|---|---|---|
| 2021-12-30 | $67.94 | 2022-05-18 | $64.86 | −4.5% | 139 |
| 2026-02-04 | $84.89 | 2026-03-20 | $79.60 | −6.2% | 44 |
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.
The two trades
The first trade entered on 2021-12-30 at an adjusted price of $67.94 and exited on 2022-05-18 at $64.86, a loss of 4.53% over 139 days. The exit date matches the fund's worst day in the window: XLP fell 6.45% on 2022-05-18, the largest one-day loss in its history over this period. The trailing stop was triggered by that single session. A 10% trail from the high-water mark means the position had been climbing to a peak somewhat above the entry before that day, and the gap down closed it out below the entry price.
The second trade entered on 2026-02-04 at $84.89 and exited on 2026-03-20 at $79.60, a loss of 6.24% over 44 days. The median return across the two trades was -4.53% and the median hold was 139 days. The average hold was 91.5 days, and the average loss was -5.38%. There were no winners, so the win rate is 0% and the profit factor is 0.
Both entries were bought after a strong burst, and in both cases the burst stopped. The exit price on each trade was below the entry, though the loss was smaller than the 10% trail width. This is because the trailing stop follows the high-water mark. A position that rises 5% and falls back is stopped at about 10% below the high, which is about 5% below the entry. The tests of the 5% and 15% trails below show how the width changed the size of the losses.
The template's description says that when a burst immediately reverses, the trail exits about 10% below the entry. On XLP the exits were 4.53% and 6.24% below, so the bursts reached some way above the entry before the trail was hit. This is a measured result on two trades.
Largest drawdowns
| Peak | Low point | Depth | Days to low | Recovered | Days to recover |
|---|---|---|---|---|---|
| 2022-04-20 | 2026-03-20 | −14.5% | 1430 | not yet | – |
| 2022-01-04 | 2022-03-11 | −7.8% | 66 | 2022-04-06 | 26 |
| 2022-04-13 | 2022-04-18 | −0.8% | 5 | 2022-04-19 | 1 |
Buy-and-hold's deepest drawdown ran from 2022-04-20 to 2022-10-07 and reached −16.0%.
Drawdowns
The sleeve's largest drawdown, 14.48%, began on 2022-04-20 and reached its low on 2026-03-20 after 1,430 days. It has not been recovered by 2026-10-02. This figure needs to be read with the trade list. The sleeve peaked on 2022-04-20 during the first trade. It fell 5.6% in May and was stopped out, and then it sat in cash until 2026-02-04. A drawdown measures the distance from the previous peak, so a sleeve with no position for years stays in drawdown. The final 14.48% low was reached when the second trade closed on 2026-03-20.
The second drawdown was 7.75%, from 2022-01-04 to 2022-03-11, with 66 days to the low and 26 days to recover, ending on 2022-04-06. It belongs to the first trade in its early months. The third was 0.81% over five days in April 2022.
XLP's own worst drawdown was 16.27%, from 2022-04-20 to 2022-10-07, recovering on 2024-03-28. The buy-and-hold figure in the result table is 15.99%. The sleeve's peak date matches the fund's, 2022-04-20, because the sleeve was invested at the time, and the sleeve left the fund in May. It avoided the fund's later low in October 2022, and it then missed the recovery.
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) | −1.9% | −14.5% | $8,975 | -0.36 |
| 5 basis points | −1.9% | −14.6% | $8,956 | -0.36 |
| 10 basis points | −1.9% | −14.8% | $8,937 | -0.37 |
Cost runs
Slippage of 5 basis points per fill moved the CAGR from -1.87% to -1.9% and the final value from $8,975 to $8,956. At 10 basis points the CAGR was -1.94% and the final value $8,937. The maximum drawdown rose from 14.48% to 14.62% and 14.75%. The Sharpe ratio moved from -0.36 to -0.363 and -0.369. The strategy made 4 fills, so costs hardly change a result that was set by the entries and the stop. XLP's average daily dollar volume was $854,044,173 and its median minute volume was 17,592 shares. The cost runs add slippage only, and do not include commissions or taxes.
Changing the parameters
| Version | CAGR | Max drawdown | Round trips | Win rate | Final value |
|---|---|---|---|---|---|
| Published rules | −1.9% | −14.5% | 2 | 0% | $8,975 |
| 5% trailing stop | −1.2% | −7.1% | 3 | 0% | $9,354 |
| 15% trailing stop | −2.6% | −18.9% | 1 | 0% | $8,587 |
| 20% return entry | 0.0% | −0.0% | 0 | – | $10,000 |
Trailing width and entry threshold
Three variants change one input each.
A 5% trailing stop gave a CAGR of -1.16% and a maximum drawdown of 7.09%, with 3 closed trades and no wins. It ended at $9,354, ahead of the published rules. A tighter stop cuts losses short on a fund that falls back after a burst, and here the three exits were all losers but smaller ones. The Sharpe ratio was -0.391.
A 15% trailing stop gave a CAGR of -2.62% and a maximum drawdown of 18.94%, with 1 trade and no wins. It ended at $8,587. A wider trail gives the position more room and gave back more. With the 15% trail the window held 1 trade.
A 20% return entry gave a CAGR of 0%, a maximum drawdown of 0% and no trades, with the sleeve ending at $10,000. No 20-day gain of 20% occurred in XLP in this window. The result is cash, and it beats the published rule's -10.25% total return. A rule that never trades has the best record in the table, which says that the entry on this fund had little edge.
The published rule was between the 5% and 15% trails on both CAGR and drawdown. The ordering is the same as on any fund where bursts reverse: the tighter the stop, the smaller the loss. That ordering comes from three small samples and cannot be read as a recommendation of a 5% trail.
How XLP behaved
| Measure | XLP |
|---|---|
| Data in this test | 2021-01-04 to 2026-10-02 (1444 sessions) |
| Total return, buy and hold | 40.3% |
| Annualized volatility | 13.3% |
| Deepest drawdown | −16.3% (2022-04-20 to 2022-10-07) |
| Up days | 51.6% |
| Average daily range | 1.12% |
| Average overnight gap | 0.29% |
| Correlation to SPY | 0.47 |
| Correlation to QQQ | 0.30 |
| Correlation to TLT | 0.13 |
| Sessions above the 200-day average | 75.1% |
| Crossings of the 200-day average | 73 |
| Falls of 10% or more from a 20-day high | 1 |
How XLP behaved
XLP returned 40.33% over the window, a CAGR of 6.08%, with annualized volatility of 13.28%. It was up on 51.63% of sessions. The average up day was 0.64% and the average down day was -0.63%, and the average intraday range was 1.12%. Its beta was 0.38 to SPY, 0.18 to QQQ and 0.11 to TLT, and its correlation to SPY was 0.47.
That volatility is the reason the entry rarely fires. Over any 20 sessions, a move of 10% in a fund with a daily range near 1% requires many days of one-sided trading. The fund spent 75.1% of its sessions above the 200-day average and crossed it 73 times. The high crossing count shows that the price repeatedly came back to the average, a feature that sits against momentum and in favour of mean reversion. The fund's lag-1 autocorrelation was -0.01.
Mean reversion had an edge on XLP in the data. RSI(14) was under 30 on 37 sessions, and the median forward 20-day return after those was 2.44%, against a baseline of 0.73%. After RSI(2) under 10 on 156 sessions the median 5-day return was 0.26% against 0.18%. That is why the RSI(2) snapback made 8.22% and RSI mean reversion made 6.51% on the same fund, with the shallowest drawdowns in the table.
XLP's overnight share of return was 27.36% and its intraday share was 72.64%. The average overnight gap was 0.29%. The worst day, -6.45% on 2022-05-18, is the day that closed the first trade. The best days were 2025-04-09 at 3.81% and 2022-02-25 at 3.19%.
Month-of-year and weekday averages for staples
XLP's monthly averages show where the two entries landed. September was the weakest month at -3.79% over 6 observations, and May the second weakest at -1.08%. November was the strongest at 3.33% over 5. The first trade closed on 2022-05-18 and May 2022 was the sleeve's worst month at -5.6%, which matches the fund's weak May average. The second trade entered in February and closed in March, two months with positive fund averages of 1.67% and 1.32%, yet it lost 6.24%.
The calendar averages cover five or six observations each, so one bad year can set the figure. They did not feed into the rule, which looks only at the 20-day return.
Weekday averages were small. Friday led at 0.13% and Wednesday was the weakest at -0.04%, with Monday at 0.06%, Tuesday at -0.02% and Thursday at 0.01%. Nothing in those numbers favours entering at one open over another.
XLP's closest correlations were with value funds, VTV at 0.64 and VOOV at 0.63. Its most negative were inverse index funds, SDS, SH and SPDN at -0.47 each. Correlation to SPY was 0.47 and beta 0.38, so the fund moved with the market at a muted size. A breakout rule that waits for a 10% gain needs the opposite, a fund that moves with large and one-sided swings.
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.
How momentum rules interact with a staples fund
A momentum rule assumes that a burst predicts more of the same. Staples funds do not often burst, and the one burst the fund had in 2026 reversed. The rule has no way to wait for confirmation and no filter for volatility, and it takes a position on the next open after the condition is met. Both of its trades gave up part of the position's gains before the stop hit.
The same strategy on the other sector funds in the test did better. The category table shows SOXX at 16.73% with 18 round trips, XLK at 11.62%, XLF at 6.99%, XLY at 3.83% and VOX at 2.19%. XLP sits last at -1.87% with 2 round trips. The category median was 6.99%. Funds with higher volatility produced more bursts and more trades.
On XLP itself the other rules did better. The monthly cycle made 5.46%. The weekly profit target made 2.37%. Golden cross made 2.05%. Only the 3-month momentum rule at -1.67% and the 200-day regime filter at -0.81% were close to the breakout rule at the bottom. The momentum rules, as a group, were the weakest on this fund.
The limits are plain. The window is 5.74 years and has two trades. The headline run has no fees. The rule fills at the open after a signal, and the 98% position size leaves a small cash reserve. A backtest of two losing trades says the rule rarely finds a signal on a staples fund and lost money on the two it found. It does not say that the same rule would lose in a different window.
The same rule on other sector funds
Among the six sector funds in the category table, the breakout rule's result on XLP is the weakest. SOXX returned 16.73% a year over 18 round trips, with a 30.23% drawdown. XLK made 11.62% over 9 trips, XLF 6.99% over 5, XLY 3.83% over 9 and VOX 2.19% over 8. XLP made -1.87% over 2.
The pattern follows how often each fund produces a 20-day gain above 10%. A semiconductor fund does it often enough to give the trailing stop many chances, and the winners paid for the losers. A staples fund gave the rule two chances. Both were entered after a burst and both reversed into the stop or the exit, so the sample held no winner to offset anything. The category median CAGR was 6.99%, well above this page's figure.
The rule's drawdown of 14.48% on XLP is the shallowest of the six, against 17.64% for XLF and 18.35% for XLY. Low exposure explains most of that. The sleeve held a position on 8.8% of days, so the account could only fall while it was invested. The longest drawdown ran from 2022-04-20 to 2026-03-20 because the account made nothing between the two losing trades.
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 XLP?
Over 2021-01-04 to 2026-10-02, momentum breakout on XLP returned −1.9% annualized vs 5.8% for buy-and-hold: it trailed buy-and-hold by 7.7% per year, with a maximum drawdown 1.5 points shallower than holding (14.5% vs 16.0%).
How many trades did it make?
2 completed round trips over 5.7 years (4 fills), with 0% 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.
How did the momentum breakout with a trailing stop do on XLP?
It turned $10,000 into $8,975 between 2021-01-04 and 2026-10-02, a CAGR of -1.87%. Buy-and-hold on XLP made $13,819, a CAGR of 5.8%. The maximum drawdown was 14.48% against 15.99% for the fund.
Why was the sleeve invested so little of the time?
The entry needs a gain of more than 10% over 20 sessions, which is uncommon for a fund with annualized volatility of 13.28%. The rule made 2 entries in 5.74 years and held a position on 8.8% of trading days. In every other period the sleeve was in cash.
What were the two trades on XLP?
The first entered on 2021-12-30 at $67.94 and exited on 2022-05-18 at $64.86, a loss of 4.53% over 139 days. The second entered on 2026-02-04 at $84.89 and exited on 2026-03-20 at $79.60, a loss of 6.24% over 44 days. Prices are adjusted for splits and dividends.
Does a tighter or wider trailing stop change the result?
A 5% trailing stop gave a CAGR of -1.16% and a drawdown of 7.09%. A 15% trail gave -2.62% and 18.94%. Both are small samples of one to three trades, so they show how the loss scales with the stop width and do not identify an ideal setting.
What happens with a 20% entry threshold on XLP?
The rule made no trades, because XLP never gained 20% over 20 sessions in this window. The sleeve stayed in cash and finished at $10,000, a CAGR of 0%. That beats the published rule on this fund and says the entry has little to work with.
Which strategy worked best on XLP?
The RSI(2) snapback made 8.22% with an 11.06% drawdown, and RSI mean reversion made 6.51% with a 9.64% drawdown. RSI(14) fell under 30 on 37 sessions and the median 20-day return afterward was 2.44%. The momentum breakout ranked last of 12 at -1.87%.
Are trading costs a factor for this rule on XLP?
Not in this test. Slippage of 5 basis points gave a CAGR of -1.9% and 10 basis points gave -1.94%, against -1.87% in the headline run. The rule made 4 fills.
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.