Learn › Strategies › EMA 12/26 Trend › XLP

EMA 12/26 Trend 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.

Result: EMA 12/26 trend on XLP turned $10,000 into $10,701 (7.0% total, 1.2% CAGR): it trailed buy-and-hold by 4.6% per year, with a maximum drawdown of 22.8% (buy-and-hold: 16.0%).
1.2%CAGR
5.8%buy & hold CAGR
−22.8%max drawdown
0.17Sharpe ratio
27round trips
48%win rate
■ EMA 12/26 trend   ■ buy & hold, $10,000 invested 2021-01-04

Year by year

YearEMA 12/26 trendbuy & hold
202111.3%18.1%
20224.2%−0.7%
20232.9%−0.9%
20246.6%12.0%
2025−15.5%1.5%
2026−0.5%5.6%

Month by month

YearJanFebMarAprMayJunJulAugSepOctNovDec
20210.0%0.0%3.2%1.9%1.7%−2.0%2.0%1.1%−2.0%0.1%−1.4%6.6%
2022−1.4%−0.7%−0.2%2.4%−1.8%0.0%2.0%−1.8%1.3%1.3%6.0%−2.6%
2023−2.8%0.0%1.7%3.6%−4.1%0.0%1.5%−2.2%0.0%0.0%2.8%2.7%
20241.2%2.0%3.3%−4.0%2.3%−0.2%1.6%5.8%1.2%−3.0%0.9%−4.2%
20250.0%5.2%−4.1%−2.5%−0.7%−2.9%−4.3%−2.6%0.0%−3.3%0.0%−1.2%
20263.4%7.6%−5.6%0.0%−2.1%−3.4%2.3%−0.1%−2.1%0.0%––

Every trade

EMA 12/26 trend on XLP made 27 closed round trips, an average hold of 48 days, an average winner of 3.05%, an average loser of −2.23%, a profit factor of 1.19, a longest losing streak of 8. It held a position at the close on 61.2% of trading days.

EntryEntry priceExitExit priceReturnDays held
2021-03-16$57.172021-06-21$59.944.8%97
2021-07-12$60.972021-09-21$61.631.1%71
2021-10-25$62.332021-12-02$61.70−1.0%38
2021-12-08$63.912022-02-15$66.564.2%69
2022-03-29$67.282022-05-11$67.520.4%43
2022-07-11$65.152022-09-02$66.111.5%53
2022-10-28$64.482023-01-19$65.581.7%83
2023-03-28$66.772023-05-24$67.471.1%57
2023-07-05$68.192023-07-13$67.61−0.8%8
2023-07-14$67.722023-08-16$67.810.1%33
2023-11-10$63.342024-04-12$69.159.2%154
2024-04-25$71.332024-10-09$76.797.7%167
2024-10-17$78.132024-10-22$77.31−1.1%5
2024-10-23$77.252024-10-24$77.550.4%1
2024-11-26$78.132024-12-20$75.46−3.4%24
2025-02-04$75.252025-03-19$75.950.9%43
2025-04-02$78.562025-04-08$75.46−4.0%6
2025-04-17$77.412025-05-15$76.43−1.3%28
2025-05-16$77.962025-06-18$77.21−1.0%33
2025-07-02$79.292025-07-16$77.52−2.2%14
2025-07-24$78.942025-07-31$77.20−2.2%7
2025-08-08$79.762025-08-29$77.62−2.7%21
2025-10-22$77.142025-10-30$74.51−3.4%8
2025-12-01$77.172026-01-08$75.16−2.6%38
2026-01-12$78.072026-03-13$83.306.7%60
2026-05-01$83.642026-06-03$80.62−3.6%33
2026-06-12$84.252026-09-09$82.62−1.9%89

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.

Largest drawdowns

PeakLow pointDepthDays to lowRecoveredDays to recover
2024-09-162026-06-22−22.8%644not yet–
2022-04-202022-07-18−6.2%892022-08-1831
2022-11-302023-07-07−5.6%2192023-12-28174

Buy-and-hold's deepest drawdown ran from 2022-04-20 to 2022-10-07 and reached −16.0%.

With trading costs

The headline run fills at the bar price. These runs charge slippage on every fill.

Slippage per fillCAGRMax drawdownFinal valueSharpe
None (headline)1.2%−22.8%$10,7010.17
5 basis points0.7%−23.9%$10,4260.12
10 basis points0.3%−25.1%$10,1470.07

Changing the parameters

VersionCAGRMax drawdownRound tripsWin rateFinal value
Published rules1.2%−22.8%2748%$10,701
EMA 8/212.9%−22.1%3145%$11,764
EMA 20/50−0.3%−19.5%1540%$9,844
EMA 12/50−0.2%−17.9%2129%$9,906

How XLP behaved

MeasureXLP
Data in this test2021-01-04 to 2026-10-02 (1444 sessions)
Total return, buy and hold40.3%
Annualized volatility13.3%
Deepest drawdown−16.3% (2022-04-20 to 2022-10-07)
Up days51.6%
Average daily range1.12%
Average overnight gap0.29%
Correlation to SPY0.47
Correlation to QQQ0.30
Correlation to TLT0.13
Sessions above the 200-day average75.1%
Crossings of the 200-day average73
Falls of 10% or more from a 20-day high1

The rules

Hold while the 12-day exponential average is above the 26-day, the core of the MACD used as a position switch.

  1. WHEN the market opens · IF not invested AND EMA(12) > EMA(26) · THEN buy with 98% of the sleeve
  2. 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.

Run EMA 12/26 trend on XLP yourself, free →

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 XLP?

Over 2021-01-04 to 2026-10-02, EMA 12/26 trend on XLP returned 1.2% annualized vs 5.8% for buy-and-hold: it trailed buy-and-hold by 4.6% per year, with a maximum drawdown of 22.8% (buy-and-hold: 16.0%).

How many trades did it make?

27 completed round trips over 5.7 years (54 fills), with 48% 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.

Related

EMA 12/26 Trend on all 59 ETFsfull results table All strategies on XLP12 templates compared RSI(14) Mean Reversion on XLPsame ETF, different rulesRSI(2) Dip Snapback on XLPsame ETF, different rules

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.