Appends ten columns. Plotted together they fan out into the bands the
name comes from: at period 2 the first is barely smoothed and the tenth
lags by ten bars, so the width of the fan is how fast the trend is moving
and its ordering is which way.
Recursive, not ten lengths
The other thing published under "rainbow" is ten averages of increasing
length over the same source. That is a different study and this is not it:
a recursive 2-bar average is a binomial filter (weights C(k, j)/2^k
at stage k), not a box, so its shape and its phase both differ from an
SMA of the same support. Measured on the oracle input, stage 10 sits 0.83
points from the 11-bar SMA covering the same eleven bars at
{ period: 2, type: 'sma' }, and 1.44 from the 21-bar one at
{ period: 3, type: 'ema' }, on a series whose whole range is 19.4 — the
generator asserts that separation so a fixture cannot pin the wrong one.
period is the length of each stage, not of the chain — the same
convention trix states for its three EMAs. 2 is Widner's.
Definition, verified
No TA-Lib function, so the oracle is a pandas replication of the
recursion above, built on the same _ma_over helper the TA-Lib-verified K2
engine cases use rather than a private smoother, with each stage's analytic
first-valid bar asserted.
Warm-up — per column, stage · (period − 1)
Every stage goes through the engine's array door, where a type waits
for period finite values, so each stage steps over the previous one's
warm-up: at period 2 the columns start on bars 1, 2, 3 … 10, and at
period 3 on 2, 4, 6 … 20. Length-preserving; each column emitted where it
is defined rather than all ten waiting for the tenth.
Edges
Linear in price — a chain of moving averages, so scaling scales every
column and shifting shifts every column (both pinned).
A leading gap shifts every column, including under 'sma': the array
door counts finite values, not rows, so unlike guppy's column
door there is no 'sma' exception here.
An interior gap costs the bar and then stage · (period − 1) bars
more with each level of the chain — the window types recover, ema skips
and recovers, smma and kama propagate to the end.
period 1 is the identity ten times over, so all ten columns equal
the source. Allowed rather than rejected: it is the honest answer, and
every K2 type is the identity at 1.
Rainbow Moving Average (Mel Widner, Stocks & Commodities, July 1997) — ten averages where each one smooths the previous average, not the price:
Appends ten columns. Plotted together they fan out into the bands the name comes from: at
period 2the first is barely smoothed and the tenth lags by ten bars, so the width of the fan is how fast the trend is moving and its ordering is which way.Recursive, not ten lengths
The other thing published under "rainbow" is ten averages of increasing length over the same source. That is a different study and this is not it: a recursive 2-bar average is a binomial filter (weights
C(k, j)/2^kat stagek), not a box, so its shape and its phase both differ from an SMA of the same support. Measured on the oracle input, stage 10 sits 0.83 points from the 11-bar SMA covering the same eleven bars at{ period: 2, type: 'sma' }, and 1.44 from the 21-bar one at{ period: 3, type: 'ema' }, on a series whose whole range is 19.4 — the generator asserts that separation so a fixture cannot pin the wrong one.periodis the length of each stage, not of the chain — the same convention trix states for its three EMAs.2is Widner's.Definition, verified
No TA-Lib function, so the oracle is a pandas replication of the recursion above, built on the same
_ma_overhelper the TA-Lib-verified K2 engine cases use rather than a private smoother, with each stage's analytic first-valid bar asserted.Warm-up — per column,
stage · (period − 1)Every stage goes through the engine's array door, where a type waits for
periodfinite values, so each stage steps over the previous one's warm-up: atperiod 2the columns start on bars 1, 2, 3 … 10, and atperiod 3on 2, 4, 6 … 20. Length-preserving; each column emitted where it is defined rather than all ten waiting for the tenth.Edges
'sma': the array door counts finite values, not rows, so unlike guppy's column door there is no'sma'exception here.stage · (period − 1)bars more with each level of the chain — the window types recover,emaskips and recovers,smmaandkamapropagate to the end.period 1is the identity ten times over, so all ten columns equal the source. Allowed rather than rejected: it is the honest answer, and every K2 type is the identity at 1.