Stochastic Oscillator
What is the stochastic oscillator?
The stochastic oscillator (also called stochastics) is a momentum indicator that measures where the latest close sits within the high–low range of the last N bars, on a scale from 0 to 100. Its main line, %K, is 100 at the top of that range and 0 at the bottom; %D is a moving average of %K.

Simulated daily candles with a slow 14,3,3 stochastic oscillator below them: %K and %D swing across the 0 to 100 scale in the ranges and stay near one end in the trends. Try the interactive version.
- %K measures where the close sits in the N-bar range: 100 at the highest high, 0 at the lowest low.
- %D is a moving average of %K. Fast, slow and full stochastics differ only in how much they smooth.
- 14,3,3 is a 14-bar look-back with two 3-bar averages, and it is a common default.
- Above 80 and below 20 are conventional zones. In a strong trend the oscillator can stay in one of them for weeks.
- Crossovers and divergence are ways traders read the lines, not rules that hold every time.
This page explains how the stochastic oscillator is calculated, read and drawn. It is not investment advice.
What does the stochastic oscillator measure?
It measures the close's position inside the recent trading range, as a percentage of that range.
Take a 14-day range from a low of 90 to a high of 110. A close of 108 is 18 points above the low in a 20-point range, so %K is 90: the market finished near the top of where it has traded for two weeks. A close of 92 gives a %K of 10, near the bottom.
The idea behind it is that in a rising market, closes tend to land near the top of each bar's range, and in a falling market near the bottom. When closes start to slip away from the extreme while the price is still trending, momentum may be fading. The oscillator turns that position into a number that can be compared over time and across instruments, because it is always between 0 and 100 whatever the price.
It uses three inputs from every bar: the high, the low and the close. The open and volume play no part.
The indicator is usually credited to George Lane, a US technical analyst and educator, in the 1950s; he described %K and %D in his article "Lane's Stochastics" (1984). Despite its name, it is a fixed calculation on past prices and has no link with stochastic processes in probability theory.
How to calculate the stochastic oscillator
Raw %K places the close in the N-bar high–low range, and %D is a short moving average of %K.
With as the look-back (14 by default), the highest high and the lowest low over the last bars including the current one, and the current close:
where is the simple moving average of the last values. With , %K is the raw value; that is the fast stochastic. The steps on each bar are:
- Look back over the last bars, including this one, and find the highest high and the lowest low.
- Subtract the lowest low from the close, divide by the range and multiply by 100. That is raw %K.
- Average the last raw values to get %K, then the last values of %K to get %D.
A few details vary between charting packages:
- Flat range. If every bar in the window has the same high and low, the range is zero and the formula divides by zero. Software returns 0, 50 or the previous value. The demo on this page uses 50, the middle of the scale.
- Warm-up. Raw %K needs bars, %K needs more and %D another . With 14,3,3, the first %D value is on bar 18.
- Kind of average. Most packages use a simple moving average for both steps; some offer an exponential one, which changes the values.
Worked example: 12 bars with a 5-bar look-back
A 5-bar look-back keeps the table short; the steps are the same for 14. Fast %K is raw %K, its 3-bar average is the fast %D (which is also the slow %K), and the 3-bar average of that is the slow %D.
| Bar | High | Low | Close | 5-bar highest high | 5-bar lowest low | Fast %K | Fast %D = slow %K | Slow %D |
|---|---|---|---|---|---|---|---|---|
| 1 | 51.0 | 50.0 | 50.6 | – | – | – | – | – |
| 2 | 51.6 | 50.6 | 51.4 | – | – | – | – | – |
| 3 | 52.4 | 51.2 | 51.9 | – |