It reacts earlier to short-term changes, which suits intraday trading.
What is the Stochastic oscillator?
Compares the close with the full range of the last N candles to show where price sits within that range.
What is Stochastic Oscillator?
Compares the close with the recent high–low range to measure momentum and overbought/oversold zones.
Illustrative signals of the rule on simulated data — not a trading recommendation.
Rule: %K crosses above %D in the zone below 20: buy; crosses below in the zone above 80: sell. Entry = close of the signal candle; SL = entry ∓ 1.5 × ATR(14); TP1/TP2/TP3 = 1R/2R/3R.
Where this indicator is strong
Three reasons Stochastic Oscillator is still used after decades.
The %K and %D cross creates a second layer of confirmation instead of a single threshold.
Very effective when price moves within a defined range.
How to read Stochastic Oscillator signals
How Stochastic Oscillator produces its number, and what each shape on the chart means.
Formula and how it works
Raw %K = 100 × (close − lowest low of N periods) / (highest high − lowest low). Slow %K is the SMA of raw %K, and %D is the SMA of slow %K. Values above 80 are overbought, below 20 oversold.
Enter when %K crosses %D in an extreme zone; combine with the main trend to avoid noisy signals in a strong one-way market.
The market moves sideways, with a relatively clear upper and lower boundary.
A strong trend. The indicator stays saturated in the extreme zone for many sessions and keeps suggesting trades against the trend.
Using it alone in a trending market. It always needs a trend filter in front to know which direction is allowed.
Recommended MT5 parameters for Stochastic Oscillator
Default values of the sample file; test them for your market and timeframe.
| Parameter | Description |
|---|---|
| InpK | Raw %K period (default 14). |
| InpSlow | %K smoothing period (default 3). |
| InpD | SMA period for the %D line (default 3). |
Put the indicator into MetaTrader 5
Four steps, no software needed besides MT5.
Click the download button above; the file saves to your computer under the indicator's name.
In MetaTrader 5 choose File → Open Data Folder, then go to MQL5/Indicators.
Open the file in MetaEditor and click Compile. No errors means the indicator is ready.
Go back to MT5, refresh the Navigator and drag the indicator onto the price chart.
DinexSpace wrote this file from the indicator's public formula, not from any commercial source. You are free to edit and reuse it.
How it differs from MetaTrader 5's built-in indicator
The short answer: the formula is not different. What differs is what you can do with it.
Stochastic Oscillator here gives exactly the same number as MetaTrader 5's built-in version — on purpose. The four points below are what differs, and all four can be read from the very stochastic.mq5 you download.
- Calls a built-in indicator
- No — the calculation sits in
OnCalculateand can be copied straight into an EA - External libraries
- Not a single #import declaration
- Code length
- 64 lines · 3
inputparameters - How it draws
- A separate window below the price chart · calculated incrementally, does not redraw the past
Why this library promises no secret formula — read the full explanation on the library page.
Which indicators to pair Stochastic Oscillator with, and what you gain
Each indicator only answers one question. Pairing well means covering the right weakness, not stacking more.
- What you gain
- An off switch. Stochastic saturates and keeps suggesting counter-trend trades when the trend is strong; ADX shows exactly when that is.
- Note
- This is the most important pair for Stochastic, because its weakness lies entirely in trending phases.
- What you gain
- Only take signals in the direction of the main trend and drop all the counter signals.
- Note
- You drop half of the signals. The number of trades falls sharply — that is the price you pay.
- What you gain
- Zone confluence: price touches the band edge while %K and %D are in the extreme zone.
- Note
- Only use it once the market is confirmed to be sideways; otherwise both indicators are wrong at the same time.
Frequently asked questions about Stochastic Oscillator
How is Stochastic different from RSI?
RSI compares gains with losses over N candles. Stochastic compares the close with the full high–low range of N candles. Stochastic is more sensitive, so it gives more signals, with more noise.
What are the %K and %D lines?
%K is the base value, %D is a moving average of %K, so it is smoother and slower. The signal usually used is %K crossing %D in the overbought or oversold zone, adding a layer of confirmation compared with just looking at the threshold.
Does Stochastic Oscillator on this page use real or simulated data?
The chart on this page uses a deterministic simulated candle series; it is not market prices or trading results.
Using Stochastic Oscillator in an EA, and further reading
State the candle-close condition, parameters and server time clearly when you put the rule into an EA. See the EAs available on the marketplace to compare options, or read how to read MT5 backtest results before judging any EA.
Other momentum indicators
Indicators in the same momentum group, often used instead of or alongside Stochastic Oscillator.
An indicator draws signals, but when to enter, where to stop out and how much to risk are still your set of rules. Send those rules and DinexSpace builds them into an EA.