2 Chart labels into 1

IHopeToLearn

New member
Hi,
Is there any way to combine these two chart labels into One?
Difficult to look at because they jump out of position
also take up double the space. THANKS
Please see video:
Here's the code:

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


#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.GREEN);

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

#PreMarket Volume
input startTime = 0600;
input endTime = 0829;
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);

# Declare variables
def BuyingVolume = if close > open then volume else 0;
def SellingVolume = if open > close then volume else 0;

#Seller Total
AddLabel(yes, "" + Round(sellPercent, 0) + "% S", if Selling > Buying then Color.LIGHT_RED else Color.BLACK);

#Buyer Total
AddLabel(yes, "" + Round(buyPercent, 0) + "% B", if Buying > Selling then Color.GREEN else Color.BLACK);

#Volume color coded by amount of volume on up-tick versus amount of volume on down-tick
 
@IHopeToLearn
See if this works out better visually for you.

Ruby:
#Seller Total
AddLabel(yes, "" + Round(sellPercent, 0) + if Round(sellPercent, 0) < 10 then "% S    " else if Round(sellPercent, 0) == 100 then "% S" else if IsNaN(Round(sellPercent, 0)) then "%S" else "% S  ", if Selling > Buying then Color.LIGHT_RED else Color.BLACK);

#Buyer Total
AddLabel(yes, "" + Round(buyPercent, 0) + if Round(buyPercent, 0) < 10 then "% B    " else if Round(buyPercent, 0) == 100 then "% B" else if IsNaN(Round(buyPercent, 0)) then "%B" else "% B  ", if Buying > Selling then Color.GREEN else Color.BLACK);
 

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

Hi,
Is there any way to combine these two chart labels into One?
Difficult to look at because they jump out of position
also take up double the space. THANKS
Please see video:
Here's the code:

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


#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.GREEN);

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

#PreMarket Volume
input startTime = 0600;
input endTime = 0829;
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);

# Declare variables
def BuyingVolume = if close > open then volume else 0;
def SellingVolume = if open > close then volume else 0;

#Seller Total
AddLabel(yes, "" + Round(sellPercent, 0) + "% S", if Selling > Buying then Color.LIGHT_RED else Color.BLACK);

#Buyer Total
AddLabel(yes, "" + Round(buyPercent, 0) + "% B", if Buying > Selling then Color.GREEN else Color.BLACK);

#Volume color coded by amount of volume on up-tick versus amount of volume on down-tick

Here is the code I think you wanted. Add this to the end of your code to see it next to the existing labels. If satisfied, comment out or delete the existing label code.

Your existing labels and the new label.

label.gif


Code:
AddLabel(yes, if Selling > Buying then Round(sellPercent, 0) + "% S" else Round(buyPercent, 0) + "% B", if Selling > Buying then Color.LIGHT_RED else Color.GREEN);
 
Last edited:
Here is the code I think you wanted. Add this to the end of your code to see it next to the existing labels. If satisfied, comment out or delete the existing label code.

Your existing labels and the new label.

View attachment 19852

Code:
AddLabel(yes, if Selling > Buying then Round(sellPercent, 0) + "% S" else Round(buyPercent, 0) + "% B", if Selling > Buying then Color.LIGHT_RED else Color.GREEN);
That's it GREAT! Thanks for lean efficient code.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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