Average Daily Volume Watchlist Column for ThinkorSwim

Hi All. I am stuck on this one. I really like to have a column in my watchlist next to volume for average daily volume for a 60 day period. I have it, but the column's format is off, it has no commas and has decimals. Would like it to look just like the volume number format. Is this possible?

I am using the ThinkScript VolumeAvg ("length" = 60) . "volavg"
 

blakedipp

New member
Hello all,

I am trying to code an info box to convert average daily volume into a Tick count for tick charts. I am not well versed in coding or thinkscript.

eFoEO8v.jpg


Basically, if the volLast30DayAvg meets a certaincriteria, then it will show one of the calculations A through F in the Tick Counter Box on my chart. Any tips? Thanks.

Code:
plot Data = close;
declare lower;


input TickCounter = yes;

#Volume Data
def volLast30DayAvg = (volume(period = "DAY")[1] + volume(period = "DAY")[2] + volume(period = "DAY")[3] + volume(period = "DAY")[4] + volume(period = "DAY")[5] + volume(period = "DAY")[6] + volume(period = "DAY")[7] + volume(period = "DAY")[8] + volume(period = "DAY")[9] + volume(period = "DAY")[10] + volume(period = "DAY")[11] + volume(period = "DAY")[12] + volume(period = "DAY")[13] + volume(period = "DAY")[14] + volume(period = "DAY")[15] + volume(period = "DAY")[16] + volume(period = "DAY")[17] + volume(period = "DAY")[18] + volume(period = "DAY")[19] + volume(period = "DAY")[20] + volume(period = "DAY")[21] + volume(period = "DAY")[22] + volume(period = "DAY")[23] + volume(period = "DAY")[24] + volume(period = "DAY")[25] + volume(period = "DAY")[26] + volume(period = "DAY")[27] + volume(period = "DAY")[28] + volume(period = "DAY")[29] + volume(period = "DAY")[30]) / 30;



# Variables:
def a;
def b;
def c;
def d;
def e;
def f;

# Calculations
a = 144;
b = 333;
c = 800;
d = 1600;
e = 3200;
f = 10000;

def SHowTickNumber = if VolLast30DayAvg < 5000000 then plot a;



AddLabel (TickCounter, "TICK: " + ShowTickNumber);
 

estebankaras

New member
Hello everyone, congratulations on your work, I need to put a parameter in my TOS watchlist that measures the average volume of the last 60 days compared to the newspaper, to make a volume scanning strategy at the moment in my watchlist, I also An unusual volume scan would serve to locate the actions so I could focus on the intradays. Thank you
;)
 

Krak£n

New member
Hello there,

I'm looking for a script which I will use in my watchlist and it will show me the %change using this argument (volume/shares)*100%

1. Volume = traded today
2. Shares = shares outstanding


Thank you!!!
 
Last edited by a moderator:

perseverance_trading1

New member
VIP
I am having some trouble displaying a watchlist item (5min volume % based on a 30 day avg) that is displayed in a chart but not in the watchlist.

In summary, I am looking to display the 5 min volume total as a percentage of the 30 day volume average.
This is basically a guide to highlight how much volume has been traded in the current 5 min window compared to a 30 day average.

Any thoughts what can be done to see the plot (5min vol / 30day vol)?
plot percentofMinVol = Round((currentMinVolNow / volLast30DayAvg) * 100, 0);

Visual of the item requested (see yellow arrow):

48OoP7N.png


PkTRjwt.png


Watchlist code (note the plot item)

Code:
# Box Volume Stats
# Version 1.0
# Created by: Enigma
# Created: 05/18/17

declare lower;

#Inputs WORKING PRIOR WITH 5min%Avg
input Show30DayAvg = no;
input ShowTodayVolume =  no;
input ShowPercentOf30DayAvg = no;
input UnusualVolumePercent = 200;
input Show30BarAvg = no;
input Show10BarAvg = no;
input ShowCurrentBar = no;
input ShowCurrent3MinVBar = no;
input ShowCurrentMinVBar = yes;


#Volume Data
def volLast30DayAvg = (volume(period = "DAY")[1] + volume(period = "DAY")[2] + volume(period = "DAY")[3] + volume(period = "DAY")[4] + volume(period = "DAY")[5] + volume(period = "DAY")[6] + volume(period = "DAY")[7] + volume(period = "DAY")[8] + volume(period = "DAY")[9] + volume(period = "DAY")[10] + volume(period = "DAY")[11] + volume(period = "DAY")[12] + volume(period = "DAY")[13] + volume(period = "DAY")[14] + volume(period = "DAY")[15] + volume(period = "DAY")[16] + volume(period = "DAY")[17] + volume(period = "DAY")[18] + volume(period = "DAY")[19] + volume(period = "DAY")[20] + volume(period = "DAY")[21] + volume(period = "DAY")[22] + volume(period = "DAY")[23] + volume(period = "DAY")[24] + volume(period = "DAY")[25] + volume(period = "DAY")[26] + volume(period = "DAY")[27] + volume(period = "DAY")[28] + volume(period = "DAY")[29] + volume(period = "DAY")[30]) / 30;
def today = volume(period = "DAY");
def percentOf30Day = Round((today / volLast30DayAvg) * 100, 0);

def currentMinVolNow = volume(period = "5 MIN");
plot percentofMinVol = Round((currentMinVolNow / volLast30DayAvg) * 100, 0);


#def avg30Bars = VolumeAvg(30).VolAvg;
def avg30Bars = (volume[1] + volume[2] + volume[3] + volume[4] + volume[5] + volume[6] + volume[7] + volume[8] + volume[9] + volume[10] + volume[11] + volume[12] + volume[13] + volume[14] + volume[15] + volume[16] + volume[17] + volume[18] + volume[19] + volume[20] + volume[21] + volume[22] + volume[23] + volume[24] + volume[25] + volume[26] + volume[27] + volume[28] + volume[29] + volume[30]) / 30;
#def avg10Bars = VolumeAvg(10).VolAvg;
def avg10Bars = (volume[1] + volume[2] + volume[3] + volume[4] + volume[5] + volume[6] + volume[7] + volume[8] + volume[9] + volume[10]) / 10;
def curVolume = volume;


# Labels
AddLabel(Show30DayAvg, "Daily Avg: " + Round(volLast30DayAvg, 0), Color.LIGHT_GRAY);
AddLabel(ShowTodayVolume, "Today: " + today, (if percentOf30Day >= UnusualVolumePercent then Color.GREEN else if percentOf30Day >= 100 then Color.ORANGE else Color.LIGHT_GRAY));
AddLabel(ShowPercentOf30DayAvg, percentOf30Day + "%", (if percentOf30Day >= UnusualVolumePercent then Color.GREEN else if percentOf30Day >= 100 then Color.ORANGE else Color.WHITE) );
AddLabel(Show30BarAvg, "Avg 30 Bars: " + Round(avg30Bars, 0), Color.LIGHT_GRAY);
AddLabel(ShowCurrentBar, "Cur Bar: " + curVolume, (if curVolume >= avg30Bars then Color.GREEN else Color.ORANGE));
AddLabel(ShowCurrentMinVBar, + percentofMinVol + "%", (if percentofMinVol >= UnusualVolumePercent then Color.GREEN else if percentofMinVol >= 100 then Color.ORANGE else Color.WHITE) );
AddLabel(Show10BarAvg, "Avg 10 Bars: " + Round(avg10Bars, 0), Color.LIGHT_GRAY);
 
Last edited:

BenTen

Administrative
Staff member
Staff
VIP
There are too many plots and labels in that script to be displayed properly as a watchlist column. So you just want to show the "5minAvg" in your column, correct?
 

perseverance_trading1

New member
VIP
I cleaned it up to try to remove the other items not needed.

Code:
# Box Volume Stats
# Version 1.0
# Created by: Enigma
# Created: 05/18/17
 
declare lower;

#Inputs WORKING PRIOR WITH 5min%Avg

input ShowPercentOf30DayAvg = no;
input UnusualVolumePercent = 200;
input ShowCurrent3MinVBar = no;
input ShowCurrentMinVBar = yes;


#Volume Data
def volLast30DayAvg = (volume(period = "DAY")[1] + volume(period = "DAY")[2] + volume(period = "DAY")[3] + volume(period = "DAY")[4] + volume(period = "DAY")[5] + volume(period = "DAY")[6] + volume(period = "DAY")[7] + volume(period = "DAY")[8] + volume(period = "DAY")[9] + volume(period = "DAY")[10] + volume(period = "DAY")[11] + volume(period = "DAY")[12] + volume(period = "DAY")[13] + volume(period = "DAY")[14] + volume(period = "DAY")[15] + volume(period = "DAY")[16] + volume(period = "DAY")[17] + volume(period = "DAY")[18] + volume(period = "DAY")[19] + volume(period = "DAY")[20] + volume(period = "DAY")[21] + volume(period = "DAY")[22] + volume(period = "DAY")[23] + volume(period = "DAY")[24] + volume(period = "DAY")[25] + volume(period = "DAY")[26] + volume(period = "DAY")[27] + volume(period = "DAY")[28] + volume(period = "DAY")[29] + volume(period = "DAY")[30]) / 30;
def today = volume(period = "DAY");
def currentMinVolNow = volume(period = "5 MIN");

plot percentofMinVol = Round((currentMinVolNow / volLast30DayAvg) * 100, 0);


def curVolume = volume;
 

perseverance_trading1

New member
VIP
Well, I found out that TOS does not support Daily and intraday calculations within the watchlist and that the intraday time frame only allows 5-6 days worth of data.

I then removed the 30 day avg reference and expanded what I could of the available intraday data until TOS was giving me errors inside the watchlist area (I then knew how much data a 5 min period could hold)

The key take away from this is if you want something bad enough, you kind of have to stick with it long enough to make it work.
Ideally, this watchlist column would capture 30 days average volume and compare against the current 5 min period but that is not possible in TOS. I did what I could based on the limitations of the system.

This is basically taking 120 periods of data on a 5 min period starting from 141 period ago and comparing the most recent period against that average to compute a figure which gives a relative sign of strength (or lack there of) based on the current 5 min volume bar.

If anyone can use the code, feel free to use it.

Thank you for reading.

Code:
# Box Volume Stats
# Version 1.0
# Created by: PerseveranceTrading
# Created: 12/9/20
 
declare lower;

#Inputs WORKING PRIOR WITH 5min%Avg

input ShowCurrentMinVBar = yes;


#Volume Data
def volLast3DayAvg = (volume(period = "5 MIN")[141] + volume(period = "5 MIN")[142] + volume(period = “5 MIN”)[143] + volume(period = “5 MIN”)[144] + volume(period = “5 MIN”)[145] + volume(period = “5 MIN”)[146] + volume(period = “5 MIN”)[147] + volume(period = “5 MIN”)[148] + volume(period = “5 MIN”)[149] + volume(period = “5 MIN”)[150] + volume(period = “5 MIN”)[151] + volume(period = “5 MIN”) [152] + volume(period = “5 MIN”)[153] + volume(period = “5 MIN”)[154] + volume(period = “5 MIN”)[155] + volume(period = “5 MIN”)[156] + volume(period = “5 MIN”)[157] + volume(period = “5 MIN”)[158] + volume(period = “5 MIN”)[159] + volume(period = “5 MIN”)[160] + volume(period = “5 MIN”)[161] + volume(period = “5 MIN”)[162] + volume(period = “5 MIN”)[163] + volume(period = “5 MIN”)[164] + volume(period = “5 MIN”)[165] + volume(period = “5 MIN”)[166] + volume(period = “5 MIN”)[167] + volume(period = “5 MIN”)[168] + volume(period = “5 MIN”)[169] + volume(period = “5 MIN”)[170] + volume(period = "5 MIN")[171] + volume(period = "5 MIN")[172] + volume(period = “5 MIN”)[173] + volume(period = “5 MIN”)[174] + volume(period = “5 MIN”)[175] + volume(period = “5 MIN”)[176] + volume(period = “5 MIN”)[177] + volume(period = “5 MIN”)[178] + volume(period = “5 MIN”)[179] + volume(period = “5 MIN”)[180] + volume(period = “5 MIN”)[181] + volume(period = “5 MIN”)[182] + volume(period = “5 MIN”)[183] + volume(period = “5 MIN”)[184] + volume(period = “5 MIN”)[185] + volume(period = “5 MIN”)[186] + volume(period = “5 MIN”)[187] + volume(period = “5 MIN”)[188] + volume(period = “5 MIN”)[189] + volume(period = “5 MIN”)[190] + volume(period = “5 MIN”)[191] + volume(period = “5 MIN”)[192] + volume(period = “5 MIN”)[193] + volume(period = “5 MIN”)[194] + volume(period = “5 MIN”)[195] + volume(period = “5 MIN”)[196] + volume(period = “5 MIN”)[197] + volume(period = “5 MIN”)[198] + volume(period = “5 MIN”)[199] + volume(period = “5 MIN”)[200])+
(volume(period = "5 MIN")[201] + volume(period = "5 MIN")[202] + volume(period = “5 MIN”)[203] + volume(period = “5 MIN”)[204] + volume(period = “5 MIN”)[205] + volume(period = “5 MIN”)[206] + volume(period = “5 MIN”)[207] + volume(period = “5 MIN”)[208] + volume(period = “5 MIN”)[209] + volume(period = “5 MIN”)[210] + volume(period = “5 MIN”)[211] + volume(period = “5 MIN”)[212] + volume(period = “5 MIN”)[213] + volume(period = “5 MIN”)[214] + volume(period = “5 MIN”)[215] + volume(period = “5 MIN”)[216] + volume(period = “5 MIN”)[217] + volume(period = “5 MIN”)[218] + volume(period = “5 MIN”)[219] + volume(period = “5 MIN”)[220] + volume(period = “5 MIN”)[221] + volume(period = “5 MIN”)[222] + volume(period = “5 MIN”)[223] + volume(period = “5 MIN”)[224] + volume(period = “5 MIN”)[225] + volume(period = “5 MIN”)[226] + volume(period = “5 MIN”)[227] + volume(period = “5 MIN”)[228] + volume(period = “5 MIN”)[229] + volume(period = “5 MIN”)[230] + volume(period = "5 MIN")[231] + volume(period = "5 MIN")[232] + volume(period = “5 MIN”)[233] + volume(period = “5 MIN”)[234] + volume(period = “5 MIN”)[235] + volume(period = “5 MIN”)[236] + volume(period = “5 MIN”)[237] + volume(period = “5 MIN”)[238] + volume(period = “5 MIN”)[239] + volume(period = “5 MIN”)[240] + volume(period = “5 MIN”)[241] + volume(period = “5 MIN”)[242] + volume(period = “5 MIN”)[243] + volume(period = “5 MIN”)[244] + volume(period = “5 MIN”)[245] + volume(period = “5 MIN”)[246] + volume(period = “5 MIN”)[247] + volume(period = “5 MIN”)[248] + volume(period = “5 MIN”)[249] + volume(period = “5 MIN”)[250] + volume(period = “5 MIN”)[251] + volume(period = “5 MIN”)[252] + volume(period = “5 MIN”)[253] + volume(period = “5 MIN”)[254] + volume(period = “5 MIN”)[255] + volume(period = “5 MIN”)[256] + volume(period = “5 MIN”)[257] + volume(period = “5 MIN”)[258] + volume(period = “5 MIN”)[259] + volume(period = “5 MIN”)[260])/ 160;
def today = volume(period = “5 MIN”);
def currentMinVolNow = volume(period = "5 MIN");

plot percentofMinVol = Round((currentMinVolNow / volLast3DayAvg) * 100, 0);


def curVolume = volume;
 
Last edited:

rogtrader

Member
Well, we shouldn’t do compare 5m volume to daily average.. can we divide daily volume in to 5m averages? The daily average is for 6.5 hours(390 min)? I guess ext volume is aggregated into daily volume, right?

So average 5m volume = (average daily volume /390)*5

What do you guys say?
 

perseverance_trading1

New member
VIP
Well, we shouldn’t do compare 5m volume to daily average.. can we divide daily volume in to 5m averages? The daily average is for 6.5 hours(390 min)? I guess ext volume is aggregated into daily volume, right?

So average 5m volume = (average daily volume /390)*5

What do you guys say?
Thanks for the reply Rogtrader. I believe the problem with watchlists in TOS, if I understand it correctly, is that in order to compute average daily volume in the watchlist, you need to manually gather the daily volume and TOS does not allow one to work with daily data and intraday data in the watchlist (this constraint is not enforced on the charts though). If you do use intraday data (like 5 min), you can only go back a few days. The solution that you present is along the lines of what I was asking for. To get around this limitation, the code above collects as much data as is allowed for the 5min period and compares the most current period against that limited dataset. For what I am doing, this does work as it helps show those tickers with high relative volume in real time.
 

perseverance_trading1

New member
VIP
@rudy seena In order to view the code below in your chart, you need to be on a 1min, 2min or 3min chart. The data readings for the 3min%avg, 5min%avg, 15min%avg will be the same and still reflect the same #'s. For some reason TOS does not display the indicator on a timeframe greater than 3 min. I do not know why. I suspect it has to do with a constraint in TOS similar to the constraint for gathering the data in the watchlist.

Cheers!

Code:
# Box Volume Stats
# Version 1.0
# Created by: Enigma
# Created: 05/18/17
# Improved 01/05/21

declare lower;

#Inputs WORKING PRIOR WITH 5min%Avg
input Show30DayAvg = yes;
input ShowTodayVolume =  yes;
input ShowPercentOf30DayAvg = yes;
input UnusualVolumePercent = 200;
input Show30BarAvg = no;
input Show10BarAvg = no;
input ShowCurrentBar = yes;
input ShowCurrentMinVBar = yes;
input ShowCurrent15MinVBar = yes;
input ShowCurrent3MinVBar = yes;



#Volume Data
def volLast30DayAvg = (volume(period = "DAY")[1] + volume(period = "DAY")[2] + volume(period = "DAY")[3] + volume(period = "DAY")[4] + volume(period = "DAY")[5] + volume(period = "DAY")[6] + volume(period = "DAY")[7] + volume(period = "DAY")[8] + volume(period = "DAY")[9] + volume(period = "DAY")[10] + volume(period = "DAY")[11] + volume(period = "DAY")[12] + volume(period = "DAY")[13] + volume(period = "DAY")[14] + volume(period = "DAY")[15] + volume(period = "DAY")[16] + volume(period = "DAY")[17] + volume(period = "DAY")[18] + volume(period = "DAY")[19] + volume(period = "DAY")[20] + volume(period = "DAY")[21] + volume(period = "DAY")[22] + volume(period = "DAY")[23] + volume(period = "DAY")[24] + volume(period = "DAY")[25] + volume(period = "DAY")[26] + volume(period = "DAY")[27] + volume(period = "DAY")[28] + volume(period = "DAY")[29] + volume(period = "DAY")[30]) / 30;
def today = volume(period = "DAY");
def currentMinVolNow = volume(period = "5 MIN");
def current15MinVolNow = volume(period = "15 MIN");
def current3MinVolNow = volume(period = "3 MIN");


def percentOf30Day = Round((today / volLast30DayAvg) * 100, 0);
def percentofMinVol = Round((currentMinVolNow / volLast30DayAvg) * 100, 0);
def percentof15MinVol = Round((current15MinVolNow / volLast30DayAvg) * 100, 0);
def percentof3MinVol = Round((current3MinVolNow / volLast30DayAvg) * 100, 0);

#def avg30Bars = VolumeAvg(30).VolAvg;
def avg30Bars = (volume[1] + volume[2] + volume[3] + volume[4] + volume[5] + volume[6] + volume[7] + volume[8] + volume[9] + volume[10] + volume[11] + volume[12] + volume[13] + volume[14] + volume[15] + volume[16] + volume[17] + volume[18] + volume[19] + volume[20] + volume[21] + volume[22] + volume[23] + volume[24] + volume[25] + volume[26] + volume[27] + volume[28] + volume[29] + volume[30]) / 30;
#def avg10Bars = VolumeAvg(10).VolAvg;
def avg10Bars = (volume[1] + volume[2] + volume[3] + volume[4] + volume[5] + volume[6] + volume[7] + volume[8] + volume[9] + volume[10]) / 10;
def curVolume = volume;


# Labels
AddLabel(Show30DayAvg, "Daily Avg: " + Round(volLast30DayAvg, 0), Color.LIGHT_GRAY);
AddLabel(ShowTodayVolume, "Today: " + today, (if percentOf30Day >= UnusualVolumePercent then Color.GREEN else if percentOf30Day >= 100 then Color.ORANGE else Color.LIGHT_GRAY));
AddLabel(ShowPercentOf30DayAvg, percentOf30Day + "%", (if percentOf30Day >= UnusualVolumePercent then Color.GREEN else if percentOf30Day >= 100 then Color.ORANGE else Color.WHITE) );
AddLabel(Show30BarAvg, "Avg 30 Bars: " + Round(avg30Bars, 0), Color.LIGHT_GRAY);
AddLabel(ShowCurrentBar, "Cur Bar: " + curVolume, (if curVolume >= avg30Bars then Color.GREEN else Color.ORANGE));
AddLabel(ShowCurrent3MinVBar, "3min%Avg: " + percentof3MinVol + "%", (if percentof3MinVol >= UnusualVolumePercent then Color.GREEN else if percentof3MinVol >= 100 then Color.ORANGE else Color.WHITE) );
AddLabel(ShowCurrentMinVBar, "5min%Avg: " + percentofMinVol + "%", (if percentofMinVol >= UnusualVolumePercent then Color.GREEN else if percentofMinVol >= 100 then Color.ORANGE else Color.WHITE) );
AddLabel(ShowCurrent15MinVBar, "15min%Avg: " + percentof15MinVol + "%", (if percentof15MinVol >= UnusualVolumePercent then Color.GREEN else if percentof15MinVol >= 100 then Color.ORANGE else Color.WHITE) );
AddLabel(Show10BarAvg, "Avg 10 Bars: " + Round(avg10Bars, 0), Color.LIGHT_GRAY);
 

rad14733

Moderator
Staff member
VIP
@perseverance_trading1 You are correct, but it is a limitation based on the Thinkscript code, not TOS in particular... The lowest average in the code is 3m which dictates the minimum timeframe... It was designed to be run on a 2m chart based on the original images posted in this topic... You would need to modify the code if you want to use it on higher timeframes... You can use higher TF averages but not lower TF averages than what your chart is set to... I believe this would be a limitation for any trading platform...
 

Similar threads

Top