EMA 12/26 Trend on XLK
Technology Select Sector SPDR Fund: S&P 500 technology stocks, the sector behind most recent bull runs. Backtest 2021-01-04 to 2026-10-02, $10,000 starting capital, computed by the same engine that runs live DeployQuant strategies.
The EMA 12/26 trend switch ended the XLK test at $17,136 from a $10,000 start. That is a CAGR of 9.84% and a total return of 71.36%. Holding the fund over the same window, 2021-01-04 to 2026-10-02, ended at $31,425 on a CAGR of 22.07%. The rule trailed the fund in five of the six calendar years. It led only in 2022, the one year when the fund lost money and the rule lost less.
The maximum drawdown was 25.57% for the rule and 32.96% for the fund. The Sharpe ratio was 0.64 against 0.95. The rule closed 23 round trips, 8 of them winners, a win rate of 35%. A twenty-fourth trade was still open at the end of the data: it began on 2026-08-07 at an adjusted price of $187.67 and stood 6.49% higher at the last close.
XLK is the Technology Select Sector SPDR Fund, and its buy-and-hold run is a hard benchmark for a long/flat switch. The fund compounded at 22.86% a year in this window with 25.13% annualized volatility. A rule that is invested on 65.7% of trading days has to dodge a large share of the losses just to keep up, and here the fund recovered quickly enough that the days spent in cash cost more than they saved. Rank-wise, this pairing sits eighth of the 12 templates on XLK and fifteenth of the 59 funds for this rule.
Year by year
| Year | EMA 12/26 trend | buy & hold |
|---|---|---|
| 2021 | 8.6% | 36.1% |
| 2022 | −22.1% | −27.2% |
| 2023 | 29.5% | 54.6% |
| 2024 | 8.0% | 21.3% |
| 2025 | 17.1% | 24.3% |
| 2026 | 23.7% | 38.9% |
How each calendar year went
The year-by-year table shows a rule that captured a fraction of every rally and gave up less than the fund in the one decline. 2021 returned 8.6% for the rule against 36.1% for the fund. The rule did not enter until 2021-02-10, and its first trade lost 6.78% in 23 days. The next two entries, in April and June, were a 2.28% loss and a 10.52% gain. By the end of the year the fund had climbed to a peak on 2021-12-27 while the rule had spent several stretches in cash.
2022 is the year the rule earned its place. The fund fell 27.2% and the rule fell 22.1%. Five round trips closed in 2022 and only one was a winner. The rule bought on 2022-03-25 at $76.58 and sold on 2022-04-13 at $71.42, a loss of 6.74%. It bought again on 2022-07-21, sold on 2022-09-01 for a 2.21% loss, and then took two small losses in November: 6.88% in two days from 2022-11-01, and 4.05% from 2022-11-14. The monthly table shows flat months in February, May, June and October 2022, when the sleeve held cash. Those four months are where the rule avoided losses the fund took. It still lost 6.92% in April and 6.65% in December, in months where an entry was reversed.
2023 returned 29.5% for the rule and 54.6% for the fund, the largest shortfall of the six years in the yearly gap table. The cause is visible in the trade list. The rule re-entered on 2023-01-18 at $64.33, which was close to the low, and held to 2023-08-10 for a 28.91% gain. That one trade carried the year. The rule missed the first weeks of the rebound and then spent September and October in two short trades that lost 4.5% and 4.82%.
2024 was 8.0% against 21.3%. The rule held from 2023-11-07 to 2024-04-16 for a 16.77% gain, then caught only 4.46% from 2024-05-13 to 2024-07-25. The entry on 2024-08-21 at $110.74 lasted 15 days and lost 7.16%, the worst trade of the test. The month of June 2024, at 7.57%, was the strongest of the year for the rule.
2025 returned 17.1% against 24.3%. The rule was in cash for March and April 2025, so the sharp April decline cost it nothing, but it also missed the days of the rebound until the 2025-05-02 entry at $106.85. That trade ran 201 days to 2025-11-19 and made 29.99%, the best of the test. The final weeks of the year gave back some of it, with 2025-12-08 and 2025-12-24 entries that lost 3.98% and 0.19%.
2026 is a partial year, running to early October. The rule is up 23.7% and the fund 38.9%. The year contains both the best and worst months of the rule's run: 19.41% in May and -8.66% in July. The long trade from 2026-04-13 at $142.08 to 2026-07-17 at $173.42 returned 22.06%, and the open position from 2026-08-07 is the latest entry.
Month by month
| Year | Jan | Feb | Mar | Apr | May | Jun | Jul | Aug | Sep | Oct | Nov | Dec |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2021 | 0.0% | −4.7% | −2.1% | 2.4% | −4.5% | 6.2% | 3.8% | 3.5% | −4.6% | 1.6% | 4.3% | 3.2% |
| 2022 | −4.8% | 0.0% | 0.4% | −6.9% | 0.0% | 0.0% | 5.2% | −6.1% | −0.9% | 0.0% | −4.0% | −6.7% |
| 2023 | 3.0% | 0.4% | 10.6% | −0.1% | 8.7% | 6.0% | 2.5% | −4.9% | −4.4% | −4.7% | 6.5% | 4.1% |
| 2024 | 2.6% | 4.6% | 0.8% | −3.0% | 1.6% | 7.6% | −4.5% | −1.8% | −2.6% | −1.5% | 5.0% | −0.3% |
| 2025 | −4.4% | −0.2% | 0.0% | 0.0% | 7.0% | 9.6% | 3.6% | 0.0% | 7.4% | 6.5% | −7.0% | −5.1% |
| 2026 | 0.4% | −4.6% | 0.0% | 11.6% | 19.4% | −0.2% | −8.7% | −0.8% | 5.0% | 2.1% | – | – |
What the monthly table shows
A 0.00% month means the sleeve sat in cash from the first session to the last. Those months bunch up in 2022 (February, May, June, October), in March and April 2025 and in March 2026, and each bunch follows a stretch of falling prices. The 12-day average had dropped under the 26-day, so the switch was already out.
The best months were 2026-05 at 19.41%, 2026-04 at 11.64% and 2023-03 at 10.58%. The worst were 2026-07 at -8.66%, 2025-11 at -6.99% and 2022-04 at -6.92%. The fund's own best month was 2026-04 at 19.71% and its worst was 2022-09 at -11.65%. In September 2022 the rule lost 0.95% while the fund lost 11.65%, since the rule had exited on 2022-09-01.
July 2026 shows the lag. The April trade was still open when the fund began to slip, and the sell on 2026-07-17 at $173.42 came only after the 12-day average had crossed under the 26-day, which happens after part of the decline is done.
Every trade
EMA 12/26 trend on XLK made 23 closed round trips and one position still open at the end of the test, an average hold of 57 days, an average winner of 15.30%, an average loser of −4.03%, a profit factor of 1.95, a longest losing streak of 4. It held a position at the close on 65.7% of trading days.
| Entry | Entry price | Exit | Exit price | Return | Days held |
|---|---|---|---|---|---|
| 2021-02-10 | $65.75 | 2021-03-05 | $61.29 | −6.8% | 23 |
| 2021-04-05 | $65.46 | 2021-05-12 | $63.97 | −2.3% | 37 |
| 2021-06-01 | $66.76 | 2021-09-22 | $73.78 | 10.5% | 113 |
| 2021-09-27 | $74.94 | 2021-09-28 | $73.93 | −1.4% | 1 |
| 2021-10-20 | $76.60 | 2022-01-11 | $79.83 | 4.2% | 83 |
| 2022-03-25 | $76.58 | 2022-04-13 | $71.42 | −6.7% | 19 |
| 2022-07-21 | $66.42 | 2022-09-01 | $64.95 | −2.2% | 42 |
| 2022-11-01 | $62.93 | 2022-11-03 | $58.60 | −6.9% | 2 |
| 2022-11-14 | $64.19 | 2022-12-21 | $61.59 | −4.0% | 37 |
| 2023-01-18 | $64.33 | 2023-08-10 | $82.93 | 28.9% | 204 |
| 2023-09-01 | $86.54 | 2023-09-19 | $82.65 | −4.5% | 18 |
| 2023-10-13 | $84.21 | 2023-10-23 | $80.15 | −4.8% | 10 |
| 2023-11-07 | $85.13 | 2024-04-16 | $99.41 | 16.8% | 161 |
| 2024-05-13 | $101.95 | 2024-07-25 | $106.50 | 4.5% | 73 |
| 2024-08-21 | $110.74 | 2024-09-05 | $102.81 | −7.2% | 15 |
| 2024-09-18 | $108.38 | 2025-01-10 | $114.28 | 5.4% | 114 |
| 2025-01-24 | $119.93 | 2025-01-29 | $115.33 | −3.8% | 5 |
| 2025-02-12 | $115.27 | 2025-02-27 | $115.06 | −0.2% | 15 |
| 2025-05-02 | $106.85 | 2025-11-19 | $138.89 | 30.0% | 201 |
| 2025-12-08 | $147.14 | 2025-12-18 | $141.29 | −4.0% | 10 |
| 2025-12-24 | $145.29 | 2026-01-22 | $145.02 | −0.2% | 29 |
| 2026-01-26 | $144.40 | 2026-02-05 | $136.56 | −5.4% | 10 |
| 2026-04-13 | $142.08 | 2026-07-17 | $173.42 | 22.1% | 95 |
| 2026-08-07 | $187.67 | open | – | 6.5% | – |
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.
What the 24 trades show
Of the 23 closed trades, 8 were winners and 15 were losers. The average winner returned 15.3% and the average loser -4.03%. The profit factor was 1.95, so the winners outweighed the losers in total despite the low hit rate. The median trade lost 2.21% and the median hold was 29 days, while the average hold was 57.3 days. The gap between those two holds comes from a few very long trades. The longest hold was 204 days, from 2023-01-18, and the shortest was 1 day, from 2021-09-27.
Three trades made most of the profit: 29.99% from 2025-05-02, 28.91% from 2023-01-18 and 22.06% from 2026-04-13. The next two best were 16.77% from 2023-11-07 and 10.52% from 2021-06-01. The five worst were between -7.16% and -5.43%. No single loss was large. The cost of the rule is the count of small losses: the longest losing streak was 4 trades and the longest winning streak was 2.
The per-year counts show where the churn sat. 2021 had 4 closed trades with 1 winner, 2022 had 5 with 1, 2023 had 3 with 1, 2024 had 3 with 2, 2025 had 5 with 2 and 2026 had 3 with 1. Eight winners out of 23 means a rule that survives on the size of its wins. Every winner was held 73 days or longer. Every trade held 19 days or fewer was a loser, including the 1-day round trip on 2021-09-27 and the 2-day one on 2022-11-01.
Largest drawdowns
| Peak | Low point | Depth | Days to low | Recovered | Days to recover |
|---|---|---|---|---|---|
| 2021-12-27 | 2023-01-19 | −25.6% | 388 | 2023-06-15 | 147 |
| 2025-10-29 | 2026-02-05 | −16.5% | 99 | 2026-05-08 | 92 |
| 2024-07-10 | 2024-09-18 | −16.3% | 70 | 2025-06-30 | 285 |
Buy-and-hold's deepest drawdown ran from 2021-12-27 to 2022-10-12 and reached −33.0%.
Drawdowns of the rule and the fund
The rule's deepest drawdown was 25.57%, from a peak on 2021-12-27 to a low on 2023-01-19, 388 days later. It recovered on 2023-06-15, another 147 days on. The fund's own drawdown started at the same peak on 2021-12-27 and reached 32.96% on 2022-10-12, then recovered on the same date, 2023-06-15. The rule lost less at the bottom but took longer to reach its low, because it kept buying and exiting into the decline instead of staying out. The rule's low came later than the fund's.
Whipsaws explain the gap. The 2022-11 and 2022-12 trades pushed the rule's equity lower after the fund had already put in its low on 2022-10-12. The 2022-11-01 entry at $62.93 lost 6.88% in two days and the 2022-11-14 entry at $64.19 lost 4.05%. The 2022-11-10 session was the second-best day of the fund in the whole window at 8.23%, and the rule was in cash for most of that move.
The second drawdown was 16.47%, from 2025-10-29 to 2026-02-05, and recovered on 2026-05-08. The third was 16.32%, from 2024-07-10 to 2024-09-18, and took 285 days to recover on 2025-06-30. The third is a useful case. The fund's own drawdown from the same 2024-07-10 peak was 16.74%, and it reached its low on 2024-08-07 and recovered by 2024-11-07. The rule fell for 70 days to 2024-09-18 and needed until 2025-06-30. The 2024-08-21 entry at $110.74 was bought after the fund's low and sold at $102.81 on 2024-09-05, so the rule re-entered during the rebound and then sold at a worse price. The pattern is typical of a lagging average: a V-shaped decline and recovery trips both signals late.
Holding the fund also produced a 25.29% decline from 2025-02-18 to 2025-04-08, recovered by 2025-06-12. No drawdown of that size appears in the rule's list for the same weeks, since it had gone to cash after the February exits and stayed out through April.
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) | 9.8% | −25.6% | $17,136 | 0.64 |
| 5 basis points | 9.4% | −25.9% | $16,748 | 0.62 |
| 10 basis points | 9.0% | −26.3% | $16,391 | 0.59 |
Slippage runs
The headline run charges nothing per fill. Charging 5 basis points per fill lowers the CAGR to 9.4% and the final value to $16,748. The Sharpe ratio goes to 0.617 and the maximum drawdown to 25.91%. At 10 basis points the CAGR is 8.99%, the final value $16,391, the Sharpe ratio 0.594 and the drawdown 26.32%.
The rule traded 47 fills in 5.74 years, a modest count, and each step of slippage shaved a little under half a point off the CAGR. XLK turns over $1,324,049,811 on an average day, so a $10,000 sleeve is far too small to move its price. The runs apply one flat charge per fill. They do not widen the cost on a violent day like 2025-04-03, when the fund fell 6.76%.
Changing the parameters
| Version | CAGR | Max drawdown | Round trips | Win rate | Final value |
|---|---|---|---|---|---|
| Published rules | 9.8% | −25.6% | 23 | 35% | $17,136 |
| EMA 8/21 | 14.0% | −20.7% | 30 | 47% | $21,256 |
| EMA 20/50 | 8.7% | −29.5% | 13 | 38% | $16,117 |
| EMA 12/50 | 9.5% | −23.1% | 18 | 50% | $16,803 |
Other EMA pairs on the same fund
Three alternative pairs were tested on the same fund. The published 12/26 pair returned 9.84% a year. The faster EMA 8/21 pair returned 14.04% with a 20.74% drawdown, a Sharpe ratio of 0.877 and 30 trades, 14 of them winners. The slower EMA 20/50 pair returned 8.67% with a 29.47% drawdown and 13 trades. EMA 12/50 returned 9.46% with a 23.13% drawdown and 18 trades, 9 of them winners.
The faster pair did best, and it traded the most. That fits the shape of the fund in this window. XLK made sharp V-shaped moves in 2022, 2024 and 2025, and a quicker crossover exits sooner and re-enters sooner. It is also one window and one fund. The 8/21 result is a single point of a grid of four, and nothing here shows that it would hold on another sample. The 12/50 variant produced a higher win rate, 50%, with a lower CAGR than the published pair, which shows that win rate and return move apart for this kind of rule.
The slower 20/50 pair had the deepest drawdown of the four, 29.47%, because it exited later. A slower average protects less when the decline is fast. The published pair sits between the two extremes on both drawdown and CAGR.
How XLK behaved
| Measure | XLK |
|---|---|
| Data in this test | 2021-01-04 to 2026-10-02 (1444 sessions) |
| Total return, buy and hold | 226.1% |
| Annualized volatility | 25.1% |
| Deepest drawdown | −33.6% (2021-12-27 to 2022-10-12) |
| Up days | 55.2% |
| Average daily range | 1.77% |
| Average overnight gap | 0.69% |
| Correlation to SPY | 0.91 |
| Correlation to QQQ | 0.97 |
| Correlation to TLT | 0.07 |
| Sessions above the 200-day average | 76.5% |
| Crossings of the 200-day average | 22 |
| Falls of 10% or more from a 20-day high | 30 |
How XLK behaved
Held through the window, XLK returned 226.13%, which is the 22.86% CAGR quoted earlier. Up days were 55.23% of sessions, with an average gain of 1.15% on up days and an average loss of 1.21% on down days. The daily range averaged 1.77% and the overnight gap 0.69%. Overnight moves supplied 55.3% of the log return and the trading day 44.7%. This rule trades at the open, so each entry has already paid the overnight gap and each exit has taken it.
XLK closed above its 200-day average on 76.47% of sessions and crossed that line 22 times. The 12/26 pair produced 24 entries in the same period, so the faster pair generated only a couple more flips than the slow benchmark line. That is why the trade count here is moderate.
Lag-1 autocorrelation of daily returns was -0.03, which is close to zero. There was no day-to-day persistence for a trend rule to use. What the rule used was multi-week persistence, which showed up in the 2023 and 2025 rallies.
XLK correlates 0.97 with QQQ and 0.91 with SPY, and 0.07 with TLT. Its beta was 1.39 to SPY. The fund's best day was 13.37% on 2025-04-09 and its worst days were -6.76% on 2025-04-03 and -6.57% on 2025-04-04. The rule was in cash on all three. It missed the best day and avoided both of the worst two. The fund's 2022 drawdown peak and trough, 2021-12-27 and 2022-10-12, define the period where the rule did best relative to the fund.
The data counts 30 events in which the fund fell 10% or more from a 20-day high. A 12/26 crossover reacts to the slow versions of those events and is late on the fast ones.
The rules
Hold while the 12-day exponential average is above the 26-day, the core of the MACD used as a position switch.
- WHEN the market opens · IF not invested AND EMA(12) > EMA(26) · THEN buy with 98% of the sleeve
- WHEN the market opens · IF invested AND EMA(12) < EMA(26) · THEN sell the whole position
The 12/26 exponential moving average pair is the core of the MACD indicator. Exponential averages weight recent days more than simple averages, so this crossover reacts faster than an SMA pair of the same length. Used as a long/flat switch, it gives you a position you can hold and measure.
Good for: traders who like MACD logic but want it expressed as a simple, testable long/flat rule.
Watch out: faster reaction means more trades and more whipsaws than a 50/200 cross; check the trade count on each backtest page.
How the rules interact with this fund
Two lines define the rule. Flat and 12-day above 26-day at the open: buy with 98% of the sleeve. Invested and 12-day below 26-day at the open: sell everything. It has no stop, no volatility filter and no minimum holding period, which is why a 1-day trade was possible.
On a trending fund with a persistent bull market, a rule like this gives up the early part of each leg and the late part of each decline. XLK spent most of the window in long uptrends, interrupted by 2022. The rule's cash days were concentrated in three places: 2021-02 and 2021-03, 2022, and early 2025. Each of those periods did involve a decline, though the fund went on to new highs after each.
The sector peers show how much the result depends on the fund. SOXX returned 17.96% a year with a 33.96% drawdown, XLK 9.84% with 25.57%, VOX 5.8% with 19.38%, XLF 5.63% with 23.98%, XLY 2.36% with 21.26% and XLP 1.19% with 22.82%. XLK is second of the six. The median CAGR for this rule was 2.76% across all 59 funds and 5.8% across the sector group, so XLK is well above both.
Seven other templates beat it on XLK. The leader, the monthly cycle, made 20.86% but with a 32.05% drawdown. The weekly 7% target reached 20.39% at 20.67% depth, which is the stronger risk trade. The 200-day regime filter and the golden cross both held drawdowns near 20% while returning 16.81% and 15.33%. Behind the EMA pair sit the SMA 10/50 trend at 9.47% and RSI mean reversion at 8.74%. The RSI(2) snapback and momentum breakout landed at 12.11% and 11.62%.
Limits: one fund, one 5.74-year window that contains a single bear market, daily decisions and no leverage. Costs enter only through the two slippage runs, and the trade prices quoted here are adjusted for splits and dividends.
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 EMA 12/26 trend beat buy-and-hold on XLK?
Over 2021-01-04 to 2026-10-02, EMA 12/26 trend on XLK returned 9.8% annualized vs 22.1% for buy-and-hold: it trailed buy-and-hold by 12.2% per year, with a maximum drawdown 7.4 points shallower than holding (25.6% vs 33.0%).
How many trades did it make?
23 completed round trips over 5.7 years (47 fills), with 35% of round trips closing profitably.
Is this the same as trading MACD signals?
It uses the MACD's underlying trend component. Classic MACD trades the signal-line crossover of the 12/26 spread. This template trades the spread's sign directly, which is simpler and can be built fully in blocks.
Does the 12/26 EMA switch outperform holding XLK?
Not in this window. The switch compounded at 9.84% against 22.07% for the fund, and led only in 2022 with -22.1% against -27.2%. Its worst drawdown was 25.57% against 32.96%.
How often does this rule trade XLK?
The test logged 47 fills. Of 23 finished round trips, 8 made money, and a position from 2026-08-07 remained open. Holds averaged 57.3 days with a median of 29.
What was the worst trade on XLK?
The worst closed trade bought at an adjusted $110.74 on 2024-08-21 and sold at $102.81 on 2024-09-05, a loss of 7.16% over 15 days. The next worst were 6.88% from 2022-11-01, 6.78% from 2021-02-10 and 6.74% from 2022-03-25.
Would a faster EMA pair have done better on XLK?
EMA 8/21 returned 14.04% a year with a 20.74% drawdown over 30 trades, ahead of 12/26 at 9.84% and 25.57%. EMA 20/50 returned 8.67% with a 29.47% drawdown. These are single runs on one fund, so they do not establish that the faster pair holds up on other funds or dates.
What do fees and slippage do to the XLK result?
Slippage of 5 basis points per fill gave a 9.4% CAGR and $16,748 at the end. Slippage of 10 basis points gave 8.99% and $16,391. The run with no costs finished at $17,136.
Which strategy did best on XLK in this test?
The monthly cycle had the highest CAGR on XLK at 20.86%, followed by the weekly 7% target at 20.39% and the 200-day regime filter at 16.81%. EMA 12/26 trend was eighth of 12 at 9.84%. Buy-and-hold on XLK returned 22.07%.
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.