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!")
สคริปต์โอเพนซอร์ซ
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน
สคริปต์โอเพนซอร์ซ
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน