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

ParameterTypeDefaultBounds or optionsDescription
Fast K Periodinteger51…100000Number of bars used to calculate the raw fast %K value.
Slow K Periodinteger31…100000Smoothing period used to produce slow %K.
Slow K Moving Average TypeenumsmaSimple 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 T3TA-Lib moving average type used for slow %K smoothing.
Slow D Periodinteger31…100000Smoothing period used to produce slow %D from slow %K.
Slow D Moving Average TypeenumsmaSimple 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 T3TA-Lib moving average type used for slow %D smoothing.

Outputs

OutputTypeDescription
Slow KnumberSmoothed %K value for the bar.
Slow DnumberSmoothed %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

  1. Treating every extreme reading as a reversal.
  2. Ignoring how both smoothing choices affect timing.
  3. Comparing outputs without matching the moving-average types.
  4. 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.

Resources

Search documentation

Search across 46 documentation pages.