All Buy / Sell Volume Pressure Indicators & Labels For ThinkOrSwim

It is the only volume indicator I use now. I scalp so it has been a game changer for me.
Im not much of a scripter, but is there any way it can plot some type of indication like a dot or arrow when volume switches to buying and the candlestick is red(selling) and vise versa for when the volume switches to selling but the candlestick is green(buying)

Here's an example of what I mean. These were Friday's EXPY SPY contracts. The Chart set up is with heiken ashi candles. What I've noticed is that when momentum is shifting to the bullish or bearish side. The Candlestick stick opposes its volume indication. So a bearish candlestick on a positive volume indication followed by a second consecutive bullish volume has been indicating a quick bullish move or a true bullish move and vise versa for the bear side. Any way we can find a way to get indications for those kinds of moments?
 

Attachments

  • 2023-08-27-TOS_CHARTSSPYEXAMPLE.png
    2023-08-27-TOS_CHARTSSPYEXAMPLE.png
    425.5 KB · Views: 697
Last edited by a moderator:
Im not much of a scripter, but is there any way it can plot some type of indication like a dot or arrow when volume switches to buying and the candlestick is red(selling) and vise versa for when the volume switches to selling but the candlestick is green(buying)

Here's an example of what I mean. These were Friday's EXPY SPY contracts. The Chart set up is with heiken ashi candles. What I've noticed is that when momentum is shifting to the bullish or bearish side. The Candlestick stick opposes its volume indication. So a bearish candlestick on a positive volume indication followed by a second consecutive bullish volume has been indicating a quick bullish move or a true bullish move and vise versa for the bear side. Any way we can find a way to get indications for those kinds of moments?
I am not sure if that would work on a lower TF as it would constantly switch from red to green in a lot of cases. This is an interesting find. It is a divergence in volume to candle and it does seem to be pretty consistent. I am not a coder. I had Chat GPT make this by accident. Maybe some of the really good coders here may be able to help. It does appear to be a good strat possibly.
 
Metal can you make buy sell separate percentage volume watchlist column for different time frame 1 2 5 15 minute and any reversal signal so we can scalp with if all align...
 
Have been following DTS and the Professor, he makes it look SO simple. He does rely heavily on the Scalping/Momentum Indicator. I had no idea METAL you were the developer. Amazing - nice work. He always posts his videos after the day, wish he, and the group would live stream. Are you part of the Million Dollars Margin Club? I actually just bought the Day Trading Vol 1 book. Did you have your hand?

Anyhow, I have been visually back testing the Heikin Ashi/Scalper Indicator combo - it does indeed to happen often. Very interesting observation. I agree it would be amazing to code up an indicator that would provide the buy/sell accordingly.
 
My understanding is that ThinkorSwim does not provide a "true" cumulative volume indicator on its platform similar to Tradingview or other more updated scripting capacity platforms. to be explicit ,TOS does not aggregate the individual spread difference for transactions spread between buyers and sellers during the actual auction process as it unfolds. (In my opinion scalpers especially favor cum delta volume because it shows the internal tension in a moment by moment unfolding process.) All the volume studies I have personally observed on usethinkscipt.com theads seem to have as their goal a "workaround" for this lack of precision and information. Given what I have seen so far, there is no perfect way to perform a true cumulative delta volume indicator in thinkorswim. Please feel free to reply and further enlighten me about this subject. One last comment: even with the cum delta volume study, I have personally observed many, I repeat, many false short term breakouts and reversals even in the most robust index like spx, spy and index options. Whatever signal a TOS trader uses to drill down into the internal auction process I suggest that it is critical pay attention to the tick indicators and the cumulative tick indicators along with all these (Mobius Volume Waves, Buy, Sell vol,

This is useful as a workaround for the reality that unlike Tradingview, there is no actual cumulative delta indicator on TOS (the accumulation spread between buyer and seller in the transactional auction process. Aside from that this is an excellent tool to decipher the internal tension over the selected time period in which you are trading. U could add a cumulative tick indicator across the price section (for the major indexes) in order to get a clearer picture of how the auction, price discovery process is unfolding. I take comfort that I have observed that the cumulative delta indicators on other platforms lead to many false breakouts and short term reversals. Do not despair as the only perfect indicator is already inside you. No single electronic signal will replace you when you are in total synchronization with the market. Thanks to everyone working on this thread. Very creative workarounds.



Great indicator. Thanks as always.

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);
What statements here to be changed in order to get it as a scan condition . for example I would like a create a scan for ,y watchlist stocks to displau only when
SellVolPercent or
BuyVolPercent
 
Last edited by a moderator:
@priyamani
Not sure that this scan has much use.
The percentage of volume pressure is not indicative of trend
If Selling Volume Pressure is increasing on my higher timeframes, I might do a deeper analysis before entry on my lower timeframe and visa-versa. But the actual value is of limited value.

@SeeMoreGreen
Sorry about that.
I try to always provide the actual code.
This post has been updated with the script.

FYI, Shared links are available in the Schwab ToS app. But there is a delay in the use of new shared links.
Shared Links are only updated into the Schwab ToS app overnight.
So new shared links are not available until the next day.


# Volume Pressure Scan For Percentage Over 80
shared scanner link: http://tos.mx/sA6ld12 Click here for --> Easiest way to load shared links
uSBt73h.png
 
Last edited:
I modified the Buy and Sell Volume indicator
https://usethinkscript.com/threads/...ssure-indicators-labels-for-thinkorswim.8466/
to plot a "buy" moving average and "sell" moving average. When the two cross, it helps to show a trend reversal.

I included some code to plot when the two cross up or down. Unfortunately, it's only showing the "cross down" and doesn't show the "cross up" plots. Can someone help me get the "cross up" to show?
Ruby:
#Buy/Sell Volume Moving Averages

declare on_volume;

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);

input length = 26;

plot VolAvg = Average(Selling, length);
plot VolAvg2 = Average(Buying, length);
VolAvg.SetDefaultColor(GetColor(2));
VolAvg2.SetDefaultColor(GetColor(6));

AddVerticalLine(VolAvg crosses above VolAvg2, "Up", Color.Green, Curve.Points);
AddVerticalLine(VolAvg2 crosses below VolAvg, "Down", Color.Yellow, Curve.Points);

#End
Here you go. I also added a cloud and a "Net Buy / Sell" avg line to spot divergences. Both can be turned on/off but most likely need to diable volume histogram for these 2 features to be useful.



#Buy/Sell Volume Moving Averages

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);

input length = 26;

plot SellingAvg = Average(Selling, length);
plot BuyingAvg = Average(Buying, length);
SellingAvg.SetDefaultColor(GetColor(2));
BuyingAvg.SetDefaultColor(GetColor(6));



AddVerticalLine(BuyingAvg crosses above SellingAvg, "Up", Color.Green, Curve.Points);
AddVerticalLine(BuyingAvg crosses below SellingAvg, "Down", Color.yellow, Curve.Points);

#End

# ---------------------------------------- Add Net Buy / Sell ----------------

DefineGlobalColor( "Net Pressure Up", color.cyan);
DefineGlobalColor( "Net Pressure Down", color.magenta);


def NetBuySell = BuyingAvg - SellingAvg;
Plot NetPressure = NetBuySell;
NetPressure.AssignValueColor(if NetPressure >= NetPressure[1] then GlobalColor ("Net Pressure Up") else GlobalColor ("Net Pressure Down"));
NetPressure.SetDefaultColor(GetColor(2));


# --------------------------------------- Add Cloud --------------------------
input ShowCloud = no;


DefineGlobalColor( "Bullish Cloud", CreateColor(201, 255, 234));
DefineGlobalColor( "Bearish Cloud", CreateColor(255, 105, 105));

AddCloud(if ShowCloud then BuyingAvg else Double.NaN, SellingAvg, GlobalColor("Bullish Cloud"), GlobalColor("Bearish Cloud"));
 
Last edited:
The ToS data feeds do not provide buying and selling volume.
You could plot your relative volume
and below it plot a buying and selling volume pressure indicator
https://usethinkscript.com/threads/all-buy-s
Code:
#Chris' Enhanced Volume V.2 /w Uptick/Downtick

declare on_volume;

###############
#DPL CRITERIA #
###############
input Audible_Alert = no;
input Deviation_Length = 60;
input 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);
ell-volume-pressure-indicators-labels-for-thinkorswim.8466/

Volume pressure indicators make an assumption as to buyers and sellers.
Bullish candlestick patterns == buyers and Bearish == sellers.
One request @MerryDay , the study which you referred for the buying/selling pressure is superb and I intend to use it on a 4 hour aggregation. I Have copied the as attached but I only see the labels, not the contrast of buy/sell on a single volume bar. Please suggest
 
One request @MerryDay , the study which you referred for the buying/selling pressure is superb and I intend to use it on a 4 hour aggregation. I Have copied the as attached but I only see the labels, not the contrast of buy/sell on a single volume bar. Please suggest

You did not provide enough information to say where you went astray.
Here is a shared chart with the indicator applied: http://tos.mx/fajmtfr
Click here for --> Easiest way to load shared links

LJ8ODYv.png
 
Hi all, I need help on those items mark in purple stars, I have this open source - similar code, can someone modify it ?

Custom Buy and Sell Side Volume Indicator for ThinkorSwim | Custom Thinkscript
https://www.youtube.com/watch?v=b2JR2AB2HtE

Screenshot 2023-12-15 215944.01.02.volume.use.png


Screenshot 2023-12-16 060254.02.USE.png




Code:
#Total Volume for Regular Trading Day
AddLabel(yes, "Total Vol: " + volume(period = AggregationPeriod.DAY), Color.white);


#Volume of Current Bar
AddLabel(yes, "CurrentBar Vol: " + volume, Color.LIGHT_GREEN);


#Volume of the Last Bar
AddLabel(yes, "LastBar Vol: " + volume[1], Color.LIGHT_ORANGE);



#PreMarket Volume
input startTime = 0400;
input endTime = 0929;
def startCounter = SecondsFromTime(startTime);
def endCounter = SecondsTillTime(endTime);
def targetPeriod = if startCounter >= 0 and endCounter >= 0 then 1 else 0;
rec volumeTotal = if targetPeriod and !targetPeriod[1] then volume else if targetPeriod then volumeTotal[1] + volume else volumeTotal[1];
AddLabel(yes, Concat("PreMrket Vol: ", volumeTotal), Color.VIOLET);



#Volume color coded 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.LIGHT_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.GREEN);
BV.HideTitle();
BV.HideBubble();
BV.SetLineWeight(5);


#Create an average volume line based on last 50 bars

input length = 20;
plot Vol = volume;
plot VolAvg = Average(volume, length);
Vol.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
 
Last edited by a moderator:
Hi all, I need help on those items mark in purple stars, I have this open source - similar code, can someone modify it ?

Custom Buy and Sell Side Volume Indicator for ThinkorSwim | Custom Thinkscript

View attachment 20423

View attachment 20424



Code:
#Total Volume for Regular Trading Day
AddLabel(yes, "Total Vol: " + volume(period = AggregationPeriod.DAY), Color.white);


#Volume of Current Bar
AddLabel(yes, "CurrentBar Vol: " + volume, Color.LIGHT_GREEN);


#Volume of the Last Bar
AddLabel(yes, "LastBar Vol: " + volume[1], Color.LIGHT_ORANGE);



#PreMarket Volume
input startTime = 0400;
input endTime = 0929;
def startCounter = SecondsFromTime(startTime);
def endCounter = SecondsTillTime(endTime);
def targetPeriod = if startCounter >= 0 and endCounter >= 0 then 1 else 0;
rec volumeTotal = if targetPeriod and !targetPeriod[1] then volume else if targetPeriod then volumeTotal[1] + volume else volumeTotal[1];
AddLabel(yes, Concat("PreMrket Vol: ", volumeTotal), Color.VIOLET);



#Volume color coded 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.LIGHT_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.GREEN);
BV.HideTitle();
BV.HideBubble();
BV.SetLineWeight(5);


#Create an average volume line based on last 50 bars

input length = 20;
plot Vol = volume;
plot VolAvg = Average(volume, length);
Vol.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
In the ToS platform, bid ask volume is not available in its data feeds
 
Last edited:
I found a bid and ask volume & percentage %, can someone add on "Yesterday volume" for the above code?


Code:
declare lower;
input over_bought = 90;
input over_sold = 10;
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);
#last bar
def OL = open[1];
def HL = high[1];
def CL = close[1];
def LL = low[1];
def VL = volume[1];
def LBuying = VL * (CL - LL) / (HL - LL);
def LSelling = VL * (HL - CL) / (HL - LL);

#Buying Selling Ratio
plot BSR = 100 * (Buying) / (Buying + Selling);
plot OverSold = over_sold;
plot OverBought = over_bought;
BSR.SetPaintingStrategy(PaintingStrategy. LINE);
BSR.HideTitle();
BSR.HideBubble();
BSR.SetLineWeight(2);
BSR.DefineColor("OverBought", GetColor(1));
BSR.DefineColor("Normal", GetColor(0));
BSR.DefineColor("OverSold", GetColor(8));
BSR.AssignValueColor(if BSR  >=  over_bought then BSR.Color("OverBought") else if BSR <= over_sold then BSR.Color("OverSold") else BSR.Color("Normal"));
AddCloud(0,  over_sold,  Color.liGHT_RED,  Color.RED);
AddCloud(100, over_bought, Color.LigHT_GREEN, Color.GREEN);

#################
#  Volume %     #
#################
def totVol = Round(Buying, 0) + Round(Selling, 0) ;
def buyPercent  = ( Round(Buying, 0)  / totVol ) * 100;
def sellPercent = ( Round(Selling, 0) / totVol ) * 100;

#######################################Chart Time Frame Buying & Selling Volumes#######################################
input Show_Labels = yes;

AddLabel(Show_Labels, "Total Vol: " + volume(period = AggregationPeriod.DAY), Color.WHITE);
#AddLabel(Show_Labels, "LastBarBuy Vol: " + Round(LBuying, 0), #Color.LIGHT_ORANGE);
#AddLabel(Show_Labels, "LastBarSell Vol: " + Round(LSelling, 0), Color.PINK);

AddLabel(Show_Labels, "CurrentBuy Vol: " + Round(Buying, 0) + " -- " + Round(buyPercent, 0) + "%", if Buying > Selling then Color.LIGHT_GREEN else Color.LIGHT_RED);
AddLabel(Show_Labels, "CurrentSell Vol: " + Round(Selling, 0) + " -- " + Round(sellPercent, 0) + "%", if Selling > Buying then Color.LIGHT_GREEN else Color.LIGHT_RED);
 
I found a bid and ask volume & percentage %, can someone add on "Yesterday volume" for the above code?


Code:
declare lower;
input over_bought = 90;
input over_sold = 10;
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);
#last bar
def OL = open[1];
def HL = high[1];
def CL = close[1];
def LL = low[1];
def VL = volume[1];
def LBuying = VL * (CL - LL) / (HL - LL);
def LSelling = VL * (HL - CL) / (HL - LL);

#Buying Selling Ratio
plot BSR = 100 * (Buying) / (Buying + Selling);
plot OverSold = over_sold;
plot OverBought = over_bought;
BSR.SetPaintingStrategy(PaintingStrategy. LINE);
BSR.HideTitle();
BSR.HideBubble();
BSR.SetLineWeight(2);
BSR.DefineColor("OverBought", GetColor(1));
BSR.DefineColor("Normal", GetColor(0));
BSR.DefineColor("OverSold", GetColor(8));
BSR.AssignValueColor(if BSR  >=  over_bought then BSR.Color("OverBought") else if BSR <= over_sold then BSR.Color("OverSold") else BSR.Color("Normal"));
AddCloud(0,  over_sold,  Color.liGHT_RED,  Color.RED);
AddCloud(100, over_bought, Color.LigHT_GREEN, Color.GREEN);

#################
#  Volume %     #
#################
def totVol = Round(Buying, 0) + Round(Selling, 0) ;
def buyPercent  = ( Round(Buying, 0)  / totVol ) * 100;
def sellPercent = ( Round(Selling, 0) / totVol ) * 100;

#######################################Chart Time Frame Buying & Selling Volumes#######################################
input Show_Labels = yes;

AddLabel(Show_Labels, "Total Vol: " + volume(period = AggregationPeriod.DAY), Color.WHITE);
#AddLabel(Show_Labels, "LastBarBuy Vol: " + Round(LBuying, 0), #Color.LIGHT_ORANGE);
#AddLabel(Show_Labels, "LastBarSell Vol: " + Round(LSelling, 0), Color.PINK);

AddLabel(Show_Labels, "CurrentBuy Vol: " + Round(Buying, 0) + " -- " + Round(buyPercent, 0) + "%", if Buying > Selling then Color.LIGHT_GREEN else Color.LIGHT_RED);
AddLabel(Show_Labels, "CurrentSell Vol: " + Round(Selling, 0) + " -- " + Round(sellPercent, 0) + "%", if Selling > Buying then Color.LIGHT_GREEN else Color.LIGHT_RED);

As mentioned in the earlier reply, it's important to note that the ToS data feeds don't include bid-ask volume information. The indicators you've been posting are Volume Pressure Indicators.

These indicators forecast buy/sell volume based on PRICE movement. The concept is that bullish candlesticks typically represent bid volume, while bearish ones reflect ask.
Volume Pressure analyzes price changes, combined with volume, to gauge MOMENTUM rather than specifically identifying bid ask volume.

Regarding your query: When your script is applied to a daily chart, the "current" labels pertain to today's data, while the "lastbar" labels refer to the 'yesterday' data you're inquiring about.

Hope this helps.
 
Last edited:
Is the code calculating Bid Ask Volume? Merry, you saying Bid/Ask Volume can't be calculated, so what's this code calculating?

Code:
declare lower;

input marketOpenTime = 0600;
input marketCloseTime = 1500;

def isMarketOpen = SecondsFromTime(marketOpenTime) >= 0 and SecondsTillTime(marketCloseTime) >= 0;

def totalBuyVolume = if isMarketOpen then
                        fold i = 1 to BarNumber()
                        with buyVolSum = 0
                        do buyVolSum + (if GetValue(close, i) > GetValue(close, i - 1) then GetValue(volume, i) else 0)
                     else Double.NaN;

def totalSellVolume = if isMarketOpen then
                         fold j = 1 to BarNumber()
                         with sellVolSum = 0
                         do sellVolSum + (if GetValue(close, j) < GetValue(close, j - 1) then GetValue(volume, j) else 0)
                      else Double.NaN;

def totalVolume = totalBuyVolume + totalSellVolume;

def buyVolumePercent = if totalVolume != 0 then
                          Min(totalBuyVolume / totalVolume * 100, 100)
                       else
                          0;

def sellVolumePercent = if totalVolume != 0 then
                           Min(totalSellVolume / totalVolume * 100, 100)
                        else
                           0;

AddLabel(yes,"  " + "Total Daily Buy Percent: " + AsPercent(buyVolumePercent / 100) + "  ", Color.GREEN);
AddLabel(yes,"  " + "Total Daily Sell Percent: " + AsPercent(sellVolumePercent / 100) + "  ", Color.LIGHT_RED);
 

Attachments

  • Screenshot 2023-12-17 065250.BUY.SELL.VOLUME.05.png
    Screenshot 2023-12-17 065250.BUY.SELL.VOLUME.05.png
    84.7 KB · Views: 281
Is the code calculating Bid Ask Volume? Merry, you saying Bid/Ask Volume can't be calculated, so what's this code calculating?

Code:
declare lower;

input marketOpenTime = 0600;
input marketCloseTime = 1500;

def isMarketOpen = SecondsFromTime(marketOpenTime) >= 0 and SecondsTillTime(marketCloseTime) >= 0;

def totalBuyVolume = if isMarketOpen then
                        fold i = 1 to BarNumber()
                        with buyVolSum = 0
                        do buyVolSum + (if GetValue(close, i) > GetValue(close, i - 1) then GetValue(volume, i) else 0)
                     else Double.NaN;

def totalSellVolume = if isMarketOpen then
                         fold j = 1 to BarNumber()
                         with sellVolSum = 0
                         do sellVolSum + (if GetValue(close, j) < GetValue(close, j - 1) then GetValue(volume, j) else 0)
                      else Double.NaN;

def totalVolume = totalBuyVolume + totalSellVolume;

def buyVolumePercent = if totalVolume != 0 then
                          Min(totalBuyVolume / totalVolume * 100, 100)
                       else
                          0;

def sellVolumePercent = if totalVolume != 0 then
                           Min(totalSellVolume / totalVolume * 100, 100)
                        else
                           0;

AddLabel(yes,"  " + "Total Daily Buy Percent: " + AsPercent(buyVolumePercent / 100) + "  ", Color.GREEN);
AddLabel(yes,"  " + "Total Daily Sell Percent: " + AsPercent(sellVolumePercent / 100) + "  ", Color.LIGHT_RED);
This is a slight variation on the idea of a bullish candlestick's (close>open) = buying volume pressure.

This script is saying if the close of the current candle is greater than the close of the prior candle, than call it == buying volume pressure.

If it helps, here are some of my favorite volume indicators on the forum:
https://usethinkscript.com/threads/favorite-volume-indicators-in-thinkorswim.15694/
 
  • 100 %
Reactions: LLP
Various shareable links have been posted in here, is there something I am missing about accessing these links with the new Schwab merger. Prior it was just click and open now links open up another TOS while it is open and can’t open the file. Not trying to be that guy, absolutely am that guy. Half of the website is now nit accessible due to many posts having shared links.
 
Various shareable links have been posted in here, is there something I am missing about accessing these links with the new Schwab merger. Prior it was just click and open now links open up another TOS while it is open and can’t open the file. Not trying to be that guy, absolutely am that guy. Half of the website is now nit accessible due to many posts having shared links.
If you are on the Schwab ToS version, please note that shareable links will be a problem for the short-term future.

If you are a TDA client still using the TDA ToS version; this method should be successful when importing links: https://usethinkscript.com/threads/...ed-item-error-in-thinkorswim.5098/#post-57930
 
Hey Traders!

I've been researching all of the volume indicators on the site, looking for something to tell me when a reversal is going to happen. I really didn't find what I was looking for so I threw together something for myself. I think the image below does a good job explaining the indicator.

This new toy will go over the top of volume, so be sure you have volume checked in the settings and make it a subgraph.

Ruby:
# Dap711 - 2024

declare on_volume;

#Chart Bars
input PaintBars       = yes;

#Volume Pressure
input Volume_AvgType  = AverageType.EXPONENTIAL;
input Volume_Length   = 14;

#Moving Average
input MovAvg_AvgType  = AverageType.EXPONENTIAL;
input MovAvg_Price    = close;
input MovAvg_Length   = 20;

def selling = volume * ( high - close ) / ( high - low );
def buying  = volume * ( close - low ) / ( high - low );
def vol     = volume;

#Plot Histograms
Plot Plot1 = min(selling,buying);
     Plot1.setPaintingStrategy(PaintingStrategy.Histogram);
     Plot1.AssignValueColor( if selling <= buying then Color.DARK_RED else Color.DARK_GREEN );
     Plot1.HideTitle();
     Plot1.HideBubble();
     Plot1.SetLineWeight(5);

Plot Plot2 =  vol;
     Plot2.setPaintingStrategy(PaintingStrategy.Histogram);
     Plot2.AssignValueColor( if selling <= buying then Color.DARK_GREEN else Color.DARK_RED);
     Plot2.HideTitle();
     Plot2.HideBubble();
     Plot2.SetLineWeight(5);

#Calculate Volume Pressure
def upper_wick = if close>open then high-close else high-open;
def lower_wick = if close>open then open-low else close-low;
def spread = high-low;
def body_length = spread - (upper_wick + lower_wick);
def percent_upper_wick = upper_wick/spread;
def percent_lower_wick = lower_wick/spread;
def percent_body_length = body_length/spread;
def buy_volume = if close>open then
               (percent_body_length + (percent_upper_wick + percent_lower_wick)/2)* volume else
               ((percent_upper_wick + percent_lower_wick)/2) * volume;
def sell_volume = if close<open then
                (percent_body_length + (percent_upper_wick + percent_lower_wick)/2)* volume else
                ((percent_upper_wick + percent_lower_wick)/2) * volume;
def buying_volume = MovingAverage(Volume_AvgType, buy_volume,Volume_Length);
def selling_volume = MovingAverage(Volume_AvgType, sell_volume,Volume_Length);

#Moving Average
def MA = MovingAverage(MovAvg_AvgType,MovAvg_Price,MovAvg_Length);

#Plots
plot Dot_Cyan = if buying_volume > selling_volume and close > MA then 0 else Double.NaN ;
Dot_Cyan.SetPaintingStrategy(PaintingStrategy.SQUARES);
Dot_Cyan.SetLineWeight(5);
Dot_Cyan.AssignValueColor(Color.CYAN);

plot Dot_Red = if buying_volume < selling_volume and close < MA then 0 else Double.NaN ;
Dot_Red.SetPaintingStrategy(PaintingStrategy.SQUARES);
Dot_Red.SetLineWeight(5);
Dot_Red.AssignValueColor(Color.Red);

#Paint Candles
AssignPriceColor( if PaintBars and !IsNan(Dot_Cyan)  then Color.Cyan
                  else if PaintBars and !IsNan(Dot_Red) then Color.Red
                  else if PaintBars then Color.GRAY
                  else Color.CURRENT);
 

Attachments

  • Volume Reversal.jpg
    Volume Reversal.jpg
    163.8 KB · Views: 403
  • Settings.jpg
    Settings.jpg
    87.4 KB · Views: 369
Last edited:
Chris's Enhanced Volume For ThinkOrSwim
Buy / Sell Volume Pressure Percentages

View attachment 913
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.
View attachment 11814View attachment 11815
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);
I like the Upper Buy/Sell Volume Labels but modified it a bit to show ONLY VOLUME. The Label that is GREEN is the label with the most volume.


#Chris' Enhanced Volume V.2 /w Uptick/Downtick
#Modified by C. Ricks to show volume only 1/5/24
#Note: Whichever label is GREEN (Buy Vol or Sell Vol) will show the most volume.

declare upper;

input spacerText = "-----";
DefineGlobalColor("Spacer Color", Color.BLACK);
AddLabel(yes, spacerText, GlobalColor("Spacer Color"));

###############
#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 #
##################

#################
# Buying Volume #
#################
DefineGlobalColor("LabelGreen", CreateColor(0, 255, 0)) ;

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

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

#End code
 
Last edited by a moderator:

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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