SimpleMeanReversion

Description

Simple Mean Reversion is a strategy created by Anthony Garner. It is based on the theory that when prices move too far away from the mean, there is a chance of price reversion. The strategy adds simulated buy and sell signals based on the following values: price, two simple moving averages, and zScore. The latter is the ratio of the difference between the price and its average to the standard deviation of the price.

The strategy adds simulated orders based on the following conditions:

  • Buy to open: zScore falls below -1.0 while the faster SMA is above the slower one;
  • Sell to close: zScore rises above -0.5;
  • Sell to open: zScore rises above 1.0 while the faster SMA is below the slower one;
  • Buy to close: zScore falls below 0.5.

By default, the faster SMA has the length equal to the length with which zScore is calculated. The slower SMA has the length ten times the length of zScore. All the mentioned numbers can be customized in the input parameters.

Input Parameters

Parameter

Description

price The price for which the averages and zScore are to be calculated.
length The length with which zScore is to be calculated.
fast length factor The factor by which length is to be multiplied to obtain the length of the faster moving average.
slow length factor The factor by which the length is to be multiplied to obtain the length of the slower moving average.
z score entry level Defines the critical value of zScore for triggering a simulated sell-to-open order. For simulated buy-to-open orders, the opposite number is used.
z score exit level Defines the critical value of zScore for triggering a simulated buy-to-close order. For simulated sell-to-close orders, the opposite number is used.

Plots

Plot

Description

FastMA The fast moving average plot.
SlowMA The slow moving average plot.

Further Reading

1. "Backtesting A Mean-Reversion Strategy In Python" by Anthony Garner. Technical Analysis of Stocks & Commodities, May 2019.

Backtesting is the evaluation of a particular trading strategy using historical data. Results presented are hypothetical, and there is no guarantee that the same strategy implemented today would produce similar results.

Technical analysis is not recommended as a sole means of investment research.

For educational purposes only. Not a recommendation of a specific security or investment strategy.

You may also like
MomentumPercentDiff
The Momentum Percent Diff is a momentum-based technical indicator. Unlike the regular Momentum ...
WilliamsAD
The Williams Accumulation/Distribution study is used to determine either the marketplace is ...
Stiffness
Stiffness is a technical indicator introduced by Markos Katsanos. This indicator helps assess ...