Advanced Volume Indicator for ThinkorSwim

Status
Not open for further replies.
try this https://tos.mx/bd5tvYX
Code:
def rthStart = 0930;
def rthEnd = 1600;
def conf = SecondsFromTime(rthStart) >= 0 and SecondsFromTime(rthEnd) <= 0;
def ETH_VOL = if !conf and conf[1] then volume else if !conf then CompoundValue(1, ETH_VOL[1] + volume, volume) else ETH_VOL[1];

plot ETHvol = ETH_VOL;
thanks love this...
 
Hi Welkin, thank you for the tremendous work you've done! Couple of questions, if you don't mind.

1) Why it wont work with the tick charts?
2) Is it possible to add a stDev threshold that will hide candles with relative volume below a given value?
3) On buy/sell strength, is it possible to add exact values for ES from Time and Sales, since it trades only on the one exchange or the problem is that thinkorswim does not allow to use this information?
 
Hi Welkin, thank you for the tremendous work you've done! Couple of questions, if you don't mind.

1) Why it wont work with the tick charts?
2) Is it possible to add a stDev threshold that will hide candles with relative volume below a given value?
3) On buy/sell strength, is it possible to add exact values for ES from Time and Sales, since it trades only on the one exchange or the problem is that thinkorswim does not allow to use this information?
1) this is due to script that calls for higher aggregation data (vol strength, and the dayvol labels) here is a lite version with all of that stripped out:
http://tos.mx/xEluGZf
I plan on reworking the indicator at some point to fix all of this... but for now you'll have to use the lite version
2) do not plot volume bars if volume is less than a user specified std dev AND rvol is below a specified value? is this correct? just clarifying
3) correct, it would be nice if we could play around with the t&s data
 
This indicator is fantastic - I have been using a relative volume by time script however it doesnt work too great on shorter time frames ie < 5minutes. I am just trying to display the rvol figure by time of day. Ie what is the volume measure today for this 3 minute candle vs this same 3 minute candle at this same time of day over say 20 periods. Thats real rvol to me as it measures the relative volume for that time of day, vs the average overall as there is different market regimes and characteristics of the market at different times of day. Can anyone point to anything like that here?

The script im using currently is below. If you can improve on it by all means. I just cant get it working for 3m charts or less.

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.cYAN else if volume > avgvol then color.yellow else color.gray);
 
This indicator is fantastic - I have been using a relative volume by time script however it doesnt work too great on shorter time frames ie < 5minutes. I am just trying to display the rvol figure by time of day. Ie what is the volume measure today for this 3 minute candle vs this same 3 minute candle at this same time of day over say 20 periods. Thats real rvol to me as it measures the relative volume for that time of day, vs the average overall as there is different market regimes and characteristics of the market at different times of day. Can anyone point to anything like that here?

The script im using currently is below. If you can improve on it by all means. I just cant get it working for 3m charts or less.

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.cYAN else if volume > avgvol then color.yellow else color.gray);
looks like this script was made specifically for 5 min charts because the barcounter only goes to 81. If you want it to work on a lower time frame you'd need to expand it to cover the number of 3 min bars there are in a regular trading day for 3 min charts, same goes for 1 min. The only other indicator that I know of that is similar in nature is this one from the onenote archive, it does rvol for a 10 day period: https://onedrive.live.com/redir?resid=2FF733D1BA1E1E79!404&authkey=!ABOXXFyQg1iUqFk&page=View&wd=target(05. Technicals/Volume.one|882850bb-78fe-4b41-b8bb-793a94b15bc7/10 Day Relative Volume _ Nube|88975925-9c97-4c71-a8da-38b9e81b857f/)
from the description in the header 'Study displays how much higher or lower current volume is than the average volume of that same bar for prior 10 days.'
 
Last edited:
looks like this script was made specifically for 5 min charts because the barcounter only goes to 81. If you want it to work on a lower time frame you'd need to expand it to cover the number of 3 min bars there are in a regular trading day for 3 min charts, same goes for 1 min. The only other indicator that I know of that is similar in nature is this one from the onenote archive, it does rvol for a 10 day period: https://onedrive.live.com/redir?resid=2FF733D1BA1E1E79!404&authkey=!ABOXXFyQg1iUqFk&page=View&wd=target(05. Technicals/Volume.one|882850bb-78fe-4b41-b8bb-793a94b15bc7/10 Day Relative Volume _ Nube|88975925-9c97-4c71-a8da-38b9e81b857f/)
from the description in the header 'Study displays how much higher or lower current volume is than the average volume of that same bar for prior 10 days.'
Thank you - I think the key takeaway for RVOL for me is to keep it simple and just measure the relative volume for that time interval vs n periods in history. Different times tend to have different characteristics, ie market open far more volatile/price discovery vs noon so measuring RVOL over a general average, vs the average of that time interval is a big one for me. I think ill try and expand it as you say and post the script back here for others to use if they want it.

Quick question - Do you know how i would add the multiple of the average to the top left of the chart? Ie this current bar is 5x more than the average volume for this specific time of day over the last 20 days for example - What would i need add for that. Thank you
 
Thank you - I think the key takeaway for RVOL for me is to keep it simple and just measure the relative volume for that time interval vs n periods in history. Different times tend to have different characteristics, ie market open far more volatile/price discovery vs noon so measuring RVOL over a general average, vs the average of that time interval is a big one for me. I think ill try and expand it as you say and post the script back here for others to use if they want it.

Quick question - Do you know how i would add the multiple of the average to the top left of the chart? Ie this current bar is 5x more than the average volume for this specific time of day over the last 20 days for example - What would i need add for that. Thank you
try adding this line
Code:
AddLabel(1, Round(volume/avgvol,2) +"xAvg / "+TotalSum(daycount)+" Days", if volume > avgvol then color.yellow else color.gray);
 
@Welkin you've been a wizard when it comes to coding with time, could you help me out on a script. How would I get the volume total from 9:30-10:30 to show up on a daily chart. I'm trying to use the morning volume to be predictive of daily volume but I can only access it on the minute chart. I think the issue stems from the fact that you essentially add the volume from every minute in the given time zone and you refer to the previous minute as conf[1] but on charts higher then 1m, conf[1] is larger then a minute. Do you have any ideas?
 
@Welkin you've been a wizard when it comes to coding with time, could you help me out on a script. How would I get the volume total from 9:30-10:30 to show up on a daily chart. I'm trying to use the morning volume to be predictive of daily volume but I can only access it on the minute chart. I think the issue stems from the fact that you essentially add the volume from every minute in the given time zone and you refer to the previous minute as conf[1] but on charts higher then 1m, conf[1] is larger then a minute. Do you have any ideas?
here is a script that will get RTH cumulative volume as well as cumulative volume specified for certain time (T1 in the script)
Code:
#[email protected]

declare lower;
def NA = Double.NaN;
def v = volume;
#Regular Trading Hours
input RTHStart = 0930;
input RTHEnd = 1559;
#T1
input T1Start = 0930;
input T1End = 1029;

#Time Confirmation
def RTHconf = SecondsFromTime(RTHStart) >= 0 and SecondsFromTime(RTHEnd) <= 0;
def T1conf = SecondsFromTime(T1Start) >= 0 and SecondsFromTime(T1End) <= 0;

def RTHvol = if !RTHconf[1] and RTHconf then v else if RTHconf then RTHvol[1] + v else RTHvol[1];
plot rthc = if RTHconf then RTHvol else NA;
def rthcfv = if isnan(rthc) and !isnan(rthc[1]) then rthc[1] else rthcfv[1];

def T1vol = if !T1conf[1] and T1conf then v else if T1conf then T1vol[1] + v else T1vol[1];
plot t1c = if T1conf then T1vol else NA;
def t1cfv = if isnan(t1c) and !isnan(t1c[1]) then t1c[1] else t1cfv[1];

AddLabel(1,"RTH: "+rthcfv, Color.GRAY);
AddLabel(1,"T1: "+t1cfv, Color.GRAY);

rthc.SetDefaultColor(Color.DARK_ORANGE);
t1c.SetDefaultColor(Color.YELLOW);
AddCloud(t1c,0,Color.YELLOW,Color.YELLOW);
AddCloud(rthc,0,Color.GRAY,Color.GRAY);
because you can't pull data from lower aggregations into a higher aggregation (1 min into a daily chart) what I'd recommend is making 2 grids, the top grid being for the daily chart, and the lower grid with a different aggregation and with the price subgraph and volume subgraph disabled in the chart settings so that only lower indicators will show. Like this: http://tos.mx/Nd1ySmB
so this way you can have your daily chart and the lower grid can be for indicators that are of a different aggregation.
R6B8BbV.png
 
Last edited:
@smeg Try this... on watchlist column.

If 3min chart, use bpd = 130, 5min chart bpd = 78, 10min chart def bpd = 39.

Code:
input STime = 0930 ; #hint STime: Start of normal trading hours
input ETime = 1600 ; #hint ETime: End of normal trading hours
input thold = 1.5 ; #hint told: Threshold for color break
#def bpd = 39 ; # 10mins Bars per day during active trading hours
#def bpd = 78 ; # 5mins Bars per day during active trading hours
def bpd = 130 ; # 3mins Bars per day during active trading hours
def daycnt = 10; # Number of days

def IsActive = if secondsTillTime(ETime) > 0 and
secondsFromTime(STime) >= 0
then 1
else 0;


# This is the cumulative volume for the current day between STime and ETime
def cumVolume = if IsActive and !IsActive[1]
then volume[1]
else if IsActive then cumVolume[1] + volume[1]
else cumVolume[1];

# This is the average cumulative volume over the same time period from the previous 10 days
def cumVolumePrev = if IsActive and !IsActive[1]
then (volume[(bpd*1)+1] + volume[(bpd*2)+1] + volume[(bpd*3)+1] + volume[(bpd*4)+1] + volume[(bpd*5)+1] + volume[(bpd*6)+1] + volume[(bpd*7)+1] + volume[(bpd*8)+1] + volume[(bpd*9)+1] + volume[(bpd*10)+1] ) / daycnt
else if IsActive then cumVolumePrev[1] + (volume[(bpd*1)+1] + volume[(bpd*2)+1] + volume[(bpd*3)+1] + volume[(bpd*4)+1] + volume[(bpd*5)+1] + volume[(bpd*6)+1] + volume[(bpd*7)+1] + volume[(bpd*8)+1] + volume[(bpd*9)+1] + volume[(bpd*10)+1] ) / daycnt
else cumVolumePrev[1];

plot RelVol = cumVolume / cumVolumePrev ;

AddLabel(yes, Concat("Rvol: ", Round(RelVol)),Color.YELLOW);
 
Last edited:
In the picture shown below, study where I can find it
The study indicates that if the volume candle is green and the price candle is green, this is a buy signal
And the exact opposite with the red color
Where can I find this study?

uSReq66.png
 
Last edited by a moderator:
Not necessarily a buy signal if the volume bar is green or red unless that is per your own trading rule. And there is no indicator needed for this. Go to your chart's settings > Appearance > Volume bars: Color as simple ticks.

1p1tuz9.png
 
@Trader2003 I see what you're saying now. But how can you say the volume bar is green when the candle is red? Is there a condition that you came up with to make the volume bar green when the candle open's is less than its close?

NOP592R.png
 
Hi @Welkin

How can I make each volume bar skinnier/narrower? Right now, the current setting makes each volume bar look wide (width wise) compared to the TOS default Volume bars.

I tried to change the "Draw as" setting (under plot -> BuyVol) for "BuyVol" and it worked. However, there is no option to do the same thing for the red part (sell strength) of the bar, so it currently looks like this:

45MM7Rv.png
 
Status
Not open for further replies.

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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