SOLVED : CODE BELOW
Hey, I have been searching for awhile for a classic RVOL indicator for TOS. None of this craziness with bright lights and a million signals. Im just trying to get the classic RVOL that is used on FINVIZ.com and Trade ideas. I know other people have been looking for it as well. I can tell by the countless requests similar to the searches i have been making on this forum and other sources.
A couple people have suggested that TOS is just not powerful enough to handle the calculation and there is some fundamental issue?
We have all seen the very simple def rVol = volume / Average(volume, 10) but this is useless intraday for the most part.
The RVOL i need and ive seen many others trying to get also is a INTRADAY RVOL based on the average daily volume.
My questions: Can someone please tell me if this is possible or suggest a better way to get this classic Intraday RVOL I would be 1000% appreciative!
i would also be willing to pay for this indicator if someone wants to go that route! I would however want to keep the code public source as i think this is a much needed indicator that from what i have seen does not have a readily available solution.
I just want a simple RVOL ratio and plot it on a chart label as-well as a custom watchlist column for scanning purposes
Cheers
This is the pseudo calculation
RVOL =
( todays Volume done thus since 9:30am )
Divided by
( last 10 days volume done in the same cumulative time as Today thus far)
Update every 5m and rolling on until 4pm
NOTE: RVOL is a rolling calculation, so as time goes on, the reference period needs to move on as well.
these are two examples based on different times
In actuality it will need to update every 5mins as will the reference period. So if its 9:35 it will be comparing the first 5m, at 9:40 it will be 10m, at 9:45 it will be first 15m and if it is 10:30, it will need to compare the first 1H volume to the previous 10 days first 1H etc etc until 4pm.
The rough idea i had to fufill this calculation in thinkscript was as follows
RVOL =
IF it is 9:40am
Todays volume = ( first 10m candle volume since open)
divided by
(the Average of the Last 10 days first 10m candle volume since open) = ( yesterday first 10m volume + 2day ago first 10m volume + 3 day ago first 10m volume + 4 day ago first 10m volume + 5 day ago first 10m volume + 6 day ago first 10m volume + 7 day ago first 10m volume + 8 day ago first 10m volume + 9 day ago first 10m volume + 10 day ago first 10m volume ) Divided by 10
IF it is 9:45am
RVOL =
Todays volume = ( first 15m candle volume since open)
divided by
(the Average of the Last 10 days first 15m candle volume since open) = ( yesterday first 15m volume + 2day ago first 15m volume + 3 day ago first 15m volume + 4 day ago first 15m volume + 5 day ago first 15m volume + 6 day ago first 15m volume + 7 day ago first 15m volume + 8 day ago first 15m volume + 9 day ago first 15m volume + 15 day ago first 15m volume ) Divided by 10
And so on until 4pm recalculating every 5m.
ANSWER Below and a big thank you to @Svanoy
Notes
1. Use on a 5m - 90day chart
2. Remove after hours data on the chart
3. its a difficult calculation for TOS, its gonna slow down the platform so run it on a separate instance if that is an issue
4. i added dynamic chart label <1 Dark red, <2 red, >2 green, >5 dark green.
declare lower;
input Number_Of_Signals_To_Be_Averaged = 60;
input Value_To_Be_Averaged = volume;
def Active = 1;
def bar = BarNumber();
def BarNum = if !IsNaN(close) then bar else BarNum[1];
def VBar = HighestAll(BarNum);
#################
def NumberedBars;
if GetDay() <> GetDay()[1] {
NumberedBars = 0;
} else {
NumberedBars = NumberedBars[1] + 1;
}
def FirstDayStart = CompoundValue(1, if GetDay() <> GetDay()[1] then 1 else FirstDayStart[1], 0);
def TotalSignalCount = if bar == 1 and GetDay() == GetDay()[1] then 0 else if TotalSignalCount[1] == 0 and FirstDayStart then 1 else if NumberedBars == 1 then TotalSignalCount[1] + 1 else TotalSignalCount[1];
################
def DayRunningTotal;
if !FirstDayStart or !Active {
DayRunningTotal = 0;
} else if NumberedBars == 0 {
DayRunningTotal = Value_To_Be_Averaged;
} else if Active {
DayRunningTotal = DayRunningTotal[1] + Value_To_Be_Averaged;
} else {
DayRunningTotal = 0;
}
def SignalRangeTotal = fold r = 1 to VBar with intr = 0 do if GetValue(NumberedBars, r) == NumberedBars then intr + GetValue(DayRunningTotal, r) else intr;
def TotalToBeRemoved = fold t = 1 to VBar with intt = 0 do if GetValue(NumberedBars, t) == NumberedBars and GetValue(TotalSignalCount, t) < TotalSignalCount - Number_Of_Signals_To_Be_Averaged then intt + GetValue(DayRunningTotal, t) else intt;
def RangeAverage = Round((SignalRangeTotal - TotalToBeRemoved) / Number_Of_Signals_To_Be_Averaged, 0);
def RVOL = if !IsNaN(close) and Active and TotalSignalCount > Number_Of_Signals_To_Be_Averaged and DayRunningTotal[1] / RangeAverage[1] > 0 then DayRunningTotal[1] / RangeAverage[1] else Double.NaN;
def zero = 0;
#addlabel(yes,"RVOL : " + RVOL,color.light_RED);
#AddLabel(yes, "RVOL : " + RVOL, ( if RVOL < 2 then Color.LIGHT_RED else if RVOL >= 2 then Color.LIGHT_GREEN else color.white));
AddLabel(
yes,
"RVOL : " + RVOL,
if RVOL < 1 then Color.DARK_RED
else if RVOL < 2 then Color.LIGHT_RED
else if RVOL > 5 then Color.DARK_GREEN
else if RVOL > 2 then Color.LIGHT_GREEN
else Color.WHITE
);
Hey, I have been searching for awhile for a classic RVOL indicator for TOS. None of this craziness with bright lights and a million signals. Im just trying to get the classic RVOL that is used on FINVIZ.com and Trade ideas. I know other people have been looking for it as well. I can tell by the countless requests similar to the searches i have been making on this forum and other sources.
A couple people have suggested that TOS is just not powerful enough to handle the calculation and there is some fundamental issue?
We have all seen the very simple def rVol = volume / Average(volume, 10) but this is useless intraday for the most part.
The RVOL i need and ive seen many others trying to get also is a INTRADAY RVOL based on the average daily volume.
My questions: Can someone please tell me if this is possible or suggest a better way to get this classic Intraday RVOL I would be 1000% appreciative!
i would also be willing to pay for this indicator if someone wants to go that route! I would however want to keep the code public source as i think this is a much needed indicator that from what i have seen does not have a readily available solution.
I just want a simple RVOL ratio and plot it on a chart label as-well as a custom watchlist column for scanning purposes
Cheers
This is the pseudo calculation
RVOL =
( todays Volume done thus since 9:30am )
Divided by
( last 10 days volume done in the same cumulative time as Today thus far)
Update every 5m and rolling on until 4pm
NOTE: RVOL is a rolling calculation, so as time goes on, the reference period needs to move on as well.
these are two examples based on different times
In actuality it will need to update every 5mins as will the reference period. So if its 9:35 it will be comparing the first 5m, at 9:40 it will be 10m, at 9:45 it will be first 15m and if it is 10:30, it will need to compare the first 1H volume to the previous 10 days first 1H etc etc until 4pm.
The rough idea i had to fufill this calculation in thinkscript was as follows
RVOL =
IF it is 9:40am
Todays volume = ( first 10m candle volume since open)
divided by
(the Average of the Last 10 days first 10m candle volume since open) = ( yesterday first 10m volume + 2day ago first 10m volume + 3 day ago first 10m volume + 4 day ago first 10m volume + 5 day ago first 10m volume + 6 day ago first 10m volume + 7 day ago first 10m volume + 8 day ago first 10m volume + 9 day ago first 10m volume + 10 day ago first 10m volume ) Divided by 10
IF it is 9:45am
RVOL =
Todays volume = ( first 15m candle volume since open)
divided by
(the Average of the Last 10 days first 15m candle volume since open) = ( yesterday first 15m volume + 2day ago first 15m volume + 3 day ago first 15m volume + 4 day ago first 15m volume + 5 day ago first 15m volume + 6 day ago first 15m volume + 7 day ago first 15m volume + 8 day ago first 15m volume + 9 day ago first 15m volume + 15 day ago first 15m volume ) Divided by 10
And so on until 4pm recalculating every 5m.
ANSWER Below and a big thank you to @Svanoy
Notes
1. Use on a 5m - 90day chart
2. Remove after hours data on the chart
3. its a difficult calculation for TOS, its gonna slow down the platform so run it on a separate instance if that is an issue
4. i added dynamic chart label <1 Dark red, <2 red, >2 green, >5 dark green.
declare lower;
input Number_Of_Signals_To_Be_Averaged = 60;
input Value_To_Be_Averaged = volume;
def Active = 1;
def bar = BarNumber();
def BarNum = if !IsNaN(close) then bar else BarNum[1];
def VBar = HighestAll(BarNum);
#################
def NumberedBars;
if GetDay() <> GetDay()[1] {
NumberedBars = 0;
} else {
NumberedBars = NumberedBars[1] + 1;
}
def FirstDayStart = CompoundValue(1, if GetDay() <> GetDay()[1] then 1 else FirstDayStart[1], 0);
def TotalSignalCount = if bar == 1 and GetDay() == GetDay()[1] then 0 else if TotalSignalCount[1] == 0 and FirstDayStart then 1 else if NumberedBars == 1 then TotalSignalCount[1] + 1 else TotalSignalCount[1];
################
def DayRunningTotal;
if !FirstDayStart or !Active {
DayRunningTotal = 0;
} else if NumberedBars == 0 {
DayRunningTotal = Value_To_Be_Averaged;
} else if Active {
DayRunningTotal = DayRunningTotal[1] + Value_To_Be_Averaged;
} else {
DayRunningTotal = 0;
}
def SignalRangeTotal = fold r = 1 to VBar with intr = 0 do if GetValue(NumberedBars, r) == NumberedBars then intr + GetValue(DayRunningTotal, r) else intr;
def TotalToBeRemoved = fold t = 1 to VBar with intt = 0 do if GetValue(NumberedBars, t) == NumberedBars and GetValue(TotalSignalCount, t) < TotalSignalCount - Number_Of_Signals_To_Be_Averaged then intt + GetValue(DayRunningTotal, t) else intt;
def RangeAverage = Round((SignalRangeTotal - TotalToBeRemoved) / Number_Of_Signals_To_Be_Averaged, 0);
def RVOL = if !IsNaN(close) and Active and TotalSignalCount > Number_Of_Signals_To_Be_Averaged and DayRunningTotal[1] / RangeAverage[1] > 0 then DayRunningTotal[1] / RangeAverage[1] else Double.NaN;
def zero = 0;
#addlabel(yes,"RVOL : " + RVOL,color.light_RED);
#AddLabel(yes, "RVOL : " + RVOL, ( if RVOL < 2 then Color.LIGHT_RED else if RVOL >= 2 then Color.LIGHT_GREEN else color.white));
AddLabel(
yes,
"RVOL : " + RVOL,
if RVOL < 1 then Color.DARK_RED
else if RVOL < 2 then Color.LIGHT_RED
else if RVOL > 5 then Color.DARK_GREEN
else if RVOL > 2 then Color.LIGHT_GREEN
else Color.WHITE
);
Last edited: