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.
| Candle | Close | EMA 20 | Lower line (EMA − 6) | What the rule does |
|---|---|---|---|---|
| 1 | 97 | 99.71 | 93.71 | The close is above the lower line: nothing |
| 2 | 93 | 99.07 | 93.07 | The close is below the lower line: entry |
| 3 | 94 | 98.59 | 92.59 | In the trade |
| 4 | 96 | 98.34 | 92.34 | In the trade |
| 5 | 99 | 98.41 | 92.41 | The 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?
#| Market | What price does | What the rule meets |
|---|---|---|
| Sideways | Moves away from the average, then back | Entries that exit at the middle line |
| Falling steadily | Stays below the average, which falls with it | An entry that waits for a move back that does not come, until the Stop Loss ends it |
| Jumps to a new level | Settles there while the average follows slowly | An 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
- RSI strategy: oversold and overbought rules, explainedAn RSI strategy enters when RSI falls below a low level such as 30 and exits as it recovers. See the rules, their weakness in a trend, and how to test them.
- Bollinger Bands strategy: rules and how to test themA Bollinger Bands strategy acts when price touches a band. See the band-touch rule, what it assumes and how to test it. Squeeze rules have their own page.