Indicator library · Momentum

Stochastic Oscillator

George Lane’s oscillator answers one question: where in its recent range did this close land? That makes it a position measure rather than a magnitude measure, and explains why it reaches its extremes on days when almost nothing happened.

The calculation

  1. Take the highest high and the lowest low of the last n bars.
  2. %K: (close − lowest low) ÷ (highest high − lowest low) × 100. The close’s position inside that range, from 0 to 100.
  3. %D: a three-period average of %K. In the "slow" version, which is what most platforms plot by default, %K is itself already an average of the raw calculation and %D is an average of that.

Note what enters and what does not. The highs and lows define the range, so this is one of the few oscillators here that cannot be computed from closing prices alone. And no measure of distance travelled appears anywhere, only where the last close sits between two extremes.

Price with a slow stochasticThe upper panel shows a price series rising for about sixteen bars then falling back and recovering. The lower panel shows the slow stochastic on a nought-to-one-hundred scale, holding in the upper part of its range through the advance, falling through the middle as price turns, reaching the low teens during the decline and rising sharply on the recovery.CLOSE805020SLOW %D35.66price highPrice with a slow stochasticThe upper panel shows a price series rising for about sixteen bars then falling back and recovering. The lower panel shows the slow stochastic on a nought-to-one-hundred scale, holding in the upper part of its range through the advance, falling through the middle as price turns, reaching the low teens during the decline and rising sharply on the recovery.CLOSE805020SLOW %D35.66price high
Fig. 1: schematicComputed at build time from the high, low and close of every bar in this page's source, with a 9-bar lookback and two rounds of 3-bar smoothing. Watch the recovery at the right-hand end: the oscillator climbs steeply while price has retraced only a fraction of its decline. Nothing is wrong. The close is landing near the top of a range that has itself contracted, which is exactly what this indicator reports and exactly what makes its extremes weaker evidence than they look.

Position, not magnitude

The property that separates this oscillator from every other one in the library is its denominator. Because the reading is divided by the range, the range decides how easily the extremes are reached.

Two sessions, same reading, different markets
SessionRange over the windowReading
Quiet market0.6% high to lowClose near the top prints 95, a move of half a per cent has produced an extreme reading.
Active market9% high to lowThe same 95 means the close landed near the top of a genuinely wide range.

Both readings are correct and they describe different events. The habit that fixes it costs one glance: read the range beside the oscillator, and treat an extreme in a contracted range as the arithmetic it is rather than as evidence of anything.

Reading it

The extremes

Above 80 the close has been finishing near the top of its recent range; below 20, near the bottom. In a range-bound market those are useful edges. In a trend the oscillator parks at one end for weeks (the close keeps landing near the top because the top keeps moving), and each crossing back through the threshold is a counter-trend trade in a market that is not turning.

The crossing of %K and %D

The most quoted signal and the noisiest, because it is one average crossing an average of itself. It fires several times a month on ordinary data and its usefulness depends almost entirely on whether the instrument was ranging, which the indicator cannot tell you.

Divergence

Price makes a higher high, the oscillator does not, the second push failed to close as near the top of its range as the first. This is the reading that survives, read exactly as on RSI: a statement about the character of the advance, not a countdown.

Where the name comes from

George Lane popularised the oscillator in the 1950s, and the name has caused confusion ever since: nothing about the calculation is stochastic in the mathematical sense. There is no randomness, no probability distribution and no process being modelled. The term was applied loosely to the idea that closing prices tend to cluster near the extremes of a range in a trending market, which is an empirical observation rather than a stochastic model.

That observation is worth keeping, because it is the honest version of what the indicator detects. In an advance, closes cluster near the top of the recent range; in a decline, near the bottom. The oscillator measures that clustering directly, and the well-known behaviour of parking at an extreme through a trend is the observation working exactly as intended rather than the indicator failing.

Where it misleads

Known failure modes
SituationWhat goes wrong
Contracted rangeThe range is the denominator. A half-per-cent week can produce a reading of 95 on a close near its top.
Strong trendThe line parks above 80 or below 20 for weeks, and every crossing is a counter-trend trade.
%K/%D crossings tradedOne average crossing an average of itself. Frequent, and mostly noise outside a range-bound market.
Fast version read rawUnsmoothed %K jumps between extremes on ordinary data; every practical version smooths it at least once.
Data source differencesThe range depends on which venues' highs and lows the feed includes, so two providers give slightly different readings.
GapsA gap outside the window's extremes resets the range instantly, moving the reading without any change in behaviour.

What volume adds

The stochastic reads three prices per bar and no participation at all. Its most common failure, an extreme produced by a contracted range in a quiet market, is precisely the case volume identifies immediately: the range contracted because almost nobody was trading.

Reading the two together turns the weakest reading this indicator produces into a usable one. A close at the top of its range on the heaviest volume in weeks is a different observation from the same close at the top of a range that narrowed because the market went quiet, and only one of them describes a market where anything happened.

Frequently asked questions

What does the stochastic oscillator measure?

Where the closing price sits inside the high-low range of the last n bars, as a percentage. A reading of 100 means the close was the highest point of the window; 0 means it was the lowest; 50 means it finished in the middle. It is a position measure, and that is the whole of it, nothing in the calculation reflects how far the price travelled, only where it ended relative to its own recent extremes.

How does it differ from RSI?

RSI aggregates the sizes of up and down changes, a magnitude measure. The stochastic locates one close within a range, a position measure. The practical consequence is that a stochastic can print 100 on a tiny range, because the range is the denominator: an instrument that moved half a per cent all week can still close at the top of that half per cent. RSI cannot reach an extreme without real movement behind it.

What is the difference between fast, slow and full?

How many times the raw calculation is averaged. Fast %K is the raw position, and it is too noisy to read; fast %D is a three-period average of it. Slow %K is that same average promoted to the main line, with %D a further average on top, so the "slow" version is the fast version smoothed once more. The full version simply exposes all three parameters — lookback, the first smoothing and the second — instead of fixing them. They are the same indicator at three degrees of smoothing.

What do 80 and 20 mean here?

That the close has been sitting near the top or the bottom of its recent range. They are conventions, not thresholds with statistical standing, and they mean less than the RSI levels do, in a trend the close spends long stretches near one extreme, so the oscillator parks above 80 or below 20 for weeks. Reading each crossing as a signal in that environment produces a stream of counter-trend losses.

Why does it reach extremes so easily?

Because the range is the denominator and ranges contract. In a quiet market the high-low window narrows, so a small move puts the close at the top of it and the oscillator reads 95 on a session that would barely register anywhere else. This is not a defect (it accurately reports where the close sat), but it is why a stochastic extreme in a dull market is close to meaningless, and why the range itself is worth a glance before the reading is trusted.

What is the most reliable reading?

Divergence, as with every oscillator here: price makes a higher high while the stochastic makes a lower one, meaning the second push failed to close as near the top of its range as the first. It is a description of weakening, not a trigger, and it persists, sometimes for months. The crossing of %K and %D is the more commonly quoted signal and is considerably noisier, since it is one average crossing an average of itself.

Which lookback should I use?

Fourteen by convention, from Lane’s original work, with 5 for a fast reading and 21 for a slow one. The choice sets what "recent range" means, and the sensible way to pick it is from the length of the swings you actually care about. Whatever you choose, state it: a stochastic on a 5-bar window and one on a 21-bar window are different measurements, not different opinions about the same one.

Does it need high and low prices, or will closes do?

It needs the highs and lows; they define the range the close is being placed inside. This makes it one of the few oscillators on this site that cannot be computed from a series of closing prices alone, and it also makes it sensitive to how your data provider records extremes: a feed that reports only consolidated prints will give a slightly different range from one including every venue, and therefore a slightly different reading.