Forex
Indicator

Indicator: What Is the Stochastic Oscillator?

Last updated 2026-07-14

The Stochastic Oscillator is a momentum indicator that compares a currency pair's closing price to its price range over a recent period. Like RSI, it ranges from 0-100 and is used to spot overbought and oversold conditions, but it uses two lines instead of one, which gives an extra crossover signal RSI doesn't have.

The Idea Behind It

The core observation (credited to George Lane in the 1950s) is that in an upward move, prices tend to close near the top of their recent range, and in a downward move, near the bottom. Stochastic simply measures where the latest close sits inside the high-low range of the last N candles (14 by default): a reading of 80 means the close is in the top 20% of the recent range, a reading of 20 means the bottom 20%. When closes stop pressing into the extremes of the range, momentum is fading — often before price itself turns.

%K and %D

  • %K line — the fast, more reactive line, based directly on where the current close sits within the recent high-low range.
  • %D line — a moving average of %K (usually 3-period), smoother and slower, used as the signal line.

Platform settings usually show three numbers, e.g. (5, 3, 3) or (14, 3, 3) — the lookback period, the %D smoothing, and an extra "slowing" applied to %K. The practical takeaway: smaller first numbers make a jumpier, faster oscillator ("fast stochastic"); the common (14, 3, 3) or the slowed (5, 3, 3) variants trade a little lag for far fewer false wiggles.

How to Read the Zones

  • Above 80 — considered Overbought, price may be due for a pullback.
  • Below 20 — considered Oversold, price may be due for a bounce.

Note the thresholds are 80/20 rather than RSI's 70/30 — stochastic moves between its extremes more readily than RSI, which is also why it generates more (and noisier) signals.

Entry Conditions

PriceBUYSELL8020OverboughtOversoldStochastic (0–100)%K%D
Entry conditions: BUY when %K crosses above %D while both are below 20 — SELL when %K crosses below %D while both are above 80
  • BUY — %K crosses above %D while both lines are below 20 (in the oversold zone).
  • SELL — %K crosses below %D while both lines are above 80 (in the overbought zone).

The crossover matters as much as the zone: a %K/%D cross that happens outside the extreme zones is a much weaker signal than one that happens inside them. Some traders add one more refinement — waiting for the lines to cross and then exit the zone (e.g. rise back above 20) before entering, trading the confirmed turn rather than the first twitch.

Divergence

Like RSI, stochastic is used to spot divergence: price sets a lower low while the oscillator sets a higher low (bullish), or price a higher high while the oscillator steps down (bearish). Because stochastic is faster than RSI, its divergences appear earlier but fail more often — the same rule applies with extra force: divergence is a warning to watch for confirmation, never an entry by itself.

Stochastic vs RSI

The two oscillators answer the same question with different machinery — RSI from the size of up vs down closes, stochastic from the close's position in the range. In practice: stochastic is faster and busier, RSI smoother and more conservative. They are alternatives more than partners — running both and calling agreement "confirmation" mostly double-counts the same information. Pick the one whose rhythm fits your trading, and pair it with something that measures a different dimension (trend, volatility, structure).

A Word of Caution

Stochastic is a fast, sensitive oscillator, which means it can whipsaw with multiple crossovers during a strong trending move — in a real uptrend it can pin above 80 and fire repeated "sell" crosses while price marches on, the same limitation RSI has in strong trends. It works best on ranging markets (check the structure first — see Trend vs Range), or combined with a trend filter so you only take oversold buy signals in an uptrend and overbought sell signals in a downtrend. A simple version: only take stochastic buy signals while price is above a 50-period Moving Average, and use levels from support and resistance to decide where a signal is worth acting on.

Download the Indicator

This custom indicator plots %K and %D, with automatic alerts when they cross inside the overbought or oversold zone. It's available for both MetaTrader 4 and MetaTrader 5 below.

How to Install — MetaTrader 4

  1. Download the stochastic-alert.mq4 file below.
  2. Open MetaTrader 4 → click FileOpen Data Folder.
  3. Place the file in the MQL4/Indicators folder.
  4. Restart MetaTrader 4, then drag the indicator from the Navigator window onto the chart.

How to Install — MetaTrader 5

  1. Download the stochastic-alert.mq5 file below.
  2. Open MetaTrader 5 → click FileOpen Data Folder.
  3. Place the file in the MQL5/Indicators folder.
  4. Restart MetaTrader 5, then drag the indicator from the Navigator window onto the chart.

Both files are source code — open and review the full code before using it, for your own safety.

Download stochastic-alert.mq4

For MetaTrader 4 — this is source code (.mq4), open and review it fully before using it.

Download File

Download stochastic-alert.mq5

For MetaTrader 5 — this is source code (.mq5), open and review it fully before using it.

Download File