Skip to content
All library documents

How Moving Average Crossovers Filter Price Changes

Article Quant Q&A · Author: cjm2671

Summary

The document compares a moving average crossover of prices with a moving average of price changes. It shows that, when prices are cumulative sums of their changes, any weighted moving average of prices can be rewritten as a weighted sum of past price changes. The resulting weights on changes are cumulative sums of the original price weights.

For a crossover between two simple moving averages, the implied weights on price changes rise gradually, then decline, rather than assigning equal weight to each lag as a simple moving average of changes would. This weighting places relatively little emphasis on the newest and oldest observations, which smooths high-frequency variation and makes the crossover act as a low-pass filter. The tradeoff is reduced responsiveness to recent changes. The comparison addresses signal shape and filtering behavior; it does not establish that either signal performs better in trading or assess transaction costs, parameter selection, or returns.

Key ideas

  • A weighted moving average of prices can be expressed as a weighted sum of past price changes.
  • The implied change weights are cumulative sums of the price weights.
  • A moving average crossover gives price changes a rising and then falling pattern of weights.
  • This weighting smooths high-frequency noise but can reduce responsiveness to recent moves.
  • The explanation compares signal construction and does not provide trading performance evidence.

Tags

Full text
# What is the difference between a moving average crossover and a moving average of returns?


# What is the difference between a moving average crossover and a moving average of returns?












In Python:

```
import pandas as pd
# z is a pd.Series of prices

# Moving average crossover
z.ewm(span=24).mean() - z.ewm(span=96).mean()

# Moving average of returns
z.diff().ewm(span=96).mean()
```

What is the difference:

- Mathematically

- Qualitatively

I believe the latter is simpler, and has the advantage of having only one parameter to configure. What's the issue with it?

## Answer by Chris Taylor (score 3, accepted)

https://quant.stackexchange.com/a/41841

Moving averages of prices are closely related to moving averages of price differences. In particular, if the price is a cumulative sum of historical price differences,

$$ p_t = \sum_{j=0} \delta p_{t-j} $$

then a moving average of prices with weights $w_k$ can be written as a moving average of price differences with weights $v_k$

$$ \sum_{k=0}w_k p_{t-k} = \sum_{k=0} w_k \sum_{j=0}\delta p_{t-j-k} = \sum_{k=0} \left(\sum_{i=0}^k w_i\right) \delta p_{t-k} = \sum_{k=0} v_k \delta p_{t-k} $$

where

$$ v_k = \sum_{i=0}^k w_i $$

In particular, a moving average crossover with spans $(n_1, n_2)$ is a moving average of prices, where

$$ w_k = \begin{cases} 1/n_1 - 1/n_2 & \text{if } k < n_1 \\ -1/n_2 & \text{if } n_1 \leq k < n_2 \\ 0 & \text{otherwise} \end{cases} $$

It is therefore also a moving average of price differences. It differs from the simple moving average, which has equal weight on all lags, by having very little weight on the first lag, with weights linearly increasing up to lag $n_1$, and then linearly decreasing up to lag $n_2$.

Qualitatively, the moving average crossover filters out more of the higher frequency noise resulting in a 'smoother' signal (intuitively this is because there is very little weight on either the most recent or most distant observation). In the language of signal processing it is a form of low pass filter. There is a tradeoff of smoothness of the resulting signal against reactivity to recent price changes.

Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.