Stochastic Oscillator

A momentum oscillator that locates the current close relative to the recent high-low range. Two-line composite — %K and %D — built for range-bound markets.

Updated 2026-05-24
9 min read
beginner

A momentum oscillator that asks where the current close sits relative to the high-low range over a lookback window. If today's close is at the top of that range, the indicator reads near 100. At the bottom, near 0.

Placeholder · Video / Clip

Slow Stochastic (14, 3, 3) cycling on MES 5m

Author hint: MES 5m, dark theme, ~80-bar window. Stochastic (Slow, 14, 3, 3) with %K and %D plotted in a sub-panel below the price chart, with horizontal lines at 80 and 20. Show a range-bound stretch where both lines cycle between extremes, plus a couple of %K/%D crossovers. ≤ 10 seconds, no audio. Save to /public/images/guide/indicators/stochastic/chart.mp4.

What it measures

  • Position within the range. Where the current close falls between the period's high and low. A normalized "where in the recent envelope" reading.
  • Momentum direction. Rising %K means recent closes are climbing toward the top of the range; falling %K means the opposite.
  • Crossover signals. The fast %K crossing its smoothed signal %D is a common entry trigger.

Formula

How AlgoLift computes it

Raw %K: ((Close − LowestLow) / (HighestHigh − LowestLow)) × 100 over the K period.

Slow Stochastic (default): %K is the SMA of Raw %K over k_slow_period bars. %D is the SMA of %K over d_period bars.

Fast Stochastic: %K = Raw %K (no smoothing). %D = SMA of %K.

Full Stochastic: All three smoothing parameters fully exposed.

AlgoLift also exposes %J = 3×%K − 2×%D as an "acceleration" line — moves faster than %K, used by some KDJ-style strategies for earlier turn detection.

Developed by George Lane in the late 1950s.

Inputs in AlgoLift

SettingDefaultRangeNotes
TypeSlowFast / Slow / FullSlow applies smoothing to the raw value; Fast doesn't; Full exposes the inner smoothing parameter.
%K Period141–500Lookback for the high-low range.
%K Smoothing31–500Only visible in Full mode. Smoothing applied to Raw %K.
%D Period31–500Smoothing for the signal line.

Recommended settings

  • (Slow, 14, 3) — default: The textbook configuration. Works well for swing setups on 1h–daily bars.
  • (Slow, 5, 3): Intraday short-term — more sensitive, more whipsaws.
  • (Full, 14, 3, 3): When you want to tune the inner smoothing independently.

Outputs in AlgoLift

HandleTypePlottedNotes
%K (Fast Line)NumericAlwaysThe main oscillator line.
%D (Signal Line)NumericAlwaysSmoothed %K — the lagging signal.
%J (Acceleration)NumericOn select3×K − 2×D. Faster than %K, more volatile. Used by KDJ traders.
Raw %KNumericOn selectUnsmoothed value — useful for inspection.
SlopeNumericOn selectRate of change of %K.
Placeholder · Screenshot

Stochastic node — default Slow configuration with all five outputs

Author hint: The Stochastic node on a fresh canvas with default settings (Slow, K Period=14, D Period=3). All five output handles labeled. Dark theme. Tight crop. Save to /public/images/guide/indicators/stochastic/node.png.

How to read it

  • %K > 80: Close is near the top of the recent range. Often called "overbought" — but in a strong trend, %K can stay above 80 for many bars.
  • %K < 20: Close is near the bottom of the recent range. "Oversold" with the same caveat.
  • %K crosses %D from below: Bullish crossover. Strongest when it occurs in the oversold zone (%K < 20) before crossing.
  • %K crosses %D from above: Bearish crossover. Strongest in the overbought zone (%K > 80).
  • Divergence: Price makes a new high but %K makes a lower high — bearish divergence. Inverse for bullish.
Key Takeaway

Stochastic is a range-bound indicator that excels in chop and fails in trends. Pair it with a trend filter before using it as a primary signal — the extremes-as-reversal interpretation is only true when there's no strong trend in progress.

Best in / worst in

Best in range-bound markets, on instruments with clear value zones, and during low-volatility regimes. Stochastic extremes mean something specific in chop — price is bumping against the bounds of a range.

Worst in trending markets. A strong uptrend will keep %K above 80 for days at a time, and selling every overbought reading will lose money continuously. The single most common stochastic mistake.

Three setups

1. Crossover in the extreme zone

The canonical entry: %K and %D cross with the prior reading in an extreme zone.

  • Long: %K crosses above %D AND %K was < 20 within the last 3 bars.
  • Short: %K crosses below %D AND %K was > 80 within the last 3 bars.

The "was recently extreme" requirement filters out crossovers happening in the middle of the range, which are noise.

Placeholder · Screenshot

Stochastic crossover gated by recent extreme

Author hint: Node graph showing Stochastic %K and %D outputs feeding two comparisons (crossover detection), gated by a Tally node tracking whether %K was < 20 in the last 3 bars, into an Entry. Save to /public/images/guide/indicators/stochastic/setup-01.png.

2. Divergence setup

Price makes a new high or low but %K doesn't follow.

  • Bearish divergence: Price closes at a 20-bar high, but %K is below its value from 5 bars ago. Suggests momentum is weakening.
  • Bullish divergence: Price closes at a 20-bar low, but %K is above its value from 5 bars ago.

Divergence is one of the few stochastic signals that holds up reasonably well in mild trends.

3. Stochastic as a pullback timer in a trend

Use a trend filter to set direction, then use stochastic oversold/overbought as the pullback entry timing.

  • Long (uptrend): Price > EMA(50) AND %K crosses above %D AND %K was < 30 within last 3 bars.
  • Short (downtrend): Price < EMA(50) AND %K crosses below %D AND %K was > 70 within last 3 bars.

The trend filter prevents the "selling overbought in a bull market" failure mode.

Advanced patterns in AlgoLift

Stochastic divergence gated by a regime filter. Combine bullish divergence detection with a long-term regime check (price > SMA(200)). When divergence fires and the regime supports it, the signal is meaningfully better than divergence alone. Wire BarsAgo Modifier to compare %K against its value 5 bars ago, then AND the result with the regime check.

%J for fast confirmation, %K for the entry trigger. %J flips direction earlier than %K. Use a %J slope flip as a "get ready" signal that primes a Set User Variable flag, and use the %K/%D crossover that follows as the actual entry. Reduces false starts by requiring two-stage confirmation.

Multi-timeframe stochastic. Add a 1h data series alongside your 5m execution. Only allow 5m stochastic entries when the 1h %K is in the corresponding extreme zone (long entries when 1h %K < 30, short entries when 1h %K > 70). The higher-timeframe state filters most noise on the execution timeframe. See the multi-series Visual Builder pattern.

Common mistakes

  • Trading every overbought / oversold reading. %K above 80 in a strong uptrend isn't a sell signal — it's confirmation the uptrend is working. Always check the trend context first.
  • Using stochastic alone on a trending instrument. A stochastic-only system on NQ during a sustained 2020-style rally lost money continuously because every "overbought" was followed by more upside.
  • Ignoring %D. Bare %K is noisy. The whole point of the %D line is to filter out single-bar spikes — strategies that trigger on %K alone leave the filter unused.
  • Optimizing the periods too tightly. Stochastic at (14, 3, 3) is a sensible default. A strategy that only works at exactly (13, 4, 2) is overfit. See overfitting in trading.
Common Misconception
Myth
Stochastic above 80 means the market will reverse soon.
Reality
%K above 80 means the recent close was near the top of the recent range — that's all. In a trending market, that's a sign of strength, not weakness. The 'overbought = sell' interpretation only holds in range-bound conditions, and stochastic doesn't tell you whether you're in one.