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
100 lines of Pine Script v4 from rsi_div_at_dvwap_stdevs.pine, published under GPL-3.0. Keep the author's credit and licence lines when you reuse it.
rsi_div_at_dvwap_stdevs.pine
// Autodetects RSI divergences when price is above a specified Standard Deviation from Daily VWAP.
// An RSI divergence is considered valid only when RSI is above/below overbought/oversold extremes.
// An RSI divergence is no longer valid if RSI has crossed the reset zone (55-45 configurable).
// An RSI divergence is not confimed until the signaled candle has closed. Use the signal before
// the close of the candle as a possible but still uncertain signal.
// As with any RSI strategy, you must use discretion.
//@version=4
study("RSI Div at dVWAP StDev", overlay=true, resolution="")
// RSI Inputs
len = input(14, minval=1, title="Length")
os = input(30, minval=1, title="Oversold")
ob = input(70, minval=1, title="Overbought")
hr = input(50, minval=1, title="Bear Div Reset level")
lr = input(50, minval=1, title="Bull Div Reset level")
xbars = input(defval=14, title="Div lookback period (bars)?", type=input.integer, minval=1)
// VWAP Inputs
useVWAP = input(true, title="Use Std Dev")
devUp = input(1.51, title="Stdev above")
devDn = input(1.51, title="Stdev below")
// DIVS code
rsi = rsi(close, len)
hb = abs(highestbars(rsi, xbars)) // Finds bar with highest value in last X bars
lb = abs(lowestbars(rsi, xbars)) // Finds bar with lowest value in last X bars
max = float(na)
max_rsi = float(na)
min = float(na)
min_rsi = float(na)
divbear = bool(na)
divbull = bool(na)
// If bar with lowest / highest is current bar and rsi is oversold/overbought, use it's value
max := hb == 0 and rsi > ob ? close : na(max[1]) ? close : max[1]
max_rsi := hb == 0 and rsi > ob ? rsi : na(max_rsi[1]) ? rsi : max_rsi[1]
min := lb == 0 and rsi < os ? close : na(min[1]) ? close : min[1]
min_rsi := lb == 0 and rsi < os ? rsi : na(min_rsi[1]) ? rsi : min_rsi[1]
// Reset if RSI crosses the Reset level
if (rsi < hr)
max_rsi := float(na)
if (rsi > lr)
min_rsi := float(na)
// Compare high of current bar being examined with previous bar's high
// If curr bar high is higher than the max bar high in the lookback window range
if close > max // we have a new high
max := close // change variable "max" to use current bar's high value
if rsi > max_rsi and rsi > ob // we have a new high
max_rsi := rsi // change variable "max_rsi" to use current bar's RSI value
if close < min // we have a new low
min := close // change variable "min" to use current bar's low value
if rsi < min_rsi and rsi < os // we have a new low
min_rsi := rsi // change variable "min_rsi" to use current bar's RSI value
// Detects divergences between price and indicator with 1 candle delay so it filters out repeating divergences
if (max[1] > max[2]) and (rsi[1] < max_rsi) and (rsi <= rsi[1])
divbear := true
if (min[1] < min[2]) and (rsi[1] > min_rsi) and (rsi >= rsi[1])
divbull := true
// VWAP Code
tickerid = tickerid(syminfo.prefix, syminfo.ticker, session.regular, adjustment.splits)
start = security(tickerid, "D", time)
newSession = iff(change(start), 1, 0)
vwapsum = 0.0
volumesum = 0.0
v2sum = 0.0
myvwap = 0.0
dev = 0.0
pos = 0
possig = 1
vwapsum := iff(newSession, hl2*volume, vwapsum[1]+hl2*volume)
volumesum := iff(newSession, volume, volumesum[1]+volume)
v2sum := iff(newSession, volume*hl2*hl2, v2sum[1]+volume*hl2*hl2)
myvwap := vwapsum/volumesum
dev := sqrt(max(v2sum/volumesum - myvwap*myvwap, 0))
U2=myvwap + devUp * dev
D2=myvwap - devDn * dev
pos := 0
if (useVWAP)
if (high > U2 and divbear)
pos := 1
if (low < D2 and divbull)
pos := -1
else
if (divbear)
pos := 1
if (divbull)
pos := -1
plotshape(pos == -1, "long", location = location.belowbar, color = color.green, style=shape.triangleup, size=size.tiny)
plotshape(pos == 1, "short", location = location.abovebar, color = color.red, style=shape.triangledown, size=size.tiny)
Overview
RSI Div at dVWAP StDev 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 or oversold levels and has not crossed the reset levels. Bearish marks require price above the upper band; bullish marks require price below the lower band. It draws on the price chart. Signals are not confirmed until the candle closes, so the live bar can change.
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
Length
int
14
len
Oversold
int
30
os
Overbought
int
70
ob
Bear Div Reset level
int
50
hr
Bull Div Reset level
int
50
lr
Div lookback period (bars)?
int
14
xbars
Use Std Dev
bool
true
useVWAP
Stdev above
float
1.51
devUp
Stdev below
float
1.51
devDn
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 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
QPulse is a multi-factor indicator that draws in a separate pane to evaluate market momentum, volume flow, and volatility dynamics. It calculates volume delta, a cumulative delta proxy, advanced adaptive ATR, and a hybrid volume-weighted RSI with overbought an
The Momentum Setup is a multi-indicator visual tool designed for trend and momentum analysis directly on the price chart. It combines Relative Strength Index (RSI), Money Flow Index (MFI), Commodity Channel Index (CCI), Supertrend, and a 250-bar percentage cha
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
LiqSpikeBounceLong Feb2026 is an indicator designed to identify long bounce entries following high-volume liquidation cascades in bearish market contexts. It checks if price is below an exponential moving average, then detects large single-bar drops exceeding
This indicator overlay generates buy and sell signals based on Aroon extreme levels combined with optional volume or volatility filters. It calculates Aroon Up and Aroon Down lines using localized high and low lookbacks, generating trade entries when Aroon rea