LearnForexHub
Indicator

Stochastic RSI: An Oscillator Built on Another Oscillator

Written by , Founder & EditorLast updated How we write and review lessons

Tushar Chande and Stanley Kroll published the Stochastic RSI in 1994 to solve a complaint traders had been making about RSI for a decade: on many pairs, in many conditions, it simply never reaches 70 or 30. A market can drift lower for weeks with RSI oscillating politely between 40 and 60, generating no signal at all while the actual swings are perfectly tradeable. Their fix was not to change RSI but to measure it differently — instead of asking "is RSI high in absolute terms?", ask "where is RSI right now relative to its own recent range?" That reframing is the whole indicator, and it turns a line that rarely reaches its extremes into one that reaches them constantly.

How Stochastic RSI Is Calculated

Run the standard Stochastic formula, but feed it RSI values instead of price:

  • Raw StochRSI = 100 × (RSI − Lowest RSI over n) / (Highest RSI over n − Lowest RSI over n)
  • %K = a simple moving average of the raw line over SlowingPeriod bars
  • %D = a simple moving average of %K over SignalPeriod bars

With the standard 14 / 14 / 3 / 3 settings, the raw line answers "of the range RSI has covered in the last 14 bars, what fraction is it currently sitting at?" A reading of 0 does not mean RSI is at 0 — it means RSI is at the lowest value it has printed in fourteen bars, whatever that value happens to be. If RSI has spent two weeks between 41 and 58, a Stochastic RSI of 0 corresponds to an RSI of 41, which no overbought/oversold rule would have flagged.

The raw line is far too jagged to trade, which is why the two smoothing stages exist. %K is what you watch; %D is the slower reference line it crosses. Neither MetaTrader platform includes a built-in Stochastic RSI, so stochastic-rsi-alert.mq4/.mq5 calculate all three stages directly — the MT4 build reads iRSI values, and the MT5 build pulls the same series out of an RSI handle with CopyBuffer.

Entry Conditions

PriceBUYSELL8020Stochastic RSI (RSI 14, Stoch 14, %K 3, %D 3 — bounded 0–100)%K%D
Entry conditions: BUY when %K crosses above %D below 20 — SELL when %K crosses below %D above 80

Because the indicator spends so much time pinned at its extremes, the naive rule — buy under 20, sell over 80 — fires almost continuously and is close to worthless. The signal the files on this page alert on adds a second requirement: a %K/%D crossover that happens inside the zone. BUY when %K crosses above %D while %K is still below 20; SELL when %K crosses below %D while still above 80.

That pairing is what makes the indicator usable. Being below 20 says RSI is at the bottom of its recent range — a condition, not an event. The crossover is the event: %K turning up through its own average is the first measurable sign that the downward pressure has stopped. Requiring both means you are acting on a turn that occurs somewhere meaningful, rather than on a level that a trending market can sit inside for twenty bars.

Why the Line Pins at 0 and 100

New users almost always assume a Stochastic RSI glued to 100 is a broken indicator. It isn't — it is the indicator working as designed, and understanding why prevents most of the mistakes made with it.

The denominator is RSI's own high-low range over the look-back. During a steady trend, each bar's RSI is the highest (or lowest) of the window, so the numerator equals the denominator and the output is exactly 100 (or 0). The line stays there until RSI prints something that is not a new extreme. In other words, a pinned Stochastic RSI is the signature of an uninterrupted trend, and the moment it unpins is genuine information.

This also explains the indicator's reputation for noise. Because the denominator shrinks whenever RSI goes quiet, small RSI movements in a flat market produce enormous swings in the output. A two-point RSI move inside a three-point range moves Stochastic RSI by 67 points. The indicator is not measuring the size of anything — only position within a range — so its dramatic appearance is not evidence of a dramatic market.

Stochastic RSI vs RSI and Stochastic

The three are easy to conflate and behave very differently. RSI measures the ratio of average up-closes to average down-closes and reports an absolute momentum level; it is slow, smooth, and its 70/30 readings are relatively rare and relatively meaningful. Stochastic measures where the close sits inside the price high-low range of the period — one layer of relativity, applied to price. Stochastic RSI applies that same relativity to RSI, so it is effectively two derivatives away from price, and it shows.

The practical trade-off is sensitivity against reliability. Stochastic RSI produces many more signals and produces them earlier; RSI produces fewer and produces them later but with fewer false alarms. If a strategy needs an early warning to prepare a trade, Stochastic RSI is the better instrument. If it needs a filter that keeps it out of bad trades, RSI is. Several experienced traders run both: RSI to define the environment, Stochastic RSI to time the entry inside it.

Parameters

  • RSIPeriod (default 14) — the look-back of the underlying RSI. Shortening it makes the whole indicator faster from the ground up; most traders leave it at 14 and adjust the stochastic layer instead.
  • StochPeriod (default 14) — the window the RSI high-low range is measured over. This is the parameter that controls how often the line reaches an extreme: a shorter window means a narrower range, which means more 0 and 100 readings.
  • SlowingPeriod (default 3) — the smoothing applied to the raw line to produce %K. Raising it to 5 visibly reduces the jaggedness at the cost of a bar or two of delay.
  • SignalPeriod (default 3) — the moving average of %K that becomes %D. A longer signal line means crossovers happen less often and later.
  • OversoldLevel / OverboughtLevel (defaults 20 / 80) — the zones a crossover must occur inside for an alert to fire. Tightening to 10 / 90 makes the signal considerably rarer and more selective.
  • EnableAlert / EnablePush — toggle the on-screen popup and mobile push notification independently.

How Traders Combine Stochastic RSI with Other Tools

Used alone, this indicator fights trends, because in a trend it will keep signalling a turn that does not come. The standard remedy is a directional filter that reduces it to a one-way timing tool: with price above a long Moving Average, or with ADX showing a trend in force, take only the bullish crossovers and treat the bearish ones as noise. That one restriction removes the large majority of this indicator's losing signals.

It also pairs naturally with divergence — because it reaches extremes so readily, the higher lows and lower highs that define a divergence are easy to see on it — and with multi-timeframe analysis, where the H4 reading sets the bias and the M15 crossover sets the entry. For a fully mechanical version of the crossover rule, including ATR-based stops and position sizing, see the Stochastic RSI Reversal EA.

A Word of Caution

Every criticism levelled at oscillators applies to this one twice over, because it is an oscillator built on an oscillator. It is fast and it is noisy, and in a strong trend it will generate a stream of countertrend signals that are all wrong for as long as the trend lasts. The zone readings are also genuinely ambiguous in a way RSI's are not: 0 can mean an exhausted sell-off about to bounce, or an orderly downtrend making a new low every bar, and the indicator itself cannot tell you which. Nothing here removes the need to know whether the market is trending or ranging before acting on a reading. Treat it as an entry-timing instrument inside a framework that already has a direction, never as a standalone reversal system.

Download the Indicator

This custom indicator plots Stochastic RSI as %K and %D lines in a separate window with 20/50/80 levels, and alerts when the two lines cross inside the oversold or overbought zone. MT4 and MT5 versions are both included in the downloads below.

Download stochastic-rsi-alert.mq4

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

Download File

Download stochastic-rsi-alert.mq5

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

Download File

How to install

MetaTrader 4

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

MetaTrader 5

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

Both files are source code. Open and read them in MetaEditor before running them on any account.