All Buy / Sell Volume Pressure Indicators & Labels For ThinkOrSwim

Knowing the percentage of buyers and sellers in the market is a powerful tool for making informed investment decisions. By using this script, traders can assess the market sentiment and determine whether there is a high demand for a particular stock, or if there are more sellers than buyers. This information can help traders to time their trades more effectively, as well as to identify potential trends or market reversals. The buyPercent and sellPercent variables calculate the percentage of buying and selling volume, respectively, in relation to the total trading volume. These percentages are displayed in the labels, along with the current buying and selling volumes. The labels are color-coded to indicate whether there is more buying or selling pressure in the market, with green indicating more buying and red indicating more selling.

(Added Current bar volume and last bar volume.) 5-06-2023

Video:

Install: Go to Studies, Edit Studies, Create, Delete whats in there, copy the code below, paste it, Name it, Move it over to the chart if not already there.

Code:
#hint: Buy_Sell_Percent_Label - Created by @uptwobucks . This Volume Label measures the percentage of buys and sells live. Wait for the buys to outnumber the sells (Turns Green) then make your decision.

declare upper;

input Show_Labels = 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);
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);
def totVol = Round(Buying, 0) + Round(Selling, 0) ;
def buyPercent  = ( Round(Buying, 0)  / totVol ) * 100;
def sellPercent = ( Round(Selling, 0) / totVol ) * 100;

AddLabel(Show_Labels, "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);

AddLabel(Show_Labels, "  BUYERS: " + Round(Buying, 0) + " -- " + Round(buyPercent, 0) + "%"  , if Buying > Selling then Color.LIGHT_GREEN else Color.BLACK);

AddLabel(Show_Labels, "  SELLERS: " + Round(Selling, 0) + " -- " + Round(sellPercent, 0) + "%"  , if Selling > Buying then Color.LIGHT_RED else Color.BLACK);



[B][B][B][B][B]End[/B][/B][/B][/B][/B]
Help, I can't get this to load, each time it comes up blank on TOS
 
Help, I can't get this to load, each time it comes up blank on TOS

You didn't provide enough information to say where you went astray.

Here is a shared chart link: http://tos.mx/!ngpkElyB with the label indicator applied.
MUST follow these instructions for loading shared links.

When you import the chart link, the indicator will be put into your library.
GVdRCtw.png
 
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?
That chart looks good for options from the screenshot. Could you please chare the chart if possible? Thanks
 
I downloaded this short script:


AddLabel(yes, "This: " + volume, Color.yellow);
AddLabel(yes, "Last: " + volume[1], color.yellow);
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];
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);
plot BV = Buying;
BV.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
BV.SetDefaultColor(Color.GREEN);
BV.HideTitle();
BV.HideBubble();
BV.SetLineWeight(1);
plot SV = Selling;
SV.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
SV.SetDefaultColor(Color.RED);
SV.HideTitle();
SV.HideBubble();
SV.SetLineWeight(1);
plot VolumeHistogram = volume;
VolumeHistogram.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
VolumeHistogram.SetDefaultColor(Color.BLUE);
VolumeHistogram.HideTitle();
VolumeHistogram.HideBubble();
VolumeHistogram.SetLineWeight(5);

# Average Volume Line
def AverageVolume = Average(VolumeHistogram, 50);
plot AverageVolumeLine = AverageVolume;
AverageVolumeLine.SetDefaultColor(Color.GRAY);
AverageVolumeLine.SetStyle(Curve.FIRM);

# Label indicating Buyers/Sellers Volume
def isBuyersVolumeGreater = BV > SV;
def isSellersVolumeGreater = SV > BV;
AddLabel(yes, if isBuyersVolumeGreater then "Buyers Volume > Sellers Volume" else if isSellersVolumeGreater then "Sellers Volume > Buyers Volume" else "Buyers Volume = Sellers Volume",
if isBuyersVolumeGreater then Color.GREEN else if isSellersVolumeGreater then Color.RED else Color.YELLOW);


# Buyer and Seller Percentage Labels
def TotalVolume = VolumeHistogram + AverageVolume;
def BuyerPercentage = Buying / TotalVolume * 100;
def SellerPercentage = Selling / TotalVolume * 100;
AddLabel(yes, "Buyer %: " + Round(BuyerPercentage, 2) + "%", Color.GRAY);
AddLabel(yes, "Seller %: " + Round(SellerPercentage, 2) + "%", Color.GRAY);


I like to change it a bit to show on the buyer and seller percentage labels at the end, to lit up green if the isBuyerVolumeGreater is true or if the isSellersVolumeGreater is true at any point in time. In other words whichever of the two is higher at any point will lit green. Not sure how to change it to reflect this. I tried using If Then Else but no luck there...
 
I downloaded this short script:


AddLabel(yes, "This: " + volume, Color.yellow);
AddLabel(yes, "Last: " + volume[1], color.yellow);
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];
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);
plot BV = Buying;
BV.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
BV.SetDefaultColor(Color.GREEN);
BV.HideTitle();
BV.HideBubble();
BV.SetLineWeight(1);
plot SV = Selling;
SV.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
SV.SetDefaultColor(Color.RED);
SV.HideTitle();
SV.HideBubble();
SV.SetLineWeight(1);
plot VolumeHistogram = volume;
VolumeHistogram.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
VolumeHistogram.SetDefaultColor(Color.BLUE);
VolumeHistogram.HideTitle();
VolumeHistogram.HideBubble();
VolumeHistogram.SetLineWeight(5);

# Average Volume Line
def AverageVolume = Average(VolumeHistogram, 50);
plot AverageVolumeLine = AverageVolume;
AverageVolumeLine.SetDefaultColor(Color.GRAY);
AverageVolumeLine.SetStyle(Curve.FIRM);

# Label indicating Buyers/Sellers Volume
def isBuyersVolumeGreater = BV > SV;
def isSellersVolumeGreater = SV > BV;
AddLabel(yes, if isBuyersVolumeGreater then "Buyers Volume > Sellers Volume" else if isSellersVolumeGreater then "Sellers Volume > Buyers Volume" else "Buyers Volume = Sellers Volume",
if isBuyersVolumeGreater then Color.GREEN else if isSellersVolumeGreater then Color.RED else Color.YELLOW);


# Buyer and Seller Percentage Labels
def TotalVolume = VolumeHistogram + AverageVolume;
def BuyerPercentage = Buying / TotalVolume * 100;
def SellerPercentage = Selling / TotalVolume * 100;
AddLabel(yes, "Buyer %: " + Round(BuyerPercentage, 2) + "%", Color.GRAY);
AddLabel(yes, "Seller %: " + Round(SellerPercentage, 2) + "%", Color.GRAY);


I like to change it a bit to show on the buyer and seller percentage labels at the end, to lit up green if the isBuyerVolumeGreater is true or if the isSellersVolumeGreater is true at any point in time. In other words whichever of the two is higher at any point will lit green. Not sure how to change it to reflect this. I tried using If Then Else but no luck there...
Replace these portions of your code with the following and it should do what you want.
Code:
AddLabel(yes, "Buyer %: " + Round(BuyerPercentage, 2) + "%", if BuyerPercentage > SellerPercentage then Color.GREEN else Color.GRAY);
AddLabel(yes, "Seller %: " + Round(SellerPercentage, 2) + "%", if SellerPercentage > BuyerPercentage then Color.GREEN else Color.GRAY);
 
This is a mashup of buy Sell volume & Built-in Warningsymbols indicator to generate a buy sell signal based on Buy volume crossing over or under Sell volume to show the Buy/Sell Bubble.

Also, the warning symbols code is used to generate Yellow color on the GREEN and RED lines - whenever the market is going from bull / bear to sideways or losing momentum.

Ruby:
# Filtered Buy and Sell Volume Averages with Warning
# Conversion from Pine Script to ThinkScript
# Author Keyur Shah (softwareklinic)

# Part of this code for warning symbols is an extract of the original think or swim WarningSymbols indicator to plot yellow color on GREEN and RED lines for buy and sell volumes
# the yellow color is to advise traders to stay away from trading that area of price

declare lower;
# Inputs
input BuyVolumeAvgLength = 18;
input SellVolumeAvgLength = 18;
input EMA_Filter_Length = 34;
input weightedAverageLength = 34;
input exponentialAverageLength = 55;

# Buy and Sell Volume calculations
def buyvol = Round(((high - open) + (close - low)) / 2 / (high - low) * volume, 0);
def sellvol = Round(((low - open) + (close - high)) / 2 / (high - low) * volume, 0);

# Moving Averages for Buy and Sell Volume
def buyvolavg = ExpAverage(buyvol, BuyVolumeAvgLength);
def sellvolavg = ExpAverage(AbsValue(sellvol), SellVolumeAvgLength);

# Additional EMA-34 filtering to reduce intertwining
def buyvolavg_filtered = ExpAverage(buyvolavg, EMA_Filter_Length);
def sellvolavg_filtered = ExpAverage(sellvolavg, EMA_Filter_Length);

# Warning conditions based on weighted and exponential averages (WMA and EMA)
def weightedAverage = WMA(close, weightedAverageLength);
def exponentialAverage = ExpAverage(close, exponentialAverageLength);

def upperWarningSymbol = close < weightedAverage and high >= exponentialAverage;
def lowerWarningSymbol = exponentialAverage > weightedAverage and close > weightedAverage;
def warningCondition = upperWarningSymbol or lowerWarningSymbol;

# Plot the Filtered Buy and Sell Volume Averages as lines
plot BuyVolumeAvgLine = buyvolavg_filtered;
plot SellVolumeAvgLine = sellvolavg_filtered;

# Set line thickness
BuyVolumeAvgLine.SetLineWeight(2);
SellVolumeAvgLine.SetLineWeight(2);

# Change line colors based on warning condition
BuyVolumeAvgLine.AssignValueColor(if warningCondition then Color.YELLOW else Color.GREEN);
SellVolumeAvgLine.AssignValueColor(if warningCondition then Color.YELLOW else Color.RED);

# Detect crossovers and add Buy/Sell labels aligned with the lines
def buyCross = buyvolavg_filtered crosses above sellvolavg_filtered;
def sellCross = buyvolavg_filtered crosses below sellvolavg_filtered;

# AddChartBubble for Buy and Sell events
AddChartBubble(buyCross, buyvolavg_filtered, "Buy", Color.GREEN, yes);
AddChartBubble(sellCross, sellvolavg_filtered, "Sell", Color.RED, yes);

Buysell.PNG
 

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