Thanks for the suggestion. I tried it:@zwedle AssignBackgroundColor() is your culprit... It is being used in the wrong context... Try using c.AssignValueColor() instead...
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);
#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);
@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.Have you figured out a way to calculate relative volume on ToS?
#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
#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
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?
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);
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);
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.@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);
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 helpsThanks, @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.
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);
#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);
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
What do you think of this idea? Is there another way you can think of that would be simpler?
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 haveSimpler, 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;
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
S | Trade Ideas Intraday , single bar , Relative Volume RVOL For ThinkOrSwim | Indicators | 16 | |
N | Relative Strength RP Labels For ThinkOrSwim | Indicators | 35 | |
ARSI - Adaptive Relative Strength Index for ThinkorSwim | Indicators | 15 | ||
YungTrader's Relative Volume | Indicators | 17 | ||
Relative Vigor Index (RVI) for ThinkorSwim | Indicators | 6 |
Start a new thread and receive assistance from our community.
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.
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.