All indicators

MACD with RSI Divergence

May 31, 2018

Static chart image
SignalsOscillatorsDivergencesMoving Averages

The MACD with RSI Divergence indicator combines the trend-following capabilities of the Moving Average Convergence Divergence (MACD) with the momentum-based insights of Relative Strength Index (RSI) divergences to identify potential market reversals and trend strength.

Usage

The tool displays a multi-colored MACD histogram alongside an RSI line and divergence signals. Traders can use the histogram to gauge the momentum of the current trend, with color shifts indicating strengthening or weakening momentum. The RSI line oscillates between overbought (80) and oversold (20) levels, where divergence signals are plotted:

  • Bullish Divergence: Occurs when the price makes a lower low but the RSI makes a higher low, suggesting a potential upward reversal. This is highlighted with green filled areas.
  • Bearish Divergence: Occurs when the price makes a higher high but the RSI makes a lower high, suggesting a potential downward reversal. This is highlighted with red filled areas.
  • MACD Crossovers: The tool can be configured to show dots or color changes when the MACD line crosses the signal line, serving as entry or exit triggers.

Details

The script utilizes a dual-engine approach. The MACD component calculates the difference between a Fast EMA and a Slow EMA, smoothed by a Signal Line. The RSI component calculates the Relative Strength Index over a user-defined period. The divergence logic compares the recent price extremes against historical peaks and troughs relative to RSI performance. Additionally, the indicator supports multi-timeframe (MTF) analysis, allowing users to view MACD data from higher timeframes on their current chart resolution.

Settings

MACD Settings

  • Use Current Chart Resolution?: If checked, the indicator uses the timeframe of the active chart.
  • Use Different Timeframe?: Specifies a custom timeframe for the MACD calculation if the above is unchecked.
  • Show MacD & Signal Line?: Toggles the visibility of the primary MACD and Signal lines.
  • Show Dots When MacD Crosses Signal Line?: Plots markers at the point of MACD/Signal crossovers.
  • Show Histogram?: Toggles the visibility of the MACD histogram.
  • Change MacD Line Color-Signal Line Cross?: Adjusts the MACD line color based on its position relative to the signal line.
  • MacD Histogram 4 Colors?: Enables a gradient color scheme for the histogram to show momentum acceleration/deceleration.
  • MACD Fast/Slow/Signal Length: Parameters for the exponential moving averages used in MACD.

RSI & Divergence Settings

  • Data Source: The price source used for calculations (default is OHLC4).
  • Short/Long Lookback Period: Defines the windows used to identify local peaks and troughs for divergence.
  • Reversal Percentage: The threshold required to confirm a price reversal for divergence detection.
  • RSI Period: The length of the Relative Strength Index.
  • Overbought/Oversold Level: Thresholds for identifying extreme momentum conditions (default 80/20).

FAQ

How do I interpret the colored histogram?

The histogram uses four colors to show trend health. Bright green/red indicates accelerating momentum in that direction, while darker shades suggest that the current trend's momentum is slowing down.

Can I use this for automated alerts?

Yes, the script includes built-in alert conditions for Bullish Divergences, Bearish Divergences, and MACD crossovers (both above and below).

How can I access MACD with RSI Divergence?

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.