Mean reversion strategy: rules, example and limits

By Oalgo · Last reviewed

A mean reversion strategy rests on one idea: after price moves far from its recent average, it tends to move back toward it. The rule enters when price is far below the average and exits when it is back near it. The idea is an assumption, not a fact about any market. The rest of the strategy is how you measure "far" and "back".

What are the rules of a mean reversion strategy?

#
  • The average: a 20-candle EMA of the close.
  • How far is far: the close is below the average by more than 2 times the ATR. That line is the lower line of the Keltner Channels with 20 candles and a multiplier of 2.
  • A filter: ADX below 25, so the rule only enters when there is little trend.
  • Exit: the close rises back above the middle line, which is the EMA.
  • Stop: a Stop Loss as a percentage, for the times price keeps going.

What does a worked example look like?

#

Take a 20-candle EMA that starts at 100, and an ATR that stays at 3 to keep the numbers simple. A real ATR changes. The lower line is then the EMA − 2 × 3, which is the EMA − 6.

CandleCloseEMA 20Lower line (EMA − 6)What the rule does
19799.7193.71The close is above the lower line: nothing
29399.0793.07The close is below the lower line: entry
39498.5992.59In the trade
49698.3492.34In the trade
59998.4192.41The close is above the EMA: exit

The middle line moved too. It fell from 100 to 98.34 while price was below it, so the exit level was not where it was when the rule began. A rule that exits at the average exits at a moving target.

When does a mean reversion strategy fail?

#
MarketWhat price doesWhat the rule meets
SidewaysMoves away from the average, then backEntries that exit at the middle line
Falling steadilyStays below the average, which falls with itAn entry that waits for a move back that does not come, until the Stop Loss ends it
Jumps to a new levelSettles there while the average follows slowlyAn entry below an average that no longer applies

ADX below 25 tries to keep the rule out of the second row. It reads the recent past, so it can be late when a trend starts.

How do you write this strategy in Oalgo?

#

In Oalgo you can tell Oalgo AI your mean reversion rule in your own words, check the rule it builds, and test it. After testing, if you choose, you Go Live with your own Live Strategy on your own Venue Account at a Supported Venue.

For example, you could tell Oalgo AI: "Enter when the close is below the lower Keltner line (20 candles, multiplier 2) and ADX (14) is below 25. Exit when the close rises above the Keltner middle line. Use a 2% Stop Loss and a 4% exit target." These numbers are examples to change. In the builder the two entry conditions are joined with an AND block, so both must be true at the same time. A Live Strategy needs a stop on each side it can enter, and an exit target is optional. The example names both.

How do you test this strategy honestly?

#
  • Run a backtest on a sideways stretch and on a falling one. This rule is made for the first and meets the second.
  • Count the trades inside a long fall. A rule that enters whenever the close is below the line can enter many times in one fall, and each trade pays fees.
  • Move the multiplier (1.5, 2 and 2.5) and the ADX level (20, 25 and 30). A rule that only holds at one exact pair may be overfitting.
  • Run a forward test on new prices, with simulated funds.

What can a mean reversion strategy not tell you?

#

Far from the average does not mean about to move back. The average is a summary of recent candles, and a real change in price can make the old average meaningless. The rule also enters while price is falling, so each entry assumes that the fall is about to stop. With five settings (20, 2, 14, 25 and the stop) it has room to be fitted to one period, so test it on dates you did not tune it on.

Read next