Detecting Price Divergences with MACD, RSI, and MFI
Summary
This indicator identifies potential divergences between closing prices and three measures: MACD, RSI, and the Money Flow Index. It compares recent local highs or lows in each indicator with price extremes over a configurable lookback window, then draws segments to mark matching bearish or bullish divergence patterns. A companion display plots the indicator values and uses color labels to distinguish the three measures.
The document describes separate scripts for drawing divergence lines on the price chart and in an indicator panel. It recommends using the same lookback setting in both, with a stated typical range of 20 to 40 bars, and claims the drawings do not repaint. No performance tests or trading results are provided, so the signals should not be treated as validated forecasts. The supplied code also contains apparent variable-reference inconsistencies, which may affect whether some MFI segments are drawn correctly.
Key ideas
- The method looks for indicator peaks or troughs that diverge from price extremes within a rolling lookback window.
- It applies the same basic comparison to MACD, RSI, and the Money Flow Index.
- Separate scripts draw divergence lines on price and plot the corresponding indicator values in a panel.
- The document recommends matching lookback settings across the two scripts.
- The claimed non-repainting behavior is not supported by test results, and the code includes apparent reference errors.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.