Mean reversion strategy: rules, edge and the trend trap

Mean reversion is the bet that price, after stretching too far from its average, snaps back. It is the opposite of trend following and powers many quant and grid systems. The edge is real in calm, range-bound markets — and it can be brutally destroyed by a single strong trend. This guide covers the rules, the math, and the risk.

On this page
  1. The core idea
  2. The z-score entry
  3. The trend trap
  4. The code
  5. FAQ

The core idea

Mean reversion assumes that extreme moves are partly noise and that price will revert toward a "fair" value — usually a moving average. When price drops well below average, a reversion trader buys, expecting a bounce; when it spikes above, they sell. The strategy wins many small trades in choppy markets, which is the opposite profile of momentum trading, which wins a few big trades and loses many small ones.

equitytime steady compoundingdeep drawdown
A smooth equity curve compounds; a volatile one with deep drawdowns risks ruin even at the same average return.

The z-score entry

A clean way to define "too far" is the z-score: how many standard deviations price sits from its moving average. A common rule enters long when the z-score falls below −2 and exits when it returns toward 0. This is exactly what the lower Bollinger Band represents visually. The z-score makes the rule adaptive — the threshold scales with volatility instead of being a fixed dollar distance.

The trend trap

Mean reversion has a fat left tail

The strategy collects small, frequent profits and occasionally takes one enormous loss when a market trends hard and never reverts. Buying every dip in a crash is the textbook way to blow up an account. The fix is a hard stop-loss and a regime filter that disables reversion when a strong trend is detected — accepting that you will sit out some range trades to avoid catastrophe. Learn how to size for it in position sizing.

The code

python · reversion.pyimport statistics as st
window = closes[-20:]
mean = sum(window)/20; sd = st.pstdev(window)
z = (price - mean) / sd if sd else 0
if z < -2 and not strong_trend: signal = 'buy'
elif z > 0: signal = 'exit'

Always backtest reversion across both calm and trending periods in the backtester. A backtest that only covers a sideways year will wildly overstate the edge.

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

It is a strategy that buys when price falls well below its average and sells when it rises above, betting that price reverts toward the mean. It wins frequent small trades in range-bound markets and is the opposite of trend following.

Why does mean reversion blow up?

Because it collects small profits and occasionally takes one huge loss when a market trends and never reverts — buying every dip in a crash. A hard stop-loss and a trend filter are essential to survive.

What is a good z-score threshold for entries?

Many traders use −2 to enter longs and 0 to exit, but the right threshold depends on the market and timeframe. It should be chosen by robust out-of-sample testing, not curve-fitting to a single period.

Is mean reversion better than trend following?

Neither is better universally. Mean reversion thrives in ranges and suffers in trends; trend following is the reverse. Many systematic traders run both so one profits when the other struggles.

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.