## Moving Average Crossover Rule and Its Anatomy

to

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 Crossover rule and the anatomy of this rule.

In this rule the value of a shorter moving average is compared with the value of a longer moving average. A Buy signal is generated when the value of a shorter moving average is greater than the value of a longer moving average.

Formally, the technical trading indicator for the Moving Average Crossover rule is computed as: $\text{Indicator}_t^{\text{MAC}(s,l)} = MA_t(s) - MA_t(l),$ where $$MA$$ denotes a moving average (SMA, LMA, EMA, etc), $$s$$ denotes the size of the shorter window, and $$l$$ denotes the size of the longer window. It is worth noting that the Moving Average Crossover rule reduces to the Price Minus Moving Average rule when the size of the shorter averaging window reduces to one (that is, when $$s=1$$).

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 $$MAC(s,l)$$ rule.

The Anatomy of the rule panel plots the price-change weighting function of the $$MAC(s,l)$$ rule.

One can change the data range, the type of a moving average, and the sizes of the shorter and longer windows.