# Stochastic Oscillator

Also known as: fast/slow/full, %K/%D, stochastic cross.
A Momentum & Oscillators concept (Stochastics) in the LuxAlgo Library, with 6 indicator implementations.

## What is the Stochastic Oscillator?

The Stochastic Oscillator, developed by George Lane in the 1950s, measures where the latest close sits inside the recent high-low range. Its %K line equals 100 times (close minus the lowest low of the lookback) divided by (highest high minus lowest low), so a reading of 80 puts the close in the top fifth of the last 14 bars' range (14 being the common length). %D, the signal line, is a 3-period simple moving average of %K.

Lane's premise was that momentum turns before price: in an advance, closes cluster near the top of the range and begin slipping toward the middle before the highs stop coming. Three variants trade speed for smoothness. Fast stochastic plots raw %K; slow stochastic uses a 3-period average of raw %K as its %K and smooths %D again; full stochastic exposes the lookback, the slowing, and the %D length as separate parameters.

The oscillator matters because its grammar became a template: 80/20 [overbought/oversold](https://www.luxalgo.com/library/concept/overbought-oversold/) zones, %K/%D crossovers, and [divergence](https://www.luxalgo.com/library/concept/regular-bullish-bearish-divergence/) reads all generalize across the oscillator family, and descendants such as the [Stochastic RSI](https://www.luxalgo.com/library/concept/stochastic-rsi/) and the [Stochastic Momentum Index](https://www.luxalgo.com/library/concept/stochastic-momentum-index/) reuse the core calculation. It is fast, bounded, and blunt: strong trends pin it at the extremes, so regime context decides how it should be read.

## How to calculate the Stochastic Oscillator

The calculation needs only highs, lows, and closes over a lookback window.

1. Choose a lookback N (14 is conventional) and find the highest high and lowest low across those N bars.
2. Compute raw %K: 100 times (close minus the lowest low) divided by (highest high minus the lowest low). The result is bounded between 0 and 100 by construction.
3. Smooth if desired: the slow version uses a 3-period SMA of raw %K as its %K line, and %D is a 3-period SMA of whichever %K you plot. The full version makes all three lengths adjustable.
4. Read the result through three lenses: position against the 80/20 zones, %K crossing %D, and divergence between oscillator swings and price swings.

## How it's calculated

The position of the latest close inside the recent high-low range, scaled from 0 to 100.

```
%K_t = 100 × (C_t - LL_n) / (HH_n - LL_n)
%D_t = SMA of %K over the last d bars (the signal line)
Fast stochastic: %K as in line 1, %D with d = 3
Slow stochastic: slow %K = SMA of %K over 3 bars, slow %D = SMA of slow %K over d bars
Full stochastic: full %K = SMA of %K over s bars, full %D = SMA of full %K over d bars (s = 1 is fast, s = 3 is slow)
Bullish %K/%D cross: %K_t > %D_t and %K_(t-1) <= %D_(t-1)

  t: bar index
  C_t: close of bar t
  HH_n: highest high of the last n bars
  LL_n: lowest low of the last n bars
  n: lookback length (commonly 14)
  %K_t: raw stochastic at bar t, on a 0 to 100 scale
  %D_t: signal line at bar t
  s: smoothing length applied to %K (1 = fast, 3 = slow)
  d: smoothing length for %D (commonly 3)
  SMA: simple moving average over the stated number of bars
```

Default settings are (14, 3, 3); readings above 80 are conventionally overbought and below 20 oversold.

When HH_n = LL_n the denominator is zero; implementations hold the prior %K or leave the bar undefined.

SMA is the standard smoothing; platforms offering EMA smoothing shift the crosses earlier.

## How traders use it

- As a pullback trigger inside trends: with a [higher-timeframe trend filter](https://www.luxalgo.com/library/concept/higher-timeframe-trend-filter/) pointing up, an oversold %K/%D cross back above 20 times entries in the trend's direction instead of fighting it.
- As a mean-reversion gauge inside a [trading range](https://www.luxalgo.com/library/concept/trading-range/), fading excursions past 80/20 as the close's position in the range rotates; this is the read that fails when a breakout turns the range into a trend.
- As a divergence engine: Lane himself emphasized divergence, price making a new swing extreme that %K does not confirm, with the crossover then serving as the trigger.
- As a continuation read: [Stochastic Pop](https://www.luxalgo.com/library/concept/stochastic-pop/) style approaches buy a push above 80 and hold while the reading stays pinned, the deliberate inverse of the reversion interpretation.

## Stochastic Oscillator vs related oscillators

- **RSI** (https://www.luxalgo.com/library/concept/rsi/): RSI averages the size of up closes against down closes; the stochastic locates the close inside the high-low range. One responds to the magnitude of changes, the other to position within the range, so a quiet drift near the top of the range can keep the stochastic pinned while RSI eases back.
- **Williams %R** (https://www.luxalgo.com/library/concept/williams-percent-r/): %R is the same range-location arithmetic measured from the top of the range: it equals %K minus 100, plotted on a 0 to -100 scale, traditionally without smoothing or a signal line. The information content is identical.
- **Stochastic RSI** (https://www.luxalgo.com/library/concept/stochastic-rsi/): The Stochastic RSI feeds RSI values, not prices, through this same formula, making it an indicator of an indicator: faster, pinned at its boundaries more often, and two derivations removed from price.
- **Stochastic Momentum Index** (https://www.luxalgo.com/library/concept/stochastic-momentum-index/): The SMI measures the close relative to the midpoint of the high-low range rather than to its extremes, then double-smooths the result, so it oscillates around zero and reads like a calmer, centered cousin.

## FAQ

### What do %K and %D mean on the Stochastic Oscillator?

%K is the main line: the close's position inside the lookback range, scaled 0 to 100. %D is a 3-period simple moving average of %K that serves as the signal line, so %K crossing %D is the classic trigger. In slow and full variants, %K is itself pre-smoothed before %D is computed.

### What is the difference between fast, slow, and full stochastic?

Fast plots raw %K with a 3-period average as %D and reacts quickest. Slow shifts everything one smoothing step: its %K is the fast version's %D, and its %D smooths that line again. Full generalizes both by exposing lookback, slowing, and %D length as parameters, so fast and slow are special cases of full.

### What are the best stochastic oscillator settings?

There is no best. The common default is 14,3,3; shorter lookbacks such as 5,3,3 trade smoothness for speed, longer ones fire less often, and heavier slowing suppresses whipsaw at the cost of lag. Settings interact with the instrument's volatility and your holding period, so they are choices to test, not answers to copy.

### Is the Stochastic Oscillator a leading indicator?

Lane described it that way, arguing momentum fades before price turns, and divergences do sometimes precede swing turns. But every value is computed from past prices, and in trends the oscillator issues early warnings repeatedly without a turn arriving. Treat readings as evidence about the current swing, not as a forecast.

### Why does the stochastic stay above 80 in a strong uptrend?

Because the formula measures exactly what a persistent advance does: closes keep finishing near the top of the recent range. A pinned reading signals one-way pressure rather than a broken indicator. Fading it without a regime check is the standard mistake; many trend systems act only on the eventual cross back below 80, if at all.

## Implementations in the Library

- Inertial Stochastic (LuxAlgo): https://www.luxalgo.com/library/indicator/inertial-stochastic/
- Stochastic Adaptive %D (LuxAlgo): https://www.luxalgo.com/library/indicator/stochastic-adaptive-d/
- Multi-Length Stochastic Average (LuxAlgo): https://www.luxalgo.com/library/indicator/multi-length-stochastic-average/
- Circular Barplot - Oscillators Sentiment (LuxAlgo): https://www.luxalgo.com/library/indicator/circular-barplot-oscillators-sentiment/
- Normalized Oscillators Spider Chart (LuxAlgo): https://www.luxalgo.com/library/indicator/normalized-oscillators-spider-chart/
- Stochastic (LuxAlgo, the standard build of the classic formula): https://www.luxalgo.com/library/indicator/stochastic/

## Related concepts

- Double Stochastic: https://www.luxalgo.com/library/concept/double-stochastic/
- Stochastic Momentum Index: https://www.luxalgo.com/library/concept/stochastic-momentum-index/
- DSS Bressert: https://www.luxalgo.com/library/concept/dss-bressert/
- Adaptive Stochastic: https://www.luxalgo.com/library/concept/adaptive-stochastic/
- Premier Stochastic: https://www.luxalgo.com/library/concept/premier-stochastic/
- Stochastic Pop: https://www.luxalgo.com/library/concept/stochastic-pop/

---

Source: https://www.luxalgo.com/library/concept/stochastic-oscillator/ (LuxAlgo Library, the encyclopedia of trading & technical analysis). Free to use with attribution: https://www.luxalgo.com/library/license/