How to show Histogram bars side by side and not stacked?

greco26

Active member
Hi All,

Anyone know how to show histogram bars side by side when comparing 2 sets of data and not stacked? The below code is from a UTS study comparing today's intraday volume vs volume of the same time 24hour ago. Thanks as always!

Code:
# prev_day_vol_0

# [URL]https://usethinkscript.com/threads/getting-yesterdays-cumulative-volume-at-todays-time.10673/[/URL]
# Getting Yesterdays cumulative volume at today's time

# for charts with a period less than a day.
# get the chart agg time and convert to minutes. then calculate how many bars are in the trading day, on the chart.
def chartagg = GetAggregationPeriod();
def chartmin = chartagg / (1000 * 60);
# 6.5 hours in a normal trading day, 390 minutes.
def daybars = 390/chartmin;


#addlabel(1, "bar min " + chartmin, color.yellow);
#addlabel(1, "bars / day " + daybars, color.yellow);

# 78 for 5min bars
 #def daybars = 78;

def isstart = If secondsfromtime(930) == 0 then 1 else 0;
def dayvol = If isstart then volume else if secondsfromtime(930) > 0 and secondstilltime(1600) > 0 then dayvol[1] + volume else dayvol[1];
#def prevdayvol = dayvol[daybars];
def prevdayvol = getvalue(dayvol, daybars);
plot yesterday = prevdayvol;
plot today = dayvol;
yesterday.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
today.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);

addlabel(1, "YDA " + prevdayvol, color.yellow);
addlabel(1, "TD " + dayvol, color.yellow);
addlabel(1, "Rvol " + round(dayvol/prevdayvol,2), color.yellow);

input test1_vol_bubbles = yes;
addchartbubble(test1_vol_bubbles, volume,
prevdayvol + " prev\n" +
dayvol + " curr"
, (if isstart then color.yellow else color.gray), yes);
addlabel(1, "           " , color.black);
 
Solution
Hi All,

Anyone know how to show histogram bars side by side when comparing 2 sets of data and not stacked? The below code is from a UTS study comparing today's intraday volume vs volume of the same time 24hour ago. Thanks as always!

Code:
# prev_day_vol_0

# [URL]https://usethinkscript.com/threads/getting-yesterdays-cumulative-volume-at-todays-time.10673/[/URL]
# Getting Yesterdays cumulative volume at today's time

# for charts with a period less than a day.
# get the chart agg time and convert to minutes. then calculate how many bars are in the trading day, on the chart.
def chartagg = GetAggregationPeriod();
def chartmin = chartagg / (1000 * 60);
# 6.5 hours in a normal trading day, 390 minutes.
def daybars = 390/chartmin...
Hi All,

Anyone know how to show histogram bars side by side when comparing 2 sets of data and not stacked? The below code is from a UTS study comparing today's intraday volume vs volume of the same time 24hour ago. Thanks as always!

Code:
# prev_day_vol_0

# [URL]https://usethinkscript.com/threads/getting-yesterdays-cumulative-volume-at-todays-time.10673/[/URL]
# Getting Yesterdays cumulative volume at today's time

# for charts with a period less than a day.
# get the chart agg time and convert to minutes. then calculate how many bars are in the trading day, on the chart.
def chartagg = GetAggregationPeriod();
def chartmin = chartagg / (1000 * 60);
# 6.5 hours in a normal trading day, 390 minutes.
def daybars = 390/chartmin;


#addlabel(1, "bar min " + chartmin, color.yellow);
#addlabel(1, "bars / day " + daybars, color.yellow);

# 78 for 5min bars
 #def daybars = 78;

def isstart = If secondsfromtime(930) == 0 then 1 else 0;
def dayvol = If isstart then volume else if secondsfromtime(930) > 0 and secondstilltime(1600) > 0 then dayvol[1] + volume else dayvol[1];
#def prevdayvol = dayvol[daybars];
def prevdayvol = getvalue(dayvol, daybars);
plot yesterday = prevdayvol;
plot today = dayvol;
yesterday.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
today.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);

addlabel(1, "YDA " + prevdayvol, color.yellow);
addlabel(1, "TD " + dayvol, color.yellow);
addlabel(1, "Rvol " + round(dayvol/prevdayvol,2), color.yellow);

input test1_vol_bubbles = yes;
addchartbubble(test1_vol_bubbles, volume,
prevdayvol + " prev\n" +
dayvol + " curr"
, (if isstart then color.yellow else color.gray), yes);
addlabel(1, "           " , color.black);

Since TOS plots a histogram bar occupies one chart bar, then I do not think side by side histogram bars can be meshed together into one bar's space.
 
Solution

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