Current Bar Volume Label

Learnbot

Active member
Hi Guys/Gals,

I am trying to figure out how to add a label at the top of my chart (sorta the square box at top left corner on the image below) that shows current bar volume. For example when I hover the mouse over specific bar in volume chart it shows the exact volume of that bar, I would like that number to be shown up at top left squarish area (if possible). is this possible? needing this because I usually trade by looking at volume...

thank you
tMURs3.png
 
@BenTen Thank you for that Ben, it helped me a lot figuring this out on my own. So here the modified @horserider code i used to add the labels i needed (thank you horserider for your work). However, I still am not able to get volume of the bar I am hovering over as i can with TOS volume chart.
As you can see in the image below, at 6:46 am for example the TOS volume graph shows the volume to be 143.256 however, the Cur Bar shows 49,641 (which is the volume of the current bar going on at around 8:50 am. is there a way to achieve this or not really?

GBS6jN.png



Here is the modified horserider code I used:


Code:
# Show total volume in gray.  Buying volume in green.  Sell Volume in red.
# Volume average is gray line.
# Specified percent over average volume is cyan triangles.
# Horserider 12/30/2019 derived from some already existing studies.




#Inputs

input Show30DayAvg = yes;
input ShowTodayVolume =  yes;
input ShowPercentOf30DayAvg = yes;
input UnusualVolumePercent = 200;
input Show30BarAvg = yes;
input ShowCurrentBar = yes;
input ShowPercentOf30BarAvg = yes;
input ShowSellVolumePercent = 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);

# Selling Volume

Def SellVol = selling;

# Total Volume

# Note that Selling + Buying Volume = Volume.
def TV =  volume;



Def BuyVol = buying;

#Volume Data

def volLast30DayAvg = (volume(period = "DAY")[1] + volume(period = "DAY")[2] + volume(period = "DAY")[3] + volume(period = "DAY")[4] + volume(period = "DAY")[5] + volume(period = "DAY")[6] + volume(period = "DAY")[7] + volume(period = "DAY")[8] + volume(period = "DAY")[9] + volume(period = "DAY")[10] + volume(period = "DAY")[11] + volume(period = "DAY")[12] + volume(period = "DAY")[13] + volume(period = "DAY")[14] + volume(period = "DAY")[15] + volume(period = "DAY")[16] + volume(period = "DAY")[17] + volume(period = "DAY")[18] + volume(period = "DAY")[19] + volume(period = "DAY")[20] + volume(period = "DAY")[21] + volume(period = "DAY")[22] + volume(period = "DAY")[23] + volume(period = "DAY")[24] + volume(period = "DAY")[25] + volume(period = "DAY")[26] + volume(period = "DAY")[27] + volume(period = "DAY")[28] + volume(period = "DAY")[29] + volume(period = "DAY")[30]) / 30;
def today = volume(period = "DAY");
def percentOf30Day = Round((today / volLast30DayAvg) * 100, 0);
def avg30Bars = (volume[1] + volume[2] + volume[3] + volume[4] + volume[5] + volume[6] + volume[7] + volume[8] + volume[9] + volume[10] + volume[11] + volume[12] + volume[13] + volume[14] + volume[15] + volume[16] + volume[17] + volume[18] + volume[19] + volume[20] + volume[21] + volume[22] + volume[23] + volume[24] + volume[25] + volume[26] + volume[27] + volume[28] + volume[29] + volume[30]) / 30;
def curVolume = volume;
def percentOf30Bar = Round((curVolume / avg30Bars) * 100, 0);
def SellVolPercent = Round((Selling / Volume) * 100, 0);

# Labels

AddLabel(ShowTodayVolume, "Today: " + today, (if percentOf30Day >= UnusualVolumePercent then Color.GREEN else if percentOf30Day >= 100 then Color.ORANGE else Color.LIGHT_GRAY));
AddLabel(ShowCurrentBar, "Cur Bar: " + curVolume, (if percentOf30Bar >= UnusualVolumePercent then Color.GREEN else if PercentOf30Bar >= 100 then Color.ORANGE else Color.LIGHT_GRAY));


#####


input length = 14;
input averageType = AverageType.WILDERS;

DEF ATR1 = MovingAverage(averageType, TrueRange(high, close, low), length);

ADDLAbel (ATR1, "ATR:" + ATR1);



once again thank you @BenTen and @horserider,
 
Hi, I want to plot daily volume # on the chart and i want to add comma separator between thousands,
instead of showing 1666278, I want to 1,66,278 and I also want to increase the font, can some one help?
you could shift the decimal point and do some rounding, to display that number as 1.666 . and just remember the numbers represent millions. if you are looking at numbers in the millions, it doesn't really matter what the digit is in the hundreds place.
round( volume/1000000,3)
if the number is displayed with a bubble, could add text to remind you of the units
... + "M"
 
Hi, I want to plot daily volume # on the chart and i want to add comma separator between thousands,
instead of showing 1666278, I want to 1,66,278 and I also want to increase the font, can some one help?

Post #3 above had what you are requesting in the code. Here are 2 ways to add bar volume, addlabel or addchartbubble that may be what you want. The addlabel is fixed to the upper left corner of the chart. The addchartbubble can be moved left/right by decreasing/increasing the bubblemover value. The volume is displayed comma separated.

Capture.jpg
Ruby:
input show_label = yes;
AddLabel(1, "Bar: " + volume, if close > open then Color.LIGHT_GREEN else Color.LIGHT_RED);

input show_bubble = yes;
input bubblemover = 5;
def n  = bubblemover;
def n1 = n + 1;
AddChartBubble(IsNaN(close[n]) and !IsNaN(close[n1]), close[n1], "Bar: " + volume[n1], if close[n1] > open[n1] then Color.LIGHT_GREEN else Color.LIGHT_RED);
 
Post #3 above had what you are requesting in the code. Here are 2 ways to add bar volume, addlabel or addchartbubble that may be what you want. The addlabel is fixed to the upper left corner of the chart. The addchartbubble can be moved left/right by decreasing/increasing the bubblemover value. The volume is displayed comma separated.
Thanks, this is exactly what I wanted. I really appreciate your help on this.
 

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