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!")
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.