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.
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

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.
All readings on this track · 8 readings
- 1989Constructing lag-matched triangular moving averages
- 1990Lag-aligned MACD from triangular moving averages
- 1990Constructing triangular moving average weights
- 1990Constructing a lag-aligned triangular MACD
- 1998Paired tests for moving-average lag and smoothness
- 1999Fixed-lag construction of moving-average smoothers
- 2003Weighting recipes inside one moving-average lookback
- 2010Assembling a smoothed percent-b oscillator from Heikin-Ashi and stacked averages