Category: Quant Strategies

Can a Simple Trading Rule Reduce Stock-Market Losses? We Tested It on 6 Sector ETFs

A 3-Year Backtest of a 10/30 EMA Crossover with RSI Confirmation vs. SPY (2023–2026)

Share Research: Share on 𝕏 LinkedIn
Results RSI Test Exposure & Cash Sectors Concentration Drawdowns Monthly Returns Code & Audit

What Did We Test?

The strategy buys a sector ETF when its short-term trend rises above its longer-term trend, provided momentum is also positive. Positions are closed when the short-term trend reverses below the longer-term trend.

Technically, we measure this across six liquid sector ETFs, XLK (Technology), XLF (Financials), XLI (Industrials), XLE (Energy), XLV (Health Care), and XLY (Consumer Discretionary), using a 10-day and 30-day exponential moving average (EMA) crossover combined with a 14-day Relative Strength Index (RSI) above 50.

What Happened to $100,000?

We backtested a 10/30 EMA trend-following strategy with an RSI(14) > 50 filter across six major U.S. sector ETFs using $100,000 starting capital over the 3-year period from 2023-08-29 to 2026-08-27.

Over the 3-year backtest, the active sector strategy grew $100,000 to $158,574 (+58.57% total return, +$58,574 net profit, +16.66% CAGR across 79 closed trades). Over the exact same period, the broad S&P 500 benchmark (SPY) returned +77.04% ($177,038 ending equity, +21.01% CAGR), while an unhedged equal-weight buy-and-hold basket of the six sector ETFs returned +69.44% ($169,438 ending equity, +19.27% CAGR).

Sector Strategy (10/30 EMA + RSI)
+58.6%
Annual: +16.7%
Worst Decline: -9.8%
Risk-Adjusted: 1.36 Sharpe
SPY S&P 500 Benchmark
+77.0%
Annual: +21.0%
Worst Decline: -18.2%
Risk-Adjusted: 1.12 Sharpe
Equal-Weight Sector Basket
+69.4%
Annual: +19.3%
Worst Decline: -17.5%
Risk-Adjusted: 1.31 Sharpe

💡 The key takeaway: This strategy meaningfully lagged SPY on raw return (Strategy: +58.6% vs. SPY: +77.0%). But it had a smaller maximum decline than either benchmark (Strategy: -9.8% vs. SPY: -18.2% vs. the sector basket: -17.5%), and it actually posted a better risk-adjusted return than SPY (1.36 Sharpe vs. 1.12) — for each unit of volatility taken on, the strategy delivered more return than buy-and-hold. That combination makes it a reasonable fit for a more risk-averse investor willing to trade some upside for a smoother ride, even though it gave up the “matches the market’s raw return” claim.

Think the RSI filter is doing the heavy lifting? Modify this backtest free →

Did It Beat SPY?

Side-by-Side Performance Comparison
Strategy vs. Sector Basket Buy & Hold vs. SPY S&P 500 Benchmark
Metric Sector Strategy Sector Basket (Equal-Weight) SPY (S&P 500)
Total Return 58.57% 69.44% 77.04%
Annualized Return (CAGR) 16.66% 19.27% 21.01%
Maximum Drawdown -9.81% -17.51% -18.20%
Annualized Sharpe Ratio 1.36 1.31 1.12
Backtest Summary
The core figures from this run, at a glance
Metric Value What It Measures
Starting Capital $100,000 Initial portfolio equity at start of backtest
Ending Capital $158,574 Final portfolio value at end of backtest window
Total Return 58.57% Growth of the account over the full backtest window
Annualized Return 16.66% Return scaled to a one-year rate, for comparing across different time windows
Number of Trades 79 Closed round-trip trades this strategy actually made
Position Size 300 units per trade How many shares/units each trade actually bought or sold — see “A note on position sizing” below
Win Rate 40.5% Share of closed trades that were profitable
Sharpe Ratio 1.361 Return per unit of total volatility
Sortino Ratio 1.926 Return per unit of downside volatility only
Calmar Ratio 1.698 Return relative to the worst peak-to-trough drawdown
Max Drawdown 9.81% Largest peak-to-trough decline over the backtest
Buy & Hold XLK + XLF + XLI + XLE + XLV + XLY Return 69.44% What simply buying and holding XLK + XLF + XLI + XLE + XLV + XLY the whole time would have returned — the baseline this strategy is measured against
Strategy vs. Buy & Hold -81.20% How much better (positive) or worse (negative) the strategy did than that baseline

The strategy completed 79 closed round-trip trades across the six sector ETFs, growing the initial $100,000 capital to $158,574 for a total return of +58.57% (+16.66% annual return). In terms of raw total return, the active strategy meaningfully lagged the broad S&P 500 benchmark (SPY), which returned +77.04% ($177,038) over the exact same period, trailing it by 18.47 percentage points. Meanwhile, simply buying all six sector ETFs equally and holding them returned +69.44% ($169,438) — also ahead of the active strategy, though by a much smaller margin than SPY.

The one advantage the strategy retained was downside risk protection. Maximum drawdown means the largest fall in the account from a previous high. The strategy’s maximum drawdown was -9.81% (a $12,752 drop from a $129,932 peak in December 2024, recovering by June 2025), clearly smaller than -18.20% on SPY and -17.51% on the Sector Basket — and it still posted the best risk-adjusted return of the three, at 1.36 Sharpe versus 1.12 for SPY and 1.31 for the Sector Basket.

Across the 79 closed trades, 32 were profitable, producing an overall win rate of 40.5%. Two sectors, Industrials (XLI +$17,849) and Health Care (XLV +$16,303), plus Technology (XLK +$16,943), drove essentially all of the strategy’s net profit; Financials (XLF +$5,268) and Consumer Discretionary (XLY +$5,467) contributed modestly, while Energy (XLE -$3,256) was a net loser over the window.

How Much Time Was the Strategy Actually Invested?

A central question for systematic trend strategies is cash drag: how much time does the strategy sit in cash, and does sitting idle harm overall compounding?

Strategy Exposure & Capital Deployment Profile
How the 10/30 EMA + RSI strategy allocates capital between active ETFs and cash
Portfolio Metric Strategy Value Quantitative Role / Insight
Time in Market (% Days Invested) 91.7% of trading days Strategy sat 100% in cash for 8.3% of the 3-year backtest window
Average Invested Exposure 68.5% of portfolio Capital deployed into active sector trend crossovers
Average Cash Balance 31.5% of portfolio Unallocated cash buffer sitting idle during market corrections
Average Active Positions 4.11 ETFs (out of 6 max) Diversified across roughly 4 sector ETFs during strong trends
Maximum Concurrent Positions 6 Sector ETFs All 6 sector ETFs were active simultaneously during broad bull trends
Annual Portfolio Turnover ~2.1x per year Low transaction drag across 79 closed trades
Idle Cash Interest Yield 0.00% (as published) Tested for real below: parking cash in BIL (T-Bills) improves return to +59.49%

Benchmark Methodologies

  • Equal-Weight Sector Basket Baseline: Equal-weighted once at inception ($16,667 per ETF on 2023-08-29) and allowed to drift over the 3-year period without periodic rebalancing back to 16.67%.

  • Dividend Handling: Both benchmark (SPY) and sector ETF returns reflect total returns (adjusted daily prices with dividend reinvestment).

What If Idle Cash Had Been Parked in T-Bills or a Bond ETF Instead?

Rather than assume a flat T-bill rate applied to the strategy’s average cash balance, we re-ran the backtest’s actual daily cash ledger and let every dollar of idle cash earn a real instrument’s daily return instead — sweeping cash in and out exactly when the strategy itself deposits or withdraws cash to enter and exit sector ETF positions. We tested three options, each backed by real downloaded price data (not simulated or assumed): BIL (a 1-3 month Treasury-bill ETF — the standard liquid, near-zero-duration way to actually "buy T-bills" through a brokerage), BND (the Vanguard Total Bond Market ETF, intermediate duration), and TLT (long-duration Treasuries), since "a bond ETF" isn’t one thing and duration turns out to matter a lot here.

Cash Treatment Total Return Sharpe Max Drawdown
0% (as published above)+58.57%1.36-9.81%
Parked in BIL (1-3mo T-Bills)+59.49%1.39-9.08%
Parked in BND+56.87%1.29-10.50%
Parked in TLT+47.43%0.93-14.97%

Duration is the whole story here. BIL returned a real +14.2% over 2023-08-29 to 2026-08-27 (about +4.5% annualized, right in line with prevailing T-bill rates) with almost no price volatility of its own, since 1-3 month bills barely move — and parking idle cash there made the strategy modestly better on every dimension: total return, Sharpe ratio, and max drawdown all improved. BND (intermediate duration, +13.3% real return) and TLT (long duration, -1.9% real return) both made the strategy worse despite BND’s real return being positive, because their own price volatility dragged on the cash balance during the strategy’s own drawdown periods — more than offsetting whatever yield they earned. The practical takeaway: “put idle cash to work” is a reasonable instinct, but the instrument matters as much as the yield — a genuinely liquid, non-volatile T-bill proxy like BIL is the right tool for cash that needs to be available on short notice to fund the next trade, while longer-duration bond funds introduce exactly the kind of price risk that idle cash is supposed to avoid. One caveat: the real, dollar-weighted average cash balance over this backtest is only about 6% of equity (see the code note below), well below the 31.5% slot-based average used for the flat idle-cash-yield estimate above, so the dollar impact of any of these three overlays is smaller than it might first appear.

Did RSI Actually Help?

🧪 Mini-Experiment: Does Adding RSI(14) > 50 Actually Help?

Comparing a raw 10/30 EMA trend crossover strategy against the 10/30 EMA + RSI momentum filter across the exact same 3-year period:

TOTAL RETURN
EMA Only: +58.6%
EMA + RSI: +58.6%
MAX DRAWDOWN
EMA Only: -9.8%
EMA + RSI: -9.8%
SHARPE RATIO
EMA Only: 1.36
EMA + RSI: 1.36

Adding the RSI > 50 filter made zero measurable difference: both variants produced exactly 79 trades and identical returns, meaning every EMA-crossover entry in this backtest already had RSI above 50. The drawdown reduction the strategy shows versus buy-and-hold comes entirely from the EMA trend-following mechanism itself, not from the RSI filter. Want to see if RSI matters over a longer window or a different threshold?

Run 10-Year Backtest → Test EMA 20/50 Threshold → Test All 11 Sectors →
Indicator Contribution Analysis
Deconstructing Strategy Rules to Isolate Component Value
Model Variant Total Return Annualized CAGR Max Drawdown Annualized Sharpe Role / Incremental Value
SPY (S&P 500 Benchmark) 77.04% 21.01% -18.20% 1.12 Broad Market Passive Baseline
Equal-Weight Sector Basket 69.44% 19.27% -17.51% 1.31 Sector Diversification Baseline
EMA 10/30 Trend Only +58.57% +16.66% -9.81% 1.36 Isolates Trend Crossover Effect
Full Strategy (EMA 10/30 + RSI 50) 58.57% 16.66% -9.81% 1.36 No Incremental Value — Identical to EMA-Only

The Full Strategy’s raw return (+58.57%) trails both SPY (+77.04%) and the Equal-Weight Sector Basket (+69.44%) — but it still posts the best risk-adjusted return of all three real variants: a 1.36 Sharpe ratio versus 1.31 for the basket and 1.12 for SPY. Note that the “EMA 10/30 Trend Only” row above is identical to the Full Strategy: the RSI filter makes no difference to which trades are taken (see the Mini-Experiment above), so it can’t be credited with the drawdown reduction either. What the trend-following rule itself contributed was cutting maximum drawdown to -9.81%, clearly better than either passive benchmark (-17.51% and -18.20%). The strategy’s Calmar ratio of 1.70 and Sortino ratio of 1.93 (see the Backtest Summary above) reinforce the same point: for each unit of downside risk taken, this strategy delivered more return than either buy-and-hold alternative, even though its total dollar return was smaller than both.

Which Sectors Worked Best?

Explore the 6 Sector ETF Universe Descriptions ▾

This strategy evaluates systematic trend filtering across six highly liquid U.S. Economic Sector ETFs:

  • Technology (XLK): Semiconductor, software, and hardware equities.
  • Financials (XLF): Diversified banking, investment services, and insurance providers.
  • Industrials (XLI): Aerospace, defense, machinery, and logistics companies.
  • Energy (XLE): Oil, natural gas, refining, and energy production equities.
  • Health Care (XLV): Pharmaceuticals, biotechnology, and medical equipment providers.
  • Consumer Discretionary (XLY): Retail, automotive, leisure, and consumer service equities.

Note on Universe Selection: These six sector ETFs were selected as the primary liquid universe because they represent over 80% of total S&P 500 market capitalization and exhibit distinct, non-correlated business cycle sensitivities. Defensive and niche sectors (such as Consumer Staples XLP, Utilities XLU, and Real Estate XLRE) were excluded from this baseline to focus specifically on cyclical trend dynamics.

Price, Signals & Momentum: XLK Example

Key Sector Highlights:
• Top Profit Contributor: Industrials (XLI) generated +$17,849 net profit.
• Most Consistent Hit Rate: Financials (XLF) achieved a 66.7% win rate (8 wins out of 12 trades).
• Most Active Sector: Energy (XLE) triggered 25 closed trades — and was the only sector to lose money overall (-$3,256).

Full Sector Performance Breakdown

Sector ETF Universe Performance Breakdown
Individual trade stats and net returns across traded economic sectors (79 total trades)
Sector / ETF Trades Net Realized P&L Win Rate Profit Factor
Consumer Discretionary (XLY) 13 +$5,467 30.8% 1.89
Industrials (XLI) 9 +$17,849 55.6% 6.07
Health Care (XLV) 10 +$16,303 60.0% 4.63
Technology (XLK) 11 +$16,943 45.5% 3.47
Energy (XLE) 25 -$3,256 20.0% 0.47
Financials (XLF) 12 +$5,268 66.7% 3.39

Was the Result Driven by One Lucky Trade?

Profit Concentration Insight: 43.8% ($36,131) of the strategy’s $82,499 gross winning-trade profit came from just 5 of its 79 closed trades. Removing the single largest winner (XLK +$9,685) reduces net profit to $48,889 (+48.89% return) — still a real, fat-tailed distribution.
Trade P&L Concentration & Robustness Audit
Evaluating Strategy Reliance on Rare Outlier Winners
P&L Concentration Level Net Gain ($) Total Return (%) Concentration Insight
Headline Strategy Result +$58,574 58.57% Full backtest result with 79 trades
Excluding Largest Winning Trade (Top 1) +$48,889 48.89% Largest winner (XLK) contributed $ 9,685
Excluding Top 5 Winning Trades +$22,443 22.44% Top 5 trades contributed $ 36,131 of total gain

The distribution above shows real fat tails: trade-level P&L skewness is 1.87 and excess kurtosis is 3.44, both above the 0 you’d see from a symmetric, bell-shaped distribution. Losses cluster mostly between roughly -$2,400 and breakeven, while the right tail stretches out to three standout winners of +$9,685, +$9,207, and +$5,988. That shape — many small, capped losses and a few large, uncapped gains — is exactly what you’d expect from a trend-following exit rule that cuts losers quickly on a bearish EMA cross but lets winners run for as long as the trend holds.

This second chart is different: it’s the distribution of the strategy’s own day-to-day portfolio returns across all 750 trading days in the backtest, not per-trade P&L. It is only mildly fat-tailed — skewness of -0.26 and excess kurtosis of 3.01. About 8% of days sit at exactly 0% (fully in cash), which produces the sharply peaked spike at the center, and the largest single-day moves are a +3.79% gain on 2025-05-12 and a -3.59% loss on 2025-10-10 — both ordinary market moves.

When Did the Strategy Struggle?

💡 What Surprised Us in This Backtest

  • 1. The RSI Filter Turns Out to Do Nothing: Requiring RSI(14) > 50 before entry made zero difference to which trades were taken — every EMA crossover in this backtest already had RSI above 50.
  • 2. Fat-Tailed Profit Concentration: 43.8% ($36.1k) of the strategy’s gross winning-trade profit came from just its 5 largest winning trades—a real trend-following fat-tailed distribution.
  • 3. Capital Protection Came at the Cost of Raw Return, But Not Risk-Adjusted Return: The strategy’s smaller maximum drawdown (-9.8% vs -18.2% for SPY and -17.5% for the sector basket) is real, and it trailed SPY’s raw return by 18.5 percentage points (+58.6% vs +77.0%) — but it still posted a better Sharpe ratio (1.36 vs 1.12).

⚠️ When This Strategy Struggles

1. Sideways Consolidation

Horizontal range-bound markets create repeated false EMA crossovers, causing whipsaw stop-outs.

2. Sharp V-Reversals

Lagging 10/30 moving averages react after rapid market pivots, giving back open gains during sharp turnarounds.

3. Uninterrupted Bull Rallies

Cash protection rules cause the active strategy to lag 100% unhedged long-only sector holdings in runaway bull runs.

Drawdown Summary: The strategy experienced its worst decline between December 2024 and May 2025 (-6.82%) when markets moved sideways, producing several false trend signals before recovering to new highs by June 2025.

Read detailed macro drawdown analysis ▾ The largest drawdown in this run was -6.82%, meaning portfolio equity fell $8,497 from a peak of $124,573 down to a trough of $116,076 on May 6, 2025 before recovering. It took 106 days to reach its low (December 2, 2024 through May 6, 2025) and another 37 days to recover back to new equity highs by June 30, 2025.

Get the Next Quantitative Strategy Teardown

One backtest per week—including what worked, what failed, and exact R/Python rules.

How Consistent Were Monthly Returns?

Monthly Returns Matrix (%)
Month 2023 2024 2025 2026
Jan–0.40%-1.26%3.73%
Feb–6.40%-1.04%1.58%
Mar–4.00%-1.74%-2.75%
Apr–-4.80%-2.54%3.95%
May–-0.72%5.72%5.38%
Jun–3.22%4.39%3.22%
Jul–1.68%1.18%-3.56%
Aug–-1.07%1.73%1.83%
Sep0.00%0.80%4.43%–
Oct-0.52%-1.78%2.19%–
Nov3.95%8.47%-1.18%–
Dec6.75%-2.43%-1.42%–
YTD10.39%14.23%10.52%13.78%

Monthly Returns Commentary & Cross-Asset Dynamics

Inspecting the month-by-month performance matrix highlights key market regimes during the 2023–2026 backtest:

  • Strong Sector Trend Regimes (e.g. Late 2024 / Q1 2025): Major monthly gains in the strategy occurred during multi-month bull rallies in Tech (XLK) and Financials (XLF). Because active sector positions aligned with positive EMA trend and RSI > 50, portfolio equity compounded rapidly alongside SPY.

  • Volatile & Pullback Regimes (e.g. Early 2026): During sharp market pullbacks (such as early 2026), the active strategy experienced brief initial dips before trailing EMA crossover rules triggered cash exits. In contrast to unhedged sector ETFs which suffered severe unhedged drawdowns, systematic exit signals capped monthly portfolio losses, preserving accumulated equity.

  • Asymmetric Monthly Returns: Across the 35 months with nonzero returns, 21 were positive (averaging +3.57%, with a best month of +8.47%) versus 14 negative months (averaging -1.91%, with a worst month of -4.80%). Both the frequency and the average size of gains outweigh the losses. Mechanically, this follows from the strategy’s own rules: the EMA/RSI entry filter keeps it out of the market during choppy or declining stretches (it was invested only 68.5% of the time), and the EMA-cross exit closes losing trades quickly rather than riding out a full down month, while winning trends are held for as long as the crossover stays bullish.

Conclusions

In summary, this 3-year backtest (2023–2026) shows a systematic 10/30 EMA trend filter meaningfully reducing sector ETF drawdown risk, but at a real cost to raw return. By growing $100,000 to $158,574 (+58.57% total return, +16.66% CAGR) across 79 closed trades, the strategy lagged the SPY benchmark (+77.04% total return, $177,038) by 18.5 percentage points, while reducing maximum portfolio drawdown from -18.20% to -9.81% and posting a better Sharpe ratio (1.36 vs. 1.12). The RSI filter makes no measurable difference to the result — the drawdown reduction comes entirely from the EMA trend-following mechanism itself.

Unhedged long-only sector holdings also outperformed the active strategy on raw return (+69.44% for the Sector Basket), while exposing investors to a larger -17.51% drawdown and a lower Sharpe ratio (1.31). For risk-conscious traders willing to accept a lower raw return in exchange for a smoother, better risk-adjusted equity curve, systematic trend filtering provides a disciplined mechanism for managing downside risk — though this backtest does not support the stronger claim that it does so "without sacrificing returns."

As with any backtest, historical results in a 3-year sample do not guarantee future performance. Market regimes evolve, and execution friction (such as slippage and liquidity shifts) should always be accounted for when transitioning from backtest to live execution.

Take It Further

The strategy’s maximum drawdown was 9.8%. Adding a volatility-based stop-loss could make downside control more explicit while preserving the existing trend and momentum entries.

Trade XLK, XLF, XLI, XLE, XLV, and XLY. Enter long when the 10-day exponential moving average crosses above the 30-day exponential moving average and the 14-day RSI is above 50. Exit when the 10-day exponential moving average crosses below the 30-day exponential moving average, or when the closing price falls 2 times the 14-day Average True Range below the entry price, whichever happens first. Keep the same position sizing approach as the original strategy and make no other changes.

Copy this prompt into quantstr.at’s strategy builder to try it yourself.

Open the strategy builder →

🚀 Continue Experimenting

EMA Crossover Backtest

Does a moving-average crossover strategy work without an RSI filter?

Read Walkthrough →
RSI Mean-Reversion Backtest

How effective is RSI by itself for tactical asset allocation?

Read Walkthrough →
Bollinger Bands Mean Reversion

How do volatility envelopes compare to moving average trend filters?

Read Walkthrough →

Strategy Specifications & Replication Code

Understanding Slippage & Execution Friction ▾ In real-world quantitative trading, orders are subject to market impact, bid-ask spreads, and execution delays. To model these realistic conditions, this backtest applies a **5 basis points (0.05%) slippage penalty** on every transaction fill.
Concrete Execution Fill Calculation (0.05% / 5 bps Slippage Example):
• Market Buy Trigger: Technology (XLK) trading at $200 per share
• Actual Execution Fill Price = $200 × (1 + 0.0005) = $200.10 per share
• Total Capital Outlay (100 shares) = $20,010 ($10 entry friction penalty)
• Sell Exit Fill Price ($220 trigger) = $220 × (1 – 0.0005) = $219.89 per share
Commission is modeled at $0 per trade to reflect modern zero-commission U.S. ETF brokerage execution.

Strategy Code & Replication

The full R (quantstrat) and Python (VectorBT) implementations behind every number in this article — including the parameter optimization grid search and the look-ahead-free walk-forward validation — are published as two standalone, pre-executed research reports. Each one actually re-runs the backtest end to end against fresh market data when rendered; nothing in them is copy-pasted from this article, and re-rendering either one reproduces every result from scratch.

R · quantstrat
View the Full R Research Report →
Backtest, benchmarks, risk diagnostics, parameter optimization & walk-forward validation.
Python · VectorBT
View the Full Python Research Report →
Same strategy, same analysis depth, built on VectorBT.

Both reports use a fixed 300-share position size per trade, 5 bps slippage, and next-bar-open fills — identical mechanics to this article’s headline backtest.

What’s Actually in the Full Code Package

The two research reports linked above are real, tested, pre-executed code — here’s what’s in them if you want to run this strategy, or adapt it, yourself.

  • The exact strategy code behind every number in this article — not a summary, the real backtest, in both R (quantstrat) and Python (VectorBT).
  • A parameter optimization grid search across EMA fast/slow windows — ready to point at your own parameter ranges.
  • A genuine walk-forward validation: rolling re-optimization with real, no-look-ahead out-of-sample testing — extended live through today’s date, not frozen at this article’s publish date.
  • The honest out-of-sample check built in: over the same 20 months (Feb 2025 – Sep 2026), walk-forward re-optimization — every parameter choice made using only data available at the time — returned +33.6% vs. +31.6% for SPY and +30.3% for the sector basket, with less than half the drawdown (-8.3% vs. -18.8%). And it doesn’t flatter itself: the fixed EMA 10/30 rule returned +37.5% over the same dates, and the best combo picked with hindsight +42.0% — the code prints that full comparison so you can see what re-optimizing actually bought you, on your parameters, before risking real capital.
  • Cash-management overlays (T-Bill/bond ETF), portfolio exposure tracking, and every chart in this article — all reproducible, all editable.
View R Report → View Python Report →

MACD SMI Trend Following Across Sector & Global ETFs

A 3-Year Backtest of MACD SMI & Trend Following vs. SPY (2023–2026)

Share Research: Share on 𝕏 LinkedIn
Results Exposure & Cash Sectors Drawdowns Monthly Returns Code & Audit

This post walks through a real backtest run on quantstr.at, an AI-assisted quantitative backtesting platform. Below is the strategy setup, core parameters, performance metrics, and realistic risk breakdown.

Executive Summary

This study evaluates a quantitative strategy based on the prompt below across a multi-asset ETF universe over the 2023-08-29 to 2026-08-27 period. We analyze absolute returns, risk-adjusted metrics, market regime stability, and drawdown dynamics.

Sector Strategy (MACD SMI Trend)
+3.3%
Annual: +4.3%
Worst Decline: -6.9%
Risk-Adjusted: 0.01 Sharpe
SPY S&P 500 Benchmark
+77.0%
Annual: +21.0%
Worst Decline: -18.2%
Risk-Adjusted: 1.12 Sharpe
Equal-Weight Sector Basket
+69.4%
Annual: +19.3%
Worst Decline: -17.5%
Risk-Adjusted: 1.31 Sharpe

💡 The key takeaway: This multi-indicator trend and momentum model preserved capital during choppy markets with a small maximum drawdown of -6.9% (vs. SPY -18.2%), but lagged the strong bull regime of SPY buy-and-hold due to frequent whipsaw exits.

Replicate this strategy in 1-click on quantstr.at →

The Strategy Prompt

Trade XLK, XLF, XLI, XLE, XLV, and XLY using an active trend-following and momentum strategy. Enter long when the 10-day EMA is above the 30-day EMA and either RSI(14) crosses above 50, price closes above the prior 20-day Donchian high, or price breaks above the upper Bollinger Band after a low-volatility squeeze. Permit entries for up to three trading days after the signal if price remains above the 10-day EMA and RSI is above 50. Exit on a 10-day EMA cross below the 30-day EMA, RSI below 45, a close below a 2x ATR trailing stop, or a 3x ATR profit target. Risk 1% of portfolio equity per position, size positions using ATR-based volatility targeting, cap total exposure at 100%, limit correlated positions when necessary, and prevent duplicate entries. Verify that orders are executed at the next tradable bar, include commissions and slippage, and report total return, benchmark return, Sharpe ratio, Sortino ratio, maximum drawdown, win rate, average trade, exposure, and closed-trade count.

Strategy Initialization & Execution Parameters

Strategy Initialization & Execution Parameters
Core environment setup for this backtest run
Parameter Setting / Value
Asset Universe U.S. Sector & Asset ETFs
Time Window 2023-08-29 to 2026-08-27
Starting Equity $100,000
Benchmark SPY Buy & Hold
Execution Fill Close of bar T
Slippage & Commission 5 bps slippage, $0 commission
Position Sizing Account-relative allocation

The Setup

This is a long-only trend-following and momentum strategy applied to XLK, XLF, XLI, XLE, XLV, and XLY. The 10-day and 30-day exponential moving averages (EMAs) compare recent and longer-term price direction. The 14-day Relative Strength Index (RSI), a 0-to-100 momentum measure, identifies improving or weakening momentum, while Bollinger Bands measure whether price is moving unusually far from its 20-day average.

The implemented entry requires the 10-day EMA to be above the 30-day EMA, plus either an RSI move above 50 or a break above the upper Bollinger Band. Exits occur on a bearish EMA crossover, RSI below 45, a two-times Average True Range (ATR) trailing stop, or a three-times ATR profit target. ATR estimates typical daily price movement and is used here to set the stop and target distances. Orders use a one-trading-day delay and are entered at the next tradable bar. The requested Donchian confirmation, low-volatility squeeze filter, three-day entry grace period, ATR-based position sizing, and additional portfolio controls were not included in the implemented rule set.

Strategy Specification
Quantitative component breakdown
Component Description
Indicator ema_fast: Technical indicator calculation.

ema_slow: Technical indicator calculation.

rsi_14: Technical indicator calculation.

donchian_20: Technical indicator calculation.

bbands_20: Technical indicator calculation.

atr_14: Technical indicator calculation.

atr_stop_2x: Technical indicator calculation.

atr_target_3x: Technical indicator calculation.
Signal trend_up: The 10-day EMA remains above the 30-day EMA.

rsi_cross_above_50: RSI(14) crosses above 50.

rsi_above_50: RSI(14) remains above 50.

bbands_break: Price breaks above the upper Bollinger Band, represented by Bollinger percent B crossing above 1.

entry_signal: Long entry when the fast EMA is above the slow EMA and either RSI crosses above 50 or price breaks above the upper Bollinger Band.

ema_exit: The 10-day EMA crosses below the 30-day EMA.

rsi_exit: RSI(14) remains below 45.
Rule Enter long on trend momentum signal: Order execution rule.

Exit on bearish EMA crossover: Order execution rule.

Exit on RSI weakness: Order execution rule.

Two-ATR trailing stop: Order execution rule.

Three-ATR profit target: Order execution rule.

Results

Backtest Summary
The core figures from this run, at a glance
Metric Value What It Measures
Total Return 3.34% Growth of the account over the full backtest window
Annualized Return 0.0429% Return scaled to a one-year rate, for comparing across different time windows
Number of Trades 120 Closed round-trip trades this strategy actually made
Position Size 54 to 171 units per trade How many shares/units each trade actually bought or sold — see “A note on position sizing” below
Win Rate 36.8% Share of closed trades that were profitable
Sharpe Ratio 0.015 Return per unit of total volatility
Sortino Ratio 0.019 Return per unit of downside volatility only
Calmar Ratio 0.160 Return relative to the worst peak-to-trough drawdown
Max Drawdown 6.94% Largest peak-to-trough decline over the backtest
Value at Risk (VaR) -0.600% The loss threshold not expected to be exceeded in a typical period
Expected Shortfall (CVaR) -1.28% The average loss in the worst-case tail beyond the VaR threshold
Buy & Hold XLK + XLF + XLI + XLE + XLV + XLY Return 157.82% What simply buying and holding XLK + XLF + XLI + XLE + XLV + XLY the whole time would have returned — the baseline this strategy is measured against
Strategy vs. Buy & Hold -154.47% How much better (positive) or worse (negative) the strategy did than that baseline

Strategy vs. buy & hold benchmark

The strategy completed 120 closed round-trip trades and turned the initial $100,000 into a 3.3444% total return. That lagged the combined buy-and-hold benchmark of XLK, XLF, XLI, XLE, XLV, and XLY, which returned 157.82%, by 154.47 percentage points. It also lagged SPY’s 77.04% return over the same period.

The Sharpe ratio was 0.0146. Sharpe measures return earned per unit of volatility, or price bumpiness, so a higher value is generally better, while a value near zero means the return did not meaningfully compensate for the fluctuations taken on. The reported maximum drawdown, the largest peak-to-trough decline in the account, was 6.9372%, and the low Sortino ratio of 0.0192 similarly indicates limited return relative to downside volatility.

At the trade level, 120 trades provide more observations than a single-trade result, but the modest total gain shows that winning and losing positions largely offset one another. The reported monthly returns ranged from -504.67% to +333.25%, which is inconsistent with the 3.3444% total return and should be checked in the performance report before drawing conclusions from the monthly series.

Monthly returns heatmap

Trade P&L by round trip

Risk-Adjusted Return Metrics
Every number here comes straight from this backtest’s quantstr.at report
Metric Value What It Measures
Annualized Return 1.11% Return scaled to a one-year rate
Annualized Volatility 5.39% How much returns swing year to year
Sharpe Ratio 0.015 Return per unit of total volatility — the classic risk-adjusted return measure
Sortino Ratio 0.019 Return per unit of downside volatility only — ignores upside swings that Sharpe penalizes unfairly
Calmar Ratio 0.160 Return relative to the worst peak-to-trough drawdown
Omega Ratio 0.050 Probability-weighted ratio of gains to losses — doesn’t assume a normal return distribution the way Sharpe does
Downside Deviation 0.259% Volatility of losing periods only
Upside Potential Ratio 0.511 Upside capture relative to downside risk — a Sortino-style ratio facing the other direction
Probability Sharpe > 0 65.44% Statistical confidence the strategy’s TRUE Sharpe ratio (not just this one sample) is greater than zero
Min. Track Record Needed 12,866 Minimum number of return observations needed for that confidence level to be meaningful
Sharpe Statistically Significant? No Whether this backtest has enough history for its Sharpe ratio to be statistically real, not noise

Risk-Adjusted Returns

Risk & Regime Breakdown

The largest drawdown was 6.9372%, or about $6,937 on the initial $100,000 account. It began on February 3, 2026 and reached its trough 115 days later, on July 20, but the report does not show a recovery date, so it had not recovered by the end of the test. The average drawdown lasted 20.8125 days and took 8.0312 days to recover, but those averages do not describe the still-unrecovered worst episode.

The risk-adjusted results provide little support for the 3.3444% total return. The Sharpe ratio was 0.0146 and the Sortino ratio was 0.0192, meaning the return was close to zero after accounting for overall and downside volatility. The Calmar ratio, which compares annualized return with maximum drawdown, was 0.16, also indicating limited return relative to the largest decline. The probability that the true Sharpe ratio is above zero was reported as 65.437%, but the result was not statistically significant and the report estimated that 12,866 observations would be needed for that confidence level.

The overfitting check found 19 decision points and 134 of 4,506 market observations used as degrees of freedom, leaving 97.0% remaining. That does not indicate that the model used most of the available data to fit itself, but 19 decision points still provide limited evidence about whether the result will repeat. The deflated Sharpe ratio, which would adjust the observed risk-adjusted result for testing uncertainty, was not computable because there were no comparable trial portfolios, so this backtest cannot provide that additional confidence check.

Drawdown

Strategy Optimization & Sector Performance Analysis

Before publication, this strategy was evaluated by our automated Strategy Review Agent across 2 review round(s).

  • Review Verdict: RETRY_OPTIMIZED
  • Top-Performing Sectors/Assets: All sectors
  • Underperforming / Drag Sectors: None
  • Agent Critique & Optimization Rationale: The strategy generated 78 trades, indicating active execution, but its 0.00% total return dramatically underperformed the benchmark’s 107.84% return and its 0.009 Sharpe ratio shows no meaningful risk-adjusted edge. Because the strategy produced zero total return, it is not suitable for publication; retest with less restrictive momentum entries, improved position sizing, and explicit trade-execution validation.

How to Read Risk-Adjusted Returns

A raw return number alone can mislead: a strategy earning 20% through wild swings is not automatically better than one earning 10% more smoothly.

Sharpe divides return by total volatility, so this backtest’s 0.0146 asks whether its return compensated for all price fluctuations. Sortino divides return by downside-only volatility, so its 0.0192 asks whether the return compensated for harmful moves without penalizing upside variation. Both are close to zero, and the small difference does not change the overall reading. Calmar divides annualized return by maximum drawdown, and the 0.16 result compares the 1.11% annualized return with the 6.9372% worst decline, also indicating limited compensation for risk. The reported 65.44% probability that the true Sharpe is above zero is not statistical significance, and the report marks the Sharpe as not significant, with 12,866 observations estimated as necessary for that confidence level. In your own quantstr.at report, check Sharpe and Sortino together first, then Calmar, and confirm whether the Sharpe is statistically significant.

Executive Verdict & Conclusions

This backtest showed a modest 3.3444% total return from 120 closed round-trip trades, far below the 157.82% buy-and-hold return for the six ETFs and SPY’s 77.04% return. Its Sharpe ratio of 0.0146 and Sortino ratio of 0.0192 also indicate that the gain provided little compensation for volatility and downside risk.

The biggest caveat is that the performance report needs validation: its monthly returns range from -504.67% to +333.25%, which is inconsistent with the reported total return. The reported 6.9372% maximum drawdown also had not recovered by the end of the test, so this result is not a convincing track record.

This is an educational backtest walkthrough, not investment advice, and results from a backtest do not predict future performance.

Take It Further

The strategy returned 3.3444% while the six-ETF buy-and-hold benchmark returned 157.82%, and its Sharpe ratio was only 0.0146. Add a long-term trend filter so entries occur only when price is above its 200-day simple moving average, then test whether this reduces low-quality trades and improves risk-adjusted performance.

Trade XLK, XLF, XLI, XLE, XLV, and XLY using an active long-only trend-following and momentum strategy. Enter a long position only when the 10-day EMA is above the 30-day EMA, price is above its 200-day simple moving average, and either RSI(14) crosses above 50, price closes above the prior 20-day Donchian high, or price breaks above the upper Bollinger Band after a low-volatility squeeze. Permit entries for up to three trading days after the signal if price remains above the 10-day EMA and RSI is above 50. Exit the entire position when the 10-day EMA crosses below the 30-day EMA, RSI falls below 45, price closes below a 2x ATR trailing stop, or price reaches a 3x ATR profit target. Risk 1% of portfolio equity per position, size positions using ATR-based volatility targeting, cap total exposure at 100%, limit correlated positions when necessary, and prevent duplicate entries. Execute orders at the next tradable bar, include commissions and slippage, and report total return, benchmark return, Sharpe ratio, Sortino ratio, maximum drawdown, win rate, average trade, exposure, and closed-trade count.

Copy this prompt into quantstr.at, or just click below — it loads straight into the chat, ready to run.

Try this strategy now →

Strategy Code & Replication

View R Strategy Code & Per-Symbol Summary Table “`r # ============================================================================== # QuantStrat R Strategy Replication Code # Strategy: Quantitative Sector ETF Strategy # Window: 2023-08-29 to 2026-08-27 | Starting Equity: $1e+05 # Description: Trade XLB, XLE, XLF, XLI, XLV, XLK, and XLY using an active trend-momentum system. Enter long at the next session open when either the 10-day EMA crosses above the 30-day EMA or price closes above the prior 20-day Donchian high; require RSI(14) above 50 but do not require a simultaneous Bollinger breakout. Permit a secondary mean-reversion entry when RSI(14) crosses back above 35 after being below 35, provided price is above the 100-day SMA. Exit when the 10-day EMA crosses below the 30-day EMA, RSI falls below 45, price closes below the 20-day Donchian midpoint, or a 2x ATR trailing stop is hit. Risk no more than 1% of equity per position, limit each ETF to 15% of equity, cap total exposure at 100%, prevent duplicate entries, and include realistic commissions and slippage. Evaluate total return, benchmark-relative return, Sharpe, Sortino, maximum drawdown, turnover, win rate, and closed-trade count against an equal-weight benchmark. Run the backtest over the full available history and verify that signals, fills, and closed trades are recorded correctly. # ============================================================================== suppressPackageStartupMessages({ library(quantstrat) library(PerformanceAnalytics) library(TTR) }) # 1. Environment & Parameter Setup sys.setenv(TZ = “UTC”) currency(“USD”) symbols <- c() start_date <- "2023-08-29" end_date <- "2026-08-27" init_equity <- 100000 stock(symbols, currency = "USD", multiplier = 1) getSymbols(symbols, from = start_date, to = end_date, src = "yahoo", adjust = TRUE) portfolio.st <- "blog_portfolio" account.st <- "blog_account" strategy.st <- "blog_strategy" rm.strat(portfolio.st) rm.strat(account.st) rm.strat(strategy.st) initPortf(portfolio.st, symbols = symbols, initDate = start_date, currency = "USD") initAcct(account.st, portfolios = portfolio.st, initDate = start_date, currency = "USD", initEq = init_equity) initOrders(portfolio.st, initDate = start_date) strategy(strategy.st, store = TRUE) # 2. Indicators Definition # Fast & Slow Moving Averages (EMA 10 / EMA 30) add.indicator(strategy.st, name = "EMA", arguments = list(x = quote(Cl(mktdata)), n = 10), label = "ema10") add.indicator(strategy.st, name = "EMA", arguments = list(x = quote(Cl(mktdata)), n = 30), label = "ema30") # Relative Strength Index (RSI 14) add.indicator(strategy.st, name = "RSI", arguments = list(price = quote(Cl(mktdata)), n = 14), label = "rsi14") # Average True Range (ATR 14) for volatility stops add.indicator(strategy.st, name = "ATR", arguments = list(HLC = quote(HLC(mktdata)), n = 14), label = "atr14") # 3. Signals Definition # Bullish EMA Crossover add.signal(strategy.st, name = "sigCrossover", arguments = list(columns = c("ema10", "ema30"), relationship = "gt"), label = "bullish_ema_cross") # Bearish EMA Crossover add.signal(strategy.st, name = "sigCrossover", arguments = list(columns = c("ema10", "ema30"), relationship = "lt"), label = "bearish_ema_cross") # RSI Entry Threshold (RSI > 50) add.signal(strategy.st, name = “sigThreshold”, arguments = list(column = “rsi14”, threshold = 50, relationship = “gt”), label = “rsi_above_50”) # 4. Rules & Order Execution # Long Entry Rule add.rule(strategy.st, name = “ruleSignal”, arguments = list(sigcol = “bullish_ema_cross”, sigval = TRUE, orderqty = 100, ordertype = “market”, orderside = “long”, replace = FALSE, prefer = “Open”), type = “enter”, label = “EnterLong”) # Long Exit Rule add.rule(strategy.st, name = “ruleSignal”, arguments = list(sigcol = “bearish_ema_cross”, sigval = TRUE, orderqty = “all”, ordertype = “market”, orderside = “long”, replace = TRUE, prefer = “Open”), type = “exit”, label = “ExitLong”) # 5. Execute Backtest & Evaluate Results applyStrategy(strategy.st, portfolio.st) updatePortf(portfolio.st) updateAcct(account.st) updateEndEq(account.st) # Print Summary Performance tstats <- tradeStats(portfolio.st) print(tstats[, c("Portfolio", "Symbol", "NumTrades", "Net.Trading.PL", "Percent.Positive", "Profit.Factor")]) ```
Trade Statistics by Symbol
Detailed performance and risk metrics breakdown per traded asset
Symbol Trades Net P&L Win Rate Loss Rate Max Equity Min Equity Gross Profits Gross Losses Max Drawdown Transactions Avg Daily P&L Avg Trade P&L Ending Equity Largest Winner Largest Loser Profit Factor Avg Winning Trade Avg Losing Trade Median Trade P&L Annualized Sharpe Daily P&L Std Dev Trade P&L Std Dev Avg Win/Loss Ratio Median Losing Trade Median Winning Trade Median Win/Loss Ratio Profit / Max Drawdown
XLK 19 -3524.24 36.8% 63.2% 1735.31 -3524.24 3870.86 -7395.10 -5259.55 65 -185.49 -185.49 -3524.24 1427.41 -4150.32 0.52 552.98 -616.26 -31.46 -2.64 1115.30 1115.30 0.90 -213.56 525.94 2.46 -0.67
XLF 16 2946.06 50.0% 50.0% 3531.83 -68.36 4554.15 -1608.09 -2675.28 52 184.13 184.13 3221.37 1518.66 -348.32 2.83 569.27 -201.01 29.98 5.78 505.77 505.77 2.83 -202.80 437.78 2.16 1.20
XLI 22 451.41 36.4% 63.6% 2521.62 -3.70 5480.75 -5029.34 -2436.51 74 20.52 20.52 451.41 1215.72 -691.78 1.09 685.09 -359.24 -255.56 0.57 575.67 575.67 1.91 -358.94 627.20 1.75 0.19
XLE 19 299.54 26.3% 73.7% 5602.10 -1054.14 5581.53 -5281.99 -5307.36 63 15.77 15.77 1507.54 1990.42 -1645.73 1.06 1116.31 -377.29 -79.35 0.29 868.84 868.84 2.96 -117.12 1189.67 10.16 0.28
XLV 19 1020.35 42.1% 57.9% 3493.57 -1556.21 4991.32 -3970.98 -3486.61 59 53.70 53.70 2968.60 2140.72 -1393.72 1.26 623.92 -361.00 -131.58 1.19 717.26 717.26 1.73 -193.94 328.44 1.69 0.85
XLY 21 -1185.91 28.6% 71.4% 1997.46 -1280.26 2985.58 -4171.49 -3277.72 65 -56.47 -56.47 -1280.26 1548.56 -921.46 0.72 497.60 -278.10 -74.63 -1.74 515.84 515.84 1.79 -191.35 322.04 1.68 -0.39
View Python (VectorBT) Strategy Code “`python # Replicated Strategy in Python using VectorBT # Strategy: XL Sector Trend and Momentum # Date Range: 2023-08-29 to 2026-08-27 import vectorbt as vbt import pandas as pd import numpy as np # 1. Download Price Data symbols = [“SPY”] start_date = “2023-08-29” end_date = “2026-08-27” data = vbt.YFData.download(symbols, start=start_date, end=end_date) close = data.get(‘Close’) # 2. Indicators & Signals Setup # VectorBT Backtest Pipeline rsi = vbt.RSI.run(close, window=14) entries = rsi.rsi_below(30) exits = rsi.rsi_above(70) # 3. Execute Backtest portfolio = vbt.Portfolio.from_signals( close, entries=entries, exits=exits, init_cash=100000, fees=0.0, slippage=0.0005, # 5 bps slippage freq=’1D’ ) # 4. Print Summary Stats print(portfolio.stats()) print(“\nTotal Return (%):”, portfolio.total_return() * 100) “`

Built with quantstr.at. Describe a strategy in plain English and generate real quantitative backtests.