This indicator detects regular and hidden divergences between price and RSI or MACD histogram oscillators, drawing lines and arrows directly on the price chart.
1Copy the scriptPress Copy script above. It reads the file straight from GitHub.
2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.
Source Code
The code stays on GitHub. The author has not published this script under an open licence, so ForexR does not show its code. Copy script reads the file straight from GitHub into your clipboard, so you can still try it on your own chart. Ask the author before reusing the code anywhere else.
Overview
Divergence Signal Alerts identifies swing highs and lows using configurable left and right pivot lookback windows, evaluating divergence conditions on closed bars. Users can adjust oscillator lengths, distance ranges between pivots, visual styles, and require confluence where both RSI and MACD must diverge together. Signals are confirmed after the specified right pivot delay, ensuring historical patterns and alerts do not repaint.
Regular and hidden divergence detection
RSI and MACD histogram multi-oscillator support
Configurable pivot lookback and distance rules
Dual-oscillator confluence filter option
Non-repainting closed-bar alerts and price chart markings
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
RSI divergence
bool
true
useRsi
RSI period
int
14
rsiLen
MACD histogram divergence
bool
true
useMacd
MACD fast EMA
int
12
fastLen
MACD slow EMA
int
26
slowLen
MACD signal EMA
int
9
sigLen
Regular divergence (reversal)
bool
true
regular
Hidden divergence (continuation)
bool
false
hidden
Pivot: bars on the left
int
5
left
Pivot: bars on the right
int
3
right
Pivots at least this many bars apart
int
5
minDist
Pivots at most this many bars apart
int
60
maxDist
Show all 17 settings
Setting
Type
Default
Variable
Clean lines
bool
true
clean
Only when RSI and MACD both diverge
bool
false
both
Line between the price pivots
bool
true
showLines
Bullish
color
#089981
bullColor
Bearish
color
#F23645
bearColor
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.
This indicator scans multiple tickers simultaneously to detect regular bullish and bearish MACD divergences filtered by long-term trend direction (150 EMA versus 600 EMA). It evaluates pivot highs and lows in the MACD line against price action across configura
This overlay indicator looks for regular price divergences against a set of oscillators, using pivot highs and lows. It compares those pivots with RSI, MACD and its histogram, stochastic, CCI, momentum, OBV, a directional oscillator, volume-weighted MACD, Chai
The RSI Divergence Scanner calculates the Relative Strength Index and identifies regular and hidden bullish or bearish divergences against price using pivot high and low points. It plots divergence lines and customizable labels directly on the price chart. Inp
This indicator detects regular and hidden divergences across multiple technical factors plotted directly on the price chart. It evaluates price highs and lows against peaks and troughs identified by a five-bar fractal mechanism on RSI, RSI Stochastic, MACD, re
This indicator marks RSI divergences only when price trades beyond daily VWAP standard-deviation bands. It compares recent RSI extremes with price highs and lows over a lookback window, and it treats a divergence as valid only while RSI stays beyond overbought
This indicator builds a momentum score from the rate of change of close, using a lookback that expands or contracts with ATR relative to its standard deviation. It divides that rate of change by price standard deviation, scales the result, and weights it by vo