RVOL (Relative Volume) Scan Label Watchlist for ThinkorSwim

Hello, Can someone explain me why some of them are not showing and giving errors ?

DxAGdjZ.png
 
Hello, Can someone explain me why some of them are not showing and giving errors ?

TOS limits the number of values it's willing to calculate in client side watchlist columns. I'm not sure what the limit is but you can expect those messages any time (symbols x computed columns) is above the limit. This only applies to columns computed on the client side, not server side, so all custom columns and some of the built-in columns like VolSizzle.

I haven't confirmed it but I think I've noticed the limit is global. Meaning every watchlist that has symbols loaded and has computed columns plus any in the scan tab if it's open seem to all be counted toward the same limit.
 
Can someone help me with a few quick things. I'm still very new to ThinkScript. You're more than welcome to use my ideas!

1) I dont like that Relative Volume on TOS is in a standard deviation format. Can someone help me design the code for Relative Volume in this format:

Relative Volume= Todays Vol/Avg. Volume

Where Avg. Volume is Average Volume of the last 30 days. If you could make it so I can change the input later that'd be great!
More than 1.00 should indicate there's more eyes on the stock than normal, Implying a possible Rise or Fall soon.

2) A Bid Size to Ask Size ratio to measure Buying Imbalances as the High Volume Price Climbs up:

Bid/Ask Ratio=Bid size/Ask Size

A less than 1.00 should show a Sell off is starting to happen.


3) The opposite of above, an Ask Size to Bid Size ratio to measure Selling Imbalances as price goes down during a high volume sell off to use for Shorting:

Ask/Bid Ratio=Ask Size/Bid Size

More than 1.00 should indicate there's more Selling than Buying.

I know #2 and #3 could be used with only one ratio but I think done separate measures the extremeness of each situation better.
Also if you have any ideas or possible indicators that can be used for Order Flow or LV.II I'd love to hear and discuss!! I have more ideas but I'm still fairly new to the Thinkscript part of TOS. Thank you!!!
 
Zanger volume (Simplified code):

#Zanger Volume ratio on 15 minutes chart for RTH
plot RVOL = (volume / ((volume + volume[79] + volume[157] + volume[235] + volume[313] + volume[391] + volume[469] + volume[547] + volume[625] + volume[703] + volume[781] + volume[859] + volume[937] + volume[1015] + volume[1093] + volume[1171] + volume[1249] + volume[1327] + volume[1405] + volume[1483]) / 20) * 100);

RVOL.AssignValueColor(if RVOL > 200 then Color.magenta else if 120 < RVOL and RVOL < 200 then Color.RED else if 80 < RVOL and RVOL < 120 then Color.orange else if 60 < RVOL and RVOL < 80 then Color.GRAY else Color.DARK_GRAY);
From my understanding, Zanger Volume Ratio compares intraday volume accumulation, if it's 15 min bar and calculated on the second bar, Zanger volume compares accumulation of 9:30-10:00 and its average, yours compares 9:45-10:00, not the same thing. Correct me if I'm wrong. Thanks
 
The code here probably has some bugs. In looking at it, this seems wrong to me:
Why is it using an index of 1, getting the previous bar instead of the current, on everything? That doesn't seem right. That seems like it'll get yesterday's last candle. It should probably be:

I'd paste the rest of my code for you but it doesn't have the active time window concept which you need.

To test/debug all of this, it's probably easiest to change to a 30m chart so you only care about one candle and don't have to keep adding candles' volumes together to see what it's capturing. Add a label that displays cumVolume. Then find the candle with matching volume. If it matches the volume of the wrong candle then play with the index.
Hi, Thx for the code it works well for calculating the first 30mins vol for the past 10 days. It matches my manual calculation perfectly.
One thing bothering me though is during the active time window of the trading day, the code is calculating the current live vol instead of keeping the past data, thus defeating the purpose of the code.
How to change the code so it keeps the past data? This is the current code. Thank you.
Code:
input STime = 0930 ; #hint STime: Start of normal trading hours
input ETime = 1000 ; #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 bpd = 195 ; # 2mins Bars per day during active trading hours
#def bpd = 390 ; # 1mins 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
    else if IsActive then cumVolume[1] + volume
    else cumVolume[1];

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


AddLabel(1, + Round(cumVolumePrev/30, 0), Color.YELLOW);
 
Last edited:
Hello, I'm trying to setup a scan but the RelativeVolumeStdDev is pulling stocks that are not actually meeting the criteria. Below is what I have so far. I'm clearly telling the script that I need the "num dev" to be above 4 but it consistently pulls stocks that are under 4 and I was wondering why. I think I may need to add something to the code but I don't know where to start.

any help would be appreciated!

RelativeVolStdDev ("length" = 50, "num dev" = 40.
"num dev" is greater than 4
 
trying to covert 5mins relativeVolumeStDev to the watchlist on TOS

when relative vol >2 watchlist also change color

anyone can help?
 

Attachments

  • XPFn4R7Icr.png
    XPFn4R7Icr.png
    14.8 KB · Views: 312
Last edited:
thank you for helping
its on TOS under chart studies.
@vince92615 , if you really are wanting to build a watchlist column using ToS internal RelativeVolumeStDev, you'll want to basically programmatically use that study and check for 3 contiguous bars to be > 2. (or however many contiguous bars you would deem a cluster). and of course, to your selected timeframe (ex. 5min chart).

that's clearly beyond the scope of this thread, which is just a watchlist column for relative volume compared to avg of past XX days.

might be best to open a new thread to see if someone is interested in helping you tinker with it. sounds REALLY compute intensive to try and find a support area for entry on a turnaround. Reason for new thread is that a lot of folks look for the simple solution in this thread, suggesting to keep it cleaner for new folks asking questions about the current indicator. your request is quite unique!

I'll check back on the thread in the hopes that I'm mis-understanding what you are trying to accomplish, and might be able to help. :)

@rad14733 if you pop into a chart and tap the question mark on the RelativeVolumeStDev study, it should pop you into the Education Center with details on the study.
 
May be a long shot here...

I use the TOS study RelativeVolumeStDev very regularly to execute my trading plan. I'm wondering if anyone is able to, or can guide me to a type of alert system that would sound anytime a ticker on my watchlist prints a rVol reading of 2+ on the 5 or 10 minute timeframe...

I have rVol in my watchlist and usually have it sorted by highest throughout the day, but have to look at it every 5-10 minutes to see if anything has received a rVol reading of 2+. I'd love just a little ding or something every time something runs over. I don't even know if this is possible, but figured I'd ask here.

Thanks
 
@mdoss2202 You would need to use a Scan set to send Alerts when a new symbol meets your conditions to do what you have described... That is the best way to handle audible message center and/or mobile Alerts...
 
@mdoss2202 You would need to use a Scan set to send Alerts when a new symbol meets your conditions to do what you have described... That is the best way to handle audible message center and/or mobile Alerts...
Thanks. I presume I do this through 'Alerts' > 'Study Alert'

Anyone know if it's possible to block out said alert in the first and last 15 min of the day, bc rVol is always higher then and it's not helpful at that point. Similarly, is it possible to set said alert on my entire watchlist as opposed to doing so one at a time for every ticker?
 
Thanks. I presume I do this through 'Alerts' > 'Study Alert'

Anyone know if it's possible to block out said alert in the first and last 15 min of the day, bc rVol is always higher then and it's not helpful at that point. Similarly, is it possible to set said alert on my entire watchlist as opposed to doing so one at a time for every ticker?

You possibly could but I usually do it via Scan and then add Alerts to the results... I create the Scan and use my Watchlist for the Scan in selection... The only issue is that the Scans lag so Alerts could be 3 - 7 minutes late... Chart Alerts have no lag but they can only make audible alerts that also populate the Message Center... A Study Alert might be more responsive but I haven't used them, personally...
 
Last edited:
The study @BenTen posted on this thread used an AssignPriceColor() statement that would be applicable in charts.

Here's a relative volume for the watchlist I have been using. It is color coded so if the watchlist column is colored LIGHT_GREEN that flags a high relative volume day. Otherwise a PINK color on the watchlist column would indicate regular/moderate relative volume day

Code:
# START
plot c = Volume(period = AggregationPeriod.DAY) / Average(volume(period = AggregationPeriod.DAY), 20);
c.SetDefaultColor(Color.BLACK);
AssignBackgroundColor(if c > 5 then Color.LIGHT_GREEN else Color.PINK);
# END
I'm getting a "custom expression subscription limit exceeded" on some stocks. Is there a way to correct this?
 
@elijahcraig18
'custom expression subscription limit exceeded'

WatchLists

There may only be 1,100 - 1,500 Custom Watchlist Fields displayed in the TOS app at one time. It is necessary to either have fewer results populate the watchlists or have less watchlists. There is no work-around for this limitation.
 
Here is the written code from the link @zeek provided:

Short version:

Code:
def rVol = volume / Average(volume, 21)[1];

AddLabel(yes, round(rVol,2));
#AddLabel(yes, asPercent(rVol));

AssignPriceColor(if rVol >= 1 then color.dark_red else if rVol <=.5 then Color.black else color.Gray);

Long version:

Code:
input length = 21;
input offset = 1;

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

# remove "#" infront of Addlabels to select prefer choice

AddLabel(yes, round(rVol,2));
#AddLabel(yes, asPercent(rVol));

AssignPriceColor(if rVol >= 1 then color.dark_red else if rVol <=.5 then Color.black else color.Gray);
is there an advantage and disadvantage from using a shorter or longer code since they give same numbers?
 
is there an advantage and disadvantage from using a shorter or longer code since they give same numbers?

@iselloptions The performance difference would be marginal for such a short script... The main difference is whether parameters can be changed using the Study Settings Panel or whether the Study code needs to be manually edited...
 
Last edited by a moderator:
How rvol is supposed to be calculated is well known to some of us but I guess it's good you got confirmation for others. There's code already in this thread that has the right intent in how to calculate rvol but it's buggy. I posted comments on how to fix it recently. I'll post my code which is specifically for a watchlist column and you guys can modify for other purposes.

Whoever posted the original code had concerns about it dragging down overall TOS performance which is why I made it handle multiple timeframes. The lower the timeframe the more the performance impact. Though, I'm not sure I ever ran it below 5m so I'm not sure if the concern is warranted. The only real benefit of using a low timeframe is that the data is meaningless until the first period closes and a small period will close earlier. After that it matters less on each subsequent period. Though, you also don't want to set this higher than needed because it compares current volume to the average volume at the start of the period. If you set to 1H then at 11:15 it's comparing current volume to the average at 10:30. Better to narrow that window. After I switched to swing trading I changed mine to 10m. Before that I was using 5m.

This data is meaningless in pre-market. Having accurate pre-market rvol on TOS isn't possible because TOS doesn't have data for periods with no volume and it skews trying to look at the same time of day on previous days. Don't use Extended Hours with this code.

RVOL Watchlist Column Don't use Extended Hours with this code.
Ruby:
input greenLevel = 1.5;

def period = GetAggregationPeriod();
def minutesPerBar = period / 60000;
def minutesPerDay = 60 * 6.5; # 6.5 hours of standard trading session
def bpd = minutesPerDay / minutesPerBar; # bars per day

# This is the cumulative volume for the current day
def day = GetDay();
def cumVolume =
  if day != day[1] then volume
  else cumVolume[1] + volume
;

# average of cumulative volume at this time of day for the last 10 trading days
def avgCumVolume = (cumVolume[(bpd*1)] + cumVolume[(bpd*2)] + cumVolume[(bpd*3)] + cumVolume[(bpd*4)] + cumVolume[(bpd*5)] + cumVolume[(bpd*6)] + cumVolume[(bpd*7)] + cumVolume[(bpd*8)] + cumVolume[(bpd*9)] + cumVolume[(bpd*10)]) / 10;

plot RVol = Round(if IsNaN(cumVolume) then 0 else cumVolume / avgCumVolume, 2);
RVol.AssignValueColor(if RVol >= 1 and RVol < greenLevel then Color.YELLOW else if RVol >= greenLevel then Color.LIGHT_GREEN else Color.PINK);
Thanks for this great script, very useful.

One question:

Can you or someone else explain what the following line does? (It is a question that has more to do with thinkScript basics, but wasn't able to find a similar example in TOS thinkscript pages to understand it)

# average of cumulative volume at this time of day for the last 10 trading days
def avgCumVolume = (cumVolume[(bpd*1)] + cumVolume[(bpd*2)] + cumVolume[(bpd*3)] + cumVolume[(bpd*4)] + cumVolume[(bpd*5)] + cumVolume[(bpd*6)] + cumVolume[(bpd*7)] + cumVolume[(bpd*8)] + cumVolume[(bpd*9)] + cumVolume[(bpd*10)]) / 10;

I understand -thanks to the comment- what it is supposed to do. But I don't get where is the cumVolume coming from.
Because when the cumVolume was declared a couple of lines above, it was storing the cumulative volume for the current day.
But in this line you can access the previous days' volume? How come? (no pun intended :p)
 
Hello, Can someone explain me why some of them are not showing and giving errors ?

DxAGdjZ.png
You can easily sort this out by eliminating some custom quotes you are using in other watchlists, or limit the number of stocks in this watchlists. I hope that helps!
 

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