2003issue C121-2
Recursive and cascaded moving-average construction
A simple moving average can be written as an explicit windowed mean, then rebuilt with a compact recurrence and with cascaded finite-impulse stages. Matching transfer responses shows those constructions implement the same average.
- A simple moving average of length N adds N observations, divides by N, and repeats that construction on each new bar.
- A compact recurrence builds a long simple moving average from the new observation, the observation delayed by N, and the previous average, then scales that combination by N+1.
- A three-stage cascade with delays of 1, 2, and 4, then divided by 8, expands to the same eight-term finite-impulse polynomial as an eight-bar simple moving average.
- The recursive and cascaded constructions are offered as coding simplifications for indicators and strategies that use these averages.
Write the windowed baseline first
A simple moving average of length N is constructed by adding N observations and dividing by N, then repeating that construction on each new bar. That moving average is a lookback mean of ordered price, volume, or breadth observations, and it is the explicit quantitative baseline being reconstructed.
Writing every delayed term of a long moving average by hand becomes cumbersome, and looped summation is not available in every construction environment. A rolling construction can drop the oldest observation and add the newest one, but that shortcut still requires computing the full-length average at least once to initialize.
Unit delay and transfer response
A unit delay represents a one-bar lag. It is the one-step lag operator that shifts an observation by a single sampling interval.
A filter transfer response is defined as the filter output divided by the filter input. That ratio is used to prove that two constructions implement the same average.
An eight-bar simple moving average has a finite-impulse transfer response equal to the current observation plus the seven preceding delayed observations, all divided by 8. A finite-impulse-response filter outputs a finite combination of the current input and a fixed set of delayed inputs, with no leftover dependence on its own past outputs once the window is written out.
Rebuild with a recursive update
A compact recurrence builds an arbitrarily long simple moving average from the new observation, the observation delayed by N, and the previous average, then scales that combination by N+1. That recursive average update replaces a full-window sum with the new observation, the observation leaving the window, and the previous average.
Exponential smoothing is a recursive smoother that carries memory by folding the previous output into the new estimate, so a long lookback does not have to be summed term by term.
Cascade short finite-impulse stages
Finite-impulse stages can be cascaded so each stage filters the previous stage output. Cascading corresponds to multiplying the stage transfer responses. That cascaded construction builds one longer finite-impulse average by feeding each short stage into the next.
A three-stage cascade with delays of 1, 2, and 4, then divided by 8, expands to the same eight-term finite-impulse polynomial as an eight-bar simple moving average.
Coding simplifications
The recursive and cascaded constructions are offered as coding simplifications for indicators and strategies that use these averages.
All readings on this track · 10 readings
- 1982An odd-length smoother from a cycle cutoff
- 1989Smoothing filters, cutoff, poles, and sample delay
- 1992Constructing a cycle-aware finite impulse response detrender
- 2002Rebuild a smoother by writing the lag into the coefficients
- 2002Timing market cycles with finite impulse response filters and FFT
- 2002Constructing the relative strength index with an even-order finite-impulse-response prefilter
- 2003Recursive and cascaded moving-average construction
- 2006One second-order transfer function, a family of trend filters
- 2019Constructing the Voss line from a bandpass and a short FIR sum
- 2020Truncated bandpass construction as a finite-length trend filter