Trend FollowingUpdated 2026-12-05

Moving Average Crossover Stock Backtest

Test classic trend-following golden cross and dual-SMA signals across US equities with realistic execution costs.

TRY IT LIVE · NO LOGIN REQUIRED

Run a Real US Stock Backtest in Seconds

Powered directly by our 93.4M-row Sharadar adjusted daily bar database with 10 bps per-side commission & slippage modeled.

STRATEGY RETURN
+245.2%
$34,524 from $10k
CAGR
+25.8%
Buy & Hold Benchmark: +119.7%
SHARPE RATIO
0.95
Annualized (252d)
MAX DRAWDOWN
-30.2%
Peak-to-trough
WIN RATE / TRADES
50%
23 fills · 1360 bars
META · Moving Average Crossover (20/60 SMA) (2021-03-03 → 2026-07-31)2026-07-31Strategy: $34,524Buy & Hold Benchmark: $21,966

Single-ticker live simulation (10 bps modeled cost per side, next-bar execution vs. dashed Buy & Hold Benchmark). Timing rules are designed to cap severe bear-market drawdowns and improve risk-adjusted stability—not to beat concentrated buy-and-hold in every bull rally.

Want custom Python rules, full trade blotters, parameter grids & 59,451 active + delisted US tickers?Sign Up Free for Full Report
Moving Average Crossover US equity backtest summary card (2006-01-01 to 2026-07-31)
Moving Average Crossover reference profile across 2006-01-01 to 2026-07-31 (US Large-Cap Liquid Equities (AAPL, MSFT, NVDA, AMZN, META)) — modeled with split-adjusted Sharadar daily bars, next-bar execution, and explicit trading friction.

Multi-Stock Portfolio Reference Backtest (2006-01-01 to 2026-07-31)

Portfolio-level benchmark (Daily close signal, next-day execution, equal-weighted across US Large-Cap Liquid Equities (AAPL, MSFT, NVDA, AMZN, META)) — distinct from the single-ticker interactive simulator above.

CAGR (Annualized)
11.4%
Sharpe Ratio
0.84
Max Drawdown
-24.8%
Win Rate
46.2%
Annual Turnover
1.8x / yr
Modeled Trades
142

Reference universe: US Large-Cap Liquid Equities (AAPL, MSFT, NVDA, AMZN, META) · Benchmark: SPY (S&P 500 ETF) · Execution: Daily close signal, next-day execution. Simulated historical results are illustrative and depend on selected tickers and date ranges.

Strategy Rules

  • Compute adjusted close simple moving averages (fast_window and slow_window) on survivorship-aware Sharadar daily bars.
  • Enter equal-weighted long position on next open when fast SMA crosses above slow SMA.
  • Exit to cash when fast SMA closes below slow SMA to cap prolonged bear-market drawdowns.
  • Apply commission and slippage on every rebalance event and compare equity curve against SPY.

Default Parameters

fast_window20

Short-term simple moving average (trading days)

slow_window60

Long-term trend filter moving average (trading days)

commission_rate0.0005

5 bps per side modeled execution commission

slippage_rate0.0005

5 bps slippage applied to every fill

Python Signal Logic

def generate_signals(df, params):
    fast = int(params.get("fast_window", 20))
    slow = int(params.get("slow_window", 60))
    close = df["close_adj"]
    sma_fast = close.rolling(fast).mean()
    sma_slow = close.rolling(slow).mean()
    return (sma_fast > sma_slow).astype(float)

When This Strategy Fails: 2008, 2020 & 2022 Market Regimes

A moving average crossover is structurally designed to sidestep prolonged bear markets, not to beat buy-and-hold in every calendar year. Auditing 20 years of US equity daily bars reveals three distinct regimes where dual-SMA rules either protect capital decisively or bleed through whipsaws.

2008 Global Financial Crisis

Prolonged Structural Bear Market

The 20/60 SMA exited major US equities early in 2008 and stayed predominantly in cash during the autumn collapse, cutting maximum drawdown by more than half relative to SPY (-55% peak-to-trough). However, sharp bear-market rallies in May 2008 and early 2009 triggered brief false re-entries that trimmed 3%–5% off peak cash preservation.

Practical mitigation: Requiring a 2-to-3 day confirmation close above the slow average or pairing with a 200-day macro index filter removes most short-lived bear-rally whipsaws.

2020 COVID-19 Crash & V-Rebound

Extreme Speed Shock & Rapid Reversal

Because the S&P 500 fell 34% in just 23 trading days during February–March 2020, lagging moving averages exited near the bottom of the liquidation wave and did not re-enter until equities had already recovered 15%–20% off the March lows.

Practical mitigation: Combining a faster 20/60 window with volatility-scaled position sizing reduces forced liquidation lag during single-month event shocks without abandoning crash protection.

2022 Rate-Hike Bear Market

Choppy Multi-Wave Downtrend

Throughout 2022, US mega-cap growth stocks staged three separate 12%–18% counter-trend rallies inside a year-long Federal Reserve tightening cycle. Fast crossovers (10/30) repeatedly bought near local rally peaks and stopped out lower, whereas slower 50/200 pairs stayed safely defensive for most of the year.

Practical mitigation: Testing both 20/60 and 50/200 side by side across 2022 exposes whether a strategy relies on low-volatility bull markets or genuinely survives rising-rate chop.

Additional Execution & Model Risks

  • Trend-following crossovers suffer whipsaw losses during sideways, range-bound markets.
  • Lagging moving averages give back part of peak gains before signaling an exit.
  • Always test parameter sensitivity across multiple rolling windows before trusting a single lookback pair.

Parameter Sensitivity & Window Selection

Moving average lookback windows directly trade off reaction speed against whipsaw frequency. When you run a parameter sweep in Quant Atlas Workbench, look for a broad performance plateau across neighboring pairs rather than chasing a single narrow spike.

Parameter VariantCAGRSharpeMax DDTurnoverResearch Takeaway
10 / 30 SMA (Fast Swing)9.8%0.69-27.4%4.6x / yrCaptures early reversals quickly but suffers heavy whipsaw drag and 2.5x higher friction in sideways years.
20 / 60 SMA (Balanced Default)11.4%0.84-24.8%1.8x / yrBest overall balance of drawdown containment and reasonable turnover across multi-decade US large-cap pools.
50 / 200 SMA (Golden Cross)10.6%0.81-26.1%0.6x / yrUltra-low turnover and tax-friendly holding periods; slower to exit fast crashes like February–March 2020.
20 / 120 SMA (Asymmetric Filter)11.1%0.85-22.9%1.2x / yrFast exit confirmation paired with a slower baseline trend reduces false entries during 2015–2016 and 2022 chop.

How Moving Average Crossover Compares to Adjacent Strategies

No single technical rule dominates every market cycle. Comparing moving average crossovers against volatility breakouts, mean reversion, and cross-sectional momentum clarifies how to combine uncorrelated sleeves in a US stock portfolio.

Bollinger Bands Strategy

Best regime: Post-compression volatility breakouts in growth leaders

Weak regime: Mean-reverting value stocks and wide choppy ranges

Bollinger breakouts adapt automatically to recent volatility via standard deviation, whereas dual-SMA uses fixed time windows.

Inspect Bollinger Bands Strategy

Mean Reversion Strategy (RSI)

Best regime: Short-term pullbacks inside steady bull markets

Weak regime: Prolonged liquidation waves and structural downtrends

RSI mean reversion achieves higher win rates (63.8% vs 46.2%) and thrives in sideways ranges where moving average crossovers get whipsawed.

Inspect Mean Reversion Strategy (RSI)

Momentum Strategy (12-1M)

Best regime: Persistent sector leadership and multi-quarter bull runs

Weak regime: Sudden factor reversals (e.g., April 2009 rebound)

Cross-sectional momentum ranks stocks against each other for higher upside CAGR, while dual-SMA is a pure time-series risk filter.

Inspect Momentum Strategy (12-1M)

Frequently Asked Questions

Does moving average crossover work on US stocks?

Moving average crossovers primarily reduce severe bear-market drawdowns rather than maximizing bull-market returns. Testing across 20+ years of US market cycles shows lower volatility and shallower drawdowns than buy-and-hold, with trade-offs during choppy sideways periods.

Which lookback periods should I test first?

Start with 20/60 days for medium-term swing regimes and 50/200 days for secular trend filtering. In Quant Atlas Workbench, you can run a parameter grid experiment to verify whether performance holds across neighboring windows.

Is EMA (Exponential Moving Average) better than SMA for stock backtesting?

Across 20-year US equity daily bars, EMA reacts 2 to 4 trading days faster than SMA at turning points, which helps slightly during sharp 2020-style drops but increases whipsaw trades in range-bound years like 2015. The net Sharpe ratio difference after 10 bps round-trip costs is usually less than 0.05.

Why does a moving average crossover backtest need adjusted prices?

Unadjusted price series contain artificial 50%–90% drops on stock split dates (such as AAPL 4-for-1 or NVDA 10-for-1) and ignore cash dividends. Using split- and dividend-adjusted Sharadar daily bars ensures moving averages reflect true economic returns.

How can I reduce whipsaw losses in a moving average crossover strategy?

Three practical filters work well in out-of-sample tests: adding a minimum 1%–2% separation buffer between the fast and slow SMA, requiring two consecutive closes past the crossover, or pairing single-stock signals with an S&P 500 200-day regime filter.

Primary Data & Empirical Research References

  • Time Series Momentum
    Moskowitz, Ooi & Pedersen — Journal of Financial Economics / AQR

    Foundational empirical study documenting persistent time-series trend predictability across equity indices and asset classes.

  • Sharadar Core US Equities Bundle (SEP / SF1)
    Nasdaq Data Link Documentation

    Primary data methodology reference for split-adjusted daily bars, corporate actions, and survivorship-free US ticker coverage.

  • S&P 500 Historical Market & Macro Regime Benchmarks
    Federal Reserve Economic Data (FRED)

    Official macro and benchmark series used to contextualize 2008, 2020, and 2022 US equity drawdown regimes.

More US Equity Strategy Templates

Related Stock Backtesting Guides

Author: Daxi, Founder & Quantitative Researcher · Data: Sharadar US Equities (1997–2026)

Quant Atlas provides historical market data and backtesting software for research and educational purposes only. Past simulated performance does not guarantee future results and does not constitute financial or investment advice.