It calculates relative (RVOL) based on the average at that time of day (rather than using a moving average).
For example, using this indicator you can see today’s during the first 5-minute candle of the market open compared to the previous day’s at the market open. Or you can see today’s at the market close during the last 15-minute candle compared to the average of the past 20 days of at the market close.
Due to the different quantity of in a session between Stocks and Forex/Crypto, I separated those markets into separate settings, making this an all-in-one indicator that works on all markets.
If you set the lookback period to 1 on the 5-minute chart and look at the 9:30am candle for a stock, then the current bar will show you what today’s is compared to yesterday’s 9:30am 5-minute candle.
If you set the lookback period to 15, then the current bar will show you what today’s is compared to the average of the last 15 days of 9:30am 5-minute candles.
Max Lookback: 64 Sessions
This setting is for traders who want to use this indicator on a timeframe lower than the 5-minute chart.
Due to limitations in how many historical bars PineScript can reference, referencing 1-minute and 3-minute bars requires a lot more historical data so I separated the two to allow the 5-minute+ timeframes to have a longer lookback period.
Max Lookback: 12 Sessions
When you set the script to Forex/Crypto, it does the same thing for stocks but calculates based on a 24-hour period.
So if you set the lookback period to 1 on the 1-hour chart and look at the 11:00am candle for a currency pair, then the current bar will show you what today’s is compared to yesterday’s 11:00am 1-hour candle.
If you set the lookback period to 10, then the current bar will show you what today’s is compared to the average of the last 10 days of 11:00am 1-hour candles.
Max Lookback: 17 Sessions
What Doesn’t It Work On?
Because I had to manually calculate how many candles to look back per timeframe to get the previous session’s candle, I had to hard-code the math in this script.
That means that this indicator will only work on 1m, 3m , 5m, 15m, 30m, 45m, 1h, 2h, 3h, 4h, Daily and Weekly timeframes. If you try to use it on any other timeframe it will revert to a regular indicator.
Why Is It Useful?
Similar to by price, this gives you a by time in a way that the default indicator does not.
For example, you can use this to determine when a stock has a particularly strong opening drive, or when a currency pair has a weak fake-out leading up to the London open, or for general confirmation on trading signals with time-specific information to work with.
The purple line and the faint gray bar is the RVOL value.
The blue number is the percentage of the current bar relative to RVOL.
There are four different bar color settings:
Heatmap – Changes color to be brighter based on higher RVOL
Price – Changes color based on price action (like the default TradingView indicator)
Traffic – Changes color based on RVOL percentages (for fast visual cues)
Trigger – Changes color only when the specified alert conditions are met
Turns very bright green at 2.0 RVOL
Turns light green at 1.0 RVOL
Turns normal green at 0.75 RVOL
Turns medium green at 0.5 RVOL
Turns very dark green at 0.25 RVOL
Is gray otherwise.
Turns red if the price action candle closed .
Turns green if the price action candle closed .
Turns red if RVOL is between 1.0 and 1.5.
Turns orange if RVOL is between 1.5 and 2.0.
Turns dark green if RVOL is between 2.0 and 3.0.
Turns bright green if RVOL is above 3.0.
Is gray otherwise.
Turns teal if any of the given alert conditions in the user settings are met.
Alerts are optional. You have to set them like any other indicator, by creating a new alert and selecting this indicator.
If you leave the "Alert At RVOL %" setting at 0, then alerts will only be triggered if the current candle exceeds the 1.0 (100%) RVOL level.
If you change the "Alert At RVOL %" setting then alerts will be triggered if the RVOL percentage (blue number) exceeds your given value. The blue number is a percentage of the average, so if it’s at 0.5, then it’s 50% of the average.
- This indicator only works with regular time bars. It will not work with range, tick, renko etc.
- This script has lookback limitations due to restrictions on how many historical bars PineScript can reference. The lookback limit varies based on the market type you choose. The more bars required for calculation the lower the lookback limit.
- If you use it on the the lookback period will count as 1 week. If you use it on the the lookback period will count as 1 month. So a Lookback of 3 on the Daily would be 3 weeks of averages, a Lookback of 5 on the Weekly would be 5 months of averages (for that Day of Week or Week number).
- Big thanks to @tb12345 for the idea and for helping to field-testing the indicator!
- Go to http://www.zenandtheartoftrading.com/ind... for the source code – it’s free!
Go to http://www.zenandtheartoftrading.com for articles on forex trading, trading psychology, trading resources, PineScript lessons and more!
Basically compare the cumulative volume from the start of the session till a point in time, with the average cumulative volume over n days till that same point in time in their respective trading sessions.
suppose now (current session of day 1) is 10.30am. calculate cumulative volume (regardless of buy or sell direction, i.e not like the obv indicator) for this current session till 10.30am
calculate cumulative volume till 10.30am for last n number of days (i.e day 2 cummulative volume till 10.30am = x, day 3 till 10.30am = y, day n till 10.30am = z )
calculate average cumulative volume till 10.30am over last n days (i.e / n)
compare cumulative volume till 10.30am of current day/session (day 1) with the previously calculated average cumulative volume till 10.30am of day 2, day 3, day n.
The resulting value is then represented as the rvol at that point in time.
Let me know, and thanks again for your work.
Happy trading :)
As in an ATR-like script by time of day? If that's what you mean then that's great. When I woke up this morning the very first thought I had was 'I should try converting that RVOL script to an ATR version' lol. I've already started working on it
The problem is that the official ATR formula uses the previous candle's data to calculate the range value, and doing that with a long lookback period in a For-Loop is far too hard to do in pinescript. I'll think about it for a while but I think it's impossible.
In the meantime I can make a simple one that only averages the range of each candle's high and low, that's probably the best we can get but it should be close enough for most markets that don't gap too frequently.
I'll play around with it and let you know what I come up with :)