Chris's Enhanced Volume Buy Sell Pressure Indicator & Labels For ThinkOrSwim

MerryDay

Administrative
Staff member
Staff
VIP
Chris's Enhanced Volume For ThinkOrSwim
Buy / Sell Volume Pressure w/ volumes and percentages

b1.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);
 
Last edited:

Takata

New member
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:

XeoNoX

Well-known member
VIP
@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:

Pelonsax

Active member
VIP
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);
 

Pelonsax

Active member
VIP
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);
 

kingkunta

New member
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!

 

Joshua

Active member
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.
 

iselloptions

New member
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
 

ChristianS

New member
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
 

renydiver

New member
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:

rad14733

Well-known member
VIP
@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...
 

Similar threads

Top