RVOL (Relative Volume) Scan Label Watchlist for ThinkorSwim

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

@zwedle AssignBackgroundColor() is your culprit... It is being used in the wrong context... Try using c.AssignValueColor() instead...
Thanks for the suggestion. I tried it:

Code:
plot c = Volume(period = AggregationPeriod.DAY) / Average(volume(period = AggregationPeriod.DAY), 63);
c.SetDefaultColor(Color.BLACK);
c.AssignValueColor(if c > 20 then Color.BLUE
else if c > 10 then Color.DARK_GREEN
else if c > 8 then Color.GREEN
else if c > 6 then Color.LIGHT_GREEN
else if c > 4 then Color.LIME
else if c > 2 then Color.YELLOW
else if c > 1 then Color.PINK
else if c < 1 then Color.RED else Color.LIGHT_GRAY);
AddLabel(yes, AsText(c, NumberFormat.TWO_DECIMAL_PLACES) + "x", Color.Black);

but now it's blacked out. And by chart study I meant chart label 👨‍⚕️🔨
 
@zwedle Well, you did code the label to be black. ;)

Maybe a nice color.blue, color.yellow. something other than black?

Code:
#change your code from:
AddLabel(yes, AsText(c, NumberFormat.TWO_DECIMAL_PLACES) + "x", Color.Black);

#to:
AddLabel(yes, AsText(c, NumberFormat.TWO_DECIMAL_PLACES) + "x", Color.Blue);
 
Last edited:
Have you figured out a way to calculate relative volume on ToS?
@ssaeed73 The script below is what I used as a column in a watchlist. I did not write the script and got it from a thread here. I believed it was written by and credit to @BenTen. I don't really rely a whole lot on the RV, but it is a good thing to see the RV value and pick the top 5 largest values.

Code:
#Relavitve Volume
# 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 AV = AggregationPeriod.DAY;
def x = Average(Volume(period=AV)[1],60);
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));

#end Code

One of my intraday strategies is entering into a position on a reverse trend. I do use Supertrend Yahoo as an indicator and customize it to my liking for an entry (less noise and entry/exit). I scan for a candle pattern of the popular Three Line Strike candle pattern set at 3 mins. I also have included below the code for this candle to include in your scans. You can google the Three Line Strike candle pattern for more info. Give it a shot and let me know.

Code:
#Three Line Strike candle pattern
#Code

def IsUp = close > open;
def IsDown = close < open;
def IsDoji = IsDoji();
def avgRange = 0.05 * Average(high - low, 20);
plot PatternPlot =
    IsDown[3] and
    IsDown[2] and
    IsDown[1] and
    IsUp[0] and
    low[3] > low[2] and
    high[1] < close[0] and
    low[2] > low[1] and
    low[1] > low[0];

#end Code

Good luck!

cabe1332
 
This is probably an easy problem to solve but I'm brand new to all this so please go easy on me....
I'd like to add a condition in a scanner that confirms the current bar (on 10 min chart) is not the highest of the last 10 in RelativeVolumeStDev ( StdLevel not vol).

If curbar.StdLevel is highest(10) then false, else true.... something to that effect.

Thanks in advance!
 
Thanks Xeo, as I said I’m a dummy when it comes to this. What I’m trying to achieve is something like the following (not in thinkscript, just how the operations would work):

def curvol = standardeviation of current bar
Def uppvol = highest standard deviation over last 10 bars

if curvol >= uppvol then return false, otherwise return true.

I’m only interested in which deviation range the volume falls and not necessarily the actual volume. I.e. 1, 2, 3, 4, etc.

Does this help?

The following code scans as follows: the largest standard volume deviation bar over last 10 bars is less than current standard volume deviation bar

(in other words the current volume deviation bar is greater than the last 10 volume deviation bars)

You can make the scan true or false or you can inverse it with "isOut "

Remember if you found this post useful to hit the like button.

Code:
declare lower;
input bars_ago = 10;
input length = 60;
input numDev = 2.0;
input allowNegativeValues = no;

def rawRelVol = (volume - Average(volume, length)) / StDev(volume, length);
def RelVol = if allowNegativeValues then rawRelVol else Max(0, rawRelVol);
def StDevLevel = numDev;

def RelVol_within_x_bars =  Highest(relvol[1],bars_ago);


plot scan = (RelVol_within_x_bars < relvol);
 
Last edited:
@we29125 I am trying to make watchlist column based on your code. I am getting N/A value. It might be due to the fact that it's not a trading hour (Sunday 3:40 PM CST). Is there any way to check if watchlist column is ok or not?

Code:
input STime = 0930 ; #hint STime: Start of normal trading hours
input ETime = 1600 ; #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 = 26 ; # 15mins Bars per day during active trading hours
#def bpd = 130 ; # 3mins Bars per day during active trading hours
def daycnt = 20; # Number of days

#input bpd = 78;

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] + volume[(bpd*11)+1] + volume[(bpd*12)+1] + volume[(bpd*13)+1] + volume[(bpd*14)+1] + volume[(bpd*15)+1] + volume[(bpd*16)+1] + volume[(bpd*17)+1] + volume[(bpd*18)+1] + volume[(bpd*19)+1] + volume[(bpd*20)+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] + volume[(bpd*11)+1] + volume[(bpd*12)+1] + volume[(bpd*13)+1] + volume[(bpd*14)+1] + volume[(bpd*15)+1] + volume[(bpd*16)+1] + volume[(bpd*17)+1] + volume[(bpd*18)+1] + volume[(bpd*19)+1] + volume[(bpd*20)+1] ) / daycnt
    else cumVolumePrev[1];

def RVOL = 100 * cumVolume / cumVolumePrev ;



AssignBackgroundColor(if RVOL > 200 then Color.dark_red
else if 115 < RVOL and  RVOL < 200 then Color.red
else if 85 < RVOL and  RVOL < 115 then Color.pink
else if 60 < RVOL and  RVOL < 85 then Color.gray
else Color.dark_gray);

AddLabel(1, Round(RVol, 2) , Color.white);
 
@alokranjan3 Try this code, I did not write the code I'm not sure who did but I'm sure it was someone in this forum

Code:
plot c = Volume(period = AggregationPeriod.DAY) / Average(volume(period = AggregationPeriod.DAY), 63);
c.SetDefaultColor(Color.BLACK);
c.AssignValueColor(if c > 20 then Color.BLUE
else if c > 10 then Color.DARK_GREEN
else if c > 8 then Color.GREEN
else if c > 6 then Color.LIGHT_GREEN
else if c > 4 then Color.LIME
else if c > 2 then Color.YELLOW
else if c > 1 then Color.PINK
else if c < .5 then Color.RED else Color.LIGHT_GRAY);
 
@alokranjan3 Try this code, I did not write the code I'm not sure who did but I'm sure it was someone in this forum

Code:
plot c = Volume(period = AggregationPeriod.DAY) / Average(volume(period = AggregationPeriod.DAY), 63);
c.SetDefaultColor(Color.BLACK);
c.AssignValueColor(if c > 20 then Color.BLUE
else if c > 10 then Color.DARK_GREEN
else if c > 8 then Color.GREEN
else if c > 6 then Color.LIGHT_GREEN
else if c > 4 then Color.LIME
else if c > 2 then Color.YELLOW
else if c > 1 then Color.PINK
else if c < .5 then Color.RED else Color.LIGHT_GRAY);
Thanks, @Break Trader.

I am trying to make RVOL watchlist work which slices day's RTH volume in 5 mins (or any other time frame) pieces. I am trying to make a system which is similar to Dan Zanger's trading method.
 
Thanks, @Break Trader.

I am trying to make RVOL watchlist work which slices day's RTH volume in 5 mins (or any other time frame) pieces. I am trying to make a system which is similar to Dan Zanger's trading method.
i have that same script on 5 min, 10 min, 30 min, hourly and daily, on my watch list, i look for i look for the hourly and daily to be + X2 and volume rising on the others if that helps
 
@Break Trader Thanks for your quick response. Its' a great help. I will try using various time frame using this watchlist column.

Code:
plot c = Volume(period = AggregationPeriod.DAY) / Average(volume(period = AggregationPeriod.DAY), 63);
c.SetDefaultColor(Color.BLACK);
c.AssignValueColor(if c > 20 then Color.BLUE
else if c > 10 then Color.DARK_GREEN
else if c > 8 then Color.GREEN
else if c > 6 then Color.LIGHT_GREEN
else if c > 4 then Color.LIME
else if c > 2 then Color.YELLOW
else if c > 1 then Color.PINK
else if c < .5 then Color.RED else Color.LIGHT_GRAY);
 
Hey @XeoNoX,

How would I go about counting the number of StandardDeviation events that occur within a certain number of bars. For example, I want to know how many times the StdDev was > 4 in the last 10 bars....

Thanks for any help!
 
How can I find the angle of the "regression" plot?

Code:
#Relative Volume slope
declare lower;
input short_Volume_length= 10;
input Volume_length = 30;
input Long_Volume_length = 50;
def x = Average(volume, Volume_length)[1];
def v = volume;
plot r = Round((v / x), 1) * 100;
plot short_regression = InertiaAll(r, short_Volume_length);
plot regression = InertiaAll(r, Volume_length);
plot Long_regression = InertiaAll(r,  Long_Volume_length);
#plot moving= movingAverage(averageType.EXPONENTIAL, r, 5);
plot Cross = regression crosses  Long_regression;
Cross.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);

How am I using this?
I have been doing a lot less day trading and have been focusing more on lower priced stocks that gradually gain traction. If you look at stocks like ZOM and SNDL there is a sudden increase in volume, then a little later on interest comes in to really move the price. So this script is being used to test out the idea of relative volume crossover against lower priced stocks. Degrees would help to define the gradual increase before the bigger moves. The idea is to jump in before major hype.

As an idea here is one scan I put together. Script should be named "Rvol_slope" for it to work. Doesn't show up with a lot of names but the idea is still a work in progress.

What do you think of this idea? Is there another way you can think of that would be simpler?

Code:
Rvol_slope()."short_regression" is greater than Rvol_slope()."short_regression" from 1 bars ago and
Rvol_slope()."long_regression" is greater than Rvol_slope()."long_regression" from 1 bars ago and 
Rvol_slope()."regression" crosses Rvol_slope()."Long_regression" within 2 bars
 
Last edited:
What do you think of this idea? Is there another way you can think of that would be simpler?

Simpler, though I'm not sure how effective, would be to look for a % increase in volume bar to bar on a higher timeframe. I'm guessing you're looking to calculate the slope on daily. You could look for an x% increase per bar on the weekly or monthly instead.

I took a quick stab at exactly what you're trying to do regarding trend angle a couple of weeks ago using a formula I found online but results weren't what I expected. Maybe it'll help you.

Ruby:
def height = regression - regression[length - 1];
def angle = ATan(height / length) * 180 / Double.Pi;
 
Simpler, though I'm not sure how effective, would be to look for a % increase in volume bar to bar on a higher timeframe. I'm guessing you're looking to calculate the slope on daily. You could look for an x% increase per bar on the weekly or monthly instead.

I took a quick stab at exactly what you're trying to do regarding trend angle a couple of weeks ago using a formula I found online but results weren't what I expected. Maybe it'll help you.

Ruby:
def height = regression - regression[length - 1];
def angle = ATan(height / length) * 180 / Double.Pi;
Thanks for the reply. I'll give the code a try. Think I might have

I have had multiple ideas regarding this. From two volume averages crossing over, to counting volume bars at or below volume average until a break above. None are exactly what I'm looking for. I'm sure a set of fresh eyes could give me some insight.
 
Just a thought, and wondering if its possible to use 100% as a zero starting point?
say volume at say 10am is only 18% of its 100% daily average being that it would now show up as -82%
then say at 1030am volume started to pick up a little now being at 64% of the 50 day averages showing volume as -36% volume and then 0 when it reaches 100% and then +10% when it reaches 110% of its 50 volume average and so on
 
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);
 
For these columns that calculate actual rvol, not a % of average daily volume, be sure to turn off Ext Hours for the column. I'm sure you've seen there are no bars on the chart for extended hours periods with no data. TOS does the same thing in scans and it skews what time of day it's looking at on previous days.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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