2006issue C011-9
Shared coefficient construction for recursive price filters
One recursive routine can produce simple averaging, exponential averaging, and momentum-style measurements by switching a type argument and the coefficients that type selects. After warmup, the same linear mix is a rational transfer that can be inspected on a chirped sine with declining frequency.
- One recursive routine can produce simple averaging, exponential averaging, and momentum-style measurements by switching a type argument and the coefficients that type selects.
- After more than N bars, the shared update is a linear mix of the current price, the two prior prices, the two prior outputs, and the price at lag N, each scaled by type-specific coefficients.
- Exponential-smoothing mode sets the current-price weight to an alpha computed from the sine and cosine of 360 divided by Period, and sets the prior-output weight to one minus that alpha.
- Band-pass and band-stop modes introduce a width parameter through a cosine term at twice the period angle, then differ in the signs and placement of the feedforward taps.
One routine, several responses
One recursive routine can produce simple averaging, exponential averaging, and momentum-style measurements by switching a type argument and the coefficients that type selects. That shared object is a unified recursive filter: a single second-order update whose coefficients are switched to produce different responses from one ordered price series.
After more than N bars, the shared update is a linear mix of the current price, the two prior prices, the two prior outputs, and the price at lag N, each scaled by type-specific coefficients.
Exponential smoothing as the one-pole case
Exponential-smoothing mode is the one-pole case of the shared update. It sets the current-price weight to an alpha computed from the sine and cosine of 360 divided by Period, and sets the prior-output weight to one minus that alpha. The angle 360 divided by Period is the period angle used for those sine and cosine gains.
Editorial: this lesson treats the Kalman filter as the conceptual parent of carrying the prior output as state, a predict-and-revise estimator that retains the last output until the new price revises it.
Simple averaging with a lag-N zero
Simple-average mode requires a nonzero lookback N, sets both the current-price weight and the lag-N subtractive weight to 1/N, and holds the first-order feedback coefficient at 1. The recursion also allows an optional extra zero at lag N, which is that lag-N subtractive term.
Two-pole gains and the alpha-beta step
Two-pole Gaussian and Butterworth modes share a beta equal to 2.415 times one minus the cosine of 360/Period, then derive alpha from that beta. They differ mainly in feedforward gain and extra input taps.
Editorial: those period-derived alpha and beta terms are used here as the two-gain pattern of an alpha-beta filter. They set how strongly new prices revise the retained state.
Warmup bars and a zero period
High-pass and two-pole high-pass modes seed the first N bars at zero, while averaging and Gaussian modes seed those bars with the input price. The first N observations are the warmup bars: they receive a type-specific seed instead of the full recursion. Most period-using modes abort if Period is zero.
Band-pass, band-stop, and the chirped test wave
Band-pass and band-stop modes introduce a width parameter through a cosine term at twice the period angle, then solve for alpha from that term. The two modes differ in the signs and placement of the feedforward taps. Band-pass keeps variation near the chosen period and rejects slower and faster variation. Band-stop attenuates variation near the chosen period.
The same band-pass constructor can be run at two nearby periods and subtracted to form a two-line difference. A chirped test wave, a synthetic sine whose frequency declines across the sample, is used as a known periodic test input for inspecting those responses.
Rational transfer and a lasting seed offset
The recursion matches a rational transfer function with at most two poles and an optional extra zero at lag N. Simple-average reconstruction is sensitive to the opening seed, and a constant initialization error can persist as a permanent level offset.
Editorial: specify the taps, the period angle, and the warmup seed completely on the chirped test wave before the same recursion is applied to a market series.
Period-20 Gaussian SWAK on daily Yahoo

SWAK type Gauss, Period 20, Price=(High+Low)/2, N=0, delta=0. Levels are approximate to about 0.2 dollars because they were read off the raster, not a printed table.
All readings on this track · 7 readings
- 1985Constructing a recursive two-gain price smoother
- 1989Constructing alpha-beta price channels and trend filters
- 1989Alpha-beta lag parameters versus moving-average windows
- 1995Constructing a reproducible alpha-beta price channel
- 2006Shared coefficient construction for recursive price filters
- 2010How to judge a Kalman filter forecast as a Trend filter
- 2019Constructing a calendar-conditioned trend filter