RVOL (Relative Volume) Scan Label Watchlist for ThinkorSwim

need help coding a simple chart label that displays RVOL for the current day compared to the last 30 days. Anyone happen to have a script for this or at least something close I can go off of? thanks.
Try this. I have the label color set if RVOL is at a certain threshold similar to trade ideas.

input offset = 1;
def ADV = VolumeAvg(63). VolAvg [offset];
def RV = volume / ADV;
AddLabel (ADV, "RV: " + Round (RV, 2), (if RV > 10 then Color.BLUE
else if RV > 8 then Color.DARK_GREEN
else if RV > 6 then Color.GREEN
else if RV > 4 then Color.LIGHT_GREEN
else if RV > 2 then Color.YELLOW
else if RV < 2 then Color.PINK else Color.BLACK));
 
@jacobbiller Yes. Try this code instead of the previous I posted. This one is much more accurate and you can actually compare it to trade ideas RVOL. Last line shows the RVOL percentage.

input offset = 1;
def rVol = volume(period = AggregationPeriod.DAY) / Average(volume(period = AggregationPeriod.DAY), 63) [offset];
AddLabel(yes, Round(rVol, 2), Color.BLACK);
AssignBackgroundColor(if rVol > 10 then Color.BLUE
else if rVol > 8 then Color.DARK_GREEN
else if rVol > 6 then Color.GREEN
else if rVol > 4 then Color.LIGHT_GREEN
else if rVol > 2 then Color.LIME
else if rVol > 1 then Color.YELLOW
else if rVol < 1 then Color.PINK else Color.BLACK);
AddLabel(yes, AsText(rVol), Color.BLACK);
 
Last edited:
All you have to do is creat a new custom study, copy and paste the code, and place the study wherever you want.
Just to clarify this code is able to determine the current volume relative to the average of the x number of days at the same time correct? Example if its 10am I will be able to compare the current days volume to the average of the x number of days at the same time 10am right? I'll test it tomorrow to see how it works.
 
Just to clarify this code is able to determine the current volume relative to the average of the x number of days at the same time correct? Example if its 10am I will be able to compare the current days volume to the average of the x number of days at the same time 10am right? I'll test it tomorrow to see how it works.

I am wondering the same thing...
 
@BeLikeWater I only need the label to be colored depending on the RVOL value, not the chart background. Can you modify the code to not color the chart background?
 
Can someone else please help modify the code below so that it doesn't color the chart background but instead only the label color? I am guessing it has to do with the bold line but not sure what to replace it with.

Anyone willing to help?

Code:
input offset = 1;
def rVol = volume(period = AggregationPeriod.DAY) / Average(volume(period = AggregationPeriod.DAY), 63) [offset];
AddLabel(yes, Round(rVol, 2), Color.BLACK);
AssignBackgroundColor(if rVol > 10 then Color.BLUE
else if rVol > 8 then Color.DARK_GREEN
else if rVol > 6 then Color.GREEN
else if rVol > 4 then Color.LIGHT_GREEN
else if rVol > 2 then Color.LIME
else if rVol > 1 then Color.YELLOW
else if rVol < 1 then Color.PINK else Color.BLACK);
AddLabel(yes, asPercent(rVol));
 
Last edited by a moderator:
Code:
 input offset = 1;
    def rVol = volume(period = AggregationPeriod.DAY) / Average(volume(period = AggregationPeriod.DAY), 63) [offset];
    AddLabel(yes, Round(rVol, 2),if rVol > 10 then Color.BLUE
    else if rVol > 8 then Color.DARK_GREEN
    else if rVol > 6 then Color.GREEN
    else if rVol > 4 then Color.LIGHT_GREEN
    else if rVol > 2 then Color.LIME
    else if rVol > 1 then Color.YELLOW
    else if rVol < 1 then Color.PINK else Color.BLACK);
    AddLabel(yes, asPercent(rVol));
 
Im trying to convert the code below into a scan that can be run over the course of the first three 15 min bars and would return true when volume is above 100% or based on the code below, coded Yellow. I'm struggling in converting the assign color line to a plot for a scan. The code works perfectly as far as I can tell from placing it on the chart. Thank you for any help!


Code:
declare lower;
#declare fullrange;
def na = double.nan;
input opentime = 0930;
def AP = getAggregationPeriod();
rec barcounter = if getDay() != getDay()[1] then 1 else barcounter[1] + 1;

rec daycount = if barNumber() == 1 then 0 else if getDay() > getDay()[1] then 1 else 0;

def istoday = if getLastDay() == getDay() then 1 else 0;

def bar1volume = if istoday then 0 else if barcounter == 1 then volume else 0;
def bar2volume = if istoday then 0 else if barcounter == 2 then volume else 0;
def bar3volume = if istoday then 0 else if barcounter == 3 then volume else 0;

def avgbar1 = TotalSum(bar1volume) / TotalSum(daycount);
def avgbar2 = TotalSum(bar2volume) / TotalSum(daycount);
def avgbar3 = TotalSum(bar3volume) / TotalSum(daycount);

def AvgVol = if getDay() != getLastDay() then na
else if barcounter == 1 then avgbar1
else if barcounter == 2 then avgbar2
else if barcounter == 3 then avgbar3
else na;

plot relavgvol=100;
relavgvol.SetDefaultColor(color.dark_gray);
#avgvol.setstyle(curve.points);
relavgvol.SetLineWeight(1);
plot zero = 0;
AddCloud(relavgvol, zero, color.gray);

plot vol = ceil(volume/avgvol*100);
vol.SetLineWeight(3);
vol.SetPaintingStrategy(paintingStrategy.HISTOGRAM);
vol.AssignValueColor(if !istoday then color.cYAN else if vol > relavgvol then color.yellow else color.gray);

zero.hideBubble();
relavgvol.hidebubble();
 
Try this. Did not test it, but it should work.

Code:
Code:

declare lower;

#declare fullrange;

def na = double.nan;

input opentime = 0930;

def AP = getAggregationPeriod();

rec barcounter = if getDay() != getDay()[1] then 1 else barcounter[1] + 1;



rec daycount = if barNumber() == 1 then 0 else if getDay() > getDay()[1] then 1 else 0;



def istoday = if getLastDay() == getDay() then 1 else 0;



def bar1volume = if istoday then 0 else if barcounter == 1 then volume else 0;

def bar2volume = if istoday then 0 else if barcounter == 2 then volume else 0;

def bar3volume = if istoday then 0 else if barcounter == 3 then volume else 0;



def avgbar1 = TotalSum(bar1volume) / TotalSum(daycount);

def avgbar2 = TotalSum(bar2volume) / TotalSum(daycount);

def avgbar3 = TotalSum(bar3volume) / TotalSum(daycount);



def AvgVol = if getDay() != getLastDay() then na

else if barcounter == 1 then avgbar1

else if barcounter == 2 then avgbar2

else if barcounter == 3 then avgbar3

else na;



def relavgvol=100;

def vol = ceil(volume/avgvol*100);



plot signal = vol > relavgvol;
 
I actually have tried this and for whatever reason it won't work on the scan. Logically based on original code that was my first thought as well but for whatever reasons the scan results returned when ran on 15m time frame are very odd and definitely not right
 
Last edited:
It would be much more relevant to have the scanner compare volumes during a given time of the day. I've done this for a Chart study that compares the today's volume from 9:30am to 10:00am - at 5 minute intervals - to the average volume from the same 5 minute intervals for the previous 5 days. Here is the link: OpeningRangeRelativeVolume I haven't tried this for Scanner. It would need to be more flexible to keep the end point moving through the day. I'm not sure how to do that yet. It's also hard coded to create the average by looking back over the previous 5 days. I wish I knew how to make that more flexible.
Code:
input OrBegin  = 0930.0; #hint OrBegin: Beginning for Period of Opening Range Breakout.
input OrEnd    = 1000.0; #hint OrEnd: End of Period of Opening Range Breakout.

  def ORActive2 = if secondsTillTime(OREnd) > 0 and
                     secondsFromTime(ORBegin) >= 0
                  then 1
                  else 0;
# This will only be true on bars found in the current day
  def today = if getDay() == getLastDay() and
                 secondsFromTime(OrBegin) >= 0
              then 1
              else 0;

# This is the cumulative volume for the current day between OrBegin and OrEnd
def cumVolume = if ORActive2 and !ORActive2[1]
    then volume[1]
    else if ORACtive2 then cumVolume[1] + volume[1]
    else cumVolume[1];

# This is the average cumulative volume over the same time period from the previous 5 days
def cumVolumePrev = if ORActive2 and !ORActive2[1]
    then (volume[(78*1)+1] + volume[(78*2)+1] + volume[(78*3)+1] + volume[(78*4)+1] + volume[(78*5)+1] ) / 5
    else if ORACtive2 then cumVolumePrev[1] + (volume[(78*1)+1] + volume[(78*2)+1]  + volume[(78*3)+1] + volume[(78*4)+1] + volume[(78*5)+1] ) / 5
    else cumVolumePrev[1];

def barNumber = if ORActive2 and !OrActive2[1]
    then 1
    else if ORActive2 then barNumber[1] + 1
    else barNumber[1];


plot Data1 = if GetAggregationPeriod() == AggregationPeriod.FIVE_MIN and ( ORActive2 or !today) then cumVolume / Min( barNumber, 6) else double.NaN ;

plot Data2 = if  GetAggregationPeriod() == AggregationPeriod.FIVE_MIN and (ORActive2 or !today) then cumVolumePrev / Min( barNumber, 6) else double.NaN ;

addCloud(Data1,Data2,createColor(66,160,100),createColor(244,83,66));
 
Last edited:
Here is a decent attempt at a High Relative Volume scanner for TOS. It basically adjusts the average daily volume for the current time of day. The adjusted average doesn't really attempt to calculate an average based on actual historical volumes from the previous x number of days for a particular stock during a particular time of day. Seems like that would be very processor intensive and slow to use in a scanner. So instead, the factors (.93, .88, .83....17) take into account the typical volume pattern throughout a trading day for stocks in general.

Code:
input threshhold = 1.5;


def hhr = if SecondsFromTime(1530) >= 0 then 1
    else if SecondsFromTime(1500) >= 0 then .93
    else if SecondsFromTime(1430) >= 0 then .88
    else if SecondsFromTime(1400) >= 0 then .83
    else if SecondsFromTime(1330) >= 0 then .78
    else if SecondsFromTime(1300) >= 0 then .73
    else if SecondsFromTime(1230) >= 0 then .68
    else if SecondsFromTime(1200) >= 0 then .62
    else if SecondsFromTime(1130) >= 0 then .56
    else if SecondsFromTime(1100) >= 0 then .49
    else if SecondsFromTime(1030) >= 0 then .41
    else if SecondsFromTime(1000) >= 0 then .31
    else if SecondsFromTime(0930) >= 0 then .17
    else double.Nan;

def adjAvg = Average("data" = volume, "length" = 65) * hhr;

plot Data = volume / adjAvg > threshhold;
 
Last edited:
Using 5 days as the average. Any existing code to be used on the watchlist.

Relative volume = Current cumulative volume for this time of day / Average cumulative volume for this time of day (5days average);
 
I've been using this as a Custom Quote column for the past week or so and it seems to work pretty well. It returns a Relative Volume using 30 Minute bars. That is why the "bpd" multiplier is 13. I tried with 5 minute bars, but TOS chokes. Too many calculations I suppose. But I don't think the additional granularity would be useful. If you wanted to try 15 MIN bars, you would change the "bpd" multiplier to 26. I haven't tried that. You could extend this out beyond 10 days by adding more expressions like "+ volume[(bpd*n)+1]" where n is the day number. You would also need to change the daycnt variable.

Code:
input STime = 0930 ; #hint STime: Start of normal trading hours
input ETime = 1530 ; #hint ETime: End of normal trading hours
input thold = 1.5 ; #hint told: Threshold for color break
def bpd = 13 ; # 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[1]
    else if IsActive then cumVolume[1] + volume[1]
    else cumVolume[1];

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

plot RelVol = cumVolume / cumVolumePrev ;

RelVol.assignValueColor(if RelVol > thold then CreateColor(0,128,0) else CreateColor(128,0,0) );
 
Hi,

I have limited experience, but I enjoy using the RelativeVolumeStDev study on TOS on intraDay trades. I wrote this crude script below that I placed in my watchlist. I aggregate it on the 2 minute chart. It adds the RelativeVolumeStDev of the last 3 closed candles and highlights the cell in the watchlist if there is a significant increase in volume, and plots the number.

Code:
# Rel Volume Watchlist Column

# By Dan Dude
# Copyright forever

def RelVolume = reference RelativeVolumeStDev();
def RelVolume1 = reference RelativeVolumeStDev()[1];
def RelVolume2 = reference RelativeVolumeStDev()[2];

def RelVolumeSum = (RelVolume + RelVolume1 + RelVolume2);

AssignBackgroundColor(if RelVolumeSum > 1 then color.dark_green else color.current);

AddLabel(yes, AsText((if RelVolumeSum > 0 then RelVolumeSum else 0),NumberFormat.TWO_DECIMAL_PLACES));
[/CODE}

Hopefully this helps!

*This works best for trades that are NOT in the first or last hour of trading, since the relative volume at that time is abnormally high anyways.
 

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