All indicators

Stochastic RSI Divergences

Feb 4, 2020

Static chart image
SignalsOscillatorsDivergences

The Stochastic RSI Divergences indicator provides an automated way to detect regular and hidden divergences between price action and the Stochastic RSI oscillator. By identifying these discrepancies, traders can potentially spot trend reversals or continuations more effectively than using standard momentum indicators alone.

Usage

The tool displays the Stochastic RSI (K and D lines) in a separate pane and highlights four distinct types of divergences:

  • Regular Bullish: Occurs when price makes a lower low but the Stochastic RSI makes a higher low. This suggests a potential bullish reversal.
  • Regular Bearish: Occurs when price makes a higher high but the Stochastic RSI makes a lower high. This suggests a potential bearish reversal.
  • Hidden Bullish: Occurs when price makes a higher low but the Stochastic RSI makes a lower low. This often indicates trend continuation.
  • Hidden Bearish: Occurs when price makes a lower high but the Stochastic RSI makes a higher high. This also often indicates trend continuation.

Traders can use the labels (Bull, Bear, H Bull, H Bear) to identify these setups. The visibility of each divergence type can be toggled in the settings to reduce chart noise.

Details

This script is adapted from classic RSI divergence logic but applies it to the Stochastic RSI oscillator for increased sensitivity. It uses pivot points to identify peaks and troughs in both price and the oscillator.

The calculation first derives the RSI, then applies the Stochastic formula to those RSI values, and finally smooths the result with a Simple Moving Average (SMA) to create the %K and %D lines. Divergences are calculated based on the %K line. Because the tool uses a "Lookback Right" parameter for pivot confirmation, signals will appear with a small delay (offset) once the pivot is confirmed as a local high or low.

Settings

  • K Period: The smoothing period for the %K line.
  • D Period: The smoothing period for the %D line.
  • Stochastic Period: The lookback period used for the Stochastic calculation.
  • RSI Period: The lookback period used for the underlying RSI calculation.
  • Pivot Lookback Right: The number of bars to the right required to confirm a pivot point.
  • Pivot Lookback Left: The number of bars to the left required to identify a pivot point.
  • Max of Lookback Range: The maximum distance (in bars) between two pivots to be considered for a divergence.
  • Min of Lookback Range: The minimum distance (in bars) between two pivots to be considered for a divergence.
  • Plot Bullish/Hidden Bullish/Bearish/Hidden Bearish: Toggles the visibility of specific divergence types and their respective labels.

FAQ

How do I use these signals for entries?

Divergences are often used as confluence with other technical analysis tools. A regular bullish divergence at a major support level, for example, may provide a higher probability reversal signal.

Why does the signal appear a few bars late?

The indicator relies on pivot points, which require a "Lookback Right" period to confirm that a high or low has actually been formed. This is necessary to prevent repainting.

How can I access this script?

You can get access on the LuxAlgo Library for charting platforms like TradingView, MetaTrader (MT4/MT5), and NinjaTrader for free.

Free indicator

Get free access to this indicator on the platforms below.

TradingView
NinjaTrader
MetaTrader 4/5

Unlock the entire LuxAlgo Library

Every indicator, every strategy, full charts, and complete access to Quant — our AI agent.