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"
 

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

This custom Thinkscript indicator shows you important volume data on your ThinkOrSwim charts. This includes Current Volume, Average 30 Day Volume, Percentage of Current Volume to Average Daily Volume, Average 30 Bar Volume and Current Bar Volume. Volume stats change colors to indicate when the volume reaches the average daily volume level as well as a customizable unusual volume level. This allows you to easily see critical changes in volume levels which are important for all types of trading.

The Script:

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

declare lower;

#Inputs
input Show30DayAvg = yes;
input ShowTodayVolume =  yes;
input ShowPercentOf30DayAvg = yes;
input UnusualVolumePercent = 200;
input Show30BarAvg = yes;
input ShowCurrentBar = 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 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.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));

Shared link: https://tos.mx/rSGwbW

YouTube

any easy formula for calculating average daily volume for 365 days ? :(
 
looking for this average volume column to display % average volume for 4 hour and 65min chart,
math seems incorrect when i backtest, essentially 100% is average volume and 200% is double average.
i tried adding the aggregation period still not getting accurate result.
thank you

input length = 30;
input unusualvolumepercent = 200;
input showpercentof30dayavg = yes;
def today = volume;
plot percentof30day = round(today/ average(today,length)*100,0);
percentof30day.assignvalueColor( (if percentOf30Day >= UnusualVolumePercent then Color.orange else if percentOf30Day >= 100 then Color.green else Color.light_gray) );
 
looking for this average volume column to display % average volume for 4 hour and 65min chart,
math seems incorrect when i backtest, essentially 100% is average volume and 200% is double average.
i tried adding the aggregation period still not getting accurate result.
thank you

input length = 30;
input unusualvolumepercent = 200;
input showpercentof30dayavg = yes;
def today = volume;
plot percentof30day = round(today/ average(today,length)*100,0);
percentof30day.assignvalueColor( (if percentOf30Day >= UnusualVolumePercent then Color.orange else if percentOf30Day >= 100 then Color.green else Color.light_gray) );
The ToS platform does not support referencing an aggregation period in watchlist column scripts
https://usethinkscript.com/threads/answers-to-commonly-asked-questions.6006/#post-58081
 
@MerryDay, the code in post #2 works great and is exactly what I am looking for however when I sort the watchlist column from high to low or vice versa, the column is sorted incorrectly. My guess is that this has something to do with the word "round" in the code. Any way you'd be able to fix this?

In addition to using this as a watchlist column, I am also using this as a chart label, would you be able to add a way to change the color of the label? TIA
 
Last edited:
@MerryDay, the code in post #2 works great and is exactly what I am looking for however when I sort the watchlist column from high to low or vice versa, the column is sorted incorrectly. My guess is that this has something to do with the word "round" in the code. Any way you'd be able to fix this? TIA
Nope. It is because it is set up as a label.
Think about it. We think and ToS thinks of "labels" as words. You can't sort 'words' numerically.
copy & paste this into your watchlist:
round( Average(volume, 60), 0 )
Sort away, and have fun.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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