@pond-ts/financial API Reference
    Preparing search index...

    Function rainbow

    • Rainbow Moving Average (Mel Widner, Stocks & Commodities, July 1997) — ten averages where each one smooths the previous average, not the price:

      ${prefix}1  = MA(column, period)
      ${prefix}2 = MA(${prefix}1, period)

      ${prefix}10 = MA(${prefix}9, period)

      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.

      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.

      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.

      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.

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

      Type Parameters

      • S extends SeriesSchema
      • const Prefix extends string = "rainbow"

      Parameters

      Returns TimeSeries<
          readonly [
              S[0],
              ValueColumnsForSchema<
                  readonly [
                      S[0],
                      ValueColumnsForSchema<
                          readonly [
                              S[0],
                              ValueColumnsForSchema<
                                  readonly [
                                      S[0],
                                      ValueColumnsForSchema<
                                          readonly [
                                              (...)[(...)],
                                              ValueColumnsForSchema<(...)>,
                                              OptionalNumberColumn<(...)>,
                                          ],
                                      >,
                                      OptionalNumberColumn<`${Prefix}7`>,
                                  ],
                              >,
                              OptionalNumberColumn<`${Prefix}8`>,
                          ],
                      >,
                      OptionalNumberColumn<`${Prefix}9`>,
                  ],
              >,
              OptionalNumberColumn<`${Prefix}10`>,
          ],
      >