Stochastic Oscillator

The stochastic shows where the close sits within the recent high–low range and is popular for spotting turning points in ranging markets.

What it is

George Lane introduced the stochastic oscillator in the 1950s. The idea is that in an uptrend price tends to close near the top of its recent range, and in a downtrend near the bottom. The result is shown on a 0 to 100 scale.

How it's calculated

  1. %K = 100 × (close − lowest low of 14) ÷ (highest high − lowest low of 14)
  2. %K is usually smoothed over 3 candles.
  3. %D = 3-period moving average of %K (the signal line)

How traders read it

  • Above 80 is considered overbought and below 20 oversold.
  • %K crossing %D in those zones is the most common stochastic signal.
  • The stochastic works better in ranges than in strong trends.

Settings

Common settings are 14, 3 and 3. The "fast" version, without smoothing %K, gives more and noisier signals.

Where it misleads

  • In a strong trend the stochastic can stay in an extreme zone for a long time, and counter-trend signals lose one after another.
  • It's better to take signals only in the direction of the higher timeframe's trend.

Its Pine Script on Vlevel

This is the script the chart runs. In the chart's indicators window you can open it, change it and save your own copy.

Stochastic · Pine Script v6
//@version=6
indicator("Stochastic", shorttitle = "Stoch", format = format.price, precision = 2)
periodK = input.int(14, "%K Length", minval = 1)
smoothK = input.int(1, "%K Smoothing", minval = 1)
periodD = input.int(3, "%D Smoothing", minval = 1)
k = ta.sma(ta.stoch(close, high, low, periodK), smoothK)
d = ta.sma(k, periodD)
plot(k, "%K", color = #1fb8ff)
plot(d, "%D", color = #f5a742)
hline(80, "Upper Band", color = color.new(color.white, 75), linestyle = hline.style_dashed)
hline(50, "Middle Band", color = color.new(color.white, 75), linestyle = hline.style_dotted)
hline(20, "Lower Band", color = color.new(color.white, 75), linestyle = hline.style_dashed)

Indicators describe past prices; none predicts the future. For education, not investment advice.