An indicator on the price chart that compares the direction of each chart bar with the net direction of the smaller intrabars inside it, fetched from a lower timeframe chosen by the chart timeframe.
1Copy the scriptPress Copy script above, or the copy button on the code below.
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
48 lines of Pine Script v5 from edu_std/polarity_divergence.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.
When the two disagree, the candle is coloured orange. Optional characters can mark divergences on up bars and down bars, with a choice of symbol, colour and placement above or below the bar. It depends on lower timeframe data being available for the symbol.
Chart bar direction compared with intrabar direction
Orange candle colouring on divergences
Optional characters for up-bar and down-bar divergences
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
Show character on divergences for up bars
bool
false
showCharUpInput
Character
string
↗
charUpInput
charUpColorInput
color
color.lime
charUpColorInput
Below bar
bool
true
charUpBelowInput
Show character on divergences for down bars
bool
false
showCharDnInput
Character
string
↘
charDnInput
charDnColorInput
color
color.fuchsia
charDnColorInput
Above bar
bool
true
charDnAboveInput
Fill candle bodies on divergences
bool
true
fillBodiesInput
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