Price Volume Divergence Indicator for ThinkorSwim

BenTen

Administrative
Staff member
Staff
VIP
Lifetime
This indicator shows divergences between price and volume.
  • Bullish Volume Divergence: When the price is falling while volume continues to rises.
  • Bearish Volume Divergence: A bearish divergence signal occurs when the price is increasing while volume is decreasing.
There are two different types of signals
  • bear3 and bull3 = divergence signals within the last 3 candlesticks or bars
  • bull4 and bear4 = divergences within the last 4 candlesticks or bars
I also included alerts for these reversal signals so you can get alerted for when a new divergence is formed.

qF1Tywp.png

mSE3jZc.png


thinkScript Code

Code:
# Price Volume Divergence Indicator for ThinkorSwim
# Based on the framework of Trend Exhaustion Indicator
# Assembled by BenTen at useThinkScript.com

# 3 Bars Bearish Divergence
def bearish4 = (CLOSE > CLOSE[1] AND CLOSE [1] > CLOSE [2] AND CLOSE [2] > CLOSE [3] AND VOLUMEAVG(LENGTH = 20) < VOLUMEAVG(LENGTH = 20)[1] AND VOLUMEAVG(LENGTH = 20)[1] < VOLUMEAVG(LENGTH = 20)[2] AND VOLUMEAVG(LENGTH = 20)[2] < VOLUMEAVG(LENGTH = 20)[3]);
plot bear3 = bearish4;
bear3.AssignValueColor(Color.MAGENTA);
bear3.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);

# 3 Bars Bullish Divergence
def bullish4 = (CLOSE < CLOSE[1] AND CLOSE [1] < CLOSE [2] AND CLOSE [2] < CLOSE [3] AND VOLUMEAVG(LENGTH = 20) > VOLUMEAVG(LENGTH = 20)[1] AND VOLUMEAVG(LENGTH = 20)[1] > VOLUMEAVG(LENGTH = 20)[2] AND VOLUMEAVG(LENGTH = 20)[2] > VOLUMEAVG(LENGTH = 20)[3]);
plot bull3 = bullish4;
bull3.AssignValueColor(Color.MAGENTA);
bull3.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);

# 4 Bars Bearish Divergence
def bearish5 = (CLOSE > CLOSE[1] AND CLOSE [1] > CLOSE [2] AND CLOSE [2] > CLOSE [3] AND CLOSE [3] > CLOSE [4] AND VOLUMEAVG(LENGTH = 20) < VOLUMEAVG(LENGTH = 20)[1] AND VOLUMEAVG(LENGTH = 20)[1] < VOLUMEAVG(LENGTH = 20)[2] AND VOLUMEAVG(LENGTH = 20)[2] < VOLUMEAVG(LENGTH = 20)[3] and VOLUMEAVG(LENGTH = 20)[3] < VOLUMEAVG(LENGTH = 20)[4]);
plot bear4 = bearish5;
bear4.AssignValueColor(Color.CYAN);
bear4.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);

# 4 Bars Bullish Divergence
def bullish5 = (CLOSE < CLOSE[1] AND CLOSE [1] < CLOSE [2] AND CLOSE [2] < CLOSE [3] AND CLOSE [3] < CLOSE [4] AND VOLUMEAVG(LENGTH = 20) > VOLUMEAVG(LENGTH = 20)[1] AND VOLUMEAVG(LENGTH = 20)[1] > VOLUMEAVG(LENGTH = 20)[2] AND VOLUMEAVG(LENGTH = 20)[2] > VOLUMEAVG(LENGTH = 20)[3] and VOLUMEAVG(LENGTH = 20)[3] > VOLUMEAVG(LENGTH = 20)[4]);
plot bull4 = bullish5;
bull4.AssignValueColor(Color.CYAN);
bull4.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);

# Alerts
Alert(bull3, " ", Alert.Bar, Sound.Chimes);
Alert(bear3, " ", Alert.Bar, Sound.Chimes);
Alert(bull4, " ", Alert.Bar, Sound.Bell);
Alert(bear4, " ", Alert.Bar, Sound.Bell);

Shareable Link

https://tos.mx/uP5aTz
 
Last edited:

BenTen

Administrative
Staff member
Staff
VIP
Lifetime
I found this indicator, though. Give it a try.

Code:
# Price Volume Divergence
# Mobius
# Chat Room Request 09.10.2014

declare lower;

def price = close;
def vol = volume;

script Scale {
    input c = close;
    input Min = .01;
    input Max =   1;
    def hh = HighestAll(c);
    def ll   = LowestAll(c);
    plot Range = (((Max - Min) * (c - ll)) /  (hh - ll)) + Min;
}

plot NormPrice = Scale(c = price).Range;
NormPrice.SetDefaultColor(Color.Green);
plot NormVolume = Scale(c = vol).Range;
NormVolume.SetDefaultColor(Color.Red);
plot mean = if isNaN(close) then Double.NaN else .5;
mean.SetDefaultColor(Color.White);

def cond1 = normprice < mean;
def cond2 = normprice > mean;

def cond3 = normvolume < mean;
def cond4 = normvolume > mean;

addlabel(cond1, "Negative Price Convergence", color.red);
addlabel(cond2, "Positive Price Convergence", color.green);

addlabel(cond3, "Negative Volume Convergence", color.red);
addlabel(cond4, "Positive Volume Convergence", color.green);

addlabel(normprice > 0.9, "Price overbought", color.red);
addlabel(normprice < 0.1, "Price oversold", color.green);
 

Dupre

New member
VIP
There have been a couple times where I get an audible alert that divergence has occurred but no arrow. Has anyone else run into this issue?
 
@tomsk
also when volume increasing stock can go any side up to down
can we define condition if vol increase and price increase then Green color and
Volume increasing and price going down red color
and we can scan this thing any idea how we do that.
 

MerryDay

Administrative
Staff member
Staff
VIP
Lifetime
@tomsk
also when volume increasing stock can go any side up to down
can we define condition if vol increase and price increase then Green color and
Volume increasing and price going down red color
and we can scan this thing any idea how we do that.
See the first post
 

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Top