Our journal app is in pre-release. If you notice a problem, please contact us.

Home › Articles › Stochastic oscillator explained: %K, %D, and the 80 and 20 lines

Article

Stochastic oscillator explained: %K, %D, and the 80 and 20 lines

Add the stochastic to a chart and you get two lines moving between 0 and 100. You may have heard "above 80 is overbought, below 20 is oversold". But what are these lines actually calculating? This article shows how %K and %D are calculated, how the stochastic differs from RSI, and what the 80 and 20 lines describe, with a chart and a worked example. It does not tell you whether to use it as a trade signal.

Published 14 Oct 2026By Kenji Okumura, Representative, Tiltnote (has traded forex)

In short

The stochastic shows, on a scale of 0 to 100, where the latest close sits within the recent price range (from the lowest low to the highest high of the last few bars). Near 100 means it closed near the recent high; near 0, near the recent low.

How %K and %D are calculated

The MT5 help calculates the stochastic like this.[1]

%K = (latest close − recent lowest low) ÷ (recent highest high − recent lowest low) × 100
%D = moving average of %K

For example, if over the last 5 bars the highest high was 1.1050 and the lowest low 1.1000, and the latest close is 1.1040, then %K = (1.1040 − 1.1000) ÷ (1.1050 − 1.1000) × 100 = 80 (our example calculation). It means price closed 80% of the way up the recent range.

MT5 also has a "slowing" setting that smooths %K. The help calls slowing 1 a "fast" stochastic and slowing 3 a "slow" stochastic.[1] In the example code that comes with MT5, with slowing 3, it adds up "close − lowest low" for the last 3 bars and divides it by the sum of "highest high − lowest low" for the same 3 bars (each bar's own lowest low and highest high over the last 5 bars).[2]

Slowed %K = (sum of "close − lowest low" over the last 3 bars) ÷ (sum of "highest high − lowest low" over the last 3 bars) × 100
%D = simple average of the slowed %K over the last 3 bars (when %D is 3)

The chart below uses this calculation with %K 5, slowing 3 and %D 3. With slowing 1, %K is just the first formula above. How many bars %K looks back, the slowing, and how many bars %D averages can all be changed. Setting names and defaults can differ between platforms, so the same "stochastic" can draw slightly different lines.

How it differs from RSI

RSI compares the sizes of recent up moves and down moves. The stochastic looks at where the latest close sits within the recent range. Both use 0 to 100 and often move in similar shapes, but they measure different things.

What the 80 and 20 lines describe

80 or above is often called "overbought" and 20 or below "oversold" (some traders use 70 and 30 instead). But above 80 only means "the latest close is near the top of the recent range". It is not a forecast that price will fall.

Top: price. Bottom: stochastic %K (solid) and %D (dashed). While price keeps rising, %K and %D stay above 80.
A made-up example. While price keeps rising, each close lands near the top of the recent range, so %K and %D stay above 80. In the sideways part, they move back and forth between 80 and 20. Settings here: %K 5, slowing 3, %D 3.

As in the chart, in a strong rise each close lands near the recent high, so the stochastic tends to stay above 80. In a strong fall, it tends to stay near or below 20. In a sideways market, it crosses the lines back and forth. Like other indicators, it is calculated from past prices and lags behind (see why indicators lag).

Check how you use it (you decide)

This article does not decide whether to use the stochastic, or which settings or lines to watch. If you use it, decide these first and log them, so you can see later how it worked for you:

The trading stats calculator turns a profit and loss list into win rate, average P&L and longest losing streak. With few trades, the numbers can change a lot. For other indicators, see MACD explained and Bollinger Bands explained.

Sources

  1. MetaQuotes. Stochastic Oscillator (MetaTrader 5 Help). https://www.metatrader5.com/en/terminal/help/indicators/oscillators/so
  2. MetaQuotes. Stochastic.mq5 (example code that comes with MetaTrader 5, in the MQL5\Indicators\Examples folder of the MT5 data folder)

Tools for this article

Tag the trades you took on the stochastic.

Tiltnote is a trading journal you can use free with manual entries. On every trade you can log your strategy name, how you felt, whether you kept your rules, and a note. Put the settings in the strategy name, like "Stoch 5/3/3", and you can look back at those trades later.

Try Tiltnote free →Opens the Tiltnote web app. On the free plan, analysis and history show your most recent 14 days (older records are kept and unlock on the paid plan).

More articles

RSI explained: the math and what "overbought" meansMACD explained: the math, the zero line and the signal lineBollinger Bands explained: the math, and a common mythWhy a backtest can show an edge that isn't thereHow far can you trust your win rate?Confirmation bias in tradingArticles →

Feedback on this page

Anything missing, unclear, or a tool you would like? Tell us in any language.

Numbers you entered in a tool are not sent. Please do not include account numbers or passwords. Privacy details

This article is general information. It is not investment advice or a recommendation to make any trade.

Updated 20 Oct 2026 · Run by Kenji Okumura, Representative, Tiltnote · About this site