SMA-200 Trend + 15% 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 trend plus trailing stop rule made 1.82% a year on XLP, the Consumer Staples Select Sector SPDR Fund. It turned $10,000 into $11,092 between 2021-01-04 and 2026-10-02, with a maximum drawdown of 21.96%. Buy-and-hold ended at $13,819, a CAGR of 5.8% with a drawdown of 15.99%. On return the fund came out ahead, and its drawdown was shallower too, so this is one of the weaker results for the template.
The rule buys at the open when yesterday's close is above the 200-day average, then holds with a stop placed 15% below the highest price since entry. It made 2 completed round trips, both losses, and has a third trade open. The completed trades lost 0.42% and 7.48%. The open trade, bought on 2023-12-14 at 66.75, was up 20.67% on the last day of data. That open trade is the reason the account finished above its starting value.
With 5 fills in 5.74 years the rule was invested 81.9% of the time. The average hold of the two closed trades was 348 days. The profit factor reads 0 because no closed trade won, and the Sharpe ratio was 0.21 against 0.51 for the fund.
Against the other 12 templates the rule placed 6th on XLP, and across the 59 funds it placed 33rd. Its median CAGR over all 59 funds was 2.61%, and over the 6 sector funds 8.57%. XLP's 1.82% sits well below the sector figure. The fund fell little in 2022, and a 15% stop is built for a fund that falls a lot.
The result rests on three trades. The 5 and 10 basis point cost runs barely move it, at 1.79% and 1.75%. The parameter variants move it a good deal more, and they explain what the stop did.
Year by year
| Year | trend + trailing stop | buy & hold |
|---|---|---|
| 2021 | 10.3% | 18.1% |
| 2022 | −6.3% | −0.7% |
| 2023 | −10.5% | −0.9% |
| 2024 | 11.9% | 12.0% |
| 2025 | 1.5% | 1.5% |
| 2026 | 5.6% | 5.6% |
Year by year
The rule returned 10.3% in 2021, -6.3% in 2022, -10.5% in 2023, 11.9% in 2024, 1.5% in 2025 and 5.6% in the partial 2026. Buy-and-hold returned 18.1%, -0.7%, -0.9%, 12%, 1.5% and 5.6%.
The rule did not beat the fund in any year. The gaps were -7.8 points in 2021, -5.6 in 2022, -9.6 in 2023 and -0.1 in 2024. In 2025 and 2026 the two were level at 0, because the rule was invested in the fund for those years in the same trade.
2021 is mostly cash. The first trade did not start until 2021-10-19 at 61.52, so the first nine months of the window show 0%. The fund returned 18.47% for the year on a price basis and the rule 10.3%, all of it from the last quarter, with 10.34% in December alone.
2022 and 2023 are where the rule lost ground. XLP was nearly flat in both years, with -0.75% in 2022 and -0.89% in 2023 on a price basis, and the rule lost 6.3% and 10.5%. A staples fund that goes sideways gives a trailing stop the worst case. The rule sold on 2022-06-14 at 61.2595 for a loss of 0.42%, then bought again on 2022-07-05 at 65.01, higher than its exit. It then held for 458 days and sold on 2023-10-06 at 60.146 for a loss of 7.48%.
The 2022 and 2023 losses together come from two trades. The cost was cumulative: an exit at 61.2595, a re-entry at 65.01, and a second exit at 60.146.
From 2024 on the rule is in one position, the trade bought on 2023-12-14 at 66.75. The fund's 12.23% in 2024 became 11.9% for the rule, and 2025 and 2026 match the fund. The stop was never hit in that stretch.
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% | 1.4% | −1.4% | 10.3% |
| 2022 | −1.4% | −1.3% | 1.5% | 2.5% | −4.0% | −7.0% | 2.2% | −1.8% | −8.0% | 8.8% | 6.0% | −2.6% |
| 2023 | −1.1% | −2.3% | 4.1% | 3.6% | −6.0% | 2.7% | 2.1% | −3.9% | −4.7% | −5.1% | 0.0% | 0.2% |
| 2024 | 1.2% | 2.0% | 3.2% | −1.0% | 2.3% | −0.2% | 1.6% | 5.8% | 1.2% | −3.4% | 3.8% | −4.7% |
| 2025 | 0.5% | 5.0% | −1.1% | 0.2% | 1.2% | −1.6% | −1.4% | 1.2% | −2.3% | −2.6% | 3.9% | −1.3% |
| 2026 | 7.3% | 7.6% | −8.3% | 2.8% | −1.6% | 0.9% | 2.3% | −0.1% | −4.5% | −0.1% | – | – |
Months
The best month was 2021-12 at 10.34%, followed by 2022-10 at 8.75%, 2026-02 at 7.64% and 2026-01 at 7.32%. The worst was 2026-03 at -8.27%, then 2022-09 at -7.95%, 2022-06 at -7.02% and 2023-05 at -6.03%. The fund's best month was 10.36% in 2021-12 and its worst was -8.31% in 2026-03.
The two zero blocks are 2021-01 to 2021-09, before the first entry, and 2023-11, the month between the second exit and the third entry. In November 2023 the rule sat in cash, and it bought on 2023-12-14 at 66.75, above its exit price of 60.146.
The run from 2022-05 to 2022-09 is the painful stretch: -4%, -7.02%, 2.24%, -1.81% and -7.95%. That sequence is the first closed trade ending, the re-entry, and the beginning of the second. The rule did not exit at the 2022 low and bought back above its sell price.
2023 shows a similar run: -6.03% in May, -3.87% in August, -4.66% in September and -5.1% in October, ending with the stop on 2023-10-06. The stop fired on 2023-10-06, after those four losing months.
Seasonal averages for the fund, from 5 or 6 observations each, were best in November at 3.33% and April at 1.68%, and worst in September at -3.79% and May at -1.08%.
The open trade month by month, and the days it covered
The trade bought on 2023-12-14 at $66.75 supplies every month from December 2023 onward, so its path can be read directly. December 2023 added 0.2%. In 2024 the months were 1.23%, 2.02%, 3.24%, -1.03%, 2.32%, -0.22%, 1.6%, 5.84%, 1.18%, -3.44%, 3.79% and -4.72%, with August the best at 5.84% and December the worst at -4.72%. In 2025 the largest months were February at 4.98%, November at 3.9% and May at 1.22%, and the weakest were October at -2.61%, September at -2.28% and June at -1.55%. 2026 began with January at 7.32% and February at 7.64%, followed by March at -8.27%, April at 2.79%, May at -1.58%, June at 0.86%, July at 2.33%, August at -0.08% and September at -4.46%.
None of those drops reached the 15% trail. The largest, 9.48% from 2026-02-27 to 2026-03-20, was the rule's second drawdown and had not recovered by the end of the data, and September 2026 added a further -4.46%. The fund's own August to November 2025 slide of 8.37% from 2025-08-20 to 2025-11-06 does not appear among the rule's three deepest drawdowns. The open gain of 20.67% was reached with the stop untouched.
Holding through those stretches meant owning XLP on its biggest days. The five worst days of the sample were 2022-05-18 at -6.45%, 2025-04-04 at -4.24%, 2022-09-13 at -3.38%, 2022-03-08 at -2.75% and 2023-01-18 at -2.72%, and the rule held the fund on every one of them. Of the five best days, it held on 2025-04-09 at 3.81%, 2022-02-25 at 3.19%, 2026-07-16 at 2.8% and 2025-01-27 at 2.77%. It was in cash on 2022-06-21 at 2.69%, between the 2022-06-14 sale and the 2022-07-05 re-entry. A defensive fund with a fall of 10% from a 20-day high only once in the window gave the stop little to react to, and the stop reacted twice, in 2022 and 2023.
Every trade
trend + trailing stop on XLP made 2 closed round trips and one position still open at the end of the test, an average hold of 348 days, an average loser of −3.95%, a longest losing streak of 2. It held a position at the close on 81.9% of trading days.
| Entry | Entry price | Exit | Exit price | Return | Days held |
|---|---|---|---|---|---|
| 2021-10-19 | $61.52 | 2022-06-14 | $61.26 | −0.4% | 238 |
| 2022-07-05 | $65.01 | 2023-10-06 | $60.15 | −7.5% | 458 |
| 2023-12-14 | $66.75 | open | – | 20.7% | – |
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.
Trades
There are 3 trades and only 2 are closed, so the table is short. The first bought on 2021-10-19 at 61.52 and sold on 2022-06-14 at 61.2595, a loss of 0.42% over 238 days. The second bought on 2022-07-05 at 65.01 and sold on 2023-10-06 at 60.146, a loss of 7.48% over 458 days. The third bought on 2023-12-14 at 66.75 and was open at the end with a gain of 20.67%.
The best closed trade was -0.42% and the worst -7.48%, so the two closed trades are both the best and the worst. The average loss was 3.95%, the median trade return was -0.42%, and the longest hold was 458 days. With a 0% win rate on closed trades and a profit factor of 0, the headline statistics look poor. The open trade changes the picture, because its 20.67% gain is not in any of them.
The sample is too small to judge the rule from. Three trades is a record of one exit near the top of a decline, one exit near the bottom, and one entry that has not been tested by a stop. The stop's job is to cap a loss, and the 7.48% loss is small against the 15% that the stop allows. Both stops filled below the entry price, so the position had risen above its entry before the trail turned it around. The entry and exit prices in the table are dividend-adjusted, which puts them under the quotes shown on the day.
The strategy page carries a warning about the stop: each exit hands back 15% from the peak, and on a choppy fund the rule can re-enter over and over once price is back above the 200-day line. XLP crossed its 200-day average 73 times in this window, a high count, yet the rule made only 2 closed trades, because the stop and not the average controls the exit.
Largest drawdowns
| Peak | Low point | Depth | Days to low | Recovered | Days to recover |
|---|---|---|---|---|---|
| 2022-04-20 | 2023-12-20 | −22.0% | 609 | 2026-02-03 | 776 |
| 2026-02-27 | 2026-03-20 | −9.5% | 21 | not yet | – |
| 2022-01-04 | 2022-03-11 | −7.8% | 66 | 2022-04-06 | 26 |
Buy-and-hold's deepest drawdown ran from 2022-04-20 to 2022-10-07 and reached −16.0%.
Drawdowns: deeper than the fund
The deepest drawdown was 21.96%, from a peak on 2022-04-20 to a trough on 2023-12-20, 609 days later. Recovery came on 2026-02-03, 776 days after that. The second was 9.48%, from 2026-02-27 to 2026-03-20, with no recovery by the end of the data. The third was 7.77%, from 2022-01-04 to 2022-03-11, recovered on 2022-04-06.
Buy-and-hold had drawdowns of 15.99%, 9.52% and 8.37%. The first ran from 2022-04-20 to 2022-10-07 and recovered on 2024-03-28. The second ran from 2026-02-27 to 2026-03-20, the same dates as the rule's second, and was also open at the end. The rule's drawdown was deeper than the fund's in 2022 and 2023 by 5.97 points.
That is the opposite of what a stop is meant to do. The cause is the sequence of trades. The first stop sold in June 2022, and the rule bought back in July at a higher price, then held through the fund's low on 2022-10-07 and sold only on 2023-10-06 at 60.146. The drawdown's trough date, 2023-12-20, falls after the third entry, and the drawdown did not recover until 2026-02-03. The fund's worst fall was 16.27% on a price basis, close to the 15% the stop allows.
The 2026 drawdown is level with the fund: 9.48% against 9.52%. In that episode the rule was in the same position as the fund and the stop had not been hit.
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.8% | −22.0% | $11,092 | 0.21 |
| 5 basis points | 1.8% | −22.1% | $11,073 | 0.21 |
| 10 basis points | 1.8% | −22.3% | $11,050 | 0.20 |
Costs
With 5 fills the cost runs change little. At 5 basis points the CAGR was 1.79%, the drawdown 22.09%, the end equity $11,073.26 and the Sharpe 0.207. At 10 basis points the CAGR was 1.75%, the drawdown 22.26%, the end equity $11,049.67 and the Sharpe 0.204. The headline run made 1.82% with a Sharpe of 0.21.
The liquidity of XLP is high. Average daily dollar volume was $854,044,173 and median minute volume was 17,592 shares. Trading costs are not the explanation for the weak result here. The explanation is in the entries and exits.
Changing the parameters
| Version | CAGR | Max drawdown | Round trips | Win rate | Final value |
|---|---|---|---|---|---|
| Published rules | 1.8% | −22.0% | 2 | 0% | $11,092 |
| 10% trailing stop | 2.5% | −17.8% | 4 | 50% | $11,549 |
| 20% trailing stop | 4.7% | −16.0% | 0 | – | $13,026 |
| 25% trailing stop | 4.7% | −16.0% | 0 | – | $13,026 |
Parameter variants
Three variants changed the stop. A 10% trailing stop made 2.54% a year with a 17.8% drawdown, 4 trades and 2 wins, ending at $11,549. A 20% trailing stop made 4.71% with a 15.96% drawdown and ended at $13,026, and a 25% stop gave exactly the same result. Neither of the two wider stops made a completed trade.
The two wide stops are the most useful rows. With a 20% or 25% stop, the account entered on the same entry rule and was never stopped out, so it held one position to the end of the data. That gave 4.71%, which is close to the fund's 5.8%, with a drawdown of 15.96% against the fund's 15.99%. The shortfall to buy-and-hold fits an entry on 2021-10-19 rather than at the start of the window. The fund's worst fall of 16.27% did not reach a 20% stop.
The 15% stop sits between the 10% variant and the 20% variants, and it did worse than both on return and drawdown. A stop at 15% was hit twice by falls of the size XLP produced in 2022 and 2023, and each re-entry came at a higher price. A stop at 20% was not hit at all. The result looks like a threshold effect around the fund's worst fall, and that is a feature of this fund in this window.
The 10% stop made 4 trades, and the 15% made 2, so a tighter stop produced more round trips and still did better than the headline. Neither is a sound basis for choosing a setting, since each rests on 4 or fewer trades.
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% on a price basis, with annualized volatility of 13.28%. Its worst fall was 16.27%, from 2022-04-20 to 2022-10-07, with recovery on 2024-03-28 and 486 sessions in the drawdown. The fund gained 18.47% in 2021 and 12.23% in 2024, lost 0.75% in 2022 and 0.89% in 2023, and made 1.53% in 2025 and 5.68% in the partial 2026.
Staples are a defensive sector, and the data shows a low beta of 0.38 to SPY with a correlation of 0.47. The most correlated funds were VTV at 0.64, VOOV at 0.63, XLF at 0.48, FAS at 0.48 and SSO at 0.47. The inverse funds SDS, SH and SPDN sat at -0.47, VIXM at -0.33 and UVXY at -0.32.
The fund was above its 200-day average on 75.1% of sessions and crossed it 73 times. That is a high crossing count for a fund with 13.28% volatility, which means the price hugged its average. A trend rule needs a price that stays on one side of its average for long periods, and XLP crossed back and forth.
Daily moves were small, with an average up day of 0.64% and an average down day of -0.63%. The worst day was 2022-05-18 at -6.45%, followed by 2025-04-04 at -4.24%, and the best was 2025-04-09 at 3.81%. The fund fell 10% from a 20-day high only once, over 3 days. Intraday moves made up 72.64% of the log return, and overnight moves made up 27.36%.
RSI(14) fell below 30 on 37 sessions with a median 5-day return of 0.59% against a baseline of 0.18%, and a 20-day return of 2.44% against 0.73%. RSI(2) fell below 10 on 156 sessions with 5-day and 20-day medians of 0.26% and 1.09%. Those figures fit the strong showing of the mean reversion rules on this fund in the comparison below.
Weekday pattern, beta and what staples did around the stops
By weekday XLP averaged 0.13% on Fridays, 0.06% on Mondays, 0.01% on Thursdays, -0.02% on Tuesdays and -0.04% on Wednesdays. Lag-1 autocorrelation was -0.01. The up-day share was 51.63%, so the fund rose slightly more often than it fell, and the average up and down days were almost equal at 0.64% and -0.63%.
The average overnight gap was 0.29% against a 1.12% range inside the session. Most of the fund's return came from the session rather than overnight, which matters for an open-fill rule: each entry, including the one on 2023-12-14 at $66.75, buys after the gap has printed.
By calendar month the fund averaged 3.33% in November, 1.68% in April, 1.67% in February and July, and 1.33% in January, and fell 3.79% in September, 1.08% in May and 0.17% in June. September 2022 took 7.95% from the rule and September 2023 took 4.66%, which matches that average, and the rule was invested in September in both years. Each month has 5 or 6 observations.
XLP's beta was 0.38 to SPY, 0.18 to QQQ and 0.11 to TLT, with correlations of 0.47, 0.3 and 0.13. That is a fund that moved with the market at about a third of its size and had little link to bonds. The stop is set as a percentage of the high-water mark, and a low-beta fund gives the 15% distance a long time to be reached. In the two stops that did fire, the fund had been drifting lower for months, which is why the first trade lasted 238 days and the second 458.
The exits show the cost of that slowness. The second trade began at $65.01 and ended at $60.146 after 458 days, while the fund's own low on 2022-10-07 and its recovery by 2024-03-28 happened inside that span. A 10% stop did better here at 2.54% over 4 trades, with 2 wins, and the 20% and 25% stops made no trades at all and returned 4.71% by never selling. The XLP fund page shows the same fund against all 12 templates.
The rules
Enter when price is above the 200-day average; exit only when a 15% trailing stop is hit.
- WHEN the market opens · IF not invested AND yesterday's close > SMA(200) · THEN buy with 98% of the sleeve
- WHILE invested · a managed trailing stop follows 15% below the position's high-water mark
A hybrid of the regime filter and the trailing stop. The 200-day average decides when to get in, and a 15% trail from the position's high-water mark decides when to get out. Winners can run well past the point where a crossover would have exited, and the position gives back 15% from every peak.
Good for: long trends with moderate pullbacks; the 15% trail is wide enough to survive normal corrections.
Watch out: every exit gives back 15% from the peak, and on choppy assets it re-enters above the 200-day repeatedly after each stop-out.
The rule against other templates and other sector funds
On XLP the RSI(2) snapback made 8.22% with an 11.06% drawdown, the RSI mean reversion rule 6.51% with 9.64%, and the monthly cycle 5.46% with 13.42%. The weekly 7% target made 2.37% and the golden cross 2.05%. The trend plus trailing stop rule came sixth at 1.82%.
Behind it were the dip buyer at 1.32% with the shallowest drawdown of any rule at 8.03%, the SMA 10/50 trend at 1.21%, the EMA 12/26 trend at 1.19%, the 200-day regime filter at -0.81%, the 3-month momentum rule at -1.67% and the momentum breakout at -1.87%.
The pattern on XLP is that rules that buy dips beat rules that follow trends. The top two templates are both RSI dip buyers, and the trend rules sit in the lower half. A fund that goes sideways rewards the first group and punishes the second. The 200-day filter, which uses the same entry signal as this rule with a different exit, lost money, so the 15% stop did help relative to the plain filter on return.
Among the 6 sector funds, the rule made 19.81% on SOXX, 12.49% on XLK, 8.57% on VOX, 2.62% on XLF, 1.82% on XLP and -4.4% on XLY. The round trips were 14, 7, 3, 4, 2 and 7. The funds with strong trends, SOXX and XLK, gave the stop room to let winners run, and the quiet funds did not.
The test stops at one fund and one 5.74-year window, and the headline result rests on three trades, one of them still open. A different entry date could have changed the first exit and every trade after it. The headline run has no fees or slippage.
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 trend + trailing stop beat buy-and-hold on XLP?
Over 2021-01-04 to 2026-10-02, trend + trailing stop on XLP returned 1.8% annualized vs 5.8% for buy-and-hold: it trailed buy-and-hold by 4.0% per year, with a maximum drawdown of 22.0% (buy-and-hold: 16.0%).
How many trades did it make?
2 completed round trips over 5.7 years (5 fills), with 0% of round trips closing profitably.
Why 15% rather than 10%?
A wider trail survives routine corrections and gives back more at the end. Both numbers are one-field edits in DeployQuant, so you can backtest both and compare.
How did the trend plus trailing stop rule do on XLP?
It turned $10,000 into $11,092, a CAGR of 1.82% with a maximum drawdown of 21.96%. It made 2 closed trades, both losses, and had a third open at the end with a gain of 20.67%. Buy-and-hold made 5.8%.
Why was the drawdown deeper than buy-and-hold on XLP?
The rule exited on 2022-06-14, bought back on 2022-07-05 at a higher price, and then held through the fund's low before a second stop on 2023-10-06. Its drawdown was 21.96% against 15.99% for the fund.
What did the wider trailing stops show?
A 20% stop and a 25% stop both made 4.71% with a 15.96% drawdown and no completed trades, because neither was hit. A 10% stop made 2.54%. The 15% headline sat between them and did worse.
Do costs explain the weak result?
No. At 5 basis points the CAGR was 1.79% and at 10 basis points it was 1.75%, against 1.82% in the headline run. The rule made only 5 fills.
Which strategies did best on XLP?
The RSI(2) snapback made 8.22% a year and the RSI mean reversion rule made 6.51%. The trend plus trailing stop rule ranks 6th of 12.
How does XLP compare with other sector funds for this rule?
The rule made 19.81% on SOXX, 12.49% on XLK, 8.57% on VOX, 2.62% on XLF and -4.4% on XLY. XLP's 1.82% had the fewest round trips of the six, at 2.
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.