Current bar volume rounded to thousands and millions

zeek

Active member
2019 Donor
Have searched the forum but couldn´t find what i was looking for so here´s my request, a chart label that displays the current bar volume and i want this to be rounded to thousands and millions. So for example, if the current bar volume is 225,670 shares, label will say 226k and if volume is 3,567,950 shares, label will say 3,57M
If it´s not possible to round into thousands, using millions for everything works too.

Would also like to color code this label depending on if it´s the highest volume bar for the day. So if this is true, color the label red, otherwise color it grey (should include extended hours if possible).

Thanks in advance.
 
Solution
Have searched the forum but couldn´t find what i was looking for so here´s my request, a chart label that displays the current bar volume and i want this to be rounded to thousands and millions. So for example, if the current bar volume is 225,670 shares, label will say 226k and if volume is 3,567,950 shares, label will say 3,57M
If it´s not possible to round into thousands, using millions for everything works too.

Would also like to color code this label depending on if it´s the highest volume bar for the day. So if this is true, color the label red, otherwise color it grey (should include extended hours if possible).

Thanks in advance.

Try this
[Edited]
Code:
def v = volume;
AddLabel(1,
if Between(v, 1000, 999999) then...

SleepyZ

Well-known member
VIP
Lifetime
Have searched the forum but couldn´t find what i was looking for so here´s my request, a chart label that displays the current bar volume and i want this to be rounded to thousands and millions. So for example, if the current bar volume is 225,670 shares, label will say 226k and if volume is 3,567,950 shares, label will say 3,57M
If it´s not possible to round into thousands, using millions for everything works too.

Would also like to color code this label depending on if it´s the highest volume bar for the day. So if this is true, color the label red, otherwise color it grey (should include extended hours if possible).

Thanks in advance.

Try this
[Edited]
Code:
def v = volume;
AddLabel(1,
if Between(v, 1000, 999999) then Round(v / 1000, 2) + "k" else
if Between(v, 1000000, 10000000000) then Round(v / 1000000, 2) + "M"
else v + "", 
Color.YELLOW);
 
Last edited:
Solution

zeek

Active member
2019 Donor
Try this
[Edited]
Code:
def v = volume;
AddLabel(1,
if Between(v, 1000, 999999) then Round(v / 1000, 2) + "k" else
if Between(v, 1000000, 10000000000) then Round(v / 1000000, 2) + "M"
else v + "",
Color.YELLOW);
Hey @SleepyZ , the label works like a charm!(y)

I was wondering if you could help me add two additional pieces of information,

Firstly, is it possible to look at the current candle volume and compare it with the previous candle volume at the same exact time and color code the label above depending on if the relative volume is higher or lower at current time? So if rvol is higher on current candle, can paint the label green and if lower, can paint it red.

Secondly, i was looking at another fine study you did earlier and was wondering if there´s a possibility to use this "bull & bear pressure volume" calculation from the CVD study and apply that to analyse the current candle vol pressure somehow and then display that as a label? Basically, i want to know the pressure on each current candle.
 

SleepyZ

Well-known member
VIP
Lifetime
Hey @SleepyZ , the label works like a charm!(y)

I was wondering if you could help me add two additional pieces of information,

Firstly, is it possible to look at the current candle volume and compare it with the previous candle volume at the same exact time and color code the label above depending on if the relative volume is higher or lower at current time? So if rvol is higher on current candle, can paint the label green and if lower, can paint it red.

Secondly, i was looking at another fine study you did earlier and was wondering if there´s a possibility to use this "bull & bear pressure volume" calculation from the CVD study and apply that to analyse the current candle vol pressure somehow and then display that as a label? Basically, i want to know the pressure on each current candle.

Here is the first comparison. The second is not provided as I do not use it and it displays sporadically on charts lower than daily.
Edited: See next post for update
addlabel(1,"Bar Volume - Current: " + volume + " Prior: " + volume[1], if volume > volume[1] then color.green else color.red);
 
Last edited:

zeek

Active member
2019 Donor
Here is the first comparison. The second is not provided as I do not use it and it displays sporadically on charts lower than daily.

Appreciate the help as always! Exactly what i was looking for in regards to the first addition. I just tried it with timezone ET and for some reason, the "today" part gets stuck after a new candle opens and the volume will not update unless i open the studies window and then close it again, not sure why..

The prior seems to show a larger vol amount than what´s actually traded. Have a look at this screen i just took, the yellow label to the left is the original study you posted in #2 and i took the screenshot just as the candle was about to close so roughly 266k shares on that candle but if you look at the prior on right side it says 512k shares.


If you could have a look at this, would be great
 

SleepyZ

Well-known member
VIP
Lifetime
Appreciate the help as always! Exactly what i was looking for in regards to the first addition. I just tried it with timezone ET and for some reason, the "today" part gets stuck after a new candle opens and the volume will not update unless i open the studies window and then close it again, not sure why..

The prior seems to show a larger vol amount than what´s actually traded. Have a look at this screen i just took, the yellow label to the left is the original study you posted in #2 and i took the screenshot just as the candle was about to close so roughly 266k shares on that candle but if you look at the prior on right side it says 512k shares.


If you could have a look at this, would be great
I think I misinterpreted what you wanted. Here is the volume of the current bar compared to the prior bar. Apparently I put too much lipstick on the code in the prior post (removed) and it slowed down the script.

Ruby:
addlabel(1,"Bar Volume - Current: " + volume + " Prior: " + volume[1], if volume > volume[1] then color.green else color.red);
 

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.
Top