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!
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);