All Buy / Sell Volume Pressure Indicators & Labels For ThinkOrSwim

MerryDay

Administrative
Staff member
Staff
VIP
Lifetime
Chris's Enhanced Volume For ThinkOrSwim
Buy / Sell Volume Pressure Percentages

b1.png

Buyers and Sellers is not information available in the data feeds.
When we look at the movement of price in comparison to volume, it is called Volume Pressure.
The scripts discussed here are representative of the PRICE spread compared to the overall volume spread.

We create a percentage for buying and selling pressure by using the candlestick patterns weighted volume.
Volume Pressure identifies the price movement which when aggregated with volume it is used to define MOMENTUM not actual buyers and sellers.
You can't apply the momentum percentage to the volume number and declare that to be the number of buyers and sellers.
nOnSBvp.png
uwFHET6.png

Ruby:
#Chris' Enhanced Volume V.2 /w Uptick/Downtick

declare on_volume;

###############
#DPL CRITERIA #
###############
input Audible_Alert = yes;
def Deviation_Length = 60;
def Deviate = 2;
def volumestdev = RelativeVolumeStDev(length = Deviation_Length);
def abovedev = volumestdev >= Deviate;
def belowdev = volumestdev <= Deviate;

############
# DPL BARS #
############
def increase = volume > volume[1];
def devincrease = increase and abovedev;
def decrease = volume < volume[1];
def devdecrease = decrease and abovedev;

##############################
# UPTICK / DOWNTICK CRITERIA #
##############################
def O = open;
def H = high;
def C = close;
def L = low;
def V = volume;
def Buying = V * (C - L) / (H - L);
def Selling = V * (H - C) / (H - L);

##################
# Selling Volume #
##################
plot SV = Selling;
SV.DefineColor("Decrease", Color.rED);
SV.DefineColor("DevDecrease", Color.pink);
SV.AssignValueColor(if devdecrease then SV.Color("DevDecrease") else SV.Color("Decrease"));
SV.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
SV.HideTitle();
SV.HideBubble();
SV.SetLineWeight(5);

#################
# Buying Volume #
#################
DefineGlobalColor("LabelGreen",  CreateColor(0, 165, 0)) ;
plot BV = Buying;
BV.DefineColor("Increase", GlobalColor("LabelGreen"));
BV.DefineColor("DevIncrease", Color.light_GREEN);
BV.AssignValueColor(if devincrease then BV.Color("DevIncrease") else BV.Color("Increase"));
BV.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
BV.HideTitle();
BV.HideBubble();
BV.SetLineWeight(5);

#################
# Adding Volume Labels #
#################

input Show_Labels = yes;
AddLabel(Show_Labels, "Buy Vol = " + Round(Buying, 0),
if Buying > Selling then GlobalColor("LabelGreen") else color.red);

AddLabel(Show_Labels, "Buy %: " + Round((Buying/(Buying+Selling))*100,2), If (Buying/(Buying+Selling))*100 > 60 then GlobalColor("LabelGreen") else color.red);

AddLabel(Show_Labels, "Sell Vol = " + Round(Selling, 0),
if Selling > Buying then GlobalColor("LabelGreen") else color.red);

AddLabel(Show_Labels, "Sell %: " + Round((Selling/(Selling+Buying))*100,2), If (Selling/(Selling+Buying))*100 > 60 then GlobalColor("LabelGreen") else color.RED);

Buy / Sell Volume Pressure w/ volumes and percentages -- Upper Study Labels Only
Ruby:
#Chris' Enhanced Volume V.2 /w Uptick/Downtick LABELS ONLY

declare upper;
###############
#DPL CRITERIA #
###############
def Deviation_Length = 60;
def Deviate = 2;
def volumestdev = RelativeVolumeStDev(length = Deviation_Length);
def abovedev = volumestdev >= Deviate;
def belowdev = volumestdev <= Deviate;

############
# DPL BARS #
############
def increase = volume > volume[1];
def devincrease = increase and abovedev;
def decrease = volume < volume[1];
def devdecrease = decrease and abovedev;

##############################
# UPTICK / DOWNTICK CRITERIA #
##############################
def O = open;
def H = high;
def C = close;
def L = low;
def V = volume;
def Buying = V * (C - L) / (H - L);
def Selling = V * (H - C) / (H - L);

##################
# Selling Volume #
##################
def SV = Selling;
def BV = Buying;

#################
# Adding Volume Labels #
#################
DefineGlobalColor("LabelGreen",  CreateColor(0, 165, 0)) ;
input Show_Labels = yes;
AddLabel(Show_Labels, "Buy Vol = " + Round(Buying, 0),
if Buying > Selling then GlobalColor("LabelGreen") else color.red);

AddLabel(Show_Labels, "Buy %: " + Round((Buying/(Buying+Selling))*100,2), If (Buying/(Buying+Selling))*100 > 60 then GlobalColor("LabelGreen") else color.red);

AddLabel(Show_Labels, "Sell Vol = " + Round(Selling, 0),
if Selling > Buying then GlobalColor("LabelGreen") else color.red);

AddLabel(Show_Labels, "Sell %: " + Round((Selling/(Selling+Buying))*100,2), If (Selling/(Selling+Buying))*100 > 60 then GlobalColor("LabelGreen") else color.RED);
 

Attachments

  • nOnSBvp.png
    nOnSBvp.png
    18.9 KB · Views: 7,101
Last edited:

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Does anyone know how to write a script that would calculate aggressive buying and selling (market orders) and show this as the Bookmap Volume Bubbles (Blue/green or red)? Also, the size of the bubbles would indicate how big those orders are, relative to others.
That would be really helpful, because it would allow us to see the big volume players, especially around support & resistance levels.
thank you in advance for your help.
 
1) When I program to show the diffrence between the bid and ask in a scan or watchlist, so I can only look at small spreads, it often screws up,
I think it never works except maybe during market hours?
Why is this? I'm 100% sure Mobius answered this for me before but I dont remember?
I'm sure he said it'll never work.

2) How do I get a percent out of the total bid ask volume?
Say 10000 shares of buying volume * 100? I want it expressed out of 100%

3) I sell 0 day SPX credit spreads. I'm looking for an indicator that will help me determine where SPX will probably close at.
I can look at market profile, market internals, and the 30 minute chart. But is there an indicator that will help me be more often right?

4) I know we cant program clouds, labels, buttons, dots, arrows, etc on mobile but is there any way to work around that for something like the Trend Reversal indicator?
Thanks

I realized in order to get a percentage I would have to compare my buying or selling volume to another number. (ASPercent function wont help me). So I did it to a 50 period of both buying and selling. BUT I want it to be based off the minute 50 period. How do I make only the total volume based on the 50 period in minute charts no matter what chart I'm on (or in a scan)?

Code:
def agg = AggregationPeriod.MIN;
plot data = close(period = agg);
def fittyperiodvolume = Round(Average(Volume,50));
def buyingpercent = fittyperiodvolume / buying;
addlabel (yes, buyingpercent, color.dark_green);
def sellingpercent = fittyperiodvolume / selling;
addlabel (yes, sellingpercent, color.red);

My buying and selling variable is already defined and they work.
 
Last edited by a moderator:
@ezrollin My recollection of Mobius comments during my time in the lounge is that bid/ask works only on intraday aggregations. You can get Bid and Ask in a Watchlist by referencing the built-in Bid() and Ask() studies. Bid and Ask is not available in the scanner. I don't use mobile so can't help with your queries on mobile. Hope this info helps

Post your COMPLETE scan code, and more importantly, describe what you're attempting to scan for. To enable anyone to assist you, do provide as much detail, context, information as necessary to help bring the reader up to speed. Only then perhaps a scan can be constructed.
 
ALL I'm trying to do is plot the buying and selling volume seperately but expressed in percentage.

Code:
declare lower;
declare zerobase;

input Audible_Alert = yes;
def Deviation_Length = 60;
def Deviate = 2;
def volumestdev = RelativeVolumeStDev(length = Deviation_Length);
def abovedev = volumestdev >= Deviate;
def belowdev = volumestdev <= Deviate;

def increase = volume > volume[1];
def devincrease = increase and abovedev;
def decrease = volume < volume[1];
def devdecrease = decrease and abovedev;

def O = open;
def H = high;
def C = close;
def L = low;
def V = volume;

plot Buying = (V * (C - L) / (H - L));
     buying.AssignValueColor( Color.dark_green);
plot Selling = (V * (H - C) / (H - L));
     selling.AssignValueColor( Color.red);

def fittyperiodvolume = Round(Average(Volume,50));
plot buyingpercent = fittyperiodvolume / buying;
buyingpercent.AssignValueColor( Color.dark_green);
addlabel(yes," buys: "+buying+ " sells: " +selling, color.black);
 
Last edited by a moderator:
@ezrollin Well then, it sure does not look like a scan code, seems that you are writing a study that determines the buying and selling volume expressed as a percentage of the total volume. Assuming your mathematical equations for Buying/Selling is correct, here's what your study would look like. You can add bells and whistles to plot, color, or whatever you like but the base code is here. I have chosen to implement this as a chart label. All the best as you complete your project

Code:
def O = open;
def H = high;
def C = close;
def L = low;
def V = volume;
def BuyV = (V * (C - L) / (H - L));
def SellV = (V * (H - C) / (H - L));
def BuyPct = BuyV / V;
def SellPct = SellV / V;
AddLabel(1, "Volume Buy Percent = " + AsPercent(BuyPct), Color.Cyan);
AddLabel(1, "Volume Sell Percent = " + AsPercent(SellPct), Color.Yellow);
 
That worked perfect! I'm not sure my plan worked out all that great but you're code is exactly right! Thank you!
 
Scan request: Can a skilled coder convert this indicator below to a scan code for 90% # buy Volume?

Code:
plot Data = close;#HINT: This study color codes volume by amount of volume on up-tick versus amount of volume on down-tick

declare lower;

def O = open;
def H = high;
def C = close;
def L = low;
def V = volume;
def Buying = V*(C-L)/(H-L);
def Selling = V*(H-C)/(H-L);

# Selling Volume
Plot SV = selling;
SV.setPaintingStrategy(PaintingStrategy.Histogram);
SV.SetDefaultColor(Color.Red);
SV.HideTitle();
SV.HideBubble();
SV.SetLineWeight(5);

# Buying Volume
# Plot BV = Buying;
# Note that Selling + Buying Volume = Volume.
Plot BV =  volume;
BV.setPaintingStrategy(PaintingStrategy.Histogram);
BV.SetDefaultColor(Color.Dark_Green);
BV.HideTitle();
BV.HideBubble();
BV.SetLineWeight(5);
 
Last edited:
I am looking for a script that show volume on the buy and sell side as well as percentages. Can anyone point me in the right direction?

unknown.png
@Bugs_Munny ,

Did you ever a response or have you made any progress on finding this? I've seen the same thing on eTrade but do not have the code for either. Keep me posted.

@zeek

Code:
declare lower;

#Inputs

input ShowSellVolumePercent = yes;

def O = open;
def H = high;
def C = close;
def L = low;
def V = volume;
def buying = V*(C-L)/(H-L);
def selling = V*(H-C)/(H-L);

#Volume Data


def today = volume(period = "DAY");

def curVolume = volume;

def SellVolPercent = Round((Selling / Volume) * 100, 0);

# Labels

AddLabel(ShowSellVolumePercent, "Cur Bar Sell %: " + SellVolPercent, (if SellVolPercent > 51 then Color.RED else if SellVolPercent < 49 then Color.GREEN else Color.ORANGE));

@horserider

What a great snippet of code.
Thank you for sharing, very grateful.

This will help a lot when combined with Fib Extensions and Elliott Wave.

Cheers!
 
Last edited:
@Takata here goes what you requested

Remember to thumbs up if you found this post useful.

Plots and/or scans volume for Buy Volume (as defined by the script) that is greater than XYZ Percent of total volume
Note: Default parameters is: Buy Volume is at least 90% of the total volume

Code:
declare lower;
#By XeoNoX via usethinkscript.com
# Plots and/or scans volume for Buy Volume (as defined by the script)
# that is greater than XYZ Percent of total volume
# Default parameters is: Buy Volume is at least 90% of the total volume
# Select desired Percentage you want greater than
input percentage = 90;
def O = open;
def H = high;
def C = close;
def L = low;
def V = volume;
def Buying = V*(C-L)/(H-L);
def Selling = V*(H-C)/(H-L);
def total = buying + selling;
def Buypercent = Buying/total * 100;
plot scan  = percentage >= Buypercent;
 
Last edited:
I am looking for a script that show volume on the buy and sell side as well as percentages. Can anyone point me in the right direction?

unknown.png

@Bugs_Munny ,

Did you ever a response or have you made any progress on finding this? I've seen the same thing on eTrade but do not have the code for either. Keep me posted.



@horserider

What a great snippet of code.
Thank you for sharing, very grateful.

This will help a lot when combined with Fib Extensions and Elliott Wave.

Cheers!

Hi Bugs_Munny, have you gotten the code for this? If so, can you please share?

Last week I look into basic Thinkscript coding I was able to follow the pattern from Horserider. This version does the aggregation by day or smaller time frame. For example, a 5 mins bar then resets to the next 5 mins. I would run two of these studies together one by day and the other by the time frame you trade on.

Code:
# Show SELL and BUY Volume and percentage.
# Referencing credit to Horserider script at https://usethinkscript.com/threads/volume-buy-sell-indicator-with-hot-percent-for-thinkorswim.389/
# Nomak 02/21/2020

declare lower; 
input timeframe = AggregationPeriod.DAY;


def Vol = volume(period = timeframe);
def at_High = high(period = timeframe);
def at_Open = open(period = timeframe);
def at_Close = close(period = timeframe);
def at_Low = low(period = timeframe);
def Vol1 = volume(period = timeframe);
def at_High1 = high(period = timeframe);
def at_Open1 = open(period = timeframe);
def at_Close1 = close(period = timeframe);
def at_Low1 = low(period = timeframe);

# Buy_Volume forumla is volume * (close_price minus low_price) / (High_price minus low_price)
def Buy_Volume = roundup(Vol * (at_close - at_low) / (at_High - at_Low));
def Buy_percent = roundup((Buy_volume / Vol) * 100);

#Sell_Volume forumla is  volume * (High_price minus Close_price) / (High_price minus Low_price)
def Sell_Volume = rounddown(Vol1 * (at_High1 - at_Close1) / (at_High1 - at_low1));
def Sell_percent = roundup((Sell_Volume / Vol1) * 100);

Addlabel(yes, "BuyVol " + Buy_Volume, Color.Green);
Addlabel(yes, "SellVol " + Sell_Volume, Color.Red);
AddLabel(yes, "Buy % " + Buy_percent, Color.Green);
Addlabel(yes, "Sell % " + Sell_percent, Color.Red);
 
Here's a Watchlist Column Mod I just made.

ISgSxyr.png


Code:
# Original author: Unknown
# Watchlist Label
# Mod by Ramon DV aka Pelonsax

declare lower;


def O = open;
def H = high;
def C = close;
def L = low;
def Price = H + L + C / 3;
def V = volume;
def buying = V * (C - L) / (H - L);
def selling = V * (H - C) / (H - L);
def SellVolPercent = Round((Selling / Volume) * 100, 0);
def BuyVolPercent = 100 - SellVolPercent;

assignBackgroundColor(if buying >= selling then color.GREEN else if buying <= selling then color.RED else color.white);
AddLabel(buying <= selling, "Sell %: "+SellVolPercent, color.black);
AddLabel(buying >= selling, "Buy %: "+BuyVolPercent, color.black);
 
Is there a way to modify the script so i can use it in a watch list so i can watch the current buy bar and sell bar over multiple timeframes.
Code:
# Original author: Unknown
# Watchlist Label
# Mod by Ramon DV aka Pelonsax

declare lower;


def O = open;
def H = high;
def C = close;
def L = low;
def Price = H + L + C / 3;
def V = volume;
def buying = V * (C - L) / (H - L);
def selling = V * (H - C) / (H - L);
def SellVolPercent = Round((Selling / Volume) * 100, 0);
def BuyVolPercent = 100 - SellVolPercent;

assignBackgroundColor(if buying >= selling then color.GREEN else if buying <= selling then color.RED else color.white);
AddLabel(buying <= selling, "Sell %: "+SellVolPercent, color.black);
AddLabel(buying >= selling, "Buy %: "+BuyVolPercent, color.black);
 
Code:
#----------------------------------------------------------#
#            Start of RCB Enhanced Volume Script           #
#                                                          #
#                                                          #
#                                                          #
#----------------------------------------------------------#


###############
# Body
###############
input Audible_Alert = yes;
def Deviation_Length = 60;
def Deviate = 2;
def volumestdev = RelativeVolumeStDev(length = Deviation_Length);
def abovedev = volumestdev >= Deviate;
def belowdev = volumestdev <= Deviate;


###############
# Volume Bars
###############
plot volumereplace = volume;
volumereplace.SetPaintingStrategy(paintingStrategy = PaintingStrategy.HISTOGRAM);
def increase = volume > volume[1];
def devincrease = increase and abovedev;
def decrease = volume < volume[1];
def devdecrease = decrease and abovedev;
volumereplace.DefineColor("Increase", Color.DARK_GREEN);
volumereplace.DefineColor("DevIncrease", Color.GREEN);
volumereplace.DefineColor("Decrease", Color.DARK_RED);
volumereplace.DefineColor("DevDecrease", Color.LIGHT_RED);
volumereplace.AssignValueColor(
if devincrease then volumereplace.Color("DevIncrease")
else
if increase then volumereplace.Color("Increase")
else
if devdecrease then volumereplace.Color("DevDecrease")
else
volumereplace.Color("Decrease"));


###############
# Alerts
###############
Alert(devincrease and Audible_Alert, "Support/Resistance Detected", Alert.BAR, Sound.Bell);
Alert(devdecrease and Audible_Alert, "Support/Resistance Detected", Alert.BAR, Sound.Bell);


#----------------------------------------------------------#
#              End of RCB Enhanced Volume Script           #
#                                                          #
#----------------------------------------------------------#


It is the volume in this picture. Thanks in advance!

 
It highlights volume bars that are considered abnormally large, based on standard deviation against some other factors. RelativeVolumeStDev() is a built-in tos study, and that is really what is at the core of what you posted. The rest is mainly decorative, changing colors and what not.
 
Hello, I am looking for help to replicate this image of Buy and sell volume along with percentages.
This can be used on equites, options prices, and indexes.
You can ignore the support lines that are on the chart, they are separate and unrelated
I am unfortunately not a coder.
This could be very useful for entering and exiting trades.
0LiS4IQ.png

The picture of the screenshot should be helpful

Thanks!
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
277 Online
Create Post

Similar threads

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.
Back
Top