diamondhands
New member
Hello, Can someone explain me why some of them are not showing and giving errors ?
Hello, Can someone explain me why some of them are not showing and giving errors ?
#Relative Volume = Todays Vol/Avg. Volume
#
def v = volume;
input avg_len = 50;
# use v[1] , so average starts with the previous bar
def avgvol = average( v[1], avg_len);
def relvol = v / avgvol;
From my understanding, Zanger Volume Ratio compares intraday volume accumulation, if it's 15 min bar and calculated on the second bar, Zanger volume compares accumulation of 9:30-10:00 and its average, yours compares 9:45-10:00, not the same thing. Correct me if I'm wrong. ThanksZanger 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);
Hi, Thx for the code it works well for calculating the first 30mins vol for the past 10 days. It matches my manual calculation perfectly.The code here probably has some bugs. In looking at it, this seems wrong to me:
Why is it using an index of 1, getting the previous bar instead of the current, on everything? That doesn't seem right. That seems like it'll get yesterday's last candle. It should probably be:
I'd paste the rest of my code for you but it doesn't have the active time window concept which you need.
To test/debug all of this, it's probably easiest to change to a 30m chart so you only care about one candle and don't have to keep adding candles' volumes together to see what it's capturing. Add a label that displayscumVolume
. Then find the candle with matching volume. If it matches the volume of the wrong candle then play with the index.
input STime = 0930 ; #hint STime: Start of normal trading hours
input ETime = 1000 ; #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 = 130 ; # 3mins Bars per day during active trading hours
#def bpd = 195 ; # 2mins Bars per day during active trading hours
#def bpd = 390 ; # 1mins 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
else if IsActive then cumVolume[1] + volume
else cumVolume[1];
# This is the average cumulative volume over the same time period from the previous 10 days
def cumVolumePrev = (cumVolume[(bpd*1)] + cumVolume[(bpd*2)] + cumVolume[(bpd*3)] + cumVolume[(bpd*4)] + cumVolume[(bpd*5)] + cumVolume[(bpd*6)] + cumVolume[(bpd*7)] + cumVolume[(bpd*8)] + cumVolume[(bpd*9)] + cumVolume[(bpd*10)]) / 10;
AddLabel(1, + Round(cumVolumePrev/30, 0), Color.YELLOW);
@vince92615 , if you really are wanting to build a watchlist column using ToS internal RelativeVolumeStDev, you'll want to basically programmatically use that study and check for 3 contiguous bars to be > 2. (or however many contiguous bars you would deem a cluster). and of course, to your selected timeframe (ex. 5min chart).thank you for helping
its on TOS under chart studies.
Thanks. I presume I do this through 'Alerts' > 'Study Alert'@mdoss2202 You would need to use a Scan set to send Alerts when a new symbol meets your conditions to do what you have described... That is the best way to handle audible message center and/or mobile Alerts...
Thanks. I presume I do this through 'Alerts' > 'Study Alert'
Anyone know if it's possible to block out said alert in the first and last 15 min of the day, bc rVol is always higher then and it's not helpful at that point. Similarly, is it possible to set said alert on my entire watchlist as opposed to doing so one at a time for every ticker?
I'm getting a "custom expression subscription limit exceeded" on some stocks. Is there a way to correct this?The study @BenTen posted on this thread used an AssignPriceColor() statement that would be applicable in charts.
Here's a relative volume for the watchlist I have been using. It is color coded so if the watchlist column is colored LIGHT_GREEN that flags a high relative volume day. Otherwise a PINK color on the watchlist column would indicate regular/moderate relative volume day
Code:# START plot c = Volume(period = AggregationPeriod.DAY) / Average(volume(period = AggregationPeriod.DAY), 20); c.SetDefaultColor(Color.BLACK); AssignBackgroundColor(if c > 5 then Color.LIGHT_GREEN else Color.PINK); # END
is there an advantage and disadvantage from using a shorter or longer code since they give same numbers?Here is the written code from the link @zeek provided:
Short version:
Code:def rVol = volume / Average(volume, 21)[1]; AddLabel(yes, round(rVol,2)); #AddLabel(yes, asPercent(rVol)); AssignPriceColor(if rVol >= 1 then color.dark_red else if rVol <=.5 then Color.black else color.Gray);
Long version:
Code:input length = 21; input offset = 1; def ADV = Average(volume, length)[offset]; def rVol = volume /ADV; # remove "#" infront of Addlabels to select prefer choice AddLabel(yes, round(rVol,2)); #AddLabel(yes, asPercent(rVol)); AssignPriceColor(if rVol >= 1 then color.dark_red else if rVol <=.5 then Color.black else color.Gray);
is there an advantage and disadvantage from using a shorter or longer code since they give same numbers?
Thanks for this great script, very useful.How rvol is supposed to be calculated is well known to some of us but I guess it's good you got confirmation for others. There's code already in this thread that has the right intent in how to calculate rvol but it's buggy. I posted comments on how to fix it recently. I'll post my code which is specifically for a watchlist column and you guys can modify for other purposes.
Whoever posted the original code had concerns about it dragging down overall TOS performance which is why I made it handle multiple timeframes. The lower the timeframe the more the performance impact. Though, I'm not sure I ever ran it below 5m so I'm not sure if the concern is warranted. The only real benefit of using a low timeframe is that the data is meaningless until the first period closes and a small period will close earlier. After that it matters less on each subsequent period. Though, you also don't want to set this higher than needed because it compares current volume to the average volume at the start of the period. If you set to 1H then at 11:15 it's comparing current volume to the average at 10:30. Better to narrow that window. After I switched to swing trading I changed mine to 10m. Before that I was using 5m.
This data is meaningless in pre-market. Having accurate pre-market rvol on TOS isn't possible because TOS doesn't have data for periods with no volume and it skews trying to look at the same time of day on previous days. Don't use Extended Hours with this code.
RVOL Watchlist Column Don't use Extended Hours with this code.
Ruby:input greenLevel = 1.5; def period = GetAggregationPeriod(); def minutesPerBar = period / 60000; def minutesPerDay = 60 * 6.5; # 6.5 hours of standard trading session def bpd = minutesPerDay / minutesPerBar; # bars per day # This is the cumulative volume for the current day def day = GetDay(); def cumVolume = if day != day[1] then volume else cumVolume[1] + volume ; # average of cumulative volume at this time of day for the last 10 trading days def avgCumVolume = (cumVolume[(bpd*1)] + cumVolume[(bpd*2)] + cumVolume[(bpd*3)] + cumVolume[(bpd*4)] + cumVolume[(bpd*5)] + cumVolume[(bpd*6)] + cumVolume[(bpd*7)] + cumVolume[(bpd*8)] + cumVolume[(bpd*9)] + cumVolume[(bpd*10)]) / 10; plot RVol = Round(if IsNaN(cumVolume) then 0 else cumVolume / avgCumVolume, 2); RVol.AssignValueColor(if RVol >= 1 and RVol < greenLevel then Color.YELLOW else if RVol >= greenLevel then Color.LIGHT_GREEN else Color.PINK);
You can easily sort this out by eliminating some custom quotes you are using in other watchlists, or limit the number of stocks in this watchlists. I hope that helps!Hello, Can someone explain me why some of them are not showing and giving errors ?
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.