Forgive me if I'm missing something, or several things, here as it's going on 6am in my time zone and I'm way overdue for sleep.
First, I'm missing why you think RVOL will drop off through the day? Though it represents volume at this time of day compared to the average at this time of day, it's not resetting every candle. It's the cumulative volume at that time of day compared to the average of cumulative volume at that time of day. For instance, for today's session, in the pre-market I selected LYFT for my watchlist. The day is over and LYFT's RVOL is 4.74. It likely never was near the average.
If volume would fall off so much that RVOL is moving back to the average it means everyone lost interest except you. It means the current/recent volume at that time of day is lower than the average day. Do you still want to trade it? Some kind of fade play? If yes, okay this is the case where you would need
within x bars
. If you don't need
within x bars
then your scan is simple and you don't have to worry about only the current day because you'll only be scanning the current bar.
If these points haven't eliminated your desire for
within x bars
but only today...
To avoid looking back to the previous day I think you'd have to give up the
within x bars
syntax and instead keep a count of the bars since open and use something like this...
Ruby:
def rvol = # your rvol code
def x = 5; # x as in `within x bars`
def barCount = if GetDay() != GetDay()[1] then 1 else barCount + 1;
plot scan = Highest(rvol, Min(x, barCount)) >= 2;
If your rvol script on your chart doesn't lend itself to this you can find other examples in this thread:
https://usethinkscript.com/threads/rvol-relative-volume-indicator-watchlist-for-thinkorswim.1014/