07 — Oscillators

Stochastic Oscillator#

Debated1 min read
◆ The PatternWhere the close sits inside its recent range: near the top in strength, near the bottom in weakness

The Stochastic Oscillator — developed by George Lane in the 1950s.

%K = (Close − Lowest Low) / (Highest High − Lowest Low) × 100
%D = SMA(3) of %K

Scale: 0–100. Default lookback: 14 periods.

Signals:
• Above 80 = overbought, below 20 = oversold
• %K crossing above %D = buy
• %K crossing below %D = sell
The slow stochastic uses smoothed %K for fewer false signals.
Worked example

Day 15, five-day window: lowest low 98 (day 13), highest high 105, close 104. %K = 100 × (104 − 98) / (105 − 98) = 85.7 — after the rebound the close sits near the top of its range. %D, the three-day average of %K, is only 46.2, because days 13 and 14 were low (10.0 and 42.9).

The example data: 15 days, used in every indicator here
DayHighLowCloseVolume
11019910050,000
210310010262,000
310310010148,000
410510110470,000
510810410785,000
610810510660,000
711010610990,000
811010710872,000
910810410580,000
1010510210366,000
1110510210455,000
1210410110275,000
13102989995,000
141029910164,000
1510510110471,000
Where it misleads
  • In a strong trend %K stays near 100 (or 0) for long stretches, so overbought and oversold readings fight the trend.
  • A narrow range makes it jumpy: when the window’s high and low are close, a small move swings %K across the whole scale.
  • %K and %D cross often; without a trend filter most crossings are noise.
In code
ll = df['low'].rolling(5).min()
hh = df['high'].rolling(5).max()
df['k'] = 100 * (df['close'] - ll) / (hh - ll)
df['d'] = df['k'].rolling(3).mean()
Python, in your browser — edit the code and run it again

Assumes import numpy as np, import pandas as pd, and a DataFrame df with columns high, low, close and volume — the 15 days above.

Sources
  • G. C. Lane, “Lane’s Stochastics”, Technical Analysis of Stocks & Commodities 2(3), 1984
  • Technical Analysis of the Financial Markets, J. J. Murphy, New York Institute of Finance, 1999

Last reviewed October 2026 · How this site checks its content · Report a mistake

Pattern bridge: Where price sits in its recent range is a percentile rank. The smoothed %D line is an EMA applied to the oscillator — momentum of momentum.
Linked from 1
← Previous
Relative Strength Index
Open in the full reader, with the topic sidebar