MomentumReference · Indicator Library

Stoch

Stochastic Oscillator

A bounded 0–100 oscillator that measures where the close sits relative to the high-low range over a chosen lookback — paired with a smoothed signal line for crossover triggers.

Stochastic is a 0–100 momentum oscillator that measures where the close sits within the high-low range over the past N bars. The fast %K line and its smoothed %D signal line cross above 80 for overbought conditions and below 20 for oversold. Default settings: %K=14, %D=3.

Developed by George Lane in the 1950s, the Stochastic Oscillator compares the current close to the trading range of the past N bars (typically 14). The fast %K line ranges 0–100, and a smoothed %D line (default 3-period SMA of %K) acts as a trigger. Readings above 80 are conventionally "overbought," below 20 "oversold."

Stochastic shines in ranging markets where price oscillates between support and resistance — the %K/%D crossovers in oversold/overbought zones produce reliable mean-reversion signals. In strong trends it tends to lock in extremes for long stretches, so use a trend filter alongside it.

How do I read Stoch?

  • Above 80 = overbought. The close is in the upper 20% of the recent range. Mean-reversion risk is elevated, but in trends Stochastic can stay above 80 for many bars without reversing.
  • Below 20 = oversold. The close is in the lower 20% of the recent range. Bounce candidate, with the same trending-market caveat.
  • %K crossing above %D in the oversold zone = textbook long trigger. Crossing below %D in overbought = exit/short trigger.
  • %K and %D direction agreement matters: both rising = strengthening bullish momentum; both falling = weakening. Disagreement = unclear regime.
  • Bullish divergence (price lower low, %K higher low) = waning downside momentum. Same logic in reverse for bearish divergence.
  • Stochastic responds faster than RSI to recent price changes — better for short timeframes, but more prone to false signals in choppy markets.

How is Stoch calculated?

Stochastic compares the current close to the trading range over the lookback period, on a 0–100 scale. A signal line smoothed from %K provides crossover triggers.

  1. 1.Identify the highest high and lowest low over the past 14 bars.
  2. 2.Compute the raw %K = 100 × (close − lowest_low) / (highest_high − lowest_low).
  3. 3.%K = 0 means the close is at the period low; %K = 100 means at the period high; %K = 50 is the midpoint.
  4. 4.Compute the %D signal line as a 3-bar simple moving average of %K.
  5. 5.Crossovers between %K and %D, especially in overbought (above 80) or oversold (below 20) zones, are the standard timing signals.

What are the default Stoch settings?

ParameterDefaultWhen to adjust
%K period14Lane's original setting. Drop to 9 for faster signals on intraday; raise to 21 for less noise on daily charts.
%K smoothing1 (raw) or 3 (slow)Raw %K = 'Fast Stochastic'. Smoothing %K with a 3-bar SMA = 'Slow Stochastic' — less noisy, more popular today.
%D smoothing3%D = 3-bar SMA of %K. The standard Stochastic signal line. Tighter (2) gives earlier signals; wider (5) is smoother.
Overbought threshold80Raise to 90 in strong uptrends to filter trend-continuation false sells.
Oversold threshold20Drop to 10 in strong downtrends.

How do I plot Stoch in Pine Script?

//@version=5
indicator("Stochastic Example", overlay=false)

lengthK = input.int(14, title="%K Length",     minval=1)
smoothK = input.int(3,  title="%K Smoothing",  minval=1)
smoothD = input.int(3,  title="%D Smoothing",  minval=1)

k = ta.sma(ta.stoch(close, high, low, lengthK), smoothK)
d = ta.sma(k, smoothD)

plot(k, title="%K", color=color.blue,   linewidth=2)
plot(d, title="%D", color=color.orange, linewidth=2)
hline(80, "Overbought", color=color.red,   linestyle=hline.style_dashed)
hline(20, "Oversold",   color=color.green, linestyle=hline.style_dashed)

Pine's ta.stoch() returns the raw %K only — you smooth it yourself with ta.sma(). Setting smoothK=1 gives you Fast Stochastic; smoothK=3 gives the more common Slow Stochastic. Plotting both %K and %D with horizontal lines at 80/20 makes the standard crossover-in-extreme-zone setup visually obvious.

Continue exploring

Related indicators

Browse all indicators

About this reference

This page is an educational reference explaining what Stoch is, how it is calculated, its default settings, and how to plot it in Pine Script. It is compiled from established trading literature and public technical documentation. Last review: .

Educational content. Not financial advice.