Skip to main content
Track Triangular moving average
4 / 8
Library

1990issue C081-12

Constructing a lag-aligned triangular MACD

Before cycles can be inspected, trend is removed so an ordered market series is stationary. This construction subtracts two even-length triangular moving averages only after each average is shifted by its midpoint lag, placing a reduced-amplitude residual back in time with the parent series.

  • Trend is removed first so remaining variation can be inspected for cyclic structure. Listed constructions include first differences, residuals from a fitted trend, departures from a centered average, and the difference of two moving averages of unequal length.
  • The oscillator is the difference of two even-length triangular moving averages, with the shorter window recommended as half the longer. A worked pair uses lengths 20 and 10.
  • Each triangular average lags the parent series by half its period minus one, so the length-10 average lags by 4 observations and the length-20 average lags by 9. The oscillator at time t uses each average evaluated at t plus its own lag.
  • End-of-sample oscillator points are unavailable until the longer window is complete. A current index of 54 leaves the last computed value at 45, a gap of 9 equal to half the longer window.
Entries in this reading3 entries

Remove trend before inspecting cycles

Before cycles can be inspected in ordered market series, trend is removed. The aim is stationarity: a series whose remaining variation can be inspected for cyclic structure. Listed constructions include first differences, residuals from a fitted trend, departures from a centered average, and the difference of two moving averages of unequal length.

MACD, in this setting, is the difference of two unequal-length moving averages, used to cancel shared trend and leave a stationary residual. The moving average inside the construction is a lookback-window smoother whose window length is constrained to an even count. The triangular moving average supplies the weights: they rise linearly to a midpoint peak and fall back to zero.

Specify even-length triangular windows

The constructed oscillator is the difference of two triangular moving averages whose window lengths are even, with the shorter window recommended as half the longer. A worked pair uses lengths 20 and 10. The even-window constraint keeps the triangular peak on a midpoint observation.

Under the stated weighting convention, the peak triangular weight is 2.0 at the window midpoint, the step size is 2 divided by half the period, the count of effective weights is one less than the period, and the weights sum to one plus that count. The weight-sum is the divisor of the triangular average. A triangular average value equals the weight-times-observation sum inside the window, divided by the sum of the weights.

Shift each average by its midpoint lag

Because the triangular window is symmetric, each average has a lag equal to half the even window length minus one. The length-10 average lags by 4 observations and the length-20 average lags by 9.

The oscillator at time t is the shorter triangular average evaluated at t plus its lag, minus the longer triangular average evaluated at t plus its lag. That placement puts the difference back in time with the parent series at a reduced amplitude.

Leave the sample end incomplete

End-of-sample oscillator points are unavailable until the longer window is complete. In the spreadsheet illustration, a current index of 54 leaves the last computed value at 45, a gap of 9 equal to half the longer window.

Inspect the residual on test and market series

In a sine-wave test series of period 40, the first length-10 triangular average needs nine prior points and the first length-20 average needs nineteen prior points. The lag of the longest average is half its period minus one.

Chart overlays on an individual equity series, a broad stock index, and a volume-adjusted advance/decline series were used to inspect whether the triangular-average difference recovered smooth peaks and troughs that were faint in the raw series.

A short program accepts operator-chosen periods, builds the triangular weights, and plots the input beside the oscillator. The bundled test input is a sine series whose period is twice the longer triangular window.

Lag-aligned triangular MACD on the 40-period test sine

Once the 10- and 20-period triangular averages are slid back by their midpoint lags, the residual turns with the parent 40-period sine instead of trailing it, at a much smaller swing. Every point is a cell from Johnson’s Figure 2 worksheet.
Once the 10- and 20-period triangular averages are slid back by their midpoint lags, the residual turns with the parent 40-period sine instead of trailing it, at a much smaller swing. Every point is a cell from Johnson’s Figure 2 worksheet.Hypothetical 40-period sine

Windows are even-length 10 and 20. Each average is shifted by lag (P/2)−1 before the subtract, so a live series would leave the last nine MACD bars unknown without extrapolation.

Educational research material, not investment advice. Historical source context does not establish present-day performance.
4 of 8 in the Triangular moving average track
19981-3 pp.Next on Triangular moving averagePaired tests for moving-average lag and smoothnessLinear-input-lag can treat a longer single-pass exponential average and a multi-pass exponential average as equally delayed even when a peaked path shows extra phase-lag for the stacked version.
All readings on this track · 8 readings
  1. 1989Constructing lag-matched triangular moving averages
  2. 1990Lag-aligned MACD from triangular moving averages
  3. 1990Constructing triangular moving average weights
  4. 1990Constructing a lag-aligned triangular MACD
  5. 1998Paired tests for moving-average lag and smoothness
  6. 1999Fixed-lag construction of moving-average smoothers
  7. 2003Weighting recipes inside one moving-average lookback
  8. 2010Assembling a smoothed percent-b oscillator from Heikin-Ashi and stacked averages
All 8 readings tagged Triangular moving average
Also on Triangular moving average5 readings