Above Average Volume by Time for ThinkorSwim

germanburrito

Active member
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);
 

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

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
406 Online
Create Post

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