Actual Relative Volume

AlexZ

New member
Does anyone have an indicator for ThinkorSwim that will display relative volume correctly? That is, rather than just comparing the current time frame's volume to the past "X" bars' volumes (which is what the default relative volume study does), the study should compare the same time slice across "X" number of historical days. For example, if looking at 5-min bars, and there were 10,000 contracts exchanged during the 5-min period from 11:50 to 11:55, but the average volume of the 11:50 to 11:55 period over the past 30 sessions is 15,000 then it should show the volume for this 5-min slice as -5,000. Would also be nice if there was a line graph overlay that showed this in terms of % (in the foregoing example it would be -33.3%...i.e., -5,000/15,000). So bar chart showing true relative volume in terms of contracts, and an overlaid line graph showing the implied % variance from average. If this doesn't exist...is anyone skilled in the TOS programming language?
 
Solution
Does anyone have an indicator for ThinkorSwim that will display relative volume correctly? That is, rather than just comparing the current time frame's volume to the past "X" bars' volumes (which is what the default relative volume study does), the study should compare the same time slice across "X" number of historical days. For example, if looking at 5-min bars, and there were 10,000 contracts exchanged during the 5-min period from 11:50 to 11:55, but the average volume of the 11:50 to 11:55 period over the past 30 sessions is 15,000 then it should show the volume for this 5-min slice as -5,000. Would also be nice if there was a line graph overlay that showed this in terms of % (in the foregoing example it would be...
Does anyone have an indicator for ThinkorSwim that will display relative volume correctly? That is, rather than just comparing the current time frame's volume to the past "X" bars' volumes (which is what the default relative volume study does), the study should compare the same time slice across "X" number of historical days. For example, if looking at 5-min bars, and there were 10,000 contracts exchanged during the 5-min period from 11:50 to 11:55, but the average volume of the 11:50 to 11:55 period over the past 30 sessions is 15,000 then it should show the volume for this 5-min slice as -5,000. Would also be nice if there was a line graph overlay that showed this in terms of % (in the foregoing example it would be -33.3%...i.e., -5,000/15,000). So bar chart showing true relative volume in terms of contracts, and an overlaid line graph showing the implied % variance from average. If this doesn't exist...is anyone skilled in the TOS programming language?

i think this thread is similar to what you are asking. time based volume, reading volume from the same time, on multiple days. the studies may have to be tweaked to get exactly what you are after.
https://usethinkscript.com/threads/time-based-volume-indicator-for-thinkorswim.124/
 
Solution

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

I've been recently reading on SMBCapital's blog on RVOL. In their words, "Relative Volume. This compares current volume to normal volume for the same time of day, and it’s displayed as a ratio. So for example, a stock trading 5 1/2 times its normal volume would have a Relative Volume display of 5.5."

I assume this means they take, for example, the last 30min candle and compare it to the 30min candle from the same time the previous trading day. If the stock at 9:00am has a volume of 10,000 and yesterday's volume at 9:00am was 5,000, this would be a ratio of 2. (or maybe instead of yesterday, they take the average of the last X days.)

I'm not sure the specifics of what they're doing for RVOL, but it does seem interesting.

Are there any ideas on how they (or anyone) else could calculate RVOL for intraday trading, keeping in mind that you only have so much time in the day, so RVOL would have to be on a relative short time period.

I found this code, but not sure if it's the most ideal, or is there something better.

Ruby:
input length = 14; #number of time units
input offset = 1; #offset: 1 = don't include current time unit
def ADV = Average(volume, length)[offset]; #ADV
def rVol = Round(volume / ADV, 2); #relative volume

AddLabel(yes, rVol, if rVol >= 1 then COLOR.GREEN else COLOR.CURRENT);

The previous code is fairly crude way of calculating from candle to candle. Is there a better way?

Thank you.
 
Last edited:
I've been recently reading on SMBCapital's blog on RVOL. In their words, "Relative Volume. This compares current volume to normal volume for the same time of day, and it’s displayed as a ratio. So for example, a stock trading 5 1/2 times its normal volume would have a Relative Volume display of 5.5."

I assume this means they take, for example, the last 30min candle and compare it to the 30min candle from the same time the previous trading day. If the stock at 9:00am has a volume of 10,000 and yesterday's volume at 9:00am was 5,000, this would be a ratio of 2. (or maybe instead of yesterday, they take the average of the last X days.)

I'm not sure the specifics of what they're doing for RVOL, but it does seem interesting.

Are there any ideas on how they (or anyone) else could calculate RVOL for intraday trading, keeping in mind that you only have so much time in the day, so RVOL would have to be on a relative short time period.

I found this code, but not sure if it's the most ideal, or is there something better.

Ruby:
input length = 14; #number of time units
input offset = 1; #offset: 1 = don't include current time unit
def ADV = Average(volume, length)[offset]; #ADV
def rVol = Round(volume / ADV, 2); #relative volume

AddLabel(yes, rVol, if rVol >= 1 then COLOR.GREEN else COLOR.CURRENT);

The previous code is fairly crude way of calculating from candle to candle. Is there a better way?

Thank you.

ive got the following code related to RVOL, i would love to have it converted to work as label, current code works for watchlist only:

def isRollover = GetYYYYMMDD() != GetYYYYMMDD()[1];
def beforeStart = GetTime() < RegularTradingStart(GetYYYYMMDD());
def vol = if isRollover and beforeStart then volume else if beforeStart then vol[1] + volume else Double.NaN;
def PMV = if IsNaN(vol) then PMV[1] else vol;
def AV = AggregationPeriod.DAY;
def x = Average(Volume(period=AV)[1],50);
def y1 = Round((PMV/x),2);
def L = Lg(y1);
def p = if L>=1 then 0 else if L>=0 then 1 else 2;
def y2 = Round(y1,p);
plot z = y2;
z.assignValueColor(if z>=10 then color.CYAN else if z>=1 then createcolor(255,153,153) else createcolor(0,215,0));
 
@red_man_1111 : Try this...

Code:
input AV = AggregationPeriod.DAY;

def isRollover = GetYYYYMMDD() != GetYYYYMMDD()[1];
def beforeStart = GetTime() < RegularTradingStart(GetYYYYMMDD());
def vol = if isRollover and beforeStart then volume else if beforeStart then vol[1] + volume else Double.NaN;
def PMV = if IsNaN(vol) then PMV[1] else vol;
def x = Average(volume(period = AV)[1], 50);
def y1 = Round((PMV / x), 2);
def L = Lg(y1);
def p = if L >= 1 then 0 else if L >= 0 then 1 else 2;
def y2 = Round(y1, p);
def z = y2;
#z.assignValueColor(if z>=10 then color.CYAN else if z>=1 then createcolor(255,153,153) else createcolor(0,215,0));

addlabel(yes, "RVOL: " + round(z, 2), if z >= 10 then Color.CYAN else if z >= 1 and z < 10 then CreateColor(255, 153, 153) else CreateColor(0, 215, 0));
 
@red_man_1111 : Try this...

Code:
input AV = AggregationPeriod.DAY;

def isRollover = GetYYYYMMDD() != GetYYYYMMDD()[1];
def beforeStart = GetTime() < RegularTradingStart(GetYYYYMMDD());
def vol = if isRollover and beforeStart then volume else if beforeStart then vol[1] + volume else Double.NaN;
def PMV = if IsNaN(vol) then PMV[1] else vol;
def x = Average(volume(period = AV)[1], 50);
def y1 = Round((PMV / x), 2);
def L = Lg(y1);
def p = if L >= 1 then 0 else if L >= 0 then 1 else 2;
def y2 = Round(y1, p);
def z = y2;
#z.assignValueColor(if z>=10 then color.CYAN else if z>=1 then createcolor(255,153,153) else createcolor(0,215,0));

addlabel(yes, "RVOL: " + round(z, 2), if z >= 10 then Color.CYAN else if z >= 1 and z < 10 then CreateColor(255, 153, 153) else CreateColor(0, 215, 0));

hey man thanks a lot, it seem to work within Daily timeframe, is there any tweak for the code in order to make it work in lower timeframes, like 1H or 3M, because when in those timeframes i get random results. thanks again!
 
@red_man_1111 : Try this...

Step 1...Load the Study...

202407191512_shot1_.png



Step 2...Right-click on the Study and select Edit Properties...

202407191518_shot2_.png



Step 3...Select the Timeframe (a/k/a Aggregation) of your choice...

202407191521_shot3_.png


Hope this helps...

Good Luck and Good Trading :cool:
 
@red_man_1111 : Try this...

Step 1...Load the Study...

View attachment 22431


Step 2...Right-click on the Study and select Edit Properties...

View attachment 22432


Step 3...Select the Timeframe (a/k/a Aggregation) of your choice...

View attachment 22433

Hope this helps...

Good Luck and Good Trading :cool:
hey man, a appreciate the help, unfortunately it doesn't work, while I'm in a lower timeframe for example 3M and the study is set to Daily, still getting fake value
 
@red_man_1111 : I'm hoping this might do it...

Code:
input AV = AggregationPeriod.DAY;

def isRollover = GetYYYYMMDD() != GetYYYYMMDD()[1];
def beforeStart = GetTime() < RegularTradingStart(GetYYYYMMDD());
def vol = if isRollover and beforeStart then volume(period = AV) else if beforeStart then vol[1] + volume(period = AV) else Double.NaN;
def PMV = if IsNaN(vol) then PMV[1] else vol;
def x = Average(volume(period = AV)[1], 50);
def y1 = Round((PMV / x), 2);
def L = Lg(y1);
def p = if L >= 1 then 0 else if L >= 0 then 1 else 2;
def y2 = Round(y1, p);
def z = y2;
#z.assignValueColor(if z>=10 then color.CYAN else if z>=1 then createcolor(255,153,153) else createcolor(0,215,0));

addlabel(yes, "RVOL: " + round(z, 2), if z >= 10 then Color.CYAN else if z >= 1 and z < 10 then CreateColor(255, 153, 153) else CreateColor(0, 215, 0));

The instructions in my last reply still apply...it should work...Looking a little closer at the script, I think the problem was "AV", the AggregationPeriod specification, was targeting only one of the volume entries when, in fact, there are three...I've updated the script to address this...

Let me know how it goes...

Good Luck and Good Trading :cool:
 
@red_man_1111 : I'm hoping this might do it...

Code:
input AV = AggregationPeriod.DAY;

def isRollover = GetYYYYMMDD() != GetYYYYMMDD()[1];
def beforeStart = GetTime() < RegularTradingStart(GetYYYYMMDD());
def vol = if isRollover and beforeStart then volume(period = AV) else if beforeStart then vol[1] + volume(period = AV) else Double.NaN;
def PMV = if IsNaN(vol) then PMV[1] else vol;
def x = Average(volume(period = AV)[1], 50);
def y1 = Round((PMV / x), 2);
def L = Lg(y1);
def p = if L >= 1 then 0 else if L >= 0 then 1 else 2;
def y2 = Round(y1, p);
def z = y2;
#z.assignValueColor(if z>=10 then color.CYAN else if z>=1 then createcolor(255,153,153) else createcolor(0,215,0));

addlabel(yes, "RVOL: " + round(z, 2), if z >= 10 then Color.CYAN else if z >= 1 and z < 10 then CreateColor(255, 153, 153) else CreateColor(0, 215, 0));

The instructions in my last reply still apply...it should work...Looking a little closer at the script, I think the problem was "AV", the AggregationPeriod specification, was targeting only one of the volume entries when, in fact, there are three...I've updated the script to address this...

Let me know how it goes...

Good Luck and Good Trading :cool:
hey man, thanks a lot, unfortunately it still giving fake value compared to the watchlist :(
 
@red_man_1111 : This is working on my end:

1. Remove the previous code and then copy/paste the following into the Watchlist:

Code:
def isRollover = GetYYYYMMDD() != GetYYYYMMDD()[1];
def beforeStart = GetTime() < RegularTradingStart(GetYYYYMMDD());
def vol = if isRollover and beforeStart then volume else if beforeStart then vol[1] + volume else Double.NaN;
def PMV = if IsNaN(vol) then PMV[1] else vol;
def x = Average(volume[1], 50);
def y1 = Round((PMV / x), 2);
def L = Lg(y1);
def p = if L >= 1 then 0 else if L >= 0 then 1 else 2;
def y2 = Round(y1, p);
plot z = y2;
z.AssignValueColor(if z >= 10 then Color.CYAN else if z >= 1 then CreateColor(255, 153, 153) else CreateColor(0, 215, 0));

2. Remove the previous code and then copy/paste the following into the study where you put the Relative Volume label:

Code:
def isRollover = GetYYYYMMDD() != GetYYYYMMDD()[1];
def beforeStart = GetTime() < RegularTradingStart(GetYYYYMMDD());
def vol = if isRollover and beforeStart then volume else if beforeStart then vol[1] + volume else Double.NaN;
def PMV = if IsNaN(vol) then PMV[1] else vol;
def x = Average(volume[1], 50);
def y1 = Round((PMV / x), 2);
def L = Lg(y1);
def p = if L >= 1 then 0 else if L >= 0 then 1 else 2;
def y2 = Round(y1, p);
def z = y2;

addlabel(yes, "RVOL: " + round(z, 2), if z >= 10 then Color.CYAN else if z >= 1 and z < 10 then CreateColor(255, 153, 153) else CreateColor(0, 215, 0));

Please note: In order for this to work, you must specify the desired timeframe for both the Watchlist and the Chart(s) where you have the Label...

202408131519_a_.png


202408131529_b_.png


202408131532_c_.png


3. I would also suggest selecting 20 days or more on a 3-minute chart and a year or more on a Daily chart...

Hope this helps...

Good Luck and Good Trading :cool:
 
Here is what I'm looking at...

3 min on the Chart and the "RVOL" Watchlist Column...

202408141046_b_.png


202408141042_a_.png


Daily on the Chart and the "RVOL" Watchlist Column...

202408141104_e_.png


202408141105_f_.png


Just to make sure, here is the code I'm using...

Chart Label:

Code:
declare upper;
def isRollover = GetYYYYMMDD() != GetYYYYMMDD()[1];
def beforeStart = GetTime() < RegularTradingStart(GetYYYYMMDD());
def vol = if isRollover and beforeStart then volume else if beforeStart then vol[1] + volume else Double.NaN;
def PMV = if IsNaN(vol) then PMV[1] else vol;
def x = Average(volume[1], 50);
def y1 = Round((PMV / x), 2);
def L = Lg(y1);
def p = if L >= 1 then 0 else if L >= 0 then 1 else 2;
def y2 = Round(y1, p);
def z = y2;

addlabel(yes, "RVOL: " + round(z, 2), if z >= 10 then Color.CYAN else if z >= 1 and z < 10 then CreateColor(255, 153, 153) else CreateColor(0, 215, 0));

"RVOL" Watchlist Column:

Code:
def isRollover = GetYYYYMMDD() != GetYYYYMMDD()[1];
def beforeStart = GetTime() < RegularTradingStart(GetYYYYMMDD());
def vol = if isRollover and beforeStart then volume else if beforeStart then vol[1] + volume else Double.NaN;
def PMV = if IsNaN(vol) then PMV[1] else vol;
def x = Average(volume[1], 50);
def y1 = Round((PMV / x), 2);
def L = Lg(y1);
def p = if L >= 1 then 0 else if L >= 0 then 1 else 2;
def y2 = Round(y1, p);
plot z = y2;
z.AssignValueColor(if z >= 10 then Color.CYAN else if z >= 1 then CreateColor(255, 153, 153) else CreateColor(0, 215, 0));

Thank you for screenshot...Please make sure the timeframes are in sync and the code for the Chart Label is the same as listed above...

Hope this helps...

Good Luck and Good Trading... :cool:
 
Here is what I'm looking at...

3 min on the Chart and the "RVOL" Watchlist Column...

View attachment 22614

View attachment 22615

Daily on the Chart and the "RVOL" Watchlist Column...

View attachment 22616

View attachment 22617

Just to make sure, here is the code I'm using...

Chart Label:

Code:
declare upper;
def isRollover = GetYYYYMMDD() != GetYYYYMMDD()[1];
def beforeStart = GetTime() < RegularTradingStart(GetYYYYMMDD());
def vol = if isRollover and beforeStart then volume else if beforeStart then vol[1] + volume else Double.NaN;
def PMV = if IsNaN(vol) then PMV[1] else vol;
def x = Average(volume[1], 50);
def y1 = Round((PMV / x), 2);
def L = Lg(y1);
def p = if L >= 1 then 0 else if L >= 0 then 1 else 2;
def y2 = Round(y1, p);
def z = y2;

addlabel(yes, "RVOL: " + round(z, 2), if z >= 10 then Color.CYAN else if z >= 1 and z < 10 then CreateColor(255, 153, 153) else CreateColor(0, 215, 0));

"RVOL" Watchlist Column:

Code:
def isRollover = GetYYYYMMDD() != GetYYYYMMDD()[1];
def beforeStart = GetTime() < RegularTradingStart(GetYYYYMMDD());
def vol = if isRollover and beforeStart then volume else if beforeStart then vol[1] + volume else Double.NaN;
def PMV = if IsNaN(vol) then PMV[1] else vol;
def x = Average(volume[1], 50);
def y1 = Round((PMV / x), 2);
def L = Lg(y1);
def p = if L >= 1 then 0 else if L >= 0 then 1 else 2;
def y2 = Round(y1, p);
plot z = y2;
z.AssignValueColor(if z >= 10 then Color.CYAN else if z >= 1 then CreateColor(255, 153, 153) else CreateColor(0, 215, 0));

Thank you for screenshot...Please make sure the timeframes are in sync and the code for the Chart Label is the same as listed above...

Hope this helps...

Good Luck and Good Trading... :cool:

hey man, I'm so thankful for your help, remember i intend to show the Daily value within the 3M timeframe :)
 
@red_man_1111 : So, if I'm listening correctly, what you're saying is you need a Multi-TimeFrame (MTF) version of the current script...OK...Let me see what I can do...Let me know if I'm off-track with my assessment regarding what you need...

I'm going to have to take a couple of days to finish up some work-related things and then I can focus on the RV script...

Good Luck and Good Trading :cool:
 
@red_man_1111 : It's been a couple of days now and I wanted to make sure to get back to you about the MTF in relation to:

remember i intend to show the Daily value within the 3M timeframe

Unfortunately, I have way to much on my plate at the moment to be of any further assistance...I'm sure one of the experts/talented 'scripters will read this thread and maybe give you a hand with reaching your goal...

Good Luck and Good Trading :cool:
 
Can someone please help me out. I would like to add an alert when the relative volume hits 10 on the custom search column.



Thank you

def isRollover = GetYYYYMMDD() != GetYYYYMMDD()[1];
def beforeStart = GetTime() < RegularTradingStart(GetYYYYMMDD());
def vol = if isRollover and beforeStart then volume else if beforeStart then vol[1] + volume else Double.NaN;
def PMV = if IsNaN(vol) then PMV[1] else vol;
def x = Average(volume[1], 50);
def y1 = Round((PMV / x), 2);
def L = Lg(y1);
def p = if L >= 1 then 0 else if L >= 0 then 1 else 2;
def y2 = Round(y1, p);
def z = y2;

addlabel(yes, " " + round(z, 2), if z >= 10 then Color.CYAN else if z >= 1 and z < 10 then CreateColor(255, 153, 153) else CreateColor(0, 215, 0));
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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