RVOL (Relative Volume) Scan Label Watchlist for ThinkorSwim

I am trying to add a scanner to my watchlist which shows the Relative Volume , I used the below code but I always get the Relative Volume"rVol" value as 1 , I found that VolumeAvg and volume always give the same number which it should not be the case . any help is appreciated . am checking the Daily volume.

The Code :

def length = 50;
def rVol = (volume / VolumeAvg(length));


addlabel(yes,rvol);
https://usethinkscript.com/threads/...chlist-for-thinkorswim.1014/page-2#post-13123
 

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

Displayed below is my simple column - relative volume number
for stocks RVOL. When I click the column
down arrow to sort, as you can see, the highest numbers do not sort
to the top. Do I need a different data type to be able to sort
a custom column correctly?. Any suggestions greatly appreciated,
Thanks.

 
Displayed below is my simple column - relative volume number
for stocks RVOL. When I click the column
down arrow to sort, as you can see, the highest numbers do not sort
to the top. Do I need a different data type to be able to sort
a custom column correctly?. Any suggestions greatly appreciated,
Thanks.

Ruby:
def avg50 = Average(volume, 50);
plot RVOL = round(volume / avg50, 1);
def rawRelVol = (volume - avg50) / StDev(volume, 50);

AssignBackgroundColor(if RawRelVol > 1 then color.green else color.red);
 
I am trying to add a scanner to my watchlist which shows the Relative Volume , I used the below code but I always get the Relative Volume"rVol" value as 1 , I found that VolumeAvg and volume always give the same number which it should not be the case . any help is appreciated . am checking the Daily volume.

The Code :

def length = 50;
def rVol = (volume / VolumeAvg(length));


addlabel(yes,rvol);



AL3ixs8.jpg
This Code worked for me :
def length = 50;

def Vol = volume;
def VolAvg = Average(volume, length);
def rVol = Vol / VolAvg;

addlabel(yes,Round(rvol,2));

AssignbackgroundColor(
if rVol > 2.0 then color.DARK_GREEN
else if rVol > 1.0 then getcolor(0) # color.DARK_ORANGE
else
color.current);
 
This label only appears in Live Market.
Ruby:
# Set the percentage threshold for the spike
input spike_percentage_threshold = 0.0;

# Calculate the relative volume for the current bar
def rel_vol = volume / Average(volume, 50);

# Calculate the percentage change in volume relative to the average volume
def vol_change_pct = (rel_vol - 1.0) * 100.0;

# Determine if the current bar has a volume spike
def is_spike = vol_change_pct >= spike_percentage_threshold;

# Define the label value as the percentage change in volume if it is a spike, otherwise NaN
def label_value = if is_spike then vol_change_pct else Double.NaN;

# Determine if the current bar is bullish or bearish based on the close price
def is_bullish = close > open;
def is_bearish = close < open;

# Define the label
AddLabel(yes,
if is_spike and is_bullish then Concat(AsPercent(vol_change_pct / 10000.0), " - Bullish")
else if is_spike and is_bearish then Concat(AsPercent(vol_change_pct / 10000.0), " - Bearish")
else "",
if is_spike and is_bullish then Color.LIGHT_GREEN
else if is_spike and is_bearish then Color.LIGHT_RED
else Color.BLACK);
 
Last edited by a moderator:
My first post to the forum.

I can't seem to find where I got the original script just a few days ago but I'm sure it was from this forum, (I think?) Anyhow, it's a simple relative volume that you can install in a scan column or in a watchlist for that matter.
You can also sort with it, the original script was unable to do this.

The colors didn't seem to work at first, besides I wasn't a fan of the background color in my watchlist so I converted it to only turn the text green when the rVol is > 1. My first attempt at thinkscript but it seems to work.
Additionally I also had issue trying to change font colors (original script was back ground only). It would skip the rounding and give me 4 or more decimals. So yeah, it was a good learning experience :)

Bottom line, first attempt at a script mod and it seems to work well now.

# rVOL script for TOS
def rVol = volume / Average(volume, 20)[1];
plot Data = round(rVol, 2);

#Script for color
AddLabel(yes, round(rVol,2),if rVol > 1 then color.green else color.white);
 
Welcome @Vern60 !

Here is the script I use, based on a basic script that everyone has here...

#Relative Volume
def x = Average(volume, 60)[1];
def v = volume;
plot r = Round((v/x),3);
r.assignValueColor(if r >= 2 then color.CYAN else if r>=.75 then createcolor(0,215,0) else if r>=.3 then color.ORANGE else color.RED);

as you can see, the avg is based on 60 days that you can change in the code to your preferred 20. Also, adjust the last line on the text color you prefer and what level to change. The code above is red text below 30%, orange from 30% to 75%, green 75% to 200%, cyan > 200%.

and you can adjust the code to number of decimal points from mine which is x.xx.

tinker with those or simplify to your taste. good luck!
 
Hi can you help me with this script, trying to have different colors for the stages of RVOL, anything helps, thanks.
# START
plot c = Volume(period = AggregationPeriod.DAY) / Average(volume(period = AggregationPeriod.DAY), 20);
c.SetDefaultColor(Color.BLACK);
AssignBackgroundColor(if c > 2 then Color.PINK else Color.RED);
AssignBackgroundColor(if c > 3 then Color.ORANGE else Color.PINK);
AssignBackgroundColor(if c > 5 then Color.GREEN else Color.ORANGE);
AssignBackgroundColor(if c > 7 then Color.DARK_GREEN else Color.GREEN);
# END
Could we make labels for this?
 
Could we make labels for this?
Ruby:
# Relative Volume Labels
# tomsk
# 1.4.2020

plot c = volume(period = AggregationPeriod.DAY) / Average(volume(period = AggregationPeriod.DAY), 20);
AddLabel(yes, " ", if c > 7 then Color.DARK_GREEN
                      else if c > 5 then Color.GREEN
                      else if c > 3 then Color.PINK
                      else if c > 2 then Color.RED
                      else Color.GRAY);
# End Relative Volume Watchlist
 
Last edited:
Could we make labels for this?
Quik, That's code for a watchlist... the only label or text is the calculation that follows 'plot c ='.

If I'm misunderstanding, happy to take another look, perhaps you can post a screenshot of what you see and annotate it with what you are trying to do?

Last thought. IF you are looking for some labels above the volume study in ToS, there is a study called 'Volume Buy Sell Indicator' that has current volume compared to Average Volume and a percent, so that would be a type of Relative Volume as well. Link is here: https://usethinkscript.com/threads/volume-buy-sell-pressure-with-hot-percent-for-thinkorswim.389/
 
This label only appears in Live Market.
Ruby:
# Set the percentage threshold for the spike
input spike_percentage_threshold = 0.0;

# Calculate the relative volume for the current bar
def rel_vol = volume / Average(volume, 50);

# Calculate the percentage change in volume relative to the average volume
def vol_change_pct = (rel_vol - 1.0) * 100.0;

# Determine if the current bar has a volume spike
def is_spike = vol_change_pct >= spike_percentage_threshold;

# Define the label value as the percentage change in volume if it is a spike, otherwise NaN
def label_value = if is_spike then vol_change_pct else Double.NaN;

# Determine if the current bar is bullish or bearish based on the close price
def is_bullish = close > open;
def is_bearish = close < open;

# Define the label
AddLabel(yes,
if is_spike and is_bullish then Concat(AsPercent(vol_change_pct / 10000.0), " - Bullish")
else if is_spike and is_bearish then Concat(AsPercent(vol_change_pct / 10000.0), " - Bearish")
else "",
if is_spike and is_bullish then Color.LIGHT_GREEN
else if is_spike and is_bearish then Color.LIGHT_RED
else Color.BLACK);

This doesn't seem to be displaying/working at all for me anymore?
 
Could we make labels for this?
Try this after the market opens.


Code:
declare upper;

# Calculate the value of 'c'
def c = Volume(period = AggregationPeriod.DAY) / Average(volume(period = AggregationPeriod.DAY), 20);

# Create a label to display the value of 'c'
AddLabel(yes, "c: " + AsText(c), if c > 7 then Color.DARK_GREEN
else if c > 5 then Color.GREEN
else if c > 3 then Color.ORANGE
else if c > 2 then Color.PINK
else Color.RED);
 
This doesn't seem to be displaying/working at all for me anymore?
Don't know why if nothing changed. This is the script off my pc. It works

Code:
# Set the percentage threshold for the spike
def spike_percentage_threshold = 0.0;

# Calculate the relative volume for the current bar
def rel_vol = volume / Average(volume, 50);

# Calculate the percentage change in volume relative to the average volume
def vol_change_pct = (rel_vol - 1.0) * 100.0;

# Determine if the current bar has a volume spike
def is_spike = vol_change_pct >= spike_percentage_threshold;

# Define the label value as the percentage change in volume if it is a spike, otherwise NaN
def label_value = if is_spike then vol_change_pct else Double.NaN;

# Determine if the current bar is bullish or bearish based on the close price
def is_bullish = close > open;
def is_bearish = close < open;

# Add the label to the watch list
AddLabel(yes,
         if is_spike and is_bullish then Concat(AsPercent(vol_change_pct / 10000.0), " - Bullish")
         else if is_spike and is_bearish then Concat(AsPercent(vol_change_pct / 10000.0), " - Bearish")
         else "",
         if is_spike and is_bullish then Color.GREEN
         else if is_spike and is_bearish then Color.dark_orange
         else Color.BLACK);
 
I have my scan setup with automated signals, is there a way to add RVOL filter to an existing scan where it only shows signals on stocks where RVOL is > 2?
 
I have my scan setup with automated signals, is there a way to add RVOL filter to an existing scan where it only shows signals on stocks where RVOL is > 2?
Paste this into a custom study in your scan..

Code:
input length = 20;
def avgVolume = Average(volume, length);
def relVolume = volume / avgVolume;

plot Scan = relVolume > 2;
 
Last edited by a moderator:
input length = 20;
def avgVolume = Average(volume, length);
def relVolume = volume / avgVolume;

plot Scan = relVolume > 2;

mod note:
Just FYI, the above is not a scan for the ToS Relative Volume Spikes
@UpTwoBucks calculation is of simple volume / average volume ratio.
Still a good idea. Just not the ToS definition:

plot scan = RelativeVolumeStDev() > 2 ;

Try them both see what works best with your strategy.
 
Last edited:

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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