RVOL (Relative Volume) Indicator / Watchlist for ThinkorSwim

B

BeLikeWater

New member
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, asPercent(rVol));
 
P

Pharmd2Retire

New member
VIP
@BeLikeWater This is not working for me in TOS. could you repost?
 
S

SirMc

New member
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.
 
J

jacobbiller

New member
2019 Donor
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...
 
zeek

zeek

Active member
2019 Donor
@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?
 
zeek

zeek

Active member
2019 Donor
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:
horserider

horserider

Well-known member
VIP
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));
 
B

boogieG

New member
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();
 
Axel

Axel

New member
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;
 
B

boogieG

New member
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
 
C

chada456

New member
Is there a way to create a specific relative volume based on time of day? So for instance current day's relative volume at 11AM vs 11AM the past 30/60/etc days? Basically relative volume at the current time looking back x amount of days. Trade ideas seems to have a version of this. I was hoping it could be created in TOS. Thank you!
 
C

chada456

New member
Anyone know if the relative volume scan posted on the 3rd page looks back at the same time for previous days? I'm looking to find relative volume at a specific time relative to previous days. The only scripts I've found tend to be relative volume based on previous DAYS rather than TIME OF DAY.
 
J

jlondono2002

New member
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, asPercent(rVol));

HI, HOW CAN APPLY THIS CODE TO GET RVOL HR BY HR ON SCANNER
 
C

chada456

New member
Forgive me if I'm wrong, but when I apply that code, it seems to do relative volume based on DAY, not hour by hour/minute by minute
 
B

BayTrader_93

New member
@horserider Is there a reason why you guys use the aggregation period for 63 days? and what chart would I look at in order to get an accurate reading displayed?
 
S

soary

Member
Last edited:
V

vikram

New member
VIP
@Axel How can I scan based on buying volume instead of total (buy+sell) volume ?
 

Similar threads

Top