Volume Stats Format, Watchlist, Scan, Label for ThinkOrSwim

IM SUPER IMPRESSED with this BOX VOLUME STATS indicator by enigma. I'm equally or even more impressed that some of you programming wizards are able to take existing code and modify it to accommodate other aspects. I have tried quite a few times and now that my fingers are bleeding. Im hoping to get some help.

I would like to convert this Enigmas indicator to be able to copy and paste in the Studies custom think script editor for the scanner, so i can save the scan. It would be nice to have the ability to change the percentage in the code to allow for different watchlists that alert (ex: 1 watchlist for 100% daily avg. volume another thats 200% or whatever percent anybody wanted to get a scan alert when it hit)

This would help because then instead of speed clicking down a watchlist of 100+ in the morning to see what tickers might be worth jumping in because volume is cooking would then just be able to have them narrowed down already in the scanners updated watchlist... Let me know if its feasible, I APPRECIATE YA!
Ruby:
# Box Volume Stats
# Version 1.2
# Created by: Enigma
# Created: 05/18/17
# Modified by: Surya Kiran C ## Included rVolume label and Changed length as input. ## Additionally Pre-Market, 1Hr Volume, AfterHour Volume labels are added.


declare on_volume;

input length = 30;
input ShowDayAvg = yes;
input ShowTodayVolume = yes;
input ShowPercentOfDayAvg = yes;
input UnusualVolumePercent = 200;
input ShowBarAvg = yes;
input ShowCurrentBar = yes;

input PreMktVol = yes;
input RTH1HrVol = yes;
input PostMktVol = yes;


def VolDayAvg = (fold index = 1 to length + 1 with Avg = 0 do (Avg + volume(period = "DAY")[index])) / length;
def AvgBars = (fold index2 = 1 to length + 1 with Bar = 0 do (Bar + volume[index2])) / length;

def Today = volume(period = "DAY");
def PercentOfDayAvg = Round((Today / VolDayAvg) * 100, 0);

def CurVol = volume;


def offset = 1;
def ADV = Average(volume, length)[offset];
def rVol = volume / ADV;

# Labels

#if GetAggregationPeriod() >= AggregationPeriod.DAY then 0 else if 1HrRTHVol then 1 else 0,

AddLabel(ShowDayAvg, length + "Day Avg: " + Round(VolDayAvg, 0) + " ", Color.LIGHT_GRAY);
AddLabel(ShowTodayVolume, "Today: " + Today + " ", (if PercentOfDayAvg >= UnusualVolumePercent then Color.GREEN else if PercentOfDayAvg >= 100 then Color.ORANGE else Color.LIGHT_GRAY));
AddLabel(ShowPercentOfDayAvg, PercentOfDayAvg + "%", (if PercentOfDayAvg >= UnusualVolumePercent then Color.GREEN else if PercentOfDayAvg >= 100 then Color.ORANGE else Color.WHITE) );
AddLabel(ShowBarAvg, "Avg" + length + "Bars: " + Round(AvgBars, 0) + " ", Color.LIGHT_GRAY);
AddLabel(ShowCurrentBar, "Cur Bar: " + CurVol + " ", (if CurVol >= AvgBars then Color.GREEN else Color.ORANGE));

AddLabel(yes, "rVol :" + Round(rVol, 2));
#AddLabel(yes, "ADV :" + ADV);
#AddLabel(yes, asPercent(rVol)); # remove "#" infront of Addlabels to select prefer choice
#AssignPriceColor(if rVol >= 1 then color.dark_red else if rVol <=.5 then Color.black else color.Gray);

#Pre, 1Hr RTH, AfterHours Volumes.
##if GetAggregationPeriod() >= AggregationPeriod.DAY then 0 else if PreMktVol then 1 else 0

input PrestartTime = 0400;
input PreendTime = 0929;

def PreMkt = SecondsFromTime(PrestartTime) >= 0 and SecondsTillTime(PreendTime) >= 0;
def PreVolMins = if PreMkt and !PreMkt[1] then volume
else if PreMkt then PreVolMins[1] + volume
else PreVolMins[1];
AddLabel(if GetAggregationPeriod() >= AggregationPeriod.DAY then 0 else if PreMktVol then 1 else 0, "PreMktVol = " + PreVolMins + " ", Color.Gray);
# End Volume PreMarket

input RTH1HrstartTime = 0930;
input RTH1HrendTime = 1029;

def RTH1Hr = SecondsFromTime(RTH1HrstartTime) >= 0 and SecondsTillTime(RTH1HrendTime) >= 0;
def RTH1HrMins = if RTH1Hr and !RTH1Hr[1] then volume
else if RTH1Hr then RTH1HrMins[1] + volume
else RTH1HrMins[1];
AddLabel(if GetAggregationPeriod() >= AggregationPeriod.DAY then 0 else if RTH1HrVol then 1 else 0, "RTH1HrVol = " + RTH1HrMins + " ", Color.Gray);
#End Volume RTH First 60 Mins

input PoststartTime = 1600;
input PostendTime = 1959;

def PostMkt = SecondsFromTime(PoststartTime) >= 0 and SecondsTillTime(PostendTime) >= 0;
def PostVolMins = if PostMkt and !PostMkt[1] then volume
else if PostMkt then PostVolMins[1] + volume
else PostVolMins[1];
AddLabel(if GetAggregationPeriod() >= AggregationPeriod.DAY then 0 else if PostMktVol then 1 else 0, "PostMktVol = " + PostVolMins + " ", Color.Gray);
# End Volume PostMarket
 
Last edited by a moderator:
Percentage (%) of Daily Volume Scan, Watchlist, Label
bwjwoMD.png


Watchlist:
ggZmE3q.png


Chart Study: see post#1 for the code
oEMm4iD.png


Scan & Watchlist Code:
Must be run on a daily aggregation!
Ruby:
# Box Volume Stats
# Version 1.2
# Created by: Enigma
# Created: 05/18/17

input length = 30;

def VolDayAvg = (fold index = 1 to length + 1 with Avg = 0 do (Avg + volume(period = "DAY")[index])) / length;
def AvgBars = (fold index2 = 1 to length + 1 with Bar = 0 do (Bar + volume[index2])) / length;
def Today = volume(period = "DAY");

plot PercentOfDayAvg = Round((Today / VolDayAvg) * 100, 0);
@GabrielNY
 
Is it possible to extract the volume from opening to close?
your question is too vague to answer.
the volume for each bar can be read into a variable and used in formulas.
not sure what period you are talking about. open and close of 1 bar? of a normal trading day?
extract? export?

i'm being a little picky, to get you (and others) , to think of asking better questions, in order to get better answers.
 
your question is too vague to answer.
the volume for each bar can be read into a variable and used in formulas.
not sure what period you are talking about. open and close of 1 bar? of a normal trading day?
extract? export?

i'm being a little picky, to get you (and others) , to think of asking better questions, in order to get better answers.
Sorry, open to close I mean 9:30 -> 4pm. I want the volume for the whole day minus pre and post market.
 
Hi! So I've been working on a volume indicator by trying to improve upon one that already exists. Basically it's a lower indicator that shows volume bars and colors them based on the amount of buying and selling volume in each bar (it's volume_cabo_1, I'm sure some use it). I added in a VolAvg line running horizontally through the chart so I can see how tall each volume bar is compared to the 60 bar average (or whatever I change the number to). However, currently it includes the extended hours volume, so every single day it slowly decreases to 0 over the course of the night, and is therefore pretty useless. And that's my problem. I want the VolAvg line to only consider the daytime trading hours in its computation so I can have a line running through the volume bars that shows what the average volume has been for the previous 60 candles only from 9:30am-4pm EST. Can someone help me with that? And/or if there is a better indicator/study I should use instead that would solve my problem that's fine too. Here is the code (my VolAvg line is only the last two lines):
This code defines Daily, premarket, after-hour volume. You can subtract the volumes you don't want.
https://usethinkscript.com/threads/volume-stats-for-thinkorswim.970/page-10#post-79775
Add that logic to your study for the results you seek.
 
Last edited:
Hey there! Thanks for the reply. For some reason when I 🤔 plug this in and Scan in: one of my watchlists the Scan results bring in the whole Watchlist, many of which didn't do 100%+ volume on the day. I cross referenced using the original enigma script...I also love your example Watchlist that's exactly what I'm looking to get! But I don't figure out how to translate Scan results into that custom Watchlist... thanks again for the time!
 
Last edited by a moderator:
Hey there! Thanks for the reply. For some reason when I 🤔 plug this in and Scan in: one of my watchlists the Scan results bring in the whole Watchlist, many of which didn't do 100%+ volume on the day. I cross referenced using the original enigma script...I also love your example Watchlist that's exactly what I'm looking to get! But I don't figure out how to translate Scan results into that custom Watchlist... thanks again for the time!
It is not possible to guess where you went astray. I can show you what you should have done:
Set up the scanner:
  1. Click on Scan in: where I have: Market Maker Move Stocks , enter the watchlist containing your symbols.
  2. Set up the filter with the percentage you want to scan for
  3. Name your scan. My scan is named 00Example2
PT5Rrze.png


4. Open up the scanned watchlist. (this is where you may have gone astray) Do NOT open your symbol list. Open the scan list. See where my scan is named: 00Example2. I opened the scanned watched list: 00Example2.​
5. Load the watchlist column script from post#2. You should now only see the scan results.​
6gST2Au.png


If you still have difficulties. Please create a post that mirrors this one. Provide a detail list as I did above and document each step that you take. Provide images of your scan and your watchlist.
Unsure of how to upload screenshots to the forum: https://usethinkscript.com/threads/how-to-insert-image-in-a-post-thread.277/
 
Last edited:
Ive been looking for something that plots the rVol like Boiler Rooms script, but I came up with something that works almost as well. Needs to be cleaned up but I will share it and see if we cant finally get a Vertical Line on a volume chart that works

Code:
#### DYLDAUB JANUARY 2021 #######

# length and type of the same bar price difference MA.
input avgLength = 5;
input avgType = {SMA, EMA, WLD, INE, default AMA};

# overbought and oversold are visual aids.
# overbought with be drawn when OHLC are the same,
# and oversold will be drawn when they are not the same.
input overbought = 1.0;
input oversold = -1.0;

# weighting of flat bars to close, meaning if current bar is
# ...not flat then adjust price histogram by the weighted close.
# Set to zero to force previous flat bar value
# ...to be used, and not weight by close.

input weight = 2;

## VROC
def day = GetDay();
def isNewDay = day != day[1];

# volume displacement length, and std. dev. average length.
input vrocLength = 14;

# increment spike counters by this amount.
input vrocInc = 0.4;

# num. of std. deviations for signaling larger spikes.
input NumDevUp = 3.5;

# use a line for the VROC spike signal instead of plot.
input useLinesForVROC = No;

# increase or decrease (make negative) to adjust VROC signal location.
input vrocSigOffset = 1.0;

def tVROC = if volume[vrocLength] <> 0 then (volume / volume[vrocLength] - 1) else 0;
def isSpike = tVROC < tVROC[1] and tVROC[1] > tVROC[2];

# store the previous tVROC value because that's the peak.
def spikes = if isSpike then tVROC[1] else spikes[1];

def rHSpikes = if isNewDay then vrocInc else if isSpike and tVROC[1] > spikes[1] then rHSpikes[1] + vrocInc else rHSpikes[1];

def rLSpikes = if isNewDay then vrocInc else if isSpike and tVROC[1] < spikes[1] then rLSpikes[1] + vrocInc else rLSpikes[1];

plot SpikeDiff = rHSpikes - rLSpikes;
SpikeDiff.AssignValueColor(if SpikeDiff > 0 then Color.CYAN else Color.MAGENTA);

# Standard deviation of VROC spike.
def sDev = StDev(tVROC, vrocLength);
def upperVROC = Average(tVROC, vrocLength) + NumDevUp * sDev;

plot VROCSpike = if !useLinesForVROC and tVROC > upperVROC then overbought + vrocSigOffset else Double.NaN;
VROCSpike.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
VROCSpike.HideBubble();
VROCSpike.HideTitle();
VROCSpike.AssignValueColor(SpikeDiff.TakeValueColor());

AddVerticalLine(useLinesForVROC and tVROC > upperVROC, "", SpikeDiff.TakeValueColor(), 3);

## VOLUME SPIKES
# determines type of volume spike signals.
# Off is no display, StdDev is using std. deviations,
# HighVol is using spikes above highest average.
input volumeSignals = {Off, default StdDev, HighVol};

# use a line for the volume spike signal instead of plot.
input useLinesForVolume = No;

# increase or decrease (make negative) to adjust VROC signal location.
input volumeSigOffset = 0.5;

# spectrum color displacement and std. dev. average length for volume.
input volumeLength = 10;

def isUU = close > close[volumeLength] and volume > volume[volumeLength];
def isUD = close > close[volumeLength] and volume < volume[volumeLength];
def isDU = close < close[volumeLength] and volume < volume[volumeLength];
def isDD = close < close[volumeLength] and volume > volume[volumeLength];

# num. of std. deviations for volume spikes.
input volNumDevUp = 2.75;

def sDevVol = StDev(volume, volumeLength);
def volUpper = if volumeSignals == volumeSignals.StdDev then Average(volume, volumeLength) + volNumDevUp * sDevVol else Highest(volume[1], volumeLength);

def isVolumeSpike = volumeSignals != volumeSignals.Off and volume > volUpper;

plot VolumeSpike = if !useLinesForVolume and isVolumeSpike then overbought + volumeSigOffset else Double.NaN;
VolumeSpike.SetPaintingStrategy(PaintingStrategy.SQUARES);
VolumeSpike.SetLineWeight(3);
VolumeSpike.HideBubble();
VolumeSpike.HideTitle();
VolumeSpike.AssignValueColor(if isUU then Color.GREEN else if isUD then Color.BLUE else if isDU then Color.ORANGE else if isDD then Color.RED else Color.GRAY);

AddVerticalLine(useLinesForVolume and isVolumeSpike, "SPIKE", if isUU then Color.GREEN else if isUD then Color.BLUE else if isDU then Color.ORANGE else if isDD then Color.RED else Color.GRAY, 2);

A1-GB-BUYSELLVOLUME-no-no-no-200-no.jpg
When you say its like BR version, does it have that alert like the purple line he talks abt in his??
 
When you say its like BR version, does it have that alert like the purple line he talks abt in his??
@JP382 Did you know that clicking on a member's avatar will allow you to see when a member was last seen on the uTS forum? @Dyldaub has not been seen in a while. :(
 
Question: For Volume Profile data, all hours vs RTH? Wouldn't RTH hold the most weight towards the data, so why do VP include PM and AH? (Assuming this is for stock data btw).

Your feedback is much appreciated folks. Thank you!
 
Question: For Volume Profile data, all hours vs RTH? Wouldn't RTH hold the most weight towards the data, so why do VP include PM and AH? (Assuming this is for stock data btw).

Your feedback is much appreciated folks. Thank you!
Depends on what works for your strategy.
I moved your post to this thread. You can find snippets to calculate Volume w/ and w/o premarket and after hours.
Test it out with different instruments across different time frames. See what integrates into your strategy best.
 
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

Greetings. What is the difference between the VolumeAvg(30), which is the purple line and the Dailly Avg (also30 day average?)?
 
Does anyone have a simple label that shows the RVOL on the chart? Nothing fancy just a label at the top of the screen that shows the RVOL. Thanks
 
@shanakrp2752 This should get you what you what.

Add these 4 lines to the end of Volume_Labels 1.5.3 version, Can be found at https://usethinkscript.com/threads/...ist-scan-label-for-thinkorswim.970/post-47658

Ruby:
def VolDayPreAvg = Average(PreVol, length);
AddLabel(if GetAggregationPeriod() > AggregationPeriod.THIRTY_MIN or !ShowPreMktVol then 0 else 1, length+"PreMktAvg = " + Round(VolDayPreAvg * .000001, 2) + "M ", Color.YELLOW);
def VolDayPostAvg = Average(PostVol, length);
AddLabel(if GetAggregationPeriod() > AggregationPeriod.THIRTY_MIN or !ShowPostMktVol then 0 else 1, length+"PostMktVol = " + Round(VolDayPostAvg * .000001, 2) + "M ", Color.YELLOW);
 
Last edited:
I was looking at volume indicators and came across this thread. Made a closeup comparison of the Volume indicator in post #1 and the @horserider Volume Indicator referred to with a link in post #4. I pared down both indicators to show just the histograms and a 390 minute simple moving average on a 1 minute chart so you are comparing apples to apples. The @horserider Volume Indicator is clearly superior in seeing the variance of Total Volume relative to Moving Average. This is a function of the fact that in thinkscript coding you are not able to stack values in a histogram as you could in Excel or Google sheets. This is information you want to have to evaluate accurately. Image below.


mLnmPUC.jpg
@horserider or @rlohmeyer : is it possible to display the actual values of sellers and buyers for each bar? or how can I quickly identify sellers are fading off as the price came down and buyers stepped in so I can take long or vice versa. I'm looking for something that can quickly tell me whether buyers or sellers in control, Is there any indicator that can signal that type of information? Thank you!
 

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
356 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