All Buy / Sell Volume Pressure Indicators & Labels For ThinkOrSwim

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
you could have found the script ?
 

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

so if you go on any of the trading view built in market profiles, you will notice the volume profile is split into 2 colors apparently showing some kind of buy and sell volume. Trading view does not let us see the code for their built in volume profile so we cant see exactly how they calculate the buying and selling portions. we have a thread that has split colored regular volume candles (the split formula is based on high, low, close of the candle) that i enjoy very much. hoping we have or can get something like one of these for thinkorswim. i dont need anything else extra on the volume profile besides the split colored candles, but cant get a source to show code to see how they do it
 
Hi, sorry since I'm new, I could only facilitate the code so that I can get the volume as a percentage as I show it below, I'm operating at 1 minute, thank you.
i can't hit it even though it looks in the graph like a lapel, green and red
 
Hello guys,

I am looking for some help with the code on this volume indicator, it works alright on time charts but I haven't been able to make it work on a range chart. If anybody have an idea on how to make it work on a range chart please help.
Ruby:
declare lower;

input period = AggregationPeriod.DAY;
input lengthB = 9;
input lengthS = 9;
input averageType = AverageType.EXPONENTIAL;

# Buying Volume

def O1 = open(period = period);
def H1 = high(period = period);
def C1 = close(period = period);
def L1 = low(period = period);
def V1 = volume(period = period);
def BV = V1 * ((C1 - L1) / (H1 - L1));
def Buy = MovingAverage (averageType, BV,lengthB);
plot BuyVol = ExpAverage (Buy, LengthB);

# Selling Volume

def O = open(period = period);
def H = high(period = period);
def C = close(period = period);
def L = low(period = period);
def V = volume(period = period);
def SV = -V * ((H - C) / (H - L));
def Sell = MovingAverage (averageType, -SV, lengthS);
plot SellVol = ExpAverage (Sell, LengthS);

# Signal

input showBreakoutSignals = no;

plot UpSignal = BuyVol+1 crosses above SellVol;
plot DownSignal = BuyVol-1 crosses below SellVol;

UpSignal.SetHiding(!showBreakoutSignals);
DownSignal.SetHiding(!showBreakoutSignals);

UpSignal.SetDefaultColor(Color.UPTICK);
UpSignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
DownSignal.SetDefaultColor(Color.DOWNTICK);
DownSignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
 
Last edited by a moderator:
@renydiver The issue is that Range Charts don't support Secondary Aggregations... The reason being that Range Bars are not based on time but, rather, price movement, just as tick based charts rely on trade transaction counts... There is no remedy for this inherent constraint...
 
Does someone know if the code below is correct? I took a label code for RVol that was posted on here and I was playing with it to see if I could utilize it with avg b/s vol. I think it's wrong though, the result looks nothing like my other buy sell volume data and the numbers seem too high on the buy and sell volume. Any input would be wonderful :)

EDITED: SOLUTION BELOW
 
Last edited by a moderator:
Does someone know if the code below is correct? I took a label code for RVol that was posted on here and I was playing with it to see if I could utilize it with avg b/s vol. I think it's wrong though, the result looks nothing like my other buy sell volume data and the numbers seem too high on the buy and sell volume. Any input would be wonderful :)

Ruby:
def isRollover = GetYYYYMMDD() != GetYYYYMMDD()[1];
def beforeStart = GetTime() < RegularTradingStart(GetYYYYMMDD());
def vol = if isRollover and beforeStart then volume else if beforeStart then vol[1] + volume else Double.NaN;
def PMV = if IsNaN(vol) then PMV[1] else vol;
def AV = AggregationPeriod.DAY;


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

# Selling Volume
def SV = Selling;


# Buying Volume
def BV = Buying;


input vlength = 60;
def x = Average(volume(period = AV)[1], vlength);
def y1 = Round((PMV / x), 2);
def Lg = Lg(y1);
def p = if Lg >= 1 then 0 else if Lg >= 0 then 1 else 2;
def y2 = Round(y1, p);
def rVol = y2;

input blength = 60;
def x_b = Average(Buying[1], blength);
def y1_b = Round((PMV / x_b), 2);
def Lg_b = Lg(y1_b);
def p_b = if Lg_b >= 1 then 0 else if Lg_b >= 0 then 1 else 2;
def y2_b = Round(y1_b, p_b);
def rVolBuying = y2_b;

input slength = 60;
def x_s = Average(Selling[1], slength);
def y1_s = Round((PMV / x_s), 2);
def Lg_s = Lg(y1_s);
def p_s = if Lg_s >= 1 then 0 else if Lg_s >= 0 then 1 else 2;
def y2_s = Round(y1_s, p_s);
def RvolSelling = y2_s;

rVol.SetPaintingStrategy(PaintingStrategy.LINE);
AddLabel(yes, "R-Vol: " + rVol, if rVol > 3 then Color.Cyan else if rVol > 2 then Color.Blue else if rVol > 1.2 then Color.Orange else if (rVol <1.2 and rVol >.8) then color.Dark_orange else color.gray);

AddLabel(yes, "R-Vol (Buying): " + rVolBuying, if rVolBuying > 3 then Color.Green else if rVolBuying > 2 then Color.Dark_Green else if rVolBuying > 1.2 then Color.light_green else if rVolBuying <1.2 and rVolBuying >.8 then color.orange else color.red);

AddLabel(yes, "R-Vol (Selling): " + rVolSelling, if rVolSelling > 3 then Color.Red else if rVolSelling > 2 then Color.Dark_Red else if rVolSelling > 1.2 then Color.light_Red else if rVolSelling <1.2 and rVolSelling >.8 then color.orange else color.Green);
I fixed it nevermind.. the premarket volume wasn't added in properly for the buy and sell vol. I posted it below in case anyone's interested. Please let me know if there's a problem with it, I'm not very experienced and I'd love to improve it.

(I edited this to correct a code mistake or two)


Ruby:
def isRollover = GetYYYYMMDD() != GetYYYYMMDD()[1];
def beforeStart = GetTime() < RegularTradingStart(GetYYYYMMDD());
def vol = if isRollover and beforeStart then volume else if beforeStart then vol[1] + volume else Double.NaN;
def PMV = if IsNaN(vol) then PMV[1] else vol;
def AV = AggregationPeriod.DAY;


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

# Selling Volume
def SV = Selling;


# Buying Volume
defBV =  Buying;



input vlength = 22;
def x = Average(volume(period = AV)[1], vlength);
def y1 = Round((PMV / x), 2);
def Lg = Lg(y1);
def p = if Lg >= 1 then 0 else if Lg >= 0 then 1 else 2;
def y2 = Round(y1, p);
def rVol = y2;

input blength = 22;
def x_b = Average(Buying[1], blength);
def y1_b = Round((pmB / x_b), 2);
def Lg_b = Lg(y1_b);
def p_b = if Lg_b >= 1 then 0 else if Lg_b >= 0 then 1 else 2;
def y2_b = Round(y1_b, p_b);
def rVolBuying = y2_b;

input slength = 22;
def x_s = Average(Selling[1], slength);
def y1_s = Round((pmS / x_s), 2);
def Lg_s = Lg(y1_s);
def p_s = if Lg_s >= 1 then 0 else if Lg_s >= 0 then 1 else 2;
def y2_s = Round(y1_s, p_s);
def RvolSelling = y2_s;




AddLabel(yes, "R-Vol: " + rVol, if rVol > 3 then Color.Cyan else if rVol > 2 then Color.Blue else if rVol > 1.2 then Color.Orange else if (rVol <1.2 and rVol >.8) then color.Dark_orange else color.gray);

AddLabel(yes, "R-Vol (Buying): " + rVolBuying, if rVolBuying > 3 then Color.Green else if rVolBuying > 2 then Color.Dark_Green else if rVolBuying > 1.2 then Color.light_green else if rVolBuying <1.2 and rVolBuying >.8 then color.orange else color.red);

AddLabel(yes, "R-Vol (Selling): " + rVolSelling, if rVolSelling > 3 then Color.Red else if rVolSelling > 2 then Color.Dark_Red else if rVolSelling > 1.2 then Color.light_Red else if rVolSelling <1.2 and rVolSelling >.8 then color.orange else color.Green);
 
So i have this code for buy & sell volume and need to create a label for the upper chart that displays which vol type is currently showing and label should be painted green for bvol and red for svol. Appreciate if anyone can help me with this.

Code:
input length = 5;
def o = open;
def h = high;
def l = low;
def c = close;
def v = volume;
def bvolsum = Sum(((c - l) / (h - l)) * v, length);
def svolsum = Sum(((h - c) / (h - l)) * v, length);
 
So i have this code for buy & sell volume and need to create a label for the upper chart that displays which vol type is currently showing and label should be painted green for bvol and red for svol. Appreciate if anyone can help me with this.

Code:
input length = 5;
def o = open;
def h = high;
def l = low;
def c = close;
def v = volume;
def bvolsum = Sum(((c - l) / (h - l)) * v, length);
def svolsum = Sum(((h - c) / (h - l)) * v, length);
See 1st post in this thread. Comment out what you don't need.
 
Chris's Enhanced Volume For ThinkOrSwim
Buy / Sell Volume Pressure w/ volumes and percentages

View attachment 913
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);
Thanks for posting, any way to change the audio alert? I looked over the code and did not see it listed so I am guessing it's TOS default?
 
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 any way to take out those icons for Earnings and Dividend info between the Symbol and the rest of watchlist? I'd like to put that space to better use.
 
BUY SELL VOLUME WITH AVERAGES AND PERCENTAGES


Code:
################################
# Original script by Cwparker23#
################################

# Original script by Cwparker23                    #
#-----------------
#DISCLAIMER
#-----------------
#I am not a certified financial advisor. The content of this page/site and tools are for informational purposes only and does not constitute financial or legal advice. Under no circumstances will the author be responsible for errors or use of this tool and site. User assumes all risks.

declare lower;
declare zerobase;

def O = open;
def H = high;
def C = close;
def L = low;
def V = volume;
DEF VOLAVG= expaverage (V);
#############################################
def buying = ((C - L) / (H - L))*volume;
def selling = ((H - C) / (H - L)*volume);
DEF buying_AVG= expaverage (buying);
DEF selling_AVG= expaverage (selling);
AddLabel(yes, "BAR: " + volume, Color.WHITE);

def buy_percentage = (buying_AVG/VOLAVG)*100;
AddLabel (yes, "BUY_VOL " + Round (buying , 2) + "    BUY_AVG " + round (buying_AVG)+  "   %" + round (buy_percentage) + "", (if buying_AVG > selling_AVG then Color.GREEN else if buying_AVG < selling_AVG then Color.GRAY else Color.YELLOW));

def SELL_percentage = (selling_AVG/VOLAVG)*100;
AddLabel (yes, "SELL_VOL " + Round (selling , 2) + "    SELL_AVG " + round (selling_AVG)+  "   %" + round (SELL_percentage) + "", (if buying_AVG < selling_AVG then Color.RED else if buying_AVG > selling_AVG then Color.GRAY  else Color.YELLOW));
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
248 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