๐๏ธ Stochastic RSI
Stochastic RSI applies the Stochastic Oscillator's own formula to the RSI series instead of to raw price. It is, quite literally, "an oscillator of an oscillator" โ designed to catch overbought/oversold extremes within the RSI itself.
๐ก Financial Meaning
Plain RSI can drift in the 40โ60 zone for long stretches without ever reaching the classic 30/70 thresholds, especially in low-volatility markets. Stochastic RSI rescales RSI's own recent range to 0โ100 every bar, so it reaches its extremes far more often โ giving more frequent, faster signals at the cost of more noise and false positives.
๐ข Mathematical Formulas
-
Base RSI series (see RSI), using the configured lookback \(N\):
\[ RSI_t = 100 - \frac{100}{1+RS_t} \] -
Stochastic transform applied to RSI itself โ where it currently sits relative to its own \(N\)-period high/low range:
\[ \%K_t = 100 \cdot \frac{RSI_t - \min_{0 \le i < N} RSI_{t-i}}{\max_{0 \le i < N} RSI_{t-i} - \min_{0 \le i < N} RSI_{t-i}} \] -
%D โ a short moving average of %K that smooths the raw stochastic line:
\[ \%D_t = SMA_{d}(\%K) \]
โ๏ธ Parameters
| Parameter | Key | Default | Description |
|---|---|---|---|
| Stochastic Period (\(N\)) | period |
14 | Shared lookback for the underlying RSI and its stochastic %K range, in sessions. |
| D Period (\(d\)) | dPeriod |
3 | SMA window applied to %K to produce %D, in sessions. |
| Overbought | overbought |
80 | Threshold for the overbought zone. |
| Oversold | oversold |
20 | Threshold for the oversold zone. |
Shared RSI and stochastic lookback
LibreFolio passes period to TA-Lib as both the underlying RSI period and the
stochastic %K lookback. A separate RSI-length parameter is intentionally not exposed.
๐๏ธ Signal Processing Equivalent โ Cascaded Normalisation Stages
Stochastic RSI is a two-stage cascade: stage one (RSI) rectifies and normalises the price derivative into 0โ100; stage two (Stochastic) re-normalises that signal against its own recent envelope, then smooths with a short FIR average (%D). Cascading two bounded, self-normalising stages produces a signal that saturates at its rails much more aggressively than either stage alone.
flowchart LR
C["๐น Close"] --> RSI["๐ช RSI(N)"]
RSI --> MINMAX["๐ Rolling min/max over N bars"]
MINMAX --> K["๐ฏ %K"]
K --> D["๐ %D = SMA(d, %K)"]
Faster but noisier
Because it normalises against a local window instead of a fixed 0โ100 scale, %K can swing from 0 to 100 in just a few bars โ useful for quick reversal signals, but more prone to whipsaws than plain RSI.