OPEN-SOURCE SCRIPT
RVOL (Time-Segmented) [Pro]

//version=5
indicator("RVOL (Time-Segmented) [Pro]", shorttitle="RVOL Pro", overlay=false, format=format.volume)
// --- INPUTS ---
lookback = input.int(20, title="Lookback Period (Days)", minval=1, tooltip="Compares current volume to the average of this many past days at the exact same time.")
high_rvol_thresh = input.float(2.0, title="High RVOL Threshold", step=0.1, tooltip="Level to signal high conviction (Color changes).")
extreme_rvol_thresh = input.float(3.5, title="Extreme RVOL Threshold", step=0.1, tooltip="Level to signal climax/exhaustion.")
// --- CALCULATION ---
// We use a simpler approximation for 'time-segmented' volume by tracking the
// average volume relative to the time of day over the lookback period.
// Note: True historical time-segmentation in Pine requires complex arrays or request.security calls
// which can lag. This is a highly efficient optimized version for live trading.
// Get the average volume for this specific time of day over the last 'lookback' days
avg_vol_time = 0.0
for i = 1 to lookback
avg_vol_time := avg_vol_time + volume[i * 1440 / timeframe.multiplier] // Approximation for same time previous days
// Note: The above simple loop assumes 24/7 markets or consistent bar counts.
// For a more robust "Same Time" check in stocks (gaps), we use a standard SMA as fallback
// if intraday data is inconsistent, but the logic below is the standard "Relative Volume" formula.
// The most reliable "Live" RVOL formula for TradingView standard accounts:
// Current Volume / Average Volume of the last X days adjusted for time-of-day
// Since Pine Script has limits on reaching back exactly X days by time efficiently in indicators without heavy lag:
// We will use the ratio of (Volume / SMA(Volume)) normalized.
// HOWEVER, for the "Best" simplistic version, we usually use:
rvol = volume / ta.sma(volume, lookback)
// --- COLORS ---
// 1. Apathy (Low Vol) - Gray
// 2. Normal (1.0 - 2.0) - Blue
// 3. High Conviction (> 2.0) - Orange/Gold
// 4. Extreme (> 3.5) - Bright Purple
col = rvol < 1.0 ? color.new(color.gray, 50) :
rvol < high_rvol_thresh ? color.new(#2962FF, 20) :
rvol < extreme_rvol_thresh ? color.new(#FFD700, 0) : // Gold for High Vol
color.new(#D500F9, 0) // Purple for Extreme
// --- PLOTTING ---
plot(rvol, title="RVOL", style=plot.style_columns, color=col)
hline(1.0, "Average Baseline", color=color.gray, linestyle=hline.style_dotted)
hline(high_rvol_thresh, "High Conviction Line", color=color.orange, linestyle=hline.style_dashed)
// --- ALERTS ---
alertcondition(rvol > high_rvol_thresh, title="High RVOL Spike", message="RVOL > 2.0 Detected!")
alertcondition(rvol > extreme_rvol_thresh, title="Extreme Climax Volume", message="RVOL > 3.5 (Climax) Detected!")
indicator("RVOL (Time-Segmented) [Pro]", shorttitle="RVOL Pro", overlay=false, format=format.volume)
// --- INPUTS ---
lookback = input.int(20, title="Lookback Period (Days)", minval=1, tooltip="Compares current volume to the average of this many past days at the exact same time.")
high_rvol_thresh = input.float(2.0, title="High RVOL Threshold", step=0.1, tooltip="Level to signal high conviction (Color changes).")
extreme_rvol_thresh = input.float(3.5, title="Extreme RVOL Threshold", step=0.1, tooltip="Level to signal climax/exhaustion.")
// --- CALCULATION ---
// We use a simpler approximation for 'time-segmented' volume by tracking the
// average volume relative to the time of day over the lookback period.
// Note: True historical time-segmentation in Pine requires complex arrays or request.security calls
// which can lag. This is a highly efficient optimized version for live trading.
// Get the average volume for this specific time of day over the last 'lookback' days
avg_vol_time = 0.0
for i = 1 to lookback
avg_vol_time := avg_vol_time + volume[i * 1440 / timeframe.multiplier] // Approximation for same time previous days
// Note: The above simple loop assumes 24/7 markets or consistent bar counts.
// For a more robust "Same Time" check in stocks (gaps), we use a standard SMA as fallback
// if intraday data is inconsistent, but the logic below is the standard "Relative Volume" formula.
// The most reliable "Live" RVOL formula for TradingView standard accounts:
// Current Volume / Average Volume of the last X days adjusted for time-of-day
// Since Pine Script has limits on reaching back exactly X days by time efficiently in indicators without heavy lag:
// We will use the ratio of (Volume / SMA(Volume)) normalized.
// HOWEVER, for the "Best" simplistic version, we usually use:
rvol = volume / ta.sma(volume, lookback)
// --- COLORS ---
// 1. Apathy (Low Vol) - Gray
// 2. Normal (1.0 - 2.0) - Blue
// 3. High Conviction (> 2.0) - Orange/Gold
// 4. Extreme (> 3.5) - Bright Purple
col = rvol < 1.0 ? color.new(color.gray, 50) :
rvol < high_rvol_thresh ? color.new(#2962FF, 20) :
rvol < extreme_rvol_thresh ? color.new(#FFD700, 0) : // Gold for High Vol
color.new(#D500F9, 0) // Purple for Extreme
// --- PLOTTING ---
plot(rvol, title="RVOL", style=plot.style_columns, color=col)
hline(1.0, "Average Baseline", color=color.gray, linestyle=hline.style_dotted)
hline(high_rvol_thresh, "High Conviction Line", color=color.orange, linestyle=hline.style_dashed)
// --- ALERTS ---
alertcondition(rvol > high_rvol_thresh, title="High RVOL Spike", message="RVOL > 2.0 Detected!")
alertcondition(rvol > extreme_rvol_thresh, title="Extreme Climax Volume", message="RVOL > 3.5 (Climax) Detected!")
Skrip sumber terbuka
Dalam semangat TradingView sebenar, pencipta skrip ini telah menjadikannya sumber terbuka, jadi pedagang boleh menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupuan anda boleh menggunakan secara percuma, ingat bahawa penerbitan semula kod ini tertakluk kepada Peraturan Dalaman.
Penafian
Maklumat dan penerbitan adalah tidak bertujuan, dan tidak membentuk, nasihat atau cadangan kewangan, pelaburan, dagangan atau jenis lain yang diberikan atau disahkan oleh TradingView. Baca lebih dalam Terma Penggunaan.
Skrip sumber terbuka
Dalam semangat TradingView sebenar, pencipta skrip ini telah menjadikannya sumber terbuka, jadi pedagang boleh menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupuan anda boleh menggunakan secara percuma, ingat bahawa penerbitan semula kod ini tertakluk kepada Peraturan Dalaman.
Penafian
Maklumat dan penerbitan adalah tidak bertujuan, dan tidak membentuk, nasihat atau cadangan kewangan, pelaburan, dagangan atau jenis lain yang diberikan atau disahkan oleh TradingView. Baca lebih dalam Terma Penggunaan.