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

    Function stochasticRsi

    • Stochastic RSI (Tushar Chande & Stanley Kroll) — the stochastic construction applied to rsi instead of to price:

      r        = rsi(column, rsiPeriod)
      raw = 100 · (r − LL(r, stochPeriod)) / (HH(r, stochPeriod) − LL(…))
      ${prefix}K = SMA(raw, kPeriod)
      ${prefix}D = SMA(${prefix}K, dPeriod)

      Appends two columns, both bounded 0..100. RSI spends most of its life between 40 and 60, so its own overbought/oversold thresholds fire rarely; normalising it against its own recent range makes it reach both extremes constantly. It is a much faster indicator than the RSI under it, and that is the point rather than a defect.

      It composes on the shipped rsi — the study, not a private copy — so Wilder's seed, the flat-window rule and every other RSI decision are inherited by construction rather than restated.

      means on stochastic

      Read this before reaching for the analogy. The two studies use their own vendor's vocabulary, and the same word lands on different knobs:

      this study stochastic TA-Lib STOCHRSI what it is
      stochPeriod kPeriod fastk_period the HH/LL look-back
      kPeriod slowing fastd_period the smoothing of the raw position
      dPeriod dPeriod the smoothing of %K

      rsiPeriod and stochPeriod are separate knobs even though both default to 14: they answer different questions (how much history the RSI averages, and how much of the RSI's own history the range covers), and vendors ship them independently.

      TA-Lib's STOCHRSI returns fastk and fastd, not a slowed %K and %D, so the correspondence is not the obvious one and the generator measures which column equals which. On the oracle input at the defaults:

      • ${prefix}K == talib.STOCHRSI(…, fastk_period = stochPeriod, fastd_period = kPeriod).fastd — bar for bar, to 9.9e-14, with identical null masks (both first valid at bar 29).
      • The raw, unsmoothed range position — which this study does not emit — equals TA-Lib's fastk to 1.3e-13.
      • ${prefix}D has no TA-Lib counterpart. STOCHRSI stops at fastd; the second smoothing is the conventional %D that every charting platform draws beside it, and it is a pandas replication in the oracle.

      Crossing the columns is a real error, not a rounding one: ${prefix}K against TA-Lib's fastk differs by 45 points on this fixture, which is why the generator asserts both the match and the mismatch.

      • A flat RSI window is undefined. When HH === LL the ratio is 0/0; TA-Lib reports 0, which is also the value for "the RSI is at the very bottom of its range". The rule lives in percentOfRangeValues so stochastic, williamsR and this study all make the same call. It is genuinely reachable here — an RSI pinned at 100 through a run of unbroken gains gives a flat window on real data, where a flat price range mostly does not — and a unit test pins it.
      • A flat RSI window inside the underlying RSI (no gains and no losses at all) is undefined too, from rsi's own rule.

      On gap-free input: the RSI at bar rsiPeriod (differences need one extra bar), the range at + stochPeriod − 1, %K at + kPeriod − 1 and %D at + dPeriod − 1. At the defaults that is bars 29 and 31. Both smoothings go through rollingMeanValues, which waits for the window's worth of finite values — the derived-input rule, and the same reason stochastic's slow %K is not one bar early.

      • Scale- and shift-invariant, because the RSI under it is: multiplying or offsetting every price leaves both columns unchanged (pinned).
      • An interior gap propagates to the end, and that is the RSI's Wilder recursion rather than anything here — a recursion has no state to carry across a hole. Fill before smoothing if you need continuity.
      • kPeriod: 1 leaves %K as the raw range position — the "fast" Stochastic RSI, one knob rather than a second function, exactly as stochastic's slowing: 1 gives the fast stochastic.

      Type Parameters

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

      Parameters

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