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!")
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.