LoginEnter the platform free
DOMINA › Technical analysis › Technical strategies › Mean reversion

Mean reversion: what it is and how to measure it

InteractiveFind the sessions far from the meanOne click on a real chart and the page tells you how far the price was from the mean, in deviations, and whether it was beyond the threshold.Try it →

Mean reversion on a real stock

Mean reversion is the idea that a price far from its average tends to move back towards it. It is measured with the z-score: how many standard deviations separate the close from the mean of the last N sessions; beyond ±2 the distance is treated as extreme.

Strategy · z-score · N-day mean and deviation · threshold in deviations
Mean reversion β€” the return to the mean
Example: Goldman Sachs · 20-day mean and standard deviation, ±2 threshold · adjusted prices
volumeperiod start 178.94sideways phasetrend20-day mean293.60164.37283.69Jun 18, 2020Aug 20, 2020Oct 21, 2020Dec 23, 2020Feb 26, 2021
+20 = on the mean−20.9720-day z-score
Sessions175Beyond +211Beyond −27Above the mean in a row52

On the price, the dashed amber line is the N-day mean and the blue lines sit at plus and minus the threshold in deviations; beneath it, the z-score, with the zones beyond the threshold in amber. The two vertical bands are the sideways phase (blue) and the trend (amber), found with the rules written at the bottom of the page.

InteractiveRead a session. Click a day on the chart or on the panel: I tell you the close, the mean, how far the price was from it and whether it was beyond the threshold.

What is mean reversion?

A price swings around a reference: the average of its last sessions. Mean reversion starts from a hypothesis: when the distance from the mean becomes very large, it tends to shrink. Those who use it buy when the price is far below the mean and sell when it is far above.

Fig. 1 · The idea: the price moves away from the mean and comes back

far abovefar belowmeanof the last N sessionsmoves awaythe distance growsand comes backthe distance shrinks
  • The mean is the reference: the dashed line.
  • The price moves away from it, above or below.
  • The hypothesis is that an extreme distance will shrink.
  • You need a measure of β€œextreme”: the eye is not enough.

How do you measure the distance from the mean? The z-score

A distance in dollars is not enough: two dollars are a lot for a calm stock and little for a volatile one. The z-score measures it in standard deviations, that is, in the typical size of that stock’s swings over that period.

mean = (C1 + C2 + … + CN) / N  ·  standard deviation = √( Σ (Ci − mean)² / N )
z = (today’s close − mean) / standard deviation  ·  here N = 20 and the threshold is ±2

Fig. 2 · How the z-score works: the distance from the mean measured in deviations

+20−220-day z-score+2 deviationshere the z-score is +2mean−2 deviationshere the z-score is −2beyond the thresholdan extreme distancez = 0the price is on the mean
  • z = 0: the price is on the mean.
  • z = +2: the price is two deviations above, on the upper blue line.
  • Beyond ±2, in the amber bands, the distance is treated as extreme.
  • The threshold is a choice: at the bottom of the page you can try 1.5, 2 and 2.5.

With N = 20 and a threshold of 2, the two blue lines are John Bollinger’s Bollinger Bands: a 20-day mean plus and minus two standard deviations. z = +2 means a close on the upper band, z = −2 a close on the lower band. The z-score says the same thing in a single number, and it can be compared across different stocks.

Fig. 3 · The same distance, two stocks

calm stocksmall deviationz = +3volatile stocklarge deviationz = +1the same distance from the mean, in dollars
  • On the left a calm stock: the same distance is z = +3.
  • On the right a volatile stock: it is z = +1.
  • That is why the distance is measured in deviations, not in dollars.

The z-score calculated by hand, on a real session

Goldman Sachs, the session furthest below the mean in the sideways phase

The 20 closes up to , as the page’s data carries them (two decimals). With these you can redo the calculation by hand and find the z-score of the panel: −2.61.

October 1, 2020: 175.35 · October 2, 2020: 176.54 · October 5, 2020: 178.22 · October 6, 2020: 177.59 · October 7, 2020: 179.81 · October 8, 2020: 183.68 · October 9, 2020: 183.29 · October 12, 2020: 189.10 · October 13, 2020: 186.18 · October 14, 2020: 186.55 · October 15, 2020: 184.23 · October 16, 2020: 182.12 · October 19, 2020: 181.66 · October 20, 2020: 183.72 · October 21, 2020: 179.20 · October 22, 2020: 181.40 · October 23, 2020: 181.08 · October 26, 2020: 177.64 · October 27, 2020: 172.82 · October 28, 2020: 167.60

The z-score of Goldman Sachs on , with N = 20
StepCalculationResult
Mean of the 20 closes3,607.78 / 20180.389
Standard deviation (divided by 20)√(481.4814 / 20)4.907
Distance from the mean167.60 − 180.389−12.789
z-score−12.789 / 4.907−2.61

Under the square root is the sum of the squared distances of the 20 closes from the mean, divided by N as in Bollinger Bands. Dividing by N − 1 gives a slightly larger deviation and a z-score about 2.5% smaller in absolute value: what matters is to always use the same formula, the one the threshold was chosen with.

When does mean reversion work, and when does it fail?

The idea holds when the price has no direction: it swings within a range and the mean stays flat. It stops holding when a trend arrives: the price can stay far from the mean for a long time, and every β€œextreme” is overtaken by another one.

Fig. 4 · In a sideways phase

+20−2sideways phase: the mean is flat
  • The mean is flat.
  • The z-score swings from one side to the other and comes back towards zero.
  • Extremes above and below alternate.

Fig. 5 · In a trend

+20−2the price risesthe z-score hits +2 again and again
  • The mean rises, but stays beneath the price.
  • The z-score stays above zero and hits +2 again and again.
  • Selling at every +2 means going against the advance.

The chart at the top shows the two phases on Goldman Sachs. From to the price moved within a 14.7% range and closed −0.7% from the start: the z-score left ±2 7 times, and each time it crossed back to the other side of the mean within 15 sessions. From to the price closed above the mean for 52 sessions in a row, a change of +32%, and the z-score rose above +2 4 times.

Fig. 6 · The sideways phase of Goldman Sachs up close, on real prices

June 18, 2020August 28, 2020November 6, 2020+2σ20-day mean−2σ
  • From to the 20-day mean stays almost flat.
  • The filled dots are the 7 moves beyond ±2; the hollow ones, the session when the z-score crossed back to the other side of the mean.
  • There are moves on both sides: no direction prevails.
The two phases of Goldman Sachs: 20-day mean and deviation, ±2 threshold
PhasePeriodSessionsPrice rangeChangeTimes beyond +2Times beyond −2Sessions in a row above the mean
Sideways – 10014.7%−0.7%3413
Trend – 5236.3%+32.4%4052

Range = (highest − lowest close) divided by their midpoint. A β€œtime” starts when the z-score crosses the threshold after a session within it. This is an example chosen to show the two phases, not a measure of how often it happens.

Fig. 7 · The mean moves

+20−2the mean fallsthe price stays flatz back to 0
  • The price falls and then stays flat.
  • The mean falls towards it.
  • The z-score returns to zero without the price recovering.

It happens on real prices too. On Goldman Sachs closed $8.72 above its 20-day mean, with z = +2.12. By the z-score had crossed to the other side of the mean: the price had fallen by $4.48, but the mean had risen by $4.98. A return to the mean is not a return to the earlier price: the mean moves too.

Mean reversion vs trend following vs momentum: what is the difference?

The same move can be read in opposite ways. A price two deviations above the mean is β€œtoo high” for a mean reversion trader and β€œstrong” for a trend follower.

1Mean reversion

  • Buys weakness and sells strength: it bets that the distance from the mean will shrink.
  • Short trades, exiting towards the mean; it holds in sideways phases.

2Trend following

  • Buys when the price breaks out of a range to the upside or sits above a long average, and holds while the trend lasts.
  • Long trades; it struggles in sideways phases, where breakouts fall back.

the trend

3Momentum

  • Buys what has risen most over a period, for example the last few months, and bets that it will continue.
  • It looks at the strength of the past move, not at the distance from an average.

the RSI, a momentum oscillator

None of the three is right in absolute terms: it depends on the phase of the market. That is why a mean reversion trader first checks whether the price is trending, and only then looks at the distance from the mean.

Why does mean reversion need a stop?

A bet on the return to the mean loses exactly when the signal looks strongest: if after an entry at z = −2 the price keeps falling, the z-score goes to −3 and the β€œextreme” distance becomes even more extreme. Without an exit decided in advance, the loss has no limit.

Fig. 8 · The risk: the distance grows after the entry

+20−2entry at z = −2stopexitz keeps falling
  • You buy at z = −2, far below the mean.
  • The price keeps falling: the trend is down.
  • The stop, decided in advance, closes the trade.
  • A time stop helps too: if the return does not come within a set number of sessions, you get out.

The chart at the top shows the opposite case, to the upside. In the trend the z-score of Goldman Sachs first rose above +2 on , at $228.19; from there the price climbed to $251.33 on (+10%), and the z-score rose above +2 another 3 times. A sale β€œbecause it is too high” would have gone against the whole advance. The stop loss is decided before you enter, not after.

Common mistakes with mean reversion

z close to 0

1Buying just because it fell

  • Down a lot does not mean far from the mean: if the mean falls with the price, the z-score stays close to zero.
  • Measure the distance, not the decline.

2Ignoring the trend

  • In an advance the z-score hits +2 again and again: every sale goes against the move.
  • First look at the phase, then at the distance.

3Averaging down

  • Buying more when the z-score drops to −3 enlarges the position exactly while the hypothesis is breaking.
  • The stop applies to the whole position, not to the last purchase.

drawdown

4Choosing N and the threshold afterwards

  • The same session can be beyond the threshold with a short mean and within it with a long one.
  • Fix them in advance, and do not change them to make an example work.
news

5Forgetting the news

  • After an earnings report or a takeover bid the price can move to a new level: the mean of the earlier sessions no longer describes it.
  • A jump on news is not necessarily an excess to be corrected.

Deeper dives: Bollinger Bands · random walk and efficient markets.

Interactive exerciseTry it: find the sessions far from the mean

Goldman Sachs, sessions from June 18, 2020 to February 26, 2021 · 20-day mean and deviation, ±2 threshold
  1. Click a session when the price was more than 2 deviations below the 20-day mean: z under −2.
  2. Now a session more than 2 deviations above: z over +2.
  3. Read the verdict: the page tells you how far the price was from the mean and whether it was beyond the threshold.
Click here: a session with the z-score under −2

No session yet. You can click on the price or on the z-score panel: the dashed line keeps the two windows aligned.

InteractiveTry the z-score settings

the panel redraws as you go, together with the chart at the top
Sessions in the mean (N)
Threshold in deviations
Sessions beyond +211out of 175 sessions
Sessions beyond −27out of 175 sessions
Within ±290%157 sessions out of 175
Above the mean in a row52from to
With 20 sessions and a ±2 threshold, out of the 175 sessions of Goldman Sachs, closes beyond +2 deviations: 11; beyond −2: 7. With a short N the mean follows the price closely and the z-score soon returns towards zero; with a long N the mean lags behind and, in a trend, the price stays beyond the threshold for more sessions.

Where to go from here

Technical strategies

The other lessons in the Β«Technical strategiesΒ» section

Swing trading

  • Holding a position for days or weeks to catch one swing.
  • Swing highs and lows with a written rule.
  • Two real trades, and the gap that jumps the stop.

Day trading

  • Opening and closing positions inside the same session.
  • Two real sessions minute by minute, with the opening range and volume.
  • Why a break promises nothing, and how much costs weigh.

Scalping trading

  • Opening and closing in minutes, for a few cents.
  • The cost math and the win rate needed to break even.
  • Two real one-minute trades, a calculator and an exercise.

Stock screening

  • You start from every stock and take away: each filter is a rule in numbers.
  • Liquidity, trend, relative strength, volatility: one question per step.
  • What is left is a list to watch, not a list to buy.

Frequently asked questions

What is mean reversion?

Mean reversion is the idea that a price far from its average tends to move back towards it. Those who use it buy when the price is far below the mean and sell when it is far above.

How do you calculate the z-score?

Take the last N closes, often 20, and calculate their mean and standard deviation. The z-score is (close βˆ’ mean) / standard deviation: it tells you how many deviations the price is from the mean.

What is the difference between mean reversion and trend following?

They read the same move in opposite ways. Mean reversion sells a price far above the mean because it sees it as too high; trend following buys it because it sees it as strong. The first holds in sideways phases, the second in trends.

When does mean reversion not work?

When the price is trending: it can stay far from the mean for weeks or months, and the z-score hits the threshold again and again while the move continues. News that moves the price to a new level also breaks the hypothesis.

How are Bollinger Bands related to mean reversion?

Bollinger Bands at 20 sessions and 2 deviations are the same lines as the z-score: a close on the upper band has z = +2, one on the lower band z = βˆ’2.

Method and sources

The sources of this page: the books are cited, the text is ours
Source
John Bollinger, Bollinger on Bollinger Bands, McGraw-Hill, 2001: the bands at 20 sessions and 2 standard deviations, %B.
Ernest P. Chan, Algorithmic Trading: Winning Strategies and Their Rationale, Wiley, 2013: mean reversion strategies and the z-score as the distance from the moving average.
John J. Murphy, Technical Analysis of the Financial Markets: chapter 10, oscillators and contrary opinion (oscillators do best in markets without a trend; in a strong trend the excess can last); chapter 16, money management and trading tactics (protective stops).

The chart uses the Goldman Sachs sessions from our end-of-day price archive, adjusted for dividends and corporate actions, from to : the first ones are only there to calculate the averages. We calculate the z-score ourselves, on closes rounded as in the page’s data. The rules behind the examples: the trend is the longest streak of closes above the 20-day mean; the sideways phase is the 100 sessions before it; a return is a change of sign of the z-score within 15 sessions. The numbered figures are diagrams drawn to explain, not prices. This guide explains how the tools work: it does not contain investment recommendations and promises no returns. Our method · license · report an error.

Cookie preferences