Interactive illustrations to Chapters 4 and 5 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.

Chapter 5 uncovers the anatomy of trend-following rules and demonstrates that the computation of a technical trading indicator for any rule can alternatively be given by the following simple formula \[ \text{Indicator}_t^{TR(n)} = \sum_{i=1}^{n-1} \pi_i \Delta P_{t-i}. \] In words, any trading indicator is computed as a weighted average of price changes over the averaging window. The price-change weighting function \(\pi_i\) of a trading rule reveals the anatomy of this rule.

These interactive illustrations demonstrate the trading with the Moving Average Convergence/Divergence rule and the anatomy of this rule.

The first step in this rule is to compute the regular MAC indicator using two MAs \[ MAC_t(s,l) = MA_t(s) - MA_t(l). \] where \(MA\) denotes a moving average (traditionally, the EMA is used), \(s\) denotes the size of the shorter window, and \(l\) denotes the size of the longer window. Recall that in the regular MAC rule a Buy signal is generated when the shorter moving average is above the longer moving average.

In the MACD rule the idea is to generate a Buy (Sell) signal when MAC increases (decreases). Specifically, in this case a Buy (Sell) signal is generated when the shorter moving average increases (decreases) faster than the longer moving average.

In order to reduce the number of false signals, a directional movement in MAC must be confirmed by a delayed and smoothed version of MAC. As a result, in the MACD rule the technical trading indicator is computed as \[ \text{Indicator}_t^{\text{MACD}(s,l,n)}= MAC_t(s,l) - MA_t(n,MAC(s,l)). \] The principle behind the computation of the trading indicator of the MACD rule is the same as that in the Price Minus Moving Average rule. In particular, if MAC is trending upward (downward), a moving average of MAC tends to be below (above) MAC.

In the Application to S&P 500 panel, the top figure plots the monthly values of the S&P 500 index and the values of the shorter and longer moving averages. The shaded areas in this plot indicate the periods where this rule generates a Sell signal. The bottom figure plots the values of the technical trading indictor of the \(MACD(s,l,n)\) rule. The middle panel in this figure plots the values of the \(MAC(s,l)\) and the \(MA(n,MAC(s,l))\).

The Anatomy of the rule panel plots the price-change weighting function of the \(MACD(s,l,n)\) rule.

One can change the data range, the type of a moving average, the sizes of the shorter and longer windows (\(s\) and \(l\)), and the size of the window for final smoothing (\(n\)).