Intraday Volume Tracking and Forecasting (VTF) for ThinkorSwim

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

I dont think theres a script that calculates above average volume per time.(red candles)

sIqbPVZ.png


Code:
declare upper;
#declare fullrange;
def na = double.nan;
#input opentime = 0930;
#def AP = getAggregationPeriod();
rec barcounter = if getDay() != getDay()[1] then 1 else barcounter[1] + 1;

rec daycount = if barNumber() == 1 then 0 else if getDay() > getDay()[1] then 1 else 0;

def istoday = if getLastDay() == getDay() then 1 else 0;

def bar1volume = if istoday then 0 else if barcounter == 1 then volume else 0;
def bar2volume = if istoday then 0 else if barcounter == 2 then volume else 0;
def bar3volume = if istoday then 0 else if barcounter == 3 then volume else 0;
def bar4volume = if istoday then 0 else if barcounter == 4 then volume else 0;
def bar5volume = if istoday then 0 else if barcounter == 5 then volume else 0;
def bar6volume = if istoday then 0 else if barcounter == 6 then volume else 0;
def bar7volume = if istoday then 0 else if barcounter == 7 then volume else 0;
def bar8volume = if istoday then 0 else if barcounter == 8 then volume else 0;
def bar9volume = if istoday then 0 else if barcounter == 9 then volume else 0;
def bar10volume = if istoday then 0 else if barcounter == 10 then volume else 0;
def bar11volume = if istoday then 0 else if barcounter == 11 then volume else 0;
def bar12volume = if istoday then 0 else if barcounter == 12 then volume else 0;
def bar13volume = if istoday then 0 else if barcounter == 13 then volume else 0;
def bar14volume = if istoday then 0 else if barcounter == 14 then volume else 0;
def bar15volume = if istoday then 0 else if barcounter == 15 then volume else 0;
def bar16volume = if istoday then 0 else if barcounter == 16 then volume else 0;
def bar17volume = if istoday then 0 else if barcounter == 17 then volume else 0;
def bar18volume = if istoday then 0 else if barcounter == 18 then volume else 0;
def bar19volume = if istoday then 0 else if barcounter == 19 then volume else 0;
def bar20volume = if istoday then 0 else if barcounter == 20 then volume else 0;
def bar21volume = if istoday then 0 else if barcounter == 21 then volume else 0;
def bar22volume = if istoday then 0 else if barcounter == 22 then volume else 0;
def bar23volume = if istoday then 0 else if barcounter == 23 then volume else 0;
def bar24volume = if istoday then 0 else if barcounter == 24 then volume else 0;
def bar25volume = if istoday then 0 else if barcounter == 25 then volume else 0;
def bar26volume = if istoday then 0 else if barcounter == 26 then volume else 0;
def bar27volume = if istoday then 0 else if barcounter == 27 then volume else 0;
def bar28volume = if istoday then 0 else if barcounter == 28 then volume else 0;
def bar29volume = if istoday then 0 else if barcounter == 29 then volume else 0;
def bar30volume = if istoday then 0 else if barcounter == 30 then volume else 0;
def bar31volume = if istoday then 0 else if barcounter == 31 then volume else 0;
def bar32volume = if istoday then 0 else if barcounter == 32 then volume else 0;
def bar33volume = if istoday then 0 else if barcounter == 33 then volume else 0;
def bar34volume = if istoday then 0 else if barcounter == 34 then volume else 0;
def bar35volume = if istoday then 0 else if barcounter == 35 then volume else 0;
def bar36volume = if istoday then 0 else if barcounter == 36 then volume else 0;
def bar37volume = if istoday then 0 else if barcounter == 37 then volume else 0;
def bar38volume = if istoday then 0 else if barcounter == 38 then volume else 0;
def bar39volume = if istoday then 0 else if barcounter == 39 then volume else 0;
def bar40volume = if istoday then 0 else if barcounter == 40 then volume else 0;
def bar41volume = if istoday then 0 else if barcounter == 41 then volume else 0;
def bar42volume = if istoday then 0 else if barcounter == 42 then volume else 0;
def bar43volume = if istoday then 0 else if barcounter == 43 then volume else 0;
def bar44volume = if istoday then 0 else if barcounter == 44 then volume else 0;
def bar45volume = if istoday then 0 else if barcounter == 45 then volume else 0;
def bar46volume = if istoday then 0 else if barcounter == 46 then volume else 0;
def bar47volume = if istoday then 0 else if barcounter == 47 then volume else 0;
def bar48volume = if istoday then 0 else if barcounter == 48 then volume else 0;
def bar49volume = if istoday then 0 else if barcounter == 49 then volume else 0;
def bar50volume = if istoday then 0 else if barcounter == 50 then volume else 0;
def bar51volume = if istoday then 0 else if barcounter == 51 then volume else 0;
def bar52volume = if istoday then 0 else if barcounter == 52 then volume else 0;
def bar53volume = if istoday then 0 else if barcounter == 53 then volume else 0;
def bar54volume = if istoday then 0 else if barcounter == 54 then volume else 0;
def bar55volume = if istoday then 0 else if barcounter == 55 then volume else 0;
def bar56volume = if istoday then 0 else if barcounter == 56 then volume else 0;
def bar57volume = if istoday then 0 else if barcounter == 57 then volume else 0;
def bar58volume = if istoday then 0 else if barcounter == 58 then volume else 0;
def bar59volume = if istoday then 0 else if barcounter == 59 then volume else 0;
def bar60volume = if istoday then 0 else if barcounter == 60 then volume else 0;
def bar61volume = if istoday then 0 else if barcounter == 61 then volume else 0;
def bar62volume = if istoday then 0 else if barcounter == 62 then volume else 0;
def bar63volume = if istoday then 0 else if barcounter == 63 then volume else 0;
def bar64volume = if istoday then 0 else if barcounter == 64 then volume else 0;
def bar65volume = if istoday then 0 else if barcounter == 65 then volume else 0;
def bar66volume = if istoday then 0 else if barcounter == 66 then volume else 0;
def bar67volume = if istoday then 0 else if barcounter == 67 then volume else 0;
def bar68volume = if istoday then 0 else if barcounter == 68 then volume else 0;
def bar69volume = if istoday then 0 else if barcounter == 69 then volume else 0;
def bar70volume = if istoday then 0 else if barcounter == 70 then volume else 0;
def bar71volume = if istoday then 0 else if barcounter == 71 then volume else 0;
def bar72volume = if istoday then 0 else if barcounter == 72 then volume else 0;
def bar73volume = if istoday then 0 else if barcounter == 73 then volume else 0;
def bar74volume = if istoday then 0 else if barcounter == 74 then volume else 0;
def bar75volume = if istoday then 0 else if barcounter == 75 then volume else 0;
def bar76volume = if istoday then 0 else if barcounter == 76 then volume else 0;
def bar77volume = if istoday then 0 else if barcounter == 77 then volume else 0;
def bar78volume = if istoday then 0 else if barcounter == 78 then volume else 0;
def bar79volume = if istoday then 0 else if barcounter == 79 then volume else 0;
def bar80volume = if istoday then 0 else if barcounter == 80 then volume else 0;
def bar81volume = if istoday then 0 else if barcounter == 81 then volume else 0;

def avgbar1 = TotalSum(bar1volume) / TotalSum(daycount);
def avgbar2 = TotalSum(bar2volume) / TotalSum(daycount);
def avgbar3 = TotalSum(bar3volume) / TotalSum(daycount);
def avgbar4 = TotalSum(bar4volume) / TotalSum(daycount);
def avgbar5 = TotalSum(bar5volume) / TotalSum(daycount);
def avgbar6 = TotalSum(bar6volume) / TotalSum(daycount);
def avgbar7 = TotalSum(bar7volume) / TotalSum(daycount);
def avgbar8 = TotalSum(bar8volume) / TotalSum(daycount);
def avgbar9 = TotalSum(bar9volume) / TotalSum(daycount);
def avgbar10 = TotalSum(bar10volume) / TotalSum(daycount);
def avgbar11 = TotalSum(bar11volume) / TotalSum(daycount);
def avgbar12 = TotalSum(bar12volume) / TotalSum(daycount);
def avgbar13 = TotalSum(bar13volume) / TotalSum(daycount);
def avgbar14 = TotalSum(bar14volume) / TotalSum(daycount);
def avgbar15 = TotalSum(bar15volume) / TotalSum(daycount);
def avgbar16 = TotalSum(bar16volume) / TotalSum(daycount);
def avgbar17 = TotalSum(bar17volume) / TotalSum(daycount);
def avgbar18 = TotalSum(bar18volume) / TotalSum(daycount);
def avgbar19 = TotalSum(bar19volume) / TotalSum(daycount);
def avgbar20 = TotalSum(bar20volume) / TotalSum(daycount);
def avgbar21 = TotalSum(bar21volume) / TotalSum(daycount);
def avgbar22 = TotalSum(bar22volume) / TotalSum(daycount);
def avgbar23 = TotalSum(bar23volume) / TotalSum(daycount);
def avgbar24 = TotalSum(bar24volume) / TotalSum(daycount);
def avgbar25 = TotalSum(bar25volume) / TotalSum(daycount);
def avgbar26 = TotalSum(bar26volume) / TotalSum(daycount);
def avgbar27 = TotalSum(bar27volume) / TotalSum(daycount);
def avgbar28 = TotalSum(bar28volume) / TotalSum(daycount);
def avgbar29 = TotalSum(bar29volume) / TotalSum(daycount);
def avgbar30 = TotalSum(bar30volume) / TotalSum(daycount);
def avgbar31 = TotalSum(bar31volume) / TotalSum(daycount);
def avgbar32 = TotalSum(bar32volume) / TotalSum(daycount);
def avgbar33 = TotalSum(bar33volume) / TotalSum(daycount);
def avgbar34 = TotalSum(bar34volume) / TotalSum(daycount);
def avgbar35 = TotalSum(bar35volume) / TotalSum(daycount);
def avgbar36 = TotalSum(bar36volume) / TotalSum(daycount);
def avgbar37 = TotalSum(bar37volume) / TotalSum(daycount);
def avgbar38 = TotalSum(bar38volume) / TotalSum(daycount);
def avgbar39 = TotalSum(bar39volume) / TotalSum(daycount);
def avgbar40 = TotalSum(bar40volume) / TotalSum(daycount);
def avgbar41 = TotalSum(bar41volume) / TotalSum(daycount);
def avgbar42 = TotalSum(bar42volume) / TotalSum(daycount);
def avgbar43 = TotalSum(bar43volume) / TotalSum(daycount);
def avgbar44 = TotalSum(bar44volume) / TotalSum(daycount);
def avgbar45 = TotalSum(bar45volume) / TotalSum(daycount);
def avgbar46 = TotalSum(bar46volume) / TotalSum(daycount);
def avgbar47 = TotalSum(bar47volume) / TotalSum(daycount);
def avgbar48 = TotalSum(bar48volume) / TotalSum(daycount);
def avgbar49 = TotalSum(bar49volume) / TotalSum(daycount);
def avgbar50 = TotalSum(bar50volume) / TotalSum(daycount);
def avgbar51 = TotalSum(bar51volume) / TotalSum(daycount);
def avgbar52 = TotalSum(bar52volume) / TotalSum(daycount);
def avgbar53 = TotalSum(bar53volume) / TotalSum(daycount);
def avgbar54 = TotalSum(bar54volume) / TotalSum(daycount);
def avgbar55 = TotalSum(bar55volume) / TotalSum(daycount);
def avgbar56 = TotalSum(bar56volume) / TotalSum(daycount);
def avgbar57 = TotalSum(bar57volume) / TotalSum(daycount);
def avgbar58 = TotalSum(bar58volume) / TotalSum(daycount);
def avgbar59 = TotalSum(bar59volume) / TotalSum(daycount);
def avgbar60 = TotalSum(bar60volume) / TotalSum(daycount);
def avgbar61 = TotalSum(bar61volume) / TotalSum(daycount);
def avgbar62 = TotalSum(bar62volume) / TotalSum(daycount);
def avgbar63 = TotalSum(bar63volume) / TotalSum(daycount);
def avgbar64 = TotalSum(bar64volume) / TotalSum(daycount);
def avgbar65 = TotalSum(bar65volume) / TotalSum(daycount);
def avgbar66 = TotalSum(bar66volume) / TotalSum(daycount);
def avgbar67 = TotalSum(bar67volume) / TotalSum(daycount);
def avgbar68 = TotalSum(bar68volume) / TotalSum(daycount);
def avgbar69 = TotalSum(bar69volume) / TotalSum(daycount);
def avgbar70 = TotalSum(bar70volume) / TotalSum(daycount);
def avgbar71 = TotalSum(bar71volume) / TotalSum(daycount);
def avgbar72 = TotalSum(bar72volume) / TotalSum(daycount);
def avgbar73 = TotalSum(bar73volume) / TotalSum(daycount);
def avgbar74 = TotalSum(bar74volume) / TotalSum(daycount);
def avgbar75 = TotalSum(bar75volume) / TotalSum(daycount);
def avgbar76 = TotalSum(bar76volume) / TotalSum(daycount);
def avgbar77 = TotalSum(bar77volume) / TotalSum(daycount);
def avgbar78 = TotalSum(bar78volume) / TotalSum(daycount);
def avgbar79 = TotalSum(bar79volume) / TotalSum(daycount);
def avgbar80 = TotalSum(bar80volume) / TotalSum(daycount);
def avgbar81 = TotalSum(bar81volume) / TotalSum(daycount);





plot AvgVol = if getDay() != getLastDay() then na
else if barcounter == 1 then avgbar1
else if barcounter == 2 then avgbar2
else if barcounter == 3 then avgbar3
else if barcounter == 4 then avgbar4
else if barcounter == 5 then avgbar5
else if barcounter == 6 then avgbar6
else if barcounter == 7 then avgbar7
else if barcounter == 8 then avgbar8
else if barcounter == 9 then avgbar9
else if barcounter == 10 then avgbar10
else if barcounter == 11 then avgbar11
else if barcounter == 12 then avgbar12
else if barcounter == 13 then avgbar13
else if barcounter == 14 then avgbar14
else if barcounter == 15 then avgbar15
else if barcounter == 16 then avgbar16
else if barcounter == 17 then avgbar17
else if barcounter == 18 then avgbar18
else if barcounter == 19 then avgbar19
else if barcounter == 20 then avgbar20
else if barcounter == 21 then avgbar21
else if barcounter == 22 then avgbar22
else if barcounter == 23 then avgbar23
else if barcounter == 24 then avgbar24
else if barcounter == 25 then avgbar25
else if barcounter == 26 then avgbar26
else if barcounter == 27 then avgbar27
else if barcounter == 28 then avgbar28
else if barcounter == 29 then avgbar29
else if barcounter == 30 then avgbar30
else if barcounter == 31 then avgbar31
else if barcounter == 32 then avgbar32
else if barcounter == 33 then avgbar33
else if barcounter == 34 then avgbar34
else if barcounter == 35 then avgbar35
else if barcounter == 36 then avgbar36
else if barcounter == 37 then avgbar37
else if barcounter == 38 then avgbar38
else if barcounter == 39 then avgbar39
else if barcounter == 40 then avgbar40
else if barcounter == 41 then avgbar41
else if barcounter == 42 then avgbar42
else if barcounter == 43 then avgbar43
else if barcounter == 44 then avgbar44
else if barcounter == 45 then avgbar45
else if barcounter == 46 then avgbar46
else if barcounter == 47 then avgbar47
else if barcounter == 48 then avgbar48
else if barcounter == 49 then avgbar49
else if barcounter == 50 then avgbar50
else if barcounter == 51 then avgbar51
else if barcounter == 52 then avgbar52
else if barcounter == 53 then avgbar53
else if barcounter == 54 then avgbar54
else if barcounter == 55 then avgbar55
else if barcounter == 56 then avgbar56
else if barcounter == 57 then avgbar57
else if barcounter == 58 then avgbar58
else if barcounter == 59 then avgbar59
else if barcounter == 60 then avgbar60
else if barcounter == 61 then avgbar61
else if barcounter == 62 then avgbar62
else if barcounter == 63 then avgbar63
else if barcounter == 64 then avgbar64
else if barcounter == 65 then avgbar65
else if barcounter == 66 then avgbar66
else if barcounter == 67 then avgbar67
else if barcounter == 68 then avgbar68
else if barcounter == 69 then avgbar69
else if barcounter == 70 then avgbar70
else if barcounter == 71 then avgbar71
else if barcounter == 72 then avgbar72
else if barcounter == 73 then avgbar73
else if barcounter == 74 then avgbar74
else if barcounter == 75 then avgbar75
else if barcounter == 76 then avgbar76
else if barcounter == 77 then avgbar77
else if barcounter == 78 then avgbar78
else if barcounter == 79 then avgbar79
else if barcounter == 80 then avgbar80
else if barcounter == 81 then avgbar81
else na;

avgvol.SetDefaultColor(color.dark_gray);
#avgvol.setstyle(curve.points);
avgvol.SetLineWeight(1);
plot zero = 0;
AddCloud(avgvol, zero, color.gray);

plot vol = volume;
vol.SetLineWeight(3);
vol.SetPaintingStrategy(paintingStrategy.HISTOGRAM);
vol.AssignValueColor(if !istoday then color.gray else if volume > avgvol then color.red else color.gray);
 
So. It's just a matter of the bar count. I think. Let me explain a bit and tell you some of the problem.

A day of /es at 1 hour has 23 bars.
at 10 minutes, it's 138 bars
at 5 minutes, that's 276 bars
when you get to 1 minute, you're looking at 1380 bars of data. That's a lot.

I wrote some python to help me write it up to cover the 5 minutes time frame:
Python:
length = 277
for i in range(1, length):
    print(f'def bar{i}volume = if istoday then 0 else if barcounter == {i} then volume else 0;')

for i in range(1, length):
    print(f'def avgbar{i} = TotalSum(bar{i}volume) / TotalSum(daycount);')

for i in range(1, length):
    print(f'else if barcounter == {i} then avgbar{i}')

for i in range(1, length):
    print(f'else if barcounter == {i}  then  VolumeProjection[1] + ( avgbar{i} * FirstHourRatio)')
This was then pasted into the correct places in the thinkscript study: It's nearly 1200 lines long. It runs, but it's slow. Simply takes a lot of processor cycles to calculate, but it gave me a projection all the way through a day of /es.

Happy Traqding,
-Mashume
Code:
# 
# Intraday Volume Tracking and Forecasting
#
# VFT
# 
# Author: Seth Urion (Mashume)
# Version: 2020-06-27
# Version 2021-04-06 
# Adapted for longer time series (276 to cover /es on 5 minutes)
#
# This code is licensed (as applicable) under the GPL v3
# 
# ----------------------


declare lower;
def na = Double.NaN;

rec barcounter = if GetDay() != GetDay()[1] then 1 else barcounter[1] + 1;
AddLabel(visible = Yes, text = Concat("BarCounter: ", barcounter), color.black);

rec daycount = if BarNumber() == 1 then 0 else if GetDay() > GetDay()[1] then 1 else 0;

def istoday = if GetLastDay() == GetDay() then 1 else 0;

def bar1volume = if istoday then 0 else if barcounter == 1 then volume else 0;
def bar2volume = if istoday then 0 else if barcounter == 2 then volume else 0;
def bar3volume = if istoday then 0 else if barcounter == 3 then volume else 0;
def bar4volume = if istoday then 0 else if barcounter == 4 then volume else 0;
def bar5volume = if istoday then 0 else if barcounter == 5 then volume else 0;
def bar6volume = if istoday then 0 else if barcounter == 6 then volume else 0;
def bar7volume = if istoday then 0 else if barcounter == 7 then volume else 0;
def bar8volume = if istoday then 0 else if barcounter == 8 then volume else 0;
def bar9volume = if istoday then 0 else if barcounter == 9 then volume else 0;
def bar10volume = if istoday then 0 else if barcounter == 10 then volume else 0;
def bar11volume = if istoday then 0 else if barcounter == 11 then volume else 0;
def bar12volume = if istoday then 0 else if barcounter == 12 then volume else 0;
def bar13volume = if istoday then 0 else if barcounter == 13 then volume else 0;
def bar14volume = if istoday then 0 else if barcounter == 14 then volume else 0;
def bar15volume = if istoday then 0 else if barcounter == 15 then volume else 0;
def bar16volume = if istoday then 0 else if barcounter == 16 then volume else 0;
def bar17volume = if istoday then 0 else if barcounter == 17 then volume else 0;
def bar18volume = if istoday then 0 else if barcounter == 18 then volume else 0;
def bar19volume = if istoday then 0 else if barcounter == 19 then volume else 0;
def bar20volume = if istoday then 0 else if barcounter == 20 then volume else 0;
def bar21volume = if istoday then 0 else if barcounter == 21 then volume else 0;
def bar22volume = if istoday then 0 else if barcounter == 22 then volume else 0;
def bar23volume = if istoday then 0 else if barcounter == 23 then volume else 0;
def bar24volume = if istoday then 0 else if barcounter == 24 then volume else 0;
def bar25volume = if istoday then 0 else if barcounter == 25 then volume else 0;
def bar26volume = if istoday then 0 else if barcounter == 26 then volume else 0;
def bar27volume = if istoday then 0 else if barcounter == 27 then volume else 0;
def bar28volume = if istoday then 0 else if barcounter == 28 then volume else 0;
def bar29volume = if istoday then 0 else if barcounter == 29 then volume else 0;
def bar30volume = if istoday then 0 else if barcounter == 30 then volume else 0;
def bar31volume = if istoday then 0 else if barcounter == 31 then volume else 0;
def bar32volume = if istoday then 0 else if barcounter == 32 then volume else 0;
def bar33volume = if istoday then 0 else if barcounter == 33 then volume else 0;
def bar34volume = if istoday then 0 else if barcounter == 34 then volume else 0;
def bar35volume = if istoday then 0 else if barcounter == 35 then volume else 0;
def bar36volume = if istoday then 0 else if barcounter == 36 then volume else 0;
def bar37volume = if istoday then 0 else if barcounter == 37 then volume else 0;
def bar38volume = if istoday then 0 else if barcounter == 38 then volume else 0;
def bar39volume = if istoday then 0 else if barcounter == 39 then volume else 0;
def bar40volume = if istoday then 0 else if barcounter == 40 then volume else 0;
def bar41volume = if istoday then 0 else if barcounter == 41 then volume else 0;
def bar42volume = if istoday then 0 else if barcounter == 42 then volume else 0;
def bar43volume = if istoday then 0 else if barcounter == 43 then volume else 0;
def bar44volume = if istoday then 0 else if barcounter == 44 then volume else 0;
def bar45volume = if istoday then 0 else if barcounter == 45 then volume else 0;
def bar46volume = if istoday then 0 else if barcounter == 46 then volume else 0;
def bar47volume = if istoday then 0 else if barcounter == 47 then volume else 0;
def bar48volume = if istoday then 0 else if barcounter == 48 then volume else 0;
def bar49volume = if istoday then 0 else if barcounter == 49 then volume else 0;
def bar50volume = if istoday then 0 else if barcounter == 50 then volume else 0;
def bar51volume = if istoday then 0 else if barcounter == 51 then volume else 0;
def bar52volume = if istoday then 0 else if barcounter == 52 then volume else 0;
def bar53volume = if istoday then 0 else if barcounter == 53 then volume else 0;
def bar54volume = if istoday then 0 else if barcounter == 54 then volume else 0;
def bar55volume = if istoday then 0 else if barcounter == 55 then volume else 0;
def bar56volume = if istoday then 0 else if barcounter == 56 then volume else 0;
def bar57volume = if istoday then 0 else if barcounter == 57 then volume else 0;
def bar58volume = if istoday then 0 else if barcounter == 58 then volume else 0;
def bar59volume = if istoday then 0 else if barcounter == 59 then volume else 0;
def bar60volume = if istoday then 0 else if barcounter == 60 then volume else 0;
def bar61volume = if istoday then 0 else if barcounter == 61 then volume else 0;
def bar62volume = if istoday then 0 else if barcounter == 62 then volume else 0;
def bar63volume = if istoday then 0 else if barcounter == 63 then volume else 0;
def bar64volume = if istoday then 0 else if barcounter == 64 then volume else 0;
def bar65volume = if istoday then 0 else if barcounter == 65 then volume else 0;
def bar66volume = if istoday then 0 else if barcounter == 66 then volume else 0;
def bar67volume = if istoday then 0 else if barcounter == 67 then volume else 0;
def bar68volume = if istoday then 0 else if barcounter == 68 then volume else 0;
def bar69volume = if istoday then 0 else if barcounter == 69 then volume else 0;
def bar70volume = if istoday then 0 else if barcounter == 70 then volume else 0;
def bar71volume = if istoday then 0 else if barcounter == 71 then volume else 0;
def bar72volume = if istoday then 0 else if barcounter == 72 then volume else 0;
def bar73volume = if istoday then 0 else if barcounter == 73 then volume else 0;
def bar74volume = if istoday then 0 else if barcounter == 74 then volume else 0;
def bar75volume = if istoday then 0 else if barcounter == 75 then volume else 0;
def bar76volume = if istoday then 0 else if barcounter == 76 then volume else 0;
def bar77volume = if istoday then 0 else if barcounter == 77 then volume else 0;
def bar78volume = if istoday then 0 else if barcounter == 78 then volume else 0;
def bar79volume = if istoday then 0 else if barcounter == 79 then volume else 0;
def bar80volume = if istoday then 0 else if barcounter == 80 then volume else 0;
def bar81volume = if istoday then 0 else if barcounter == 81 then volume else 0;
def bar82volume = if istoday then 0 else if barcounter == 82 then volume else 0;
def bar83volume = if istoday then 0 else if barcounter == 83 then volume else 0;
def bar84volume = if istoday then 0 else if barcounter == 84 then volume else 0;
def bar85volume = if istoday then 0 else if barcounter == 85 then volume else 0;
def bar86volume = if istoday then 0 else if barcounter == 86 then volume else 0;
def bar87volume = if istoday then 0 else if barcounter == 87 then volume else 0;
def bar88volume = if istoday then 0 else if barcounter == 88 then volume else 0;
def bar89volume = if istoday then 0 else if barcounter == 89 then volume else 0;
def bar90volume = if istoday then 0 else if barcounter == 90 then volume else 0;
def bar91volume = if istoday then 0 else if barcounter == 91 then volume else 0;
def bar92volume = if istoday then 0 else if barcounter == 92 then volume else 0;
def bar93volume = if istoday then 0 else if barcounter == 93 then volume else 0;
def bar94volume = if istoday then 0 else if barcounter == 94 then volume else 0;
def bar95volume = if istoday then 0 else if barcounter == 95 then volume else 0;
def bar96volume = if istoday then 0 else if barcounter == 96 then volume else 0;
def bar97volume = if istoday then 0 else if barcounter == 97 then volume else 0;
def bar98volume = if istoday then 0 else if barcounter == 98 then volume else 0;
def bar99volume = if istoday then 0 else if barcounter == 99 then volume else 0;
def bar100volume = if istoday then 0 else if barcounter == 100 then volume else 0;
def bar101volume = if istoday then 0 else if barcounter == 101 then volume else 0;
def bar102volume = if istoday then 0 else if barcounter == 102 then volume else 0;
def bar103volume = if istoday then 0 else if barcounter == 103 then volume else 0;
def bar104volume = if istoday then 0 else if barcounter == 104 then volume else 0;
def bar105volume = if istoday then 0 else if barcounter == 105 then volume else 0;
def bar106volume = if istoday then 0 else if barcounter == 106 then volume else 0;
def bar107volume = if istoday then 0 else if barcounter == 107 then volume else 0;
def bar108volume = if istoday then 0 else if barcounter == 108 then volume else 0;
def bar109volume = if istoday then 0 else if barcounter == 109 then volume else 0;
def bar110volume = if istoday then 0 else if barcounter == 110 then volume else 0;
def bar111volume = if istoday then 0 else if barcounter == 111 then volume else 0;
def bar112volume = if istoday then 0 else if barcounter == 112 then volume else 0;
def bar113volume = if istoday then 0 else if barcounter == 113 then volume else 0;
def bar114volume = if istoday then 0 else if barcounter == 114 then volume else 0;
def bar115volume = if istoday then 0 else if barcounter == 115 then volume else 0;
def bar116volume = if istoday then 0 else if barcounter == 116 then volume else 0;
def bar117volume = if istoday then 0 else if barcounter == 117 then volume else 0;
def bar118volume = if istoday then 0 else if barcounter == 118 then volume else 0;
def bar119volume = if istoday then 0 else if barcounter == 119 then volume else 0;
def bar120volume = if istoday then 0 else if barcounter == 120 then volume else 0;
def bar121volume = if istoday then 0 else if barcounter == 121 then volume else 0;
def bar122volume = if istoday then 0 else if barcounter == 122 then volume else 0;
def bar123volume = if istoday then 0 else if barcounter == 123 then volume else 0;
def bar124volume = if istoday then 0 else if barcounter == 124 then volume else 0;
def bar125volume = if istoday then 0 else if barcounter == 125 then volume else 0;
def bar126volume = if istoday then 0 else if barcounter == 126 then volume else 0;
def bar127volume = if istoday then 0 else if barcounter == 127 then volume else 0;
def bar128volume = if istoday then 0 else if barcounter == 128 then volume else 0;
def bar129volume = if istoday then 0 else if barcounter == 129 then volume else 0;
def bar130volume = if istoday then 0 else if barcounter == 130 then volume else 0;
def bar131volume = if istoday then 0 else if barcounter == 131 then volume else 0;
def bar132volume = if istoday then 0 else if barcounter == 132 then volume else 0;
def bar133volume = if istoday then 0 else if barcounter == 133 then volume else 0;
def bar134volume = if istoday then 0 else if barcounter == 134 then volume else 0;
def bar135volume = if istoday then 0 else if barcounter == 135 then volume else 0;
def bar136volume = if istoday then 0 else if barcounter == 136 then volume else 0;
def bar137volume = if istoday then 0 else if barcounter == 137 then volume else 0;
def bar138volume = if istoday then 0 else if barcounter == 138 then volume else 0;
def bar139volume = if istoday then 0 else if barcounter == 139 then volume else 0;
def bar140volume = if istoday then 0 else if barcounter == 140 then volume else 0;
def bar141volume = if istoday then 0 else if barcounter == 141 then volume else 0;
def bar142volume = if istoday then 0 else if barcounter == 142 then volume else 0;
def bar143volume = if istoday then 0 else if barcounter == 143 then volume else 0;
def bar144volume = if istoday then 0 else if barcounter == 144 then volume else 0;
def bar145volume = if istoday then 0 else if barcounter == 145 then volume else 0;
def bar146volume = if istoday then 0 else if barcounter == 146 then volume else 0;
def bar147volume = if istoday then 0 else if barcounter == 147 then volume else 0;
def bar148volume = if istoday then 0 else if barcounter == 148 then volume else 0;
def bar149volume = if istoday then 0 else if barcounter == 149 then volume else 0;
def bar150volume = if istoday then 0 else if barcounter == 150 then volume else 0;
def bar151volume = if istoday then 0 else if barcounter == 151 then volume else 0;
def bar152volume = if istoday then 0 else if barcounter == 152 then volume else 0;
def bar153volume = if istoday then 0 else if barcounter == 153 then volume else 0;
def bar154volume = if istoday then 0 else if barcounter == 154 then volume else 0;
def bar155volume = if istoday then 0 else if barcounter == 155 then volume else 0;
def bar156volume = if istoday then 0 else if barcounter == 156 then volume else 0;
def bar157volume = if istoday then 0 else if barcounter == 157 then volume else 0;
def bar158volume = if istoday then 0 else if barcounter == 158 then volume else 0;
def bar159volume = if istoday then 0 else if barcounter == 159 then volume else 0;
def bar160volume = if istoday then 0 else if barcounter == 160 then volume else 0;
def bar161volume = if istoday then 0 else if barcounter == 161 then volume else 0;
def bar162volume = if istoday then 0 else if barcounter == 162 then volume else 0;
def bar163volume = if istoday then 0 else if barcounter == 163 then volume else 0;
def bar164volume = if istoday then 0 else if barcounter == 164 then volume else 0;
def bar165volume = if istoday then 0 else if barcounter == 165 then volume else 0;
def bar166volume = if istoday then 0 else if barcounter == 166 then volume else 0;
def bar167volume = if istoday then 0 else if barcounter == 167 then volume else 0;
def bar168volume = if istoday then 0 else if barcounter == 168 then volume else 0;
def bar169volume = if istoday then 0 else if barcounter == 169 then volume else 0;
def bar170volume = if istoday then 0 else if barcounter == 170 then volume else 0;
def bar171volume = if istoday then 0 else if barcounter == 171 then volume else 0;
def bar172volume = if istoday then 0 else if barcounter == 172 then volume else 0;
def bar173volume = if istoday then 0 else if barcounter == 173 then volume else 0;
def bar174volume = if istoday then 0 else if barcounter == 174 then volume else 0;
def bar175volume = if istoday then 0 else if barcounter == 175 then volume else 0;
def bar176volume = if istoday then 0 else if barcounter == 176 then volume else 0;
def bar177volume = if istoday then 0 else if barcounter == 177 then volume else 0;
def bar178volume = if istoday then 0 else if barcounter == 178 then volume else 0;
def bar179volume = if istoday then 0 else if barcounter == 179 then volume else 0;
def bar180volume = if istoday then 0 else if barcounter == 180 then volume else 0;
def bar181volume = if istoday then 0 else if barcounter == 181 then volume else 0;
def bar182volume = if istoday then 0 else if barcounter == 182 then volume else 0;
def bar183volume = if istoday then 0 else if barcounter == 183 then volume else 0;
def bar184volume = if istoday then 0 else if barcounter == 184 then volume else 0;
def bar185volume = if istoday then 0 else if barcounter == 185 then volume else 0;
def bar186volume = if istoday then 0 else if barcounter == 186 then volume else 0;
def bar187volume = if istoday then 0 else if barcounter == 187 then volume else 0;
def bar188volume = if istoday then 0 else if barcounter == 188 then volume else 0;
def bar189volume = if istoday then 0 else if barcounter == 189 then volume else 0;
def bar190volume = if istoday then 0 else if barcounter == 190 then volume else 0;
def bar191volume = if istoday then 0 else if barcounter == 191 then volume else 0;
def bar192volume = if istoday then 0 else if barcounter == 192 then volume else 0;
def bar193volume = if istoday then 0 else if barcounter == 193 then volume else 0;
def bar194volume = if istoday then 0 else if barcounter == 194 then volume else 0;
def bar195volume = if istoday then 0 else if barcounter == 195 then volume else 0;
def bar196volume = if istoday then 0 else if barcounter == 196 then volume else 0;
def bar197volume = if istoday then 0 else if barcounter == 197 then volume else 0;
def bar198volume = if istoday then 0 else if barcounter == 198 then volume else 0;
def bar199volume = if istoday then 0 else if barcounter == 199 then volume else 0;
def bar200volume = if istoday then 0 else if barcounter == 200 then volume else 0;
def bar201volume = if istoday then 0 else if barcounter == 201 then volume else 0;
def bar202volume = if istoday then 0 else if barcounter == 202 then volume else 0;
def bar203volume = if istoday then 0 else if barcounter == 203 then volume else 0;
def bar204volume = if istoday then 0 else if barcounter == 204 then volume else 0;
def bar205volume = if istoday then 0 else if barcounter == 205 then volume else 0;
def bar206volume = if istoday then 0 else if barcounter == 206 then volume else 0;
def bar207volume = if istoday then 0 else if barcounter == 207 then volume else 0;
def bar208volume = if istoday then 0 else if barcounter == 208 then volume else 0;
def bar209volume = if istoday then 0 else if barcounter == 209 then volume else 0;
def bar210volume = if istoday then 0 else if barcounter == 210 then volume else 0;
def bar211volume = if istoday then 0 else if barcounter == 211 then volume else 0;
def bar212volume = if istoday then 0 else if barcounter == 212 then volume else 0;
def bar213volume = if istoday then 0 else if barcounter == 213 then volume else 0;
def bar214volume = if istoday then 0 else if barcounter == 214 then volume else 0;
def bar215volume = if istoday then 0 else if barcounter == 215 then volume else 0;
def bar216volume = if istoday then 0 else if barcounter == 216 then volume else 0;
def bar217volume = if istoday then 0 else if barcounter == 217 then volume else 0;
def bar218volume = if istoday then 0 else if barcounter == 218 then volume else 0;
def bar219volume = if istoday then 0 else if barcounter == 219 then volume else 0;
def bar220volume = if istoday then 0 else if barcounter == 220 then volume else 0;
def bar221volume = if istoday then 0 else if barcounter == 221 then volume else 0;
def bar222volume = if istoday then 0 else if barcounter == 222 then volume else 0;
def bar223volume = if istoday then 0 else if barcounter == 223 then volume else 0;
def bar224volume = if istoday then 0 else if barcounter == 224 then volume else 0;
def bar225volume = if istoday then 0 else if barcounter == 225 then volume else 0;
def bar226volume = if istoday then 0 else if barcounter == 226 then volume else 0;
def bar227volume = if istoday then 0 else if barcounter == 227 then volume else 0;
def bar228volume = if istoday then 0 else if barcounter == 228 then volume else 0;
def bar229volume = if istoday then 0 else if barcounter == 229 then volume else 0;
def bar230volume = if istoday then 0 else if barcounter == 230 then volume else 0;
def bar231volume = if istoday then 0 else if barcounter == 231 then volume else 0;
def bar232volume = if istoday then 0 else if barcounter == 232 then volume else 0;
def bar233volume = if istoday then 0 else if barcounter == 233 then volume else 0;
def bar234volume = if istoday then 0 else if barcounter == 234 then volume else 0;
def bar235volume = if istoday then 0 else if barcounter == 235 then volume else 0;
def bar236volume = if istoday then 0 else if barcounter == 236 then volume else 0;
def bar237volume = if istoday then 0 else if barcounter == 237 then volume else 0;
def bar238volume = if istoday then 0 else if barcounter == 238 then volume else 0;
def bar239volume = if istoday then 0 else if barcounter == 239 then volume else 0;
def bar240volume = if istoday then 0 else if barcounter == 240 then volume else 0;
def bar241volume = if istoday then 0 else if barcounter == 241 then volume else 0;
def bar242volume = if istoday then 0 else if barcounter == 242 then volume else 0;
def bar243volume = if istoday then 0 else if barcounter == 243 then volume else 0;
def bar244volume = if istoday then 0 else if barcounter == 244 then volume else 0;
def bar245volume = if istoday then 0 else if barcounter == 245 then volume else 0;
def bar246volume = if istoday then 0 else if barcounter == 246 then volume else 0;
def bar247volume = if istoday then 0 else if barcounter == 247 then volume else 0;
def bar248volume = if istoday then 0 else if barcounter == 248 then volume else 0;
def bar249volume = if istoday then 0 else if barcounter == 249 then volume else 0;
def bar250volume = if istoday then 0 else if barcounter == 250 then volume else 0;
def bar251volume = if istoday then 0 else if barcounter == 251 then volume else 0;
def bar252volume = if istoday then 0 else if barcounter == 252 then volume else 0;
def bar253volume = if istoday then 0 else if barcounter == 253 then volume else 0;
def bar254volume = if istoday then 0 else if barcounter == 254 then volume else 0;
def bar255volume = if istoday then 0 else if barcounter == 255 then volume else 0;
def bar256volume = if istoday then 0 else if barcounter == 256 then volume else 0;
def bar257volume = if istoday then 0 else if barcounter == 257 then volume else 0;
def bar258volume = if istoday then 0 else if barcounter == 258 then volume else 0;
def bar259volume = if istoday then 0 else if barcounter == 259 then volume else 0;
def bar260volume = if istoday then 0 else if barcounter == 260 then volume else 0;
def bar261volume = if istoday then 0 else if barcounter == 261 then volume else 0;
def bar262volume = if istoday then 0 else if barcounter == 262 then volume else 0;
def bar263volume = if istoday then 0 else if barcounter == 263 then volume else 0;
def bar264volume = if istoday then 0 else if barcounter == 264 then volume else 0;
def bar265volume = if istoday then 0 else if barcounter == 265 then volume else 0;
def bar266volume = if istoday then 0 else if barcounter == 266 then volume else 0;
def bar267volume = if istoday then 0 else if barcounter == 267 then volume else 0;
def bar268volume = if istoday then 0 else if barcounter == 268 then volume else 0;
def bar269volume = if istoday then 0 else if barcounter == 269 then volume else 0;
def bar270volume = if istoday then 0 else if barcounter == 270 then volume else 0;
def bar271volume = if istoday then 0 else if barcounter == 271 then volume else 0;
def bar272volume = if istoday then 0 else if barcounter == 272 then volume else 0;
def bar273volume = if istoday then 0 else if barcounter == 273 then volume else 0;
def bar274volume = if istoday then 0 else if barcounter == 274 then volume else 0;
def bar275volume = if istoday then 0 else if barcounter == 275 then volume else 0;
def bar276volume = if istoday then 0 else if barcounter == 276 then volume else 0;

def avgbar1 = TotalSum(bar1volume) / TotalSum(daycount);
def avgbar2 = TotalSum(bar2volume) / TotalSum(daycount);
def avgbar3 = TotalSum(bar3volume) / TotalSum(daycount);
def avgbar4 = TotalSum(bar4volume) / TotalSum(daycount);
def avgbar5 = TotalSum(bar5volume) / TotalSum(daycount);
def avgbar6 = TotalSum(bar6volume) / TotalSum(daycount);
def avgbar7 = TotalSum(bar7volume) / TotalSum(daycount);
def avgbar8 = TotalSum(bar8volume) / TotalSum(daycount);
def avgbar9 = TotalSum(bar9volume) / TotalSum(daycount);
def avgbar10 = TotalSum(bar10volume) / TotalSum(daycount);
def avgbar11 = TotalSum(bar11volume) / TotalSum(daycount);
def avgbar12 = TotalSum(bar12volume) / TotalSum(daycount);
def avgbar13 = TotalSum(bar13volume) / TotalSum(daycount);
def avgbar14 = TotalSum(bar14volume) / TotalSum(daycount);
def avgbar15 = TotalSum(bar15volume) / TotalSum(daycount);
def avgbar16 = TotalSum(bar16volume) / TotalSum(daycount);
def avgbar17 = TotalSum(bar17volume) / TotalSum(daycount);
def avgbar18 = TotalSum(bar18volume) / TotalSum(daycount);
def avgbar19 = TotalSum(bar19volume) / TotalSum(daycount);
def avgbar20 = TotalSum(bar20volume) / TotalSum(daycount);
def avgbar21 = TotalSum(bar21volume) / TotalSum(daycount);
def avgbar22 = TotalSum(bar22volume) / TotalSum(daycount);
def avgbar23 = TotalSum(bar23volume) / TotalSum(daycount);
def avgbar24 = TotalSum(bar24volume) / TotalSum(daycount);
def avgbar25 = TotalSum(bar25volume) / TotalSum(daycount);
def avgbar26 = TotalSum(bar26volume) / TotalSum(daycount);
def avgbar27 = TotalSum(bar27volume) / TotalSum(daycount);
def avgbar28 = TotalSum(bar28volume) / TotalSum(daycount);
def avgbar29 = TotalSum(bar29volume) / TotalSum(daycount);
def avgbar30 = TotalSum(bar30volume) / TotalSum(daycount);
def avgbar31 = TotalSum(bar31volume) / TotalSum(daycount);
def avgbar32 = TotalSum(bar32volume) / TotalSum(daycount);
def avgbar33 = TotalSum(bar33volume) / TotalSum(daycount);
def avgbar34 = TotalSum(bar34volume) / TotalSum(daycount);
def avgbar35 = TotalSum(bar35volume) / TotalSum(daycount);
def avgbar36 = TotalSum(bar36volume) / TotalSum(daycount);
def avgbar37 = TotalSum(bar37volume) / TotalSum(daycount);
def avgbar38 = TotalSum(bar38volume) / TotalSum(daycount);
def avgbar39 = TotalSum(bar39volume) / TotalSum(daycount);
def avgbar40 = TotalSum(bar40volume) / TotalSum(daycount);
def avgbar41 = TotalSum(bar41volume) / TotalSum(daycount);
def avgbar42 = TotalSum(bar42volume) / TotalSum(daycount);
def avgbar43 = TotalSum(bar43volume) / TotalSum(daycount);
def avgbar44 = TotalSum(bar44volume) / TotalSum(daycount);
def avgbar45 = TotalSum(bar45volume) / TotalSum(daycount);
def avgbar46 = TotalSum(bar46volume) / TotalSum(daycount);
def avgbar47 = TotalSum(bar47volume) / TotalSum(daycount);
def avgbar48 = TotalSum(bar48volume) / TotalSum(daycount);
def avgbar49 = TotalSum(bar49volume) / TotalSum(daycount);
def avgbar50 = TotalSum(bar50volume) / TotalSum(daycount);
def avgbar51 = TotalSum(bar51volume) / TotalSum(daycount);
def avgbar52 = TotalSum(bar52volume) / TotalSum(daycount);
def avgbar53 = TotalSum(bar53volume) / TotalSum(daycount);
def avgbar54 = TotalSum(bar54volume) / TotalSum(daycount);
def avgbar55 = TotalSum(bar55volume) / TotalSum(daycount);
def avgbar56 = TotalSum(bar56volume) / TotalSum(daycount);
def avgbar57 = TotalSum(bar57volume) / TotalSum(daycount);
def avgbar58 = TotalSum(bar58volume) / TotalSum(daycount);
def avgbar59 = TotalSum(bar59volume) / TotalSum(daycount);
def avgbar60 = TotalSum(bar60volume) / TotalSum(daycount);
def avgbar61 = TotalSum(bar61volume) / TotalSum(daycount);
def avgbar62 = TotalSum(bar62volume) / TotalSum(daycount);
def avgbar63 = TotalSum(bar63volume) / TotalSum(daycount);
def avgbar64 = TotalSum(bar64volume) / TotalSum(daycount);
def avgbar65 = TotalSum(bar65volume) / TotalSum(daycount);
def avgbar66 = TotalSum(bar66volume) / TotalSum(daycount);
def avgbar67 = TotalSum(bar67volume) / TotalSum(daycount);
def avgbar68 = TotalSum(bar68volume) / TotalSum(daycount);
def avgbar69 = TotalSum(bar69volume) / TotalSum(daycount);
def avgbar70 = TotalSum(bar70volume) / TotalSum(daycount);
def avgbar71 = TotalSum(bar71volume) / TotalSum(daycount);
def avgbar72 = TotalSum(bar72volume) / TotalSum(daycount);
def avgbar73 = TotalSum(bar73volume) / TotalSum(daycount);
def avgbar74 = TotalSum(bar74volume) / TotalSum(daycount);
def avgbar75 = TotalSum(bar75volume) / TotalSum(daycount);
def avgbar76 = TotalSum(bar76volume) / TotalSum(daycount);
def avgbar77 = TotalSum(bar77volume) / TotalSum(daycount);
def avgbar78 = TotalSum(bar78volume) / TotalSum(daycount);
def avgbar79 = TotalSum(bar79volume) / TotalSum(daycount);
def avgbar80 = TotalSum(bar80volume) / TotalSum(daycount);
def avgbar81 = TotalSum(bar81volume) / TotalSum(daycount);
def avgbar82 = TotalSum(bar82volume) / TotalSum(daycount);
def avgbar83 = TotalSum(bar83volume) / TotalSum(daycount);
def avgbar84 = TotalSum(bar84volume) / TotalSum(daycount);
def avgbar85 = TotalSum(bar85volume) / TotalSum(daycount);
def avgbar86 = TotalSum(bar86volume) / TotalSum(daycount);
def avgbar87 = TotalSum(bar87volume) / TotalSum(daycount);
def avgbar88 = TotalSum(bar88volume) / TotalSum(daycount);
def avgbar89 = TotalSum(bar89volume) / TotalSum(daycount);
def avgbar90 = TotalSum(bar90volume) / TotalSum(daycount);
def avgbar91 = TotalSum(bar91volume) / TotalSum(daycount);
def avgbar92 = TotalSum(bar92volume) / TotalSum(daycount);
def avgbar93 = TotalSum(bar93volume) / TotalSum(daycount);
def avgbar94 = TotalSum(bar94volume) / TotalSum(daycount);
def avgbar95 = TotalSum(bar95volume) / TotalSum(daycount);
def avgbar96 = TotalSum(bar96volume) / TotalSum(daycount);
def avgbar97 = TotalSum(bar97volume) / TotalSum(daycount);
def avgbar98 = TotalSum(bar98volume) / TotalSum(daycount);
def avgbar99 = TotalSum(bar99volume) / TotalSum(daycount);
def avgbar100 = TotalSum(bar100volume) / TotalSum(daycount);
def avgbar101 = TotalSum(bar101volume) / TotalSum(daycount);
def avgbar102 = TotalSum(bar102volume) / TotalSum(daycount);
def avgbar103 = TotalSum(bar103volume) / TotalSum(daycount);
def avgbar104 = TotalSum(bar104volume) / TotalSum(daycount);
def avgbar105 = TotalSum(bar105volume) / TotalSum(daycount);
def avgbar106 = TotalSum(bar106volume) / TotalSum(daycount);
def avgbar107 = TotalSum(bar107volume) / TotalSum(daycount);
def avgbar108 = TotalSum(bar108volume) / TotalSum(daycount);
def avgbar109 = TotalSum(bar109volume) / TotalSum(daycount);
def avgbar110 = TotalSum(bar110volume) / TotalSum(daycount);
def avgbar111 = TotalSum(bar111volume) / TotalSum(daycount);
def avgbar112 = TotalSum(bar112volume) / TotalSum(daycount);
def avgbar113 = TotalSum(bar113volume) / TotalSum(daycount);
def avgbar114 = TotalSum(bar114volume) / TotalSum(daycount);
def avgbar115 = TotalSum(bar115volume) / TotalSum(daycount);
def avgbar116 = TotalSum(bar116volume) / TotalSum(daycount);
def avgbar117 = TotalSum(bar117volume) / TotalSum(daycount);
def avgbar118 = TotalSum(bar118volume) / TotalSum(daycount);
def avgbar119 = TotalSum(bar119volume) / TotalSum(daycount);
def avgbar120 = TotalSum(bar120volume) / TotalSum(daycount);
def avgbar121 = TotalSum(bar121volume) / TotalSum(daycount);
def avgbar122 = TotalSum(bar122volume) / TotalSum(daycount);
def avgbar123 = TotalSum(bar123volume) / TotalSum(daycount);
def avgbar124 = TotalSum(bar124volume) / TotalSum(daycount);
def avgbar125 = TotalSum(bar125volume) / TotalSum(daycount);
def avgbar126 = TotalSum(bar126volume) / TotalSum(daycount);
def avgbar127 = TotalSum(bar127volume) / TotalSum(daycount);
def avgbar128 = TotalSum(bar128volume) / TotalSum(daycount);
def avgbar129 = TotalSum(bar129volume) / TotalSum(daycount);
def avgbar130 = TotalSum(bar130volume) / TotalSum(daycount);
def avgbar131 = TotalSum(bar131volume) / TotalSum(daycount);
def avgbar132 = TotalSum(bar132volume) / TotalSum(daycount);
def avgbar133 = TotalSum(bar133volume) / TotalSum(daycount);
def avgbar134 = TotalSum(bar134volume) / TotalSum(daycount);
def avgbar135 = TotalSum(bar135volume) / TotalSum(daycount);
def avgbar136 = TotalSum(bar136volume) / TotalSum(daycount);
def avgbar137 = TotalSum(bar137volume) / TotalSum(daycount);
def avgbar138 = TotalSum(bar138volume) / TotalSum(daycount);
def avgbar139 = TotalSum(bar139volume) / TotalSum(daycount);
def avgbar140 = TotalSum(bar140volume) / TotalSum(daycount);
def avgbar141 = TotalSum(bar141volume) / TotalSum(daycount);
def avgbar142 = TotalSum(bar142volume) / TotalSum(daycount);
def avgbar143 = TotalSum(bar143volume) / TotalSum(daycount);
def avgbar144 = TotalSum(bar144volume) / TotalSum(daycount);
def avgbar145 = TotalSum(bar145volume) / TotalSum(daycount);
def avgbar146 = TotalSum(bar146volume) / TotalSum(daycount);
def avgbar147 = TotalSum(bar147volume) / TotalSum(daycount);
def avgbar148 = TotalSum(bar148volume) / TotalSum(daycount);
def avgbar149 = TotalSum(bar149volume) / TotalSum(daycount);
def avgbar150 = TotalSum(bar150volume) / TotalSum(daycount);
def avgbar151 = TotalSum(bar151volume) / TotalSum(daycount);
def avgbar152 = TotalSum(bar152volume) / TotalSum(daycount);
def avgbar153 = TotalSum(bar153volume) / TotalSum(daycount);
def avgbar154 = TotalSum(bar154volume) / TotalSum(daycount);
def avgbar155 = TotalSum(bar155volume) / TotalSum(daycount);
def avgbar156 = TotalSum(bar156volume) / TotalSum(daycount);
def avgbar157 = TotalSum(bar157volume) / TotalSum(daycount);
def avgbar158 = TotalSum(bar158volume) / TotalSum(daycount);
def avgbar159 = TotalSum(bar159volume) / TotalSum(daycount);
def avgbar160 = TotalSum(bar160volume) / TotalSum(daycount);
def avgbar161 = TotalSum(bar161volume) / TotalSum(daycount);
def avgbar162 = TotalSum(bar162volume) / TotalSum(daycount);
def avgbar163 = TotalSum(bar163volume) / TotalSum(daycount);
def avgbar164 = TotalSum(bar164volume) / TotalSum(daycount);
def avgbar165 = TotalSum(bar165volume) / TotalSum(daycount);
def avgbar166 = TotalSum(bar166volume) / TotalSum(daycount);
def avgbar167 = TotalSum(bar167volume) / TotalSum(daycount);
def avgbar168 = TotalSum(bar168volume) / TotalSum(daycount);
def avgbar169 = TotalSum(bar169volume) / TotalSum(daycount);
def avgbar170 = TotalSum(bar170volume) / TotalSum(daycount);
def avgbar171 = TotalSum(bar171volume) / TotalSum(daycount);
def avgbar172 = TotalSum(bar172volume) / TotalSum(daycount);
def avgbar173 = TotalSum(bar173volume) / TotalSum(daycount);
def avgbar174 = TotalSum(bar174volume) / TotalSum(daycount);
def avgbar175 = TotalSum(bar175volume) / TotalSum(daycount);
def avgbar176 = TotalSum(bar176volume) / TotalSum(daycount);
def avgbar177 = TotalSum(bar177volume) / TotalSum(daycount);
def avgbar178 = TotalSum(bar178volume) / TotalSum(daycount);
def avgbar179 = TotalSum(bar179volume) / TotalSum(daycount);
def avgbar180 = TotalSum(bar180volume) / TotalSum(daycount);
def avgbar181 = TotalSum(bar181volume) / TotalSum(daycount);
def avgbar182 = TotalSum(bar182volume) / TotalSum(daycount);
def avgbar183 = TotalSum(bar183volume) / TotalSum(daycount);
def avgbar184 = TotalSum(bar184volume) / TotalSum(daycount);
def avgbar185 = TotalSum(bar185volume) / TotalSum(daycount);
def avgbar186 = TotalSum(bar186volume) / TotalSum(daycount);
def avgbar187 = TotalSum(bar187volume) / TotalSum(daycount);
def avgbar188 = TotalSum(bar188volume) / TotalSum(daycount);
def avgbar189 = TotalSum(bar189volume) / TotalSum(daycount);
def avgbar190 = TotalSum(bar190volume) / TotalSum(daycount);
def avgbar191 = TotalSum(bar191volume) / TotalSum(daycount);
def avgbar192 = TotalSum(bar192volume) / TotalSum(daycount);
def avgbar193 = TotalSum(bar193volume) / TotalSum(daycount);
def avgbar194 = TotalSum(bar194volume) / TotalSum(daycount);
def avgbar195 = TotalSum(bar195volume) / TotalSum(daycount);
def avgbar196 = TotalSum(bar196volume) / TotalSum(daycount);
def avgbar197 = TotalSum(bar197volume) / TotalSum(daycount);
def avgbar198 = TotalSum(bar198volume) / TotalSum(daycount);
def avgbar199 = TotalSum(bar199volume) / TotalSum(daycount);
def avgbar200 = TotalSum(bar200volume) / TotalSum(daycount);
def avgbar201 = TotalSum(bar201volume) / TotalSum(daycount);
def avgbar202 = TotalSum(bar202volume) / TotalSum(daycount);
def avgbar203 = TotalSum(bar203volume) / TotalSum(daycount);
def avgbar204 = TotalSum(bar204volume) / TotalSum(daycount);
def avgbar205 = TotalSum(bar205volume) / TotalSum(daycount);
def avgbar206 = TotalSum(bar206volume) / TotalSum(daycount);
def avgbar207 = TotalSum(bar207volume) / TotalSum(daycount);
def avgbar208 = TotalSum(bar208volume) / TotalSum(daycount);
def avgbar209 = TotalSum(bar209volume) / TotalSum(daycount);
def avgbar210 = TotalSum(bar210volume) / TotalSum(daycount);
def avgbar211 = TotalSum(bar211volume) / TotalSum(daycount);
def avgbar212 = TotalSum(bar212volume) / TotalSum(daycount);
def avgbar213 = TotalSum(bar213volume) / TotalSum(daycount);
def avgbar214 = TotalSum(bar214volume) / TotalSum(daycount);
def avgbar215 = TotalSum(bar215volume) / TotalSum(daycount);
def avgbar216 = TotalSum(bar216volume) / TotalSum(daycount);
def avgbar217 = TotalSum(bar217volume) / TotalSum(daycount);
def avgbar218 = TotalSum(bar218volume) / TotalSum(daycount);
def avgbar219 = TotalSum(bar219volume) / TotalSum(daycount);
def avgbar220 = TotalSum(bar220volume) / TotalSum(daycount);
def avgbar221 = TotalSum(bar221volume) / TotalSum(daycount);
def avgbar222 = TotalSum(bar222volume) / TotalSum(daycount);
def avgbar223 = TotalSum(bar223volume) / TotalSum(daycount);
def avgbar224 = TotalSum(bar224volume) / TotalSum(daycount);
def avgbar225 = TotalSum(bar225volume) / TotalSum(daycount);
def avgbar226 = TotalSum(bar226volume) / TotalSum(daycount);
def avgbar227 = TotalSum(bar227volume) / TotalSum(daycount);
def avgbar228 = TotalSum(bar228volume) / TotalSum(daycount);
def avgbar229 = TotalSum(bar229volume) / TotalSum(daycount);
def avgbar230 = TotalSum(bar230volume) / TotalSum(daycount);
def avgbar231 = TotalSum(bar231volume) / TotalSum(daycount);
def avgbar232 = TotalSum(bar232volume) / TotalSum(daycount);
def avgbar233 = TotalSum(bar233volume) / TotalSum(daycount);
def avgbar234 = TotalSum(bar234volume) / TotalSum(daycount);
def avgbar235 = TotalSum(bar235volume) / TotalSum(daycount);
def avgbar236 = TotalSum(bar236volume) / TotalSum(daycount);
def avgbar237 = TotalSum(bar237volume) / TotalSum(daycount);
def avgbar238 = TotalSum(bar238volume) / TotalSum(daycount);
def avgbar239 = TotalSum(bar239volume) / TotalSum(daycount);
def avgbar240 = TotalSum(bar240volume) / TotalSum(daycount);
def avgbar241 = TotalSum(bar241volume) / TotalSum(daycount);
def avgbar242 = TotalSum(bar242volume) / TotalSum(daycount);
def avgbar243 = TotalSum(bar243volume) / TotalSum(daycount);
def avgbar244 = TotalSum(bar244volume) / TotalSum(daycount);
def avgbar245 = TotalSum(bar245volume) / TotalSum(daycount);
def avgbar246 = TotalSum(bar246volume) / TotalSum(daycount);
def avgbar247 = TotalSum(bar247volume) / TotalSum(daycount);
def avgbar248 = TotalSum(bar248volume) / TotalSum(daycount);
def avgbar249 = TotalSum(bar249volume) / TotalSum(daycount);
def avgbar250 = TotalSum(bar250volume) / TotalSum(daycount);
def avgbar251 = TotalSum(bar251volume) / TotalSum(daycount);
def avgbar252 = TotalSum(bar252volume) / TotalSum(daycount);
def avgbar253 = TotalSum(bar253volume) / TotalSum(daycount);
def avgbar254 = TotalSum(bar254volume) / TotalSum(daycount);
def avgbar255 = TotalSum(bar255volume) / TotalSum(daycount);
def avgbar256 = TotalSum(bar256volume) / TotalSum(daycount);
def avgbar257 = TotalSum(bar257volume) / TotalSum(daycount);
def avgbar258 = TotalSum(bar258volume) / TotalSum(daycount);
def avgbar259 = TotalSum(bar259volume) / TotalSum(daycount);
def avgbar260 = TotalSum(bar260volume) / TotalSum(daycount);
def avgbar261 = TotalSum(bar261volume) / TotalSum(daycount);
def avgbar262 = TotalSum(bar262volume) / TotalSum(daycount);
def avgbar263 = TotalSum(bar263volume) / TotalSum(daycount);
def avgbar264 = TotalSum(bar264volume) / TotalSum(daycount);
def avgbar265 = TotalSum(bar265volume) / TotalSum(daycount);
def avgbar266 = TotalSum(bar266volume) / TotalSum(daycount);
def avgbar267 = TotalSum(bar267volume) / TotalSum(daycount);
def avgbar268 = TotalSum(bar268volume) / TotalSum(daycount);
def avgbar269 = TotalSum(bar269volume) / TotalSum(daycount);
def avgbar270 = TotalSum(bar270volume) / TotalSum(daycount);
def avgbar271 = TotalSum(bar271volume) / TotalSum(daycount);
def avgbar272 = TotalSum(bar272volume) / TotalSum(daycount);
def avgbar273 = TotalSum(bar273volume) / TotalSum(daycount);
def avgbar274 = TotalSum(bar274volume) / TotalSum(daycount);
def avgbar275 = TotalSum(bar275volume) / TotalSum(daycount);
def avgbar276 = TotalSum(bar276volume) / TotalSum(daycount);





plot AvgVol = if GetDay() != GetLastDay() then na 
else if barcounter == 1 then avgbar1
else if barcounter == 2 then avgbar2
else if barcounter == 3 then avgbar3
else if barcounter == 4 then avgbar4
else if barcounter == 5 then avgbar5
else if barcounter == 6 then avgbar6
else if barcounter == 7 then avgbar7
else if barcounter == 8 then avgbar8
else if barcounter == 9 then avgbar9
else if barcounter == 10 then avgbar10
else if barcounter == 11 then avgbar11
else if barcounter == 12 then avgbar12
else if barcounter == 13 then avgbar13
else if barcounter == 14 then avgbar14
else if barcounter == 15 then avgbar15
else if barcounter == 16 then avgbar16
else if barcounter == 17 then avgbar17
else if barcounter == 18 then avgbar18
else if barcounter == 19 then avgbar19
else if barcounter == 20 then avgbar20
else if barcounter == 21 then avgbar21
else if barcounter == 22 then avgbar22
else if barcounter == 23 then avgbar23
else if barcounter == 24 then avgbar24
else if barcounter == 25 then avgbar25
else if barcounter == 26 then avgbar26
else if barcounter == 27 then avgbar27
else if barcounter == 28 then avgbar28
else if barcounter == 29 then avgbar29
else if barcounter == 30 then avgbar30
else if barcounter == 31 then avgbar31
else if barcounter == 32 then avgbar32
else if barcounter == 33 then avgbar33
else if barcounter == 34 then avgbar34
else if barcounter == 35 then avgbar35
else if barcounter == 36 then avgbar36
else if barcounter == 37 then avgbar37
else if barcounter == 38 then avgbar38
else if barcounter == 39 then avgbar39
else if barcounter == 40 then avgbar40
else if barcounter == 41 then avgbar41
else if barcounter == 42 then avgbar42
else if barcounter == 43 then avgbar43
else if barcounter == 44 then avgbar44
else if barcounter == 45 then avgbar45
else if barcounter == 46 then avgbar46
else if barcounter == 47 then avgbar47
else if barcounter == 48 then avgbar48
else if barcounter == 49 then avgbar49
else if barcounter == 50 then avgbar50
else if barcounter == 51 then avgbar51
else if barcounter == 52 then avgbar52
else if barcounter == 53 then avgbar53
else if barcounter == 54 then avgbar54
else if barcounter == 55 then avgbar55
else if barcounter == 56 then avgbar56
else if barcounter == 57 then avgbar57
else if barcounter == 58 then avgbar58
else if barcounter == 59 then avgbar59
else if barcounter == 60 then avgbar60
else if barcounter == 61 then avgbar61
else if barcounter == 62 then avgbar62
else if barcounter == 63 then avgbar63
else if barcounter == 64 then avgbar64
else if barcounter == 65 then avgbar65
else if barcounter == 66 then avgbar66
else if barcounter == 67 then avgbar67
else if barcounter == 68 then avgbar68
else if barcounter == 69 then avgbar69
else if barcounter == 70 then avgbar70
else if barcounter == 71 then avgbar71
else if barcounter == 72 then avgbar72
else if barcounter == 73 then avgbar73
else if barcounter == 74 then avgbar74
else if barcounter == 75 then avgbar75
else if barcounter == 76 then avgbar76
else if barcounter == 77 then avgbar77
else if barcounter == 78 then avgbar78
else if barcounter == 79 then avgbar79
else if barcounter == 80 then avgbar80
else if barcounter == 81 then avgbar81
else if barcounter == 82 then avgbar82
else if barcounter == 83 then avgbar83
else if barcounter == 84 then avgbar84
else if barcounter == 85 then avgbar85
else if barcounter == 86 then avgbar86
else if barcounter == 87 then avgbar87
else if barcounter == 88 then avgbar88
else if barcounter == 89 then avgbar89
else if barcounter == 90 then avgbar90
else if barcounter == 91 then avgbar91
else if barcounter == 92 then avgbar92
else if barcounter == 93 then avgbar93
else if barcounter == 94 then avgbar94
else if barcounter == 95 then avgbar95
else if barcounter == 96 then avgbar96
else if barcounter == 97 then avgbar97
else if barcounter == 98 then avgbar98
else if barcounter == 99 then avgbar99
else if barcounter == 100 then avgbar100
else if barcounter == 101 then avgbar101
else if barcounter == 102 then avgbar102
else if barcounter == 103 then avgbar103
else if barcounter == 104 then avgbar104
else if barcounter == 105 then avgbar105
else if barcounter == 106 then avgbar106
else if barcounter == 107 then avgbar107
else if barcounter == 108 then avgbar108
else if barcounter == 109 then avgbar109
else if barcounter == 110 then avgbar110
else if barcounter == 111 then avgbar111
else if barcounter == 112 then avgbar112
else if barcounter == 113 then avgbar113
else if barcounter == 114 then avgbar114
else if barcounter == 115 then avgbar115
else if barcounter == 116 then avgbar116
else if barcounter == 117 then avgbar117
else if barcounter == 118 then avgbar118
else if barcounter == 119 then avgbar119
else if barcounter == 120 then avgbar120
else if barcounter == 121 then avgbar121
else if barcounter == 122 then avgbar122
else if barcounter == 123 then avgbar123
else if barcounter == 124 then avgbar124
else if barcounter == 125 then avgbar125
else if barcounter == 126 then avgbar126
else if barcounter == 127 then avgbar127
else if barcounter == 128 then avgbar128
else if barcounter == 129 then avgbar129
else if barcounter == 130 then avgbar130
else if barcounter == 131 then avgbar131
else if barcounter == 132 then avgbar132
else if barcounter == 133 then avgbar133
else if barcounter == 134 then avgbar134
else if barcounter == 135 then avgbar135
else if barcounter == 136 then avgbar136
else if barcounter == 137 then avgbar137
else if barcounter == 138 then avgbar138
else if barcounter == 139 then avgbar139
else if barcounter == 140 then avgbar140
else if barcounter == 141 then avgbar141
else if barcounter == 142 then avgbar142
else if barcounter == 143 then avgbar143
else if barcounter == 144 then avgbar144
else if barcounter == 145 then avgbar145
else if barcounter == 146 then avgbar146
else if barcounter == 147 then avgbar147
else if barcounter == 148 then avgbar148
else if barcounter == 149 then avgbar149
else if barcounter == 150 then avgbar150
else if barcounter == 151 then avgbar151
else if barcounter == 152 then avgbar152
else if barcounter == 153 then avgbar153
else if barcounter == 154 then avgbar154
else if barcounter == 155 then avgbar155
else if barcounter == 156 then avgbar156
else if barcounter == 157 then avgbar157
else if barcounter == 158 then avgbar158
else if barcounter == 159 then avgbar159
else if barcounter == 160 then avgbar160
else if barcounter == 161 then avgbar161
else if barcounter == 162 then avgbar162
else if barcounter == 163 then avgbar163
else if barcounter == 164 then avgbar164
else if barcounter == 165 then avgbar165
else if barcounter == 166 then avgbar166
else if barcounter == 167 then avgbar167
else if barcounter == 168 then avgbar168
else if barcounter == 169 then avgbar169
else if barcounter == 170 then avgbar170
else if barcounter == 171 then avgbar171
else if barcounter == 172 then avgbar172
else if barcounter == 173 then avgbar173
else if barcounter == 174 then avgbar174
else if barcounter == 175 then avgbar175
else if barcounter == 176 then avgbar176
else if barcounter == 177 then avgbar177
else if barcounter == 178 then avgbar178
else if barcounter == 179 then avgbar179
else if barcounter == 180 then avgbar180
else if barcounter == 181 then avgbar181
else if barcounter == 182 then avgbar182
else if barcounter == 183 then avgbar183
else if barcounter == 184 then avgbar184
else if barcounter == 185 then avgbar185
else if barcounter == 186 then avgbar186
else if barcounter == 187 then avgbar187
else if barcounter == 188 then avgbar188
else if barcounter == 189 then avgbar189
else if barcounter == 190 then avgbar190
else if barcounter == 191 then avgbar191
else if barcounter == 192 then avgbar192
else if barcounter == 193 then avgbar193
else if barcounter == 194 then avgbar194
else if barcounter == 195 then avgbar195
else if barcounter == 196 then avgbar196
else if barcounter == 197 then avgbar197
else if barcounter == 198 then avgbar198
else if barcounter == 199 then avgbar199
else if barcounter == 200 then avgbar200
else if barcounter == 201 then avgbar201
else if barcounter == 202 then avgbar202
else if barcounter == 203 then avgbar203
else if barcounter == 204 then avgbar204
else if barcounter == 205 then avgbar205
else if barcounter == 206 then avgbar206
else if barcounter == 207 then avgbar207
else if barcounter == 208 then avgbar208
else if barcounter == 209 then avgbar209
else if barcounter == 210 then avgbar210
else if barcounter == 211 then avgbar211
else if barcounter == 212 then avgbar212
else if barcounter == 213 then avgbar213
else if barcounter == 214 then avgbar214
else if barcounter == 215 then avgbar215
else if barcounter == 216 then avgbar216
else if barcounter == 217 then avgbar217
else if barcounter == 218 then avgbar218
else if barcounter == 219 then avgbar219
else if barcounter == 220 then avgbar220
else if barcounter == 221 then avgbar221
else if barcounter == 222 then avgbar222
else if barcounter == 223 then avgbar223
else if barcounter == 224 then avgbar224
else if barcounter == 225 then avgbar225
else if barcounter == 226 then avgbar226
else if barcounter == 227 then avgbar227
else if barcounter == 228 then avgbar228
else if barcounter == 229 then avgbar229
else if barcounter == 230 then avgbar230
else if barcounter == 231 then avgbar231
else if barcounter == 232 then avgbar232
else if barcounter == 233 then avgbar233
else if barcounter == 234 then avgbar234
else if barcounter == 235 then avgbar235
else if barcounter == 236 then avgbar236
else if barcounter == 237 then avgbar237
else if barcounter == 238 then avgbar238
else if barcounter == 239 then avgbar239
else if barcounter == 240 then avgbar240
else if barcounter == 241 then avgbar241
else if barcounter == 242 then avgbar242
else if barcounter == 243 then avgbar243
else if barcounter == 244 then avgbar244
else if barcounter == 245 then avgbar245
else if barcounter == 246 then avgbar246
else if barcounter == 247 then avgbar247
else if barcounter == 248 then avgbar248
else if barcounter == 249 then avgbar249
else if barcounter == 250 then avgbar250
else if barcounter == 251 then avgbar251
else if barcounter == 252 then avgbar252
else if barcounter == 253 then avgbar253
else if barcounter == 254 then avgbar254
else if barcounter == 255 then avgbar255
else if barcounter == 256 then avgbar256
else if barcounter == 257 then avgbar257
else if barcounter == 258 then avgbar258
else if barcounter == 259 then avgbar259
else if barcounter == 260 then avgbar260
else if barcounter == 261 then avgbar261
else if barcounter == 262 then avgbar262
else if barcounter == 263 then avgbar263
else if barcounter == 264 then avgbar264
else if barcounter == 265 then avgbar265
else if barcounter == 266 then avgbar266
else if barcounter == 267 then avgbar267
else if barcounter == 268 then avgbar268
else if barcounter == 269 then avgbar269
else if barcounter == 270 then avgbar270
else if barcounter == 271 then avgbar271
else if barcounter == 272 then avgbar272
else if barcounter == 273 then avgbar273
else if barcounter == 274 then avgbar274
else if barcounter == 275 then avgbar275
else if barcounter == 276 then avgbar276
else na;

AvgVol.SetDefaultColor(Color.DARK_GRAY);
AvgVol.SetLineWeight(1);
def zero = 0;


def vol = volume;

def avg_vol = SimpleMovingAvg(vol, 8);

input OpenBell  = 0400.0;
input CloseBell  = 1600.0;


def RTH = if SecondsTillTime(CloseBell) > 0 and
                    SecondsFromTime(OpenBell) > 0 
                 then 1 
                 else 0;

def cum_vol = if RTH ==  0 then 0 else cum_vol[1] + VOLUME;
plot day_volume = cum_vol;


def AvgVolSum =  if GetDay() == GetLastDay() 
# and RTH == 1
 then AvgVolSum[1] + AvgVol else 0;;
plot AVS = if AvgVolSum != 0 then AvgVolSum else double.nan;
addCloud(AVS, Day_Volume, color.pink, color.cyan, no);

input OpenHour = 1030.0;
def FirstHour = if SecondsTillTime(OpenHour) > 0 and
                    SecondsFromTime(OpenBell) >= 0 
                 then 1 
                 else 0;

def FirstHourRatio = if GetDay() == GetLastDay() 

    and FirstHour == 1 
    then
        cum_vol / AvgVolSum
    else
        FirstHourRatio[1]
    ;
addVerticalLine(if GetDay() == GetLastDay() and FirstHour == 0 and FirstHour[1] == 1 then yes else no, "First Hour Ratio Set", color = Color.BLUE);
addLabel(yes, concat("Ratio: ", FirstHourRatio), color.blue);

def VolumeProjection = if GetDay() != GetLastDay() then na 
else if barcounter == 1  then avgbar1 * FirstHourRatio
else if barcounter == 2  then  VolumeProjection[1] + ( avgbar2 * FirstHourRatio)
else if barcounter == 3  then  VolumeProjection[1] + ( avgbar3 * FirstHourRatio)
else if barcounter == 4  then  VolumeProjection[1] + ( avgbar4 * FirstHourRatio)
else if barcounter == 5  then  VolumeProjection[1] + ( avgbar5 * FirstHourRatio)
else if barcounter == 6  then  VolumeProjection[1] + ( avgbar6 * FirstHourRatio)
else if barcounter == 7  then  VolumeProjection[1] + ( avgbar7 * FirstHourRatio)
else if barcounter == 8  then  VolumeProjection[1] + ( avgbar8 * FirstHourRatio)
else if barcounter == 9  then  VolumeProjection[1] + ( avgbar9 * FirstHourRatio)
else if barcounter == 10  then  VolumeProjection[1] + ( avgbar10 * FirstHourRatio)
else if barcounter == 11  then  VolumeProjection[1] + ( avgbar11 * FirstHourRatio)
else if barcounter == 12  then  VolumeProjection[1] + ( avgbar12 * FirstHourRatio)
else if barcounter == 13  then  VolumeProjection[1] + ( avgbar13 * FirstHourRatio)
else if barcounter == 14  then  VolumeProjection[1] + ( avgbar14 * FirstHourRatio)
else if barcounter == 15  then  VolumeProjection[1] + ( avgbar15 * FirstHourRatio)
else if barcounter == 16  then  VolumeProjection[1] + ( avgbar16 * FirstHourRatio)
else if barcounter == 17  then  VolumeProjection[1] + ( avgbar17 * FirstHourRatio)
else if barcounter == 18  then  VolumeProjection[1] + ( avgbar18 * FirstHourRatio)
else if barcounter == 19  then  VolumeProjection[1] + ( avgbar19 * FirstHourRatio)
else if barcounter == 20  then  VolumeProjection[1] + ( avgbar20 * FirstHourRatio)
else if barcounter == 21  then  VolumeProjection[1] + ( avgbar21 * FirstHourRatio)
else if barcounter == 22  then  VolumeProjection[1] + ( avgbar22 * FirstHourRatio)
else if barcounter == 23  then  VolumeProjection[1] + ( avgbar23 * FirstHourRatio)
else if barcounter == 24  then  VolumeProjection[1] + ( avgbar24 * FirstHourRatio)
else if barcounter == 25  then  VolumeProjection[1] + ( avgbar25 * FirstHourRatio)
else if barcounter == 26  then  VolumeProjection[1] + ( avgbar26 * FirstHourRatio)
else if barcounter == 27  then  VolumeProjection[1] + ( avgbar27 * FirstHourRatio)
else if barcounter == 28  then  VolumeProjection[1] + ( avgbar28 * FirstHourRatio)
else if barcounter == 29  then  VolumeProjection[1] + ( avgbar29 * FirstHourRatio)
else if barcounter == 30  then  VolumeProjection[1] + ( avgbar30 * FirstHourRatio)
else if barcounter == 31  then  VolumeProjection[1] + ( avgbar31 * FirstHourRatio)
else if barcounter == 32  then  VolumeProjection[1] + ( avgbar32 * FirstHourRatio)
else if barcounter == 33  then  VolumeProjection[1] + ( avgbar33 * FirstHourRatio)
else if barcounter == 34  then  VolumeProjection[1] + ( avgbar34 * FirstHourRatio)
else if barcounter == 35  then  VolumeProjection[1] + ( avgbar35 * FirstHourRatio)
else if barcounter == 36  then  VolumeProjection[1] + ( avgbar36 * FirstHourRatio)
else if barcounter == 37  then  VolumeProjection[1] + ( avgbar37 * FirstHourRatio)
else if barcounter == 38  then  VolumeProjection[1] + ( avgbar38 * FirstHourRatio)
else if barcounter == 39  then  VolumeProjection[1] + ( avgbar39 * FirstHourRatio)
else if barcounter == 40  then  VolumeProjection[1] + ( avgbar40 * FirstHourRatio)
else if barcounter == 41  then  VolumeProjection[1] + ( avgbar41 * FirstHourRatio)
else if barcounter == 42  then  VolumeProjection[1] + ( avgbar42 * FirstHourRatio)
else if barcounter == 43  then  VolumeProjection[1] + ( avgbar43 * FirstHourRatio)
else if barcounter == 44  then  VolumeProjection[1] + ( avgbar44 * FirstHourRatio)
else if barcounter == 45  then  VolumeProjection[1] + ( avgbar45 * FirstHourRatio)
else if barcounter == 46  then  VolumeProjection[1] + ( avgbar46 * FirstHourRatio)
else if barcounter == 47  then  VolumeProjection[1] + ( avgbar47 * FirstHourRatio)
else if barcounter == 48  then  VolumeProjection[1] + ( avgbar48 * FirstHourRatio)
else if barcounter == 49  then  VolumeProjection[1] + ( avgbar49 * FirstHourRatio)
else if barcounter == 50  then  VolumeProjection[1] + ( avgbar50 * FirstHourRatio)
else if barcounter == 51  then  VolumeProjection[1] + ( avgbar51 * FirstHourRatio)
else if barcounter == 52  then  VolumeProjection[1] + ( avgbar52 * FirstHourRatio)
else if barcounter == 53  then  VolumeProjection[1] + ( avgbar53 * FirstHourRatio)
else if barcounter == 54  then  VolumeProjection[1] + ( avgbar54 * FirstHourRatio)
else if barcounter == 55  then  VolumeProjection[1] + ( avgbar55 * FirstHourRatio)
else if barcounter == 56  then  VolumeProjection[1] + ( avgbar56 * FirstHourRatio)
else if barcounter == 57  then  VolumeProjection[1] + ( avgbar57 * FirstHourRatio)
else if barcounter == 58  then  VolumeProjection[1] + ( avgbar58 * FirstHourRatio)
else if barcounter == 59  then  VolumeProjection[1] + ( avgbar59 * FirstHourRatio)
else if barcounter == 60  then  VolumeProjection[1] + ( avgbar60 * FirstHourRatio)
else if barcounter == 61  then  VolumeProjection[1] + ( avgbar61 * FirstHourRatio)
else if barcounter == 62  then  VolumeProjection[1] + ( avgbar62 * FirstHourRatio)
else if barcounter == 63  then  VolumeProjection[1] + ( avgbar63 * FirstHourRatio)
else if barcounter == 64  then  VolumeProjection[1] + ( avgbar64 * FirstHourRatio)
else if barcounter == 65  then  VolumeProjection[1] + ( avgbar65 * FirstHourRatio)
else if barcounter == 66  then  VolumeProjection[1] + ( avgbar66 * FirstHourRatio)
else if barcounter == 67  then  VolumeProjection[1] + ( avgbar67 * FirstHourRatio)
else if barcounter == 68  then  VolumeProjection[1] + ( avgbar68 * FirstHourRatio)
else if barcounter == 69  then  VolumeProjection[1] + ( avgbar69 * FirstHourRatio)
else if barcounter == 70  then  VolumeProjection[1] + ( avgbar70 * FirstHourRatio)
else if barcounter == 71  then  VolumeProjection[1] + ( avgbar71 * FirstHourRatio)
else if barcounter == 72  then  VolumeProjection[1] + ( avgbar72 * FirstHourRatio)
else if barcounter == 73  then  VolumeProjection[1] + ( avgbar73 * FirstHourRatio)
else if barcounter == 74  then  VolumeProjection[1] + ( avgbar74 * FirstHourRatio)
else if barcounter == 75  then  VolumeProjection[1] + ( avgbar75 * FirstHourRatio)
else if barcounter == 76  then  VolumeProjection[1] + ( avgbar76 * FirstHourRatio)
else if barcounter == 77  then  VolumeProjection[1] + ( avgbar77 * FirstHourRatio)
else if barcounter == 78  then  VolumeProjection[1] + ( avgbar78 * FirstHourRatio)
else if barcounter == 79  then  VolumeProjection[1] + ( avgbar79 * FirstHourRatio)
else if barcounter == 80  then  VolumeProjection[1] + ( avgbar80 * FirstHourRatio)
else if barcounter == 81  then  VolumeProjection[1] + ( avgbar81 * FirstHourRatio)
else if barcounter == 82  then  VolumeProjection[1] + ( avgbar82 * FirstHourRatio)
else if barcounter == 83  then  VolumeProjection[1] + ( avgbar83 * FirstHourRatio)
else if barcounter == 84  then  VolumeProjection[1] + ( avgbar84 * FirstHourRatio)
else if barcounter == 85  then  VolumeProjection[1] + ( avgbar85 * FirstHourRatio)
else if barcounter == 86  then  VolumeProjection[1] + ( avgbar86 * FirstHourRatio)
else if barcounter == 87  then  VolumeProjection[1] + ( avgbar87 * FirstHourRatio)
else if barcounter == 88  then  VolumeProjection[1] + ( avgbar88 * FirstHourRatio)
else if barcounter == 89  then  VolumeProjection[1] + ( avgbar89 * FirstHourRatio)
else if barcounter == 90  then  VolumeProjection[1] + ( avgbar90 * FirstHourRatio)
else if barcounter == 91  then  VolumeProjection[1] + ( avgbar91 * FirstHourRatio)
else if barcounter == 92  then  VolumeProjection[1] + ( avgbar92 * FirstHourRatio)
else if barcounter == 93  then  VolumeProjection[1] + ( avgbar93 * FirstHourRatio)
else if barcounter == 94  then  VolumeProjection[1] + ( avgbar94 * FirstHourRatio)
else if barcounter == 95  then  VolumeProjection[1] + ( avgbar95 * FirstHourRatio)
else if barcounter == 96  then  VolumeProjection[1] + ( avgbar96 * FirstHourRatio)
else if barcounter == 97  then  VolumeProjection[1] + ( avgbar97 * FirstHourRatio)
else if barcounter == 98  then  VolumeProjection[1] + ( avgbar98 * FirstHourRatio)
else if barcounter == 99  then  VolumeProjection[1] + ( avgbar99 * FirstHourRatio)
else if barcounter == 100  then  VolumeProjection[1] + ( avgbar100 * FirstHourRatio)
else if barcounter == 101  then  VolumeProjection[1] + ( avgbar101 * FirstHourRatio)
else if barcounter == 102  then  VolumeProjection[1] + ( avgbar102 * FirstHourRatio)
else if barcounter == 103  then  VolumeProjection[1] + ( avgbar103 * FirstHourRatio)
else if barcounter == 104  then  VolumeProjection[1] + ( avgbar104 * FirstHourRatio)
else if barcounter == 105  then  VolumeProjection[1] + ( avgbar105 * FirstHourRatio)
else if barcounter == 106  then  VolumeProjection[1] + ( avgbar106 * FirstHourRatio)
else if barcounter == 107  then  VolumeProjection[1] + ( avgbar107 * FirstHourRatio)
else if barcounter == 108  then  VolumeProjection[1] + ( avgbar108 * FirstHourRatio)
else if barcounter == 109  then  VolumeProjection[1] + ( avgbar109 * FirstHourRatio)
else if barcounter == 110  then  VolumeProjection[1] + ( avgbar110 * FirstHourRatio)
else if barcounter == 111  then  VolumeProjection[1] + ( avgbar111 * FirstHourRatio)
else if barcounter == 112  then  VolumeProjection[1] + ( avgbar112 * FirstHourRatio)
else if barcounter == 113  then  VolumeProjection[1] + ( avgbar113 * FirstHourRatio)
else if barcounter == 114  then  VolumeProjection[1] + ( avgbar114 * FirstHourRatio)
else if barcounter == 115  then  VolumeProjection[1] + ( avgbar115 * FirstHourRatio)
else if barcounter == 116  then  VolumeProjection[1] + ( avgbar116 * FirstHourRatio)
else if barcounter == 117  then  VolumeProjection[1] + ( avgbar117 * FirstHourRatio)
else if barcounter == 118  then  VolumeProjection[1] + ( avgbar118 * FirstHourRatio)
else if barcounter == 119  then  VolumeProjection[1] + ( avgbar119 * FirstHourRatio)
else if barcounter == 120  then  VolumeProjection[1] + ( avgbar120 * FirstHourRatio)
else if barcounter == 121  then  VolumeProjection[1] + ( avgbar121 * FirstHourRatio)
else if barcounter == 122  then  VolumeProjection[1] + ( avgbar122 * FirstHourRatio)
else if barcounter == 123  then  VolumeProjection[1] + ( avgbar123 * FirstHourRatio)
else if barcounter == 124  then  VolumeProjection[1] + ( avgbar124 * FirstHourRatio)
else if barcounter == 125  then  VolumeProjection[1] + ( avgbar125 * FirstHourRatio)
else if barcounter == 126  then  VolumeProjection[1] + ( avgbar126 * FirstHourRatio)
else if barcounter == 127  then  VolumeProjection[1] + ( avgbar127 * FirstHourRatio)
else if barcounter == 128  then  VolumeProjection[1] + ( avgbar128 * FirstHourRatio)
else if barcounter == 129  then  VolumeProjection[1] + ( avgbar129 * FirstHourRatio)
else if barcounter == 130  then  VolumeProjection[1] + ( avgbar130 * FirstHourRatio)
else if barcounter == 131  then  VolumeProjection[1] + ( avgbar131 * FirstHourRatio)
else if barcounter == 132  then  VolumeProjection[1] + ( avgbar132 * FirstHourRatio)
else if barcounter == 133  then  VolumeProjection[1] + ( avgbar133 * FirstHourRatio)
else if barcounter == 134  then  VolumeProjection[1] + ( avgbar134 * FirstHourRatio)
else if barcounter == 135  then  VolumeProjection[1] + ( avgbar135 * FirstHourRatio)
else if barcounter == 136  then  VolumeProjection[1] + ( avgbar136 * FirstHourRatio)
else if barcounter == 137  then  VolumeProjection[1] + ( avgbar137 * FirstHourRatio)
else if barcounter == 138  then  VolumeProjection[1] + ( avgbar138 * FirstHourRatio)
else if barcounter == 139  then  VolumeProjection[1] + ( avgbar139 * FirstHourRatio)
else if barcounter == 140  then  VolumeProjection[1] + ( avgbar140 * FirstHourRatio)
else if barcounter == 141  then  VolumeProjection[1] + ( avgbar141 * FirstHourRatio)
else if barcounter == 142  then  VolumeProjection[1] + ( avgbar142 * FirstHourRatio)
else if barcounter == 143  then  VolumeProjection[1] + ( avgbar143 * FirstHourRatio)
else if barcounter == 144  then  VolumeProjection[1] + ( avgbar144 * FirstHourRatio)
else if barcounter == 145  then  VolumeProjection[1] + ( avgbar145 * FirstHourRatio)
else if barcounter == 146  then  VolumeProjection[1] + ( avgbar146 * FirstHourRatio)
else if barcounter == 147  then  VolumeProjection[1] + ( avgbar147 * FirstHourRatio)
else if barcounter == 148  then  VolumeProjection[1] + ( avgbar148 * FirstHourRatio)
else if barcounter == 149  then  VolumeProjection[1] + ( avgbar149 * FirstHourRatio)
else if barcounter == 150  then  VolumeProjection[1] + ( avgbar150 * FirstHourRatio)
else if barcounter == 151  then  VolumeProjection[1] + ( avgbar151 * FirstHourRatio)
else if barcounter == 152  then  VolumeProjection[1] + ( avgbar152 * FirstHourRatio)
else if barcounter == 153  then  VolumeProjection[1] + ( avgbar153 * FirstHourRatio)
else if barcounter == 154  then  VolumeProjection[1] + ( avgbar154 * FirstHourRatio)
else if barcounter == 155  then  VolumeProjection[1] + ( avgbar155 * FirstHourRatio)
else if barcounter == 156  then  VolumeProjection[1] + ( avgbar156 * FirstHourRatio)
else if barcounter == 157  then  VolumeProjection[1] + ( avgbar157 * FirstHourRatio)
else if barcounter == 158  then  VolumeProjection[1] + ( avgbar158 * FirstHourRatio)
else if barcounter == 159  then  VolumeProjection[1] + ( avgbar159 * FirstHourRatio)
else if barcounter == 160  then  VolumeProjection[1] + ( avgbar160 * FirstHourRatio)
else if barcounter == 161  then  VolumeProjection[1] + ( avgbar161 * FirstHourRatio)
else if barcounter == 162  then  VolumeProjection[1] + ( avgbar162 * FirstHourRatio)
else if barcounter == 163  then  VolumeProjection[1] + ( avgbar163 * FirstHourRatio)
else if barcounter == 164  then  VolumeProjection[1] + ( avgbar164 * FirstHourRatio)
else if barcounter == 165  then  VolumeProjection[1] + ( avgbar165 * FirstHourRatio)
else if barcounter == 166  then  VolumeProjection[1] + ( avgbar166 * FirstHourRatio)
else if barcounter == 167  then  VolumeProjection[1] + ( avgbar167 * FirstHourRatio)
else if barcounter == 168  then  VolumeProjection[1] + ( avgbar168 * FirstHourRatio)
else if barcounter == 169  then  VolumeProjection[1] + ( avgbar169 * FirstHourRatio)
else if barcounter == 170  then  VolumeProjection[1] + ( avgbar170 * FirstHourRatio)
else if barcounter == 171  then  VolumeProjection[1] + ( avgbar171 * FirstHourRatio)
else if barcounter == 172  then  VolumeProjection[1] + ( avgbar172 * FirstHourRatio)
else if barcounter == 173  then  VolumeProjection[1] + ( avgbar173 * FirstHourRatio)
else if barcounter == 174  then  VolumeProjection[1] + ( avgbar174 * FirstHourRatio)
else if barcounter == 175  then  VolumeProjection[1] + ( avgbar175 * FirstHourRatio)
else if barcounter == 176  then  VolumeProjection[1] + ( avgbar176 * FirstHourRatio)
else if barcounter == 177  then  VolumeProjection[1] + ( avgbar177 * FirstHourRatio)
else if barcounter == 178  then  VolumeProjection[1] + ( avgbar178 * FirstHourRatio)
else if barcounter == 179  then  VolumeProjection[1] + ( avgbar179 * FirstHourRatio)
else if barcounter == 180  then  VolumeProjection[1] + ( avgbar180 * FirstHourRatio)
else if barcounter == 181  then  VolumeProjection[1] + ( avgbar181 * FirstHourRatio)
else if barcounter == 182  then  VolumeProjection[1] + ( avgbar182 * FirstHourRatio)
else if barcounter == 183  then  VolumeProjection[1] + ( avgbar183 * FirstHourRatio)
else if barcounter == 184  then  VolumeProjection[1] + ( avgbar184 * FirstHourRatio)
else if barcounter == 185  then  VolumeProjection[1] + ( avgbar185 * FirstHourRatio)
else if barcounter == 186  then  VolumeProjection[1] + ( avgbar186 * FirstHourRatio)
else if barcounter == 187  then  VolumeProjection[1] + ( avgbar187 * FirstHourRatio)
else if barcounter == 188  then  VolumeProjection[1] + ( avgbar188 * FirstHourRatio)
else if barcounter == 189  then  VolumeProjection[1] + ( avgbar189 * FirstHourRatio)
else if barcounter == 190  then  VolumeProjection[1] + ( avgbar190 * FirstHourRatio)
else if barcounter == 191  then  VolumeProjection[1] + ( avgbar191 * FirstHourRatio)
else if barcounter == 192  then  VolumeProjection[1] + ( avgbar192 * FirstHourRatio)
else if barcounter == 193  then  VolumeProjection[1] + ( avgbar193 * FirstHourRatio)
else if barcounter == 194  then  VolumeProjection[1] + ( avgbar194 * FirstHourRatio)
else if barcounter == 195  then  VolumeProjection[1] + ( avgbar195 * FirstHourRatio)
else if barcounter == 196  then  VolumeProjection[1] + ( avgbar196 * FirstHourRatio)
else if barcounter == 197  then  VolumeProjection[1] + ( avgbar197 * FirstHourRatio)
else if barcounter == 198  then  VolumeProjection[1] + ( avgbar198 * FirstHourRatio)
else if barcounter == 199  then  VolumeProjection[1] + ( avgbar199 * FirstHourRatio)
else if barcounter == 200  then  VolumeProjection[1] + ( avgbar200 * FirstHourRatio)
else if barcounter == 201  then  VolumeProjection[1] + ( avgbar201 * FirstHourRatio)
else if barcounter == 202  then  VolumeProjection[1] + ( avgbar202 * FirstHourRatio)
else if barcounter == 203  then  VolumeProjection[1] + ( avgbar203 * FirstHourRatio)
else if barcounter == 204  then  VolumeProjection[1] + ( avgbar204 * FirstHourRatio)
else if barcounter == 205  then  VolumeProjection[1] + ( avgbar205 * FirstHourRatio)
else if barcounter == 206  then  VolumeProjection[1] + ( avgbar206 * FirstHourRatio)
else if barcounter == 207  then  VolumeProjection[1] + ( avgbar207 * FirstHourRatio)
else if barcounter == 208  then  VolumeProjection[1] + ( avgbar208 * FirstHourRatio)
else if barcounter == 209  then  VolumeProjection[1] + ( avgbar209 * FirstHourRatio)
else if barcounter == 210  then  VolumeProjection[1] + ( avgbar210 * FirstHourRatio)
else if barcounter == 211  then  VolumeProjection[1] + ( avgbar211 * FirstHourRatio)
else if barcounter == 212  then  VolumeProjection[1] + ( avgbar212 * FirstHourRatio)
else if barcounter == 213  then  VolumeProjection[1] + ( avgbar213 * FirstHourRatio)
else if barcounter == 214  then  VolumeProjection[1] + ( avgbar214 * FirstHourRatio)
else if barcounter == 215  then  VolumeProjection[1] + ( avgbar215 * FirstHourRatio)
else if barcounter == 216  then  VolumeProjection[1] + ( avgbar216 * FirstHourRatio)
else if barcounter == 217  then  VolumeProjection[1] + ( avgbar217 * FirstHourRatio)
else if barcounter == 218  then  VolumeProjection[1] + ( avgbar218 * FirstHourRatio)
else if barcounter == 219  then  VolumeProjection[1] + ( avgbar219 * FirstHourRatio)
else if barcounter == 220  then  VolumeProjection[1] + ( avgbar220 * FirstHourRatio)
else if barcounter == 221  then  VolumeProjection[1] + ( avgbar221 * FirstHourRatio)
else if barcounter == 222  then  VolumeProjection[1] + ( avgbar222 * FirstHourRatio)
else if barcounter == 223  then  VolumeProjection[1] + ( avgbar223 * FirstHourRatio)
else if barcounter == 224  then  VolumeProjection[1] + ( avgbar224 * FirstHourRatio)
else if barcounter == 225  then  VolumeProjection[1] + ( avgbar225 * FirstHourRatio)
else if barcounter == 226  then  VolumeProjection[1] + ( avgbar226 * FirstHourRatio)
else if barcounter == 227  then  VolumeProjection[1] + ( avgbar227 * FirstHourRatio)
else if barcounter == 228  then  VolumeProjection[1] + ( avgbar228 * FirstHourRatio)
else if barcounter == 229  then  VolumeProjection[1] + ( avgbar229 * FirstHourRatio)
else if barcounter == 230  then  VolumeProjection[1] + ( avgbar230 * FirstHourRatio)
else if barcounter == 231  then  VolumeProjection[1] + ( avgbar231 * FirstHourRatio)
else if barcounter == 232  then  VolumeProjection[1] + ( avgbar232 * FirstHourRatio)
else if barcounter == 233  then  VolumeProjection[1] + ( avgbar233 * FirstHourRatio)
else if barcounter == 234  then  VolumeProjection[1] + ( avgbar234 * FirstHourRatio)
else if barcounter == 235  then  VolumeProjection[1] + ( avgbar235 * FirstHourRatio)
else if barcounter == 236  then  VolumeProjection[1] + ( avgbar236 * FirstHourRatio)
else if barcounter == 237  then  VolumeProjection[1] + ( avgbar237 * FirstHourRatio)
else if barcounter == 238  then  VolumeProjection[1] + ( avgbar238 * FirstHourRatio)
else if barcounter == 239  then  VolumeProjection[1] + ( avgbar239 * FirstHourRatio)
else if barcounter == 240  then  VolumeProjection[1] + ( avgbar240 * FirstHourRatio)
else if barcounter == 241  then  VolumeProjection[1] + ( avgbar241 * FirstHourRatio)
else if barcounter == 242  then  VolumeProjection[1] + ( avgbar242 * FirstHourRatio)
else if barcounter == 243  then  VolumeProjection[1] + ( avgbar243 * FirstHourRatio)
else if barcounter == 244  then  VolumeProjection[1] + ( avgbar244 * FirstHourRatio)
else if barcounter == 245  then  VolumeProjection[1] + ( avgbar245 * FirstHourRatio)
else if barcounter == 246  then  VolumeProjection[1] + ( avgbar246 * FirstHourRatio)
else if barcounter == 247  then  VolumeProjection[1] + ( avgbar247 * FirstHourRatio)
else if barcounter == 248  then  VolumeProjection[1] + ( avgbar248 * FirstHourRatio)
else if barcounter == 249  then  VolumeProjection[1] + ( avgbar249 * FirstHourRatio)
else if barcounter == 250  then  VolumeProjection[1] + ( avgbar250 * FirstHourRatio)
else if barcounter == 251  then  VolumeProjection[1] + ( avgbar251 * FirstHourRatio)
else if barcounter == 252  then  VolumeProjection[1] + ( avgbar252 * FirstHourRatio)
else if barcounter == 253  then  VolumeProjection[1] + ( avgbar253 * FirstHourRatio)
else if barcounter == 254  then  VolumeProjection[1] + ( avgbar254 * FirstHourRatio)
else if barcounter == 255  then  VolumeProjection[1] + ( avgbar255 * FirstHourRatio)
else if barcounter == 256  then  VolumeProjection[1] + ( avgbar256 * FirstHourRatio)
else if barcounter == 257  then  VolumeProjection[1] + ( avgbar257 * FirstHourRatio)
else if barcounter == 258  then  VolumeProjection[1] + ( avgbar258 * FirstHourRatio)
else if barcounter == 259  then  VolumeProjection[1] + ( avgbar259 * FirstHourRatio)
else if barcounter == 260  then  VolumeProjection[1] + ( avgbar260 * FirstHourRatio)
else if barcounter == 261  then  VolumeProjection[1] + ( avgbar261 * FirstHourRatio)
else if barcounter == 262  then  VolumeProjection[1] + ( avgbar262 * FirstHourRatio)
else if barcounter == 263  then  VolumeProjection[1] + ( avgbar263 * FirstHourRatio)
else if barcounter == 264  then  VolumeProjection[1] + ( avgbar264 * FirstHourRatio)
else if barcounter == 265  then  VolumeProjection[1] + ( avgbar265 * FirstHourRatio)
else if barcounter == 266  then  VolumeProjection[1] + ( avgbar266 * FirstHourRatio)
else if barcounter == 267  then  VolumeProjection[1] + ( avgbar267 * FirstHourRatio)
else if barcounter == 268  then  VolumeProjection[1] + ( avgbar268 * FirstHourRatio)
else if barcounter == 269  then  VolumeProjection[1] + ( avgbar269 * FirstHourRatio)
else if barcounter == 270  then  VolumeProjection[1] + ( avgbar270 * FirstHourRatio)
else if barcounter == 271  then  VolumeProjection[1] + ( avgbar271 * FirstHourRatio)
else if barcounter == 272  then  VolumeProjection[1] + ( avgbar272 * FirstHourRatio)
else if barcounter == 273  then  VolumeProjection[1] + ( avgbar273 * FirstHourRatio)
else if barcounter == 274  then  VolumeProjection[1] + ( avgbar274 * FirstHourRatio)
else if barcounter == 275  then  VolumeProjection[1] + ( avgbar275 * FirstHourRatio)
else if barcounter == 276  then  VolumeProjection[1] + ( avgbar276 * FirstHourRatio)
else na;

plot VP = volumeProjection;
def last_five_d_vol = (
GetValue(data = VOLUME(period = AggregationPeriod.DAY), "dynamic offset" = 1) + 
GetValue(data = VOLUME(period = AggregationPeriod.DAY), "dynamic offset" = 2) + GetValue(data = VOLUME(period = AggregationPeriod.DAY), "dynamic offset" = 3) + GetValue(data = VOLUME(period = AggregationPeriod.DAY), "dynamic offset" = 4) + GetValue(data = VOLUME(period = AggregationPeriod.DAY), "dynamic offset" = 5)) / 5;
def eod = last_five_d_vol * FirstHourRatio;

addLabel(yes, concat("Projected: ", round(eod, 0)), color.dark_orange);
plot ratio = FirstHourRatio;

addLabel(yes, concat("Current: ", round(day_volume / AvgVolSum, 4)), color=if day_volume / AvgVolSum > FirstHourRatio then color.dark_green else color.dark_red);
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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