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 strategy, select all of the template text and paste. Press Save and give it a name.
4Add it to the chartPress Add to chart. The trades and results appear in the Strategy Tester tab; adjust the settings with the gear icon.
Source Code
175 lines of Pine Script v5 from Tradingview/divergence-scanner.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.
Divergence Scanner initiates long and short strategy entries when divergence signals meet conditions, optionally filtered by New York trading session hours and oscillator polarity. Exits are managed using a configurable tick profit target alongside either a recent swing high or low stop loss or a fixed tick offset. The strategy executes and plots directly on the main price chart with optional trend-based candle coloring.
Buy and sell volume pressure convergence and divergence
Awesome Oscillator polarity trend filter
Session time window trading filter
Recent swing high or low and tick stop loss options
Candle recoloring based on oscillator and volume trend
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
Use Trading Hours
bool
false
useTradingHours
Trading Time
session
0930-1600
trading_time
Long Trades
bool
true
long_trades
Short Trades
bool
true
short_trades
AO FIlter
bool
true
use_ao_filter
Profit Target Amount
int
300
profit_amount
Stop Type
string
Recent Low/High
stop_type
Stop Amount
int
5
stop_amount
Base for FastMA Periods:
int
3
signal
Buy to Sell Conv/Div Lookback:
int
27
long
Buy to Sell Convergence/Div OSC:
bool
true
vmacd
Buy to Sell Conv/Div as cummulative:
bool
false
vinv
Show all 13 settings
Setting
Type
Default
Variable
Color Candles based on AO and BSVP
bool
true
color_candles
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.
Divergence Strategy scans multiple technical oscillators to detect regular and hidden divergences against price action. It evaluates customizable indicators including MACD, RSI, Stochastic, CCI, Momentum, OBV, and Money Flow Index to trigger strategy entries o
This script combines five distinct RSI pattern setups with volume ratio filters to generate trading signals. It identifies RSI double bottoms, hooks, bullish divergences, oversold bounces, and midline breakouts to form long conditions, alongside overbought dow
This strategy calculates the Chaikin Oscillator by taking the difference between fast and slow exponential moving averages of the Accumulation/Distribution line. It generates long and short entries when the oscillator crosses the signal threshold with directio
This strategy enters long on an outside bar when the candle is bullish, the Klinger Volume Oscillator is positive, and price is above a Hull moving average. It enters short on an inside bar when the candle is bearish, the oscillator is negative, and price is b
This overlay strategy looks for gold scalps from break of structure and change of character. It enters long when a bullish break, a bullish character change, and an optional volume filter align, and short on the opposite set. Optional RSI levels can block trad
This strategy trades on the price chart using multiple indicators. It enters long positions when price dips meet conditions on Bollinger Bands 40 and 20, RSI, MFI, volume and other thresholds. It exits at custom ROI profit levels based on RSI or after timeout