Mean reversion trading strategy (rules, code and the trend trap)

Mean reversion is momentum's opposite twin: it bets that stretched prices snap back toward their average. Buy oversold, sell overbought, pocket the bounce. It has a flattering signature — a high win rate that feels great — and a dangerous one: the rare loss can be huge, because “oversold” in a real downtrend just keeps getting more oversold. This guide explains the rules with RSI and Bollinger bands, shows the code, and is blunt about the trap that blows up reversion traders.

On this page
  1. The core idea
  2. RSI & Bollinger rules
  3. The code
  4. High win rate, fat-tail loss
  5. The trend trap
  6. Sizing & risk
  7. FAQ

The core idea

Prices oscillate around an average. Mean reversion assumes that when price stretches far from that average, it tends to snap back — so you buy unusual weakness and sell unusual strength. It thrives in range-bound, choppy markets, which is most markets, most of the time. The catch is the minority of the time when price doesn't revert.

The rules: RSI and Bollinger bands

mean upper lower buy sell buy
Buy at the lower band/oversold, sell at the upper band/overbought — harvesting the oscillation around the mean.

The code

python · mean_reversion.pydef rsi(closes, n=14):
    d = [closes[i]-closes[i-1] for i in range(1,len(closes))]
    up = sum(x for x in d[-n:] if x>0)/n
    dn = -sum(x for x in d[-n:] if x<0)/n or 1e-9
    return 100 - 100/(1+up/dn)

r = rsi(closes)
if r < 30: signal = 'buy'     # oversold
elif r > 70: signal = 'sell'   # overbought

The signature: high win rate, fat-tail loss

The flattering trap

Mean reversion wins often — 65–75% win rates are common — which feels wonderful and breeds overconfidence. But the losers, when they come, are large: a position bought “oversold” that keeps falling. Judge reversion by profit factor and worst-case drawdown, not by its seductive win rate.

The trend trap that blows up reversion traders

“Oversold” can stay oversold for a long time

In a strong downtrend, every dip looks like a buy and every buy loses more. Mean reversion without a trend filter or a hard stop is how accounts blow up catching falling knives. Always pair it with a stop, and consider only trading reversion when a longer-term trend filter says the market is ranging, not crashing.

Sizing and risk

Because the rare loss is the big one, mean reversion lives or dies on risk control. Use a hard stop (not “it'll come back”), size small with the position calculator, and never average down without a cap. Compare RSI mean reversion against momentum on the same market in the backtester — their mirror-image profiles are the clearest lesson in regime matching.

Not financial advice. This content is educational. Automated and algorithmic trading carries a real risk of financial loss. Never trade money you cannot afford to lose. Review the SEC investor.gov and CFTC resources before trading.

Frequently asked questions

What is a mean reversion trading strategy?

Mean reversion bets that prices stretched far from their average will snap back, so you buy oversold and sell overbought using tools like RSI or Bollinger bands. It thrives in range-bound markets and has a high win rate but occasional large losses.

Why does mean reversion have a high win rate but still risk big losses?

Most reverting trades win small as price bounces back, producing a flattering win rate. But when price doesn't revert — in a strong trend — the loss can be large because 'oversold' keeps getting more oversold. Judge it by profit factor and drawdown.

What is the biggest risk in mean reversion trading?

The trend trap: in a sustained downtrend every dip looks like a buy and keeps losing. Trading reversion without a stop or a trend filter is how traders catch falling knives and blow up. Always use a hard stop and avoid crashing markets.

How is mean reversion different from momentum?

They're opposites. Momentum buys strength and rides trends with a low win rate and big winners; mean reversion buys weakness expecting a bounce, with a high win rate and rare large losses. Momentum wins in trends, reversion wins in ranges.

MB

Mustafa Bilgic

Algorithmic trading practitioner · Founder, AITradingBot.us

Mustafa builds and backtests automated trading systems and writes about them without the hype. Every tool on this site is free and runs entirely in your browser.