Moving Average Envelope Rule


Interactive illustrations to Chapter 4 of the book Market Timing with Moving Averages: The Anatomy and Performance of Trading Rules by Valeriy Zakamulin

Chapter 4 reviews the most common trend-following rules.

These interactive illustrations demonstrate the trading with the Moving Average Envelope rule.

A moving average envelope consists of two boundaries above and below a moving average. The distance from the moving average and a boundary of the envelope is usually specified as a percentage (for example, 5%). As long as the price lies within these two boundaries, no trading takes place. A Buy (Sell) signal is generated when the price crosses the upper (lower) boundary of the envelope. Formally, denote by \(MA_t(n)\) the moving average of prices over a window of size \(n\) and by \(p\) the envelope percentage. The upper and lower boundaries of the moving average envelope are computed by \[ L_t = MA_t(n)\times(1-p), \quad U_t = MA_t(n)\times(1+p). \] Mathematically, the trading signal is generated according to: \[ \text{Signal}_{t+1} = \begin{cases} \text{Buy} & \text{if } P_t>U_t, \\ \text{Sell} & \text{if } P_t<L_t , \\ \text{Signal}_{t} & \text{if } L_t\leq P_t\leq U_t. \end{cases} \]

In the Application to S&P 500 panel, the figure plots the monthly values of the S&P 500 index and the values of the upper and lower boundaries of the moving average envelope. The shaded areas in this plot indicate the periods where this rule generates a Sell signal.

One can change the data range, the type of a moving average, the size of the window, \(n\), to compute the trading signal, and the evelope percentage \(p\).