All indicators

Stochastic with Divergences

Sep 3, 2022

Static chart image
SignalsOscillatorsDivergences

The Stochastic with Divergences indicator provides a comprehensive toolkit for identifying momentum shifts and trend continuations by combining the classic Stochastic oscillator with automated divergence detection and trend-following signals. It helps traders distinguish between ranging and trending market conditions by visualizing regular and hidden divergences directly on the oscillator.

Usage

The indicator can be utilized in several ways depending on the market environment:

  • Range Markets: Traders can use the overbought (80) and oversold (20) levels to identify potential reversals. Selling when the indicator is overbought and buying when it is oversold is a common approach in sideways markets.
  • Trending Markets: By enabling the "Signals" option, the tool highlights buy/sell opportunities that align with the 200 EMA. A sell signal is generated in a downtrend when the Stochastic crosses below 80, while a buy signal occurs in an uptrend when it crosses above 20.
  • Divergence Trading:
    • Regular Divergence: Used to identify potential trend reversals. Bullish regular divergence occurs when price makes a lower low but the Stochastic makes a higher low.
    • Hidden Divergence: Used to identify trend continuation. Bullish hidden divergence occurs when price makes a higher low but the Stochastic makes a lower low.

Details

The script calculates the Stochastic oscillator based on user-defined periods and smoothing. It includes an option to use the Stochastic RSI formula for those who prefer a more sensitive momentum reading. The divergence logic searches for pivot points within a specific look-back window (configurable via settings) and compares price action to the oscillator's movement. To improve signal quality, the "Middle Filter" ensures that bullish pivots only occur in the oversold half (<50) and bearish pivots in the overbought half (>50).

Settings

  • StochK / D / Smooth: Adjusts the periods and smoothing for the Stochastic oscillator calculation.
  • Stochastic RSI: Toggles between the standard Stochastic and the Stochastic RSI calculation.
  • Signals: Enables background highlights for trend-aligned overbought/oversold signals based on the 200 EMA.
  • Fill: Visualizes the gap between the %K and %D lines with color.
  • Divergence: Dropdown menu to select "Off", "Regular", "Hidden", or "Both" types of divergences.
  • Only Trending Divergences: If enabled, filters divergences to only show those that align with the 200 EMA trend.
  • Middle Filter: Restricts divergence detection to the respective upper or lower halves of the oscillator.
  • Pivots to look back: Determines how many previous pivots the script evaluates for potential divergence (1 to 3).

FAQ

How do I enable the divergence lines?

By default, divergences are set to "Off". Navigate to the indicator settings, locate the "Divergence" dropdown, and select "Regular", "Hidden", or "Both".

What does the "Only Trending Divergences" setting do?

When active, it only displays bullish signals when price is above the 200 EMA and bearish signals when price is below it, helping to filter out counter-trend noise.

How can I access the Stochastic with Divergences?

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.