Skip to content
All library documents

Detecting MACD Divergences Between Price and Momentum

Article ProRealCode

Summary

The document describes a two-panel indicator for identifying bullish and bearish divergences between closing prices and the MACD line. One version draws divergence segments on the price chart, while a second plots corresponding segments in a separate MACD pane. Both use MACD calculated from short and long exponential averages and compare local extrema over a configurable lookback window. A bearish setup pairs a higher price high with a lower MACD peak; a bullish setup pairs a lower price low with a higher MACD trough.

The author states that the segments are drawn automatically and that the indicator does not repaint, and recommends using the same lookback setting for both panels. The document provides no backtest, performance evidence, entry or exit rules, or risk controls. It therefore explains a visual signal-detection method rather than establishing that divergences predict profitable trades; the examples are code for a particular charting platform.

Key ideas

  • The method compares price extrema with MACD extrema over a selected lookback window.
  • Bearish divergence is identified when price makes a higher high while MACD forms a lower peak.
  • Bullish divergence is identified when price makes a lower low while MACD forms a higher trough.
  • Separate indicators draw the divergence segments on the price chart and in a MACD pane.
  • The document supplies no performance testing or complete trading rules.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.