2005issue C051-2
Moving-average construction: windows, weights and stops
A moving average is a comparable quantitative baseline only when the input transform, the weight or length rule, and an explicit stopping condition are specified together.
- Treat a moving average as one construction: the input transform, the weight or length rule, and an explicit stop belong together.
- Adaptive-length search needs a loop-escape, because reducing length by two each pass can leave the while-condition true if no lower bound is set.
- Midpoint-price input groups the high and low before division; re-keying from a non-text listing dropped that grouping and changed the arithmetic.
- A move-adjusted-average can sit in one array-window, so the same weighted sum can widen to a 50-period lookback without a helper column for each length.
Windows, weights and stops
The moving-average is a lookback statistic that maps ordered prices into one smoothed value at each sampling interval. TradersWeek editorial view: the input transform, the weight or length rule, and an explicit stopping condition have to be specified together before that series can serve as a comparable quantitative baseline.
Named windows and midpoint-price input
A dual-average alert was specified as a 50-day average crossing above a 200-day average.
The intended adaptive-filter input was the midpoint-price, the average of the bar high and low. That sum must be grouped before dividing by two. The same symbols without those parentheses change the arithmetic.
Re-keying filter code from a non-text listing introduced the midpoint-parentheses error. A copyable text listing was the intended distribution form.
Adaptive-length, median-average and loop-escape
An adaptive-length construction shortens the averaging window during computation instead of holding the lookback fixed. Inside the adaptive loop, length was reduced by 2 on each pass, so a missing lower bound could leave the while-condition permanently true.
A defensive loop-escape set the loop residual to 0 once length fell below 1, forcing the while-condition to fail even if the threshold test had not.
The recursive branch used a smoothing weight of 2 divided by length plus 1, then measured disagreement as the absolute gap between a same-length median and that recursion, scaled by the median. That median-average comparison is a same-window check used to decide whether length should keep shrinking.
Move-adjusted-average and the array-window
A move-adjusted-average can be written as one windowed sum that weights each price by the absolute size of its period-to-period change and then divides by the sum of those absolute changes. It is a weighted mean that scales each observation by the absolute size of its recent change.
Entering that weighted sum as an array-window lets the same construction expand from a short window to a 50-period window without a separate helper column for each length.
All readings on this track · 15 readings
- 1990Building a percent-difference moving-average oscillator
- 1991Ease of movement oscillator construction
- 1993A twelve-month moving-average filter for inflation direction
- 1993Constructing two-endpoint JSA moving averages
- 1999Centered moving averages for trend construction
- 2000Constructing a slope-corrected moving average
- 2000Lookback length as a construction check for the modified moving average
- 2001Smoothing balance of market power with a moving average
- 2005Three-state moving-average directional breakout construction
- 2005Constructing a move-adjusted moving average
- 2005Moving-average construction: windows, weights and stops
- 2008Constructing stacked moving-average filters
- 2011Constructing percentage-offset moving-average bands
- 2015Linearity, commutation, and ratio smoothing in moving averages
- 2019Constructing a 50-200 sma-channel for swing entries and exits