Momentum indicators
Stochastic
Oscillator comparing close position against the recent high-low range.
- Engine
- TA-Lib
- Function
STOCH- Input series
- high, low, close
- Outputs
- 2
How it works
STOCH calculates a fast %K value from the close position within the recent high-low range, then smooths it into slow %K and slow %D outputs using configurable smoothing periods and TA-Lib moving average type codes.
Use case
Use Stochastic outputs as bounded momentum features that describe where price closes relative to its recent range.
Parameters
| Parameter | Type | Default | Bounds or options | Description |
|---|---|---|---|---|
| Fast K Period | integer | 5 | 1…100000 | Number of bars used to calculate the raw fast %K value. |
| Slow K Period | integer | 3 | 1…100000 | Smoothing period used to produce slow %K. |
| Slow K Moving Average Type | enum | sma | Simple Moving Average, Exponential Moving Average, Weighted Moving Average, Double Exponential Moving Average, Triple Exponential Moving Average, Triangular Moving Average, Kaufman Adaptive Moving Average, MESA Adaptive Moving Average, Triple Exponential Moving Average T3 | TA-Lib moving average type used for slow %K smoothing. |
| Slow D Period | integer | 3 | 1…100000 | Smoothing period used to produce slow %D from slow %K. |
| Slow D Moving Average Type | enum | sma | Simple Moving Average, Exponential Moving Average, Weighted Moving Average, Double Exponential Moving Average, Triple Exponential Moving Average, Triangular Moving Average, Kaufman Adaptive Moving Average, MESA Adaptive Moving Average, Triple Exponential Moving Average T3 | TA-Lib moving average type used for slow %D smoothing. |
Outputs
| Output | Type | Description |
|---|---|---|
| Slow K | number | Smoothed %K value for the bar. |
| Slow D | number | Smoothed %D signal value for the bar. |
Reading the result
Stochastic places the close within the recent high-low range and then smooths that relative position. Its two outputs can describe the level and a slower comparison line.
Values near an extreme mean the close remains near one edge of the recent range. In a sustained trend, that condition can persist rather than reverse immediately.
Common mistakes
- Treating every extreme reading as a reversal.
- Ignoring how both smoothing choices affect timing.
- Comparing outputs without matching the moving-average types.
- Using the indicator when a near-zero recent range makes position unstable or uninformative.
DataCat workflow notes
Keep both output mappings explicit in downstream queries. If you derive crossings, calculate them only after filtering or labeling warmup and unavailable rows.