Skip to main content
Track Weighted moving average
3 / 20
Library

1990issue C111-8

Seed and recurrence construction for moving averages

Routine technical work is described as being dominated by a simple moving average, a step-weighted moving average, and an exponentially smoothed average. After a window seed, the simple and step-weighted forms can be advanced with iterative updates that no longer vary with window length.

  • Routine technical work is described as being dominated by three constructions: a simple moving average, a step-weighted moving average, and an exponentially smoothed average.
  • The exponentially smoothed average is already recursive: each new value depends only on the prior smoother, the new observation, and a smoothing constant.
  • After the window seed, simple and step-weighted averages admit iterative updates whose work no longer varies with window length.
  • Only the prior running window sum needs to be kept for the next step-weighted update, and a five-bar walk-through matches the batch and recurrent paths.
Entries in this reading2 entries

Three constructions in routine work

Routine technical work is described as being dominated by three constructions: a simple moving average, a step-weighted moving average, and an exponentially smoothed average. A simple moving average is the equal-weight mean of the most recent window of ordered observations. A step-weighted moving average is a windowed mean that assigns linearly rising integer weights, with the newest observation heaviest, then divides by the sum of those weights. An exponentially smoothed average is a recursive smoother that blends the newest observation with the prior smoother value through a constant between zero and one.

The exponential step is already recursive

The exponential construction is already recursive: each new value depends only on the prior smoother, the new observation, and a smoothing constant. One common smoothing constant equals two divided by one plus the target window length. A direct reading of the windowed formulas makes simple and step-weighted work appear to grow with lookback, while one exponential step uses two additions or subtractions and one multiplication regardless of that constant.

Window seed and the simple iterative update

The window seed is the first fully populated average. It still uses the whole lookback and is the only step whose work scales with window length. After the first complete window, a simple average updates by adding the newest observation minus the observation that leaves the window, then dividing that difference by the window length. That step is an iterative update: a recurrence that forms the next average from the previous average plus a fixed arithmetic correction.

Step-weighted update with a running window sum

A step-weighted average can be rewritten with a running window sum, the unweighted total of the current window, and a triangular divisor. The triangular divisor is the closed-form sum of the first n integers, n times n plus one, divided by two, used to normalize step weights. Each later step-weighted value equals the previous step-weighted value plus the window length times the new observation, minus the prior running window sum, all scaled by that same divisor. The running window sum is itself updated by adding the entering observation and subtracting the observation that exits. Only the prior running window sum needs to be kept for the next step-weighted update.

Arithmetic after the seed

Once the seed term is formed, incremental simple and step-weighted updates no longer vary with window length, so on a series much longer than the window the three constructions take roughly comparable arithmetic. The recurrences can be checked by induction. A five-bar numerical walk-through produces matching next values from the batch and recurrent step-weighted paths, and from the batch and recurrent simple-average paths.

Five-day step-weighted average on the sidebar prices

After the day-5 seed the step-weighted average advances one bar at a time and tracks the last printed closes instead of re-summing the whole window. Price and SWMA figures are the ones Glazier writes out in the five-day sidebar, not a curve read off the figure.
After the day-5 seed the step-weighted average advances one bar at a time and tracks the last printed closes instead of re-summing the whole window. Price and SWMA figures are the ones Glazier writes out in the five-day sidebar, not a curve read off the figure.daily

Window length is n=5 and the weight divisor is the closed form c=n(n+1)/2=15. Only the first two simple-average values are stated, so SMA is omitted.

Educational research material, not investment advice. Historical source context does not establish present-day performance.
3 of 20 in the Weighted moving average track
19901-2 pp.Next on Weighted moving averageConstructing a five-day step-weighted moving averageA five-observation step-weighted moving average multiplies successive values by the integers 1 through 5 and divides by the sum of those weights.
All readings on this track · 20 readings
  1. 1988Indicator smoothing: lookback, weight, and scale
  2. 1990Recency weighting in simple, linear, and exponential moving averages
  3. 1990Seed and recurrence construction for moving averages
  4. 1990Constructing a five-day step-weighted moving average
  5. 1992Constructing simple, weighted, and exponential moving averages
  6. 1992Constructing moving averages with weighting schemes and extra filters
  7. 1992Constructing a weighted-average TRIN10 with Bollinger envelopes
  8. 1992Constructing a banded weighted open-TRIN oscillator
  9. 1993Evaluating a weighted dual rate-of-change momentum filter
  10. 1993Constructing equal, linear and exponential moving averages
  11. 1993Constructing a general weighted moving average from one exponent
  12. 1993Calibrating the weighted-moving-average exponent
  13. 1993Constructing an exponent-weighted average of put-call ratios
  14. 1994Cycle-tuned momentum with spectral peaks
  15. 1999How a five-bar sine-weighted average is assembled
  16. 2003Same-scale trend filter from a rolling least-squares endpoint
  17. 2003How a rolling linear-regression endpoint is assembled as a moving-trend
  18. 2004Constructing a volume-weighted moving average as a forecast baseline
  19. 2005Constructing a move, volume and recency weighted average
  20. 2016MACD as a zero-line filter with dual moving averages
All 24 readings tagged Weighted moving average
Also on Weighted moving average5 readings