Watchlist Column: Average Daily Volume Percentage

hydroflask

New member
I cannot find it on here but I am sure one of you already have this study and would be thankful for a share.

Another thread discusses a study that lists only the average daily volume in the column.

I want to see what percentage of the daily volume average we are currently sitting at in the watchlist column.

If it is a choppy day and is 12:30pm and we are only at 15% of the 30 day average volume, I will go do other things with my time.

If it is 10:00am and we are at 50% of the 30 day average volume, I will pay attention.
 

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

Hi BenTen, thanks for the response.

That's the thread I was referring to.

That script lists the Average Daily Volume, not the percentage of the Average Daily Volume we are currently at.

It also doesn't calculate it correctly from what I can see. /ES for example has a 30 ADV of 1,503,943 and this script displays 1,268,722 after adjusting it to 30 days.

The script below is what I use to display the percentage on the chart.

I cannot translate it into a column script because the calculations are way off for some reason.

It will also freeze when aftermarket hours start and only reset when premarket hours start.

Hence I wanted to see if anyone already had a functioning column script and could share.

Code:
declare upper;

#Inputs
input Show30DayAvg = no;
input ShowTodayVolume =  no;
input ShowPercentOf30DayAvg = yes;
input UnusualVolumePercent = 75;
input Show30BarAvg = no;
input ShowCurrentBar = no;


#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 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 curVolume = volume;


# Labels
AddLabel(Show30DayAvg, "Daily Avg: " + Round(volLast30DayAvg, 0), Color.LIGHT_GRAY);
AddLabel(ShowTodayVolume, "Today: " + today, (if percentOf30Day >= UnusualVolumePercent then Color.RED else if percentOf30Day >= 100 then Color.ORANGE else Color.LIGHT_GRAY));
AddLabel(ShowPercentOf30DayAvg, percentOf30Day + "%", (if percentOf30Day >= UnusualVolumePercent then Color.RED 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.RED else Color.ORANGE));
 
You can see that it works for equities, but not futures. Does anyone have this, or is it a niche study?

Ex. AMZN:

94I4eIn.png


Ex. GC:

KmChh1P.png
 
Hi BenTen, thanks for the response.

That's the thread I was referring to.

That script lists the Average Daily Volume, not the percentage of the Average Daily Volume we are currently at.

It also doesn't calculate it correctly from what I can see. /ES for example has a 30 ADV of 1,503,943 and this script displays 1,268,722 after adjusting it to 30 days.

The script below is what I use to display the percentage on the chart.

I cannot translate it into a column script because the calculations are way off for some reason.

It will also freeze when aftermarket hours start and only reset when premarket hours start.

Hence I wanted to see if anyone already had a functioning column script and could share.

Code:
declare upper;

#Inputs
input Show30DayAvg = no;
input ShowTodayVolume =  no;
input ShowPercentOf30DayAvg = yes;
input UnusualVolumePercent = 75;
input Show30BarAvg = no;
input ShowCurrentBar = no;


#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 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 curVolume = volume;


# Labels
AddLabel(Show30DayAvg, "Daily Avg: " + Round(volLast30DayAvg, 0), Color.LIGHT_GRAY);
AddLabel(ShowTodayVolume, "Today: " + today, (if percentOf30Day >= UnusualVolumePercent then Color.RED else if percentOf30Day >= 100 then Color.ORANGE else Color.LIGHT_GRAY));
AddLabel(ShowPercentOf30DayAvg, percentOf30Day + "%", (if percentOf30Day >= UnusualVolumePercent then Color.RED 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.RED else Color.ORANGE));

i'll guess futures data isn't gathered correctly because that study uses 2nd aggregation of day, which i think is 9:30 to 4, and futures are 4:45 to 4.

maybe if the code was changed to use,
RegularTradingStart()
RegularTradingend()
it would work?

def RTH = getTime() >= regularTradingStart(getYYYYMMDD()) and
getTime() <= regularTradingEnd(getYYYYMMDD());

i don't trade futures, so can't test code, so hopefully someone else can help.

https://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Date---Time/RegularTradingStart

futures
https://www.cboe.com/about/hours/us-futures/
 
You can see that it works for equities, but not futures. Does anyone have this, or is it a niche study?
i explained this in a different thread. I noticed you are running the script on a 5 minute chart which is smaller than the Day chart. TD's tick data is dependent on their data source and is received in "bulk package". when it comes specifically to VOLUME and tick, Sometimes there will be a SLIGHT difference in it compared to other data sources. However the larger time frame (DAY timeframe) will normally fix this error to correctly reflect the total day's volume, however smaller timeframes may miss a few ticks and slightly differ when TD scripts attempt to grab the data on smaller time frames and attempt to add it to the OFFICIAL day's total volume. If you want true tick data you will have to find a different broker and platform and take note that you will probably have to pay for this kind of data and obtain a subscription. If tick is important you may want to look into https://www.cqg.com/
trust me i ran into the same problem on a volume script so i had researched it online and spent almost a whole day fiddling with different code to come to the same conclusion that i had read elsewhere thats its just the way TD grabs the tick data.


As and example you can see this thread:
https://usethinkscript.com/threads/...st-scan-label-for-thinkorswim.970/post-127571
if you use that script you will see the difference in how it counts the volume by bar vs the official DAY aggregated volume


My personal advice would be to make the script run and calculate from the day aggregation to get a accurate calculation.
 
Last edited:
i explained this in a different thread. I noticed you are running the script on a 5 minute chart which is smaller than the Day chart. TD's tick data is dependent on their data source and is received in "bulk package". when it comes specifically to VOLUME and tick, Sometimes there will be a SLIGHT difference in it compared to other data sources. However the larger time frame (DAY timeframe) will normally fix this error to correctly reflect the total day's volume, however smaller timeframes may miss a few ticks and slightly differ when TD scripts attempt to grab the data on smaller time frames and attempt to add it to the OFFICIAL day's total volume. If you want true tick data you will have to find a different broker and platform and take note that you will probably have to pay for this kind of data and obtain a subscription. If tick is important you may want to look into https://www.cqg.com/
trust me i ran into the same problem on a volume script so i had researched it online and spent almost a whole day fiddling with different code to come to the same conclusion that i had read elsewhere thats its just the way TD grabs the tick data.

My personal advice would be to make the script run and calculate from the day aggregation to get a accurate calculation.
Thanks for your input. To clarify, the script on the chart is actually correct on all time frames, it's the script in the column that isn't calculating correctly.
 
Thanks for your input. To clarify, the script on the chart is actually correct on all time frames, it's the script in the column that isn't calculating correctly.
im seeing
1689218648724.png

and from the code i see you are trying to grab the last 30 days, maybe the column is correct and your chart is wrong, remember the indicators can only grab what is visible on the chart, you have 5 days visible but trying to compare 30 days.
 
im seeing
View attachment 19136
and from the code i see you are trying to grab the last 30 days, maybe the column is correct and your chart is wrong, remember the indicators can only grab what is visible on the chart, you have 5 days visible but trying to compare 30 days.
Thanks for taking a look. I'm working on 180 day charts and it doesn't work there either. I think it would take a high level coder to figure this one out.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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