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

    Function rainbowOscillator

    • Rainbow Oscillator — how far the price sits from the rainbow stack's centre, as a percentage of the recent range, with the width of the stack itself drawn as a band around it:

      ${prefix}      = 100 · (price − mean(rainbow1…rainbow10)) / (HHLL)
      ${prefix}Upper = 100 · (max(rainbow1…rainbow10) − min(…)) / (HHLL)
      ${prefix}Lower = −${prefix}Upper

      where HH / LL are the highest and lowest of column over lookback bars. Appends three columns. The line is the momentum reading; the bands are the fan's own width, so a line pushing outside them is price moving faster than the stack has spread.

      "Rainbow Oscillator" is published in several incompatible forms, so the source is named rather than averaged. This is ChartIQ's: the numerator is the distance from the stack's mean, the denominator is the range of the source column over lookback bars, and the bands are the stack's own max-minus-min over the same denominator, mirrored about zero.

      The two nearest alternatives, and how far away they are — measured on the oracle input at the defaults, where the reading itself spans −68.6 to +63.8:

      variant max distance from this
      normalise by the price (100·(c − mean)/c) rather than the range 67.27
      numerator against the first average rather than the stack's mean 49.16

      Both are the size of the reading itself, so neither is a rounding difference, and the generator asserts the separation so a fixture cannot silently pin one of them.

      lookback and period are separate knobs because they answer different questions — how much history the stack smooths, and what range the answer is a percentage of.

      • A flat lookback window is undefined, not 0. Apply the test rather than the precedent: unlike a flat bar, whose close-location numerator is forced to zero, nothing here forces these numerators. The stack reaches back past the lookback window, so on a series that rises and then holds a level for lookback bars the reading is a real number over zero — not a 0/0 — which is an infinity, not a value. Measured on such a series at period 2: with lookback: 3 the stack's mean is more than 10 points from the flat level, and even with the default lookback: 10, by which point the stack has nearly caught up, it is still 0.0044 away. Both are pinned by tests, because the "it converges, so it is really 0/0" intuition is the one that would talk someone into returning 0 here.
      • Scale-invariant and shift-invariant. Numerator and denominator are both differences of prices, so k·price + c leaves all three columns unchanged (both pinned).
      • Warm-up is shared by all three columns: the deepest average's (RAINBOW_DEPTH · (period − 1)) or the range's (lookback − 1), whichever is later — bar 10 at the defaults. The bands and the line warm up together because they read the same complete stack.
      • Not bounded. HH − LL is the range of the source over lookback bars while the stack reaches further back, so a fast move takes the line outside ±100 honestly rather than clamped.
      • An interior gap blanks the bar and every window the stack carries it into; the range itself skips a missing cell (core's reducer policy), so the denominator survives a hole the numerator does not.

      Type Parameters

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

      Parameters

      Returns TimeSeries<
          readonly [
              S[0],
              ValueColumnsForSchema<
                  readonly [
                      S[0],
                      ValueColumnsForSchema<
                          readonly [
                              S[0],
                              ValueColumnsForSchema<S>,
                              OptionalNumberColumn<`${Prefix}`>,
                          ],
                      >,
                      OptionalNumberColumn<`${Prefix}Upper`>,
                  ],
              >,
              OptionalNumberColumn<`${Prefix}Lower`>,
          ],
      >