VietRoadie's RVol Label

vietroadie · study · 51 行 · 点赞 19 · TradingView 原页

本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。

Pine Script

//@version=6
// Created by @VietRoadie
// Last Updated: 2026-07-25 20:06 CST
// Relative Volume and total volume with Average Volume in the same row
 
indicator("VietRoadie's RVol Label", "RVol", true)
 
// === Inputs ===
var string GP1 = "Input Data"
vol_len = input.int(20, title="Relative Volume Length", group=GP1)
 
var string GP2 = "Display"
txt_sizeopt = input.string("auto", title="Text Size", inline="10", options=["auto", "tiny", "small", "normal", "large", "huge"], group=GP2)
txt_size = txt_sizeopt == "auto" ? size.auto : txt_sizeopt == "tiny" ? size.tiny : txt_sizeopt == "small" ? size.small : txt_sizeopt == "normal" ? size.normal : txt_sizeopt == "large" ? size.large : size.huge
i_tableYpos = input.string("top", "Panel position", inline="15", options=["top", "middle", "bottom"], group=GP2)
i_tableXpos = input.string("center", "", inline="30", options=["left", "center", "right"], group=GP2)
 
showbarLine = input.bool(false, title="Show Selected Bar RVol Line")
 
// === Table ===
var table rvolDisplay = table.new(i_tableYpos + "_" + i_tableXpos, 1, 1, border_width=1, border_color=color.white)
 
// === Data ===
t = syminfo.tickerid
timeFrame = timeframe.isweekly ? "W" : timeframe.ismonthly ? "M" : "D"
 
today_vol = request.security(t, timeFrame, volume)
yday_vol  = request.security(t, timeFrame, volume[1])
avg_vol   = request.security(t, timeFrame, ta.sma(volume[1], vol_len))
 
rvol   = today_vol / avg_vol
volpct = math.round(rvol * 100)
 
// === Formatting ===
avg_vol_display   = avg_vol   >= 1000000 ? str.tostring(math.round(avg_vol   / 1000000, 2)) + " Mil" : str.tostring(math.round(avg_vol   / 1000, 2)) + "k"
today_vol_display = today_vol >= 1000000 ? str.tostring(math.round(today_vol / 1000000, 2)) + " Mil" : str.tostring(math.round(today_vol / 1000, 2)) + "k"
 
// === RVol zones ===
zoneText = rvol < 1.0 ? "Ignore Zone" : rvol <= 1.5 ? "Elevated Retail" : rvol > 2.0 ? "Strong BO, Big Institutional Acculumation" : "Momentum Build"
 
labelText = "Vol: " + today_vol_display + "   Avg Vol: " + avg_vol_display + "   RVol: " + str.tostring(math.round(rvol, 2)) + "x (" + str.tostring(volpct) + "%)" + "   " + zoneText
 
labelColor = rvol < 1.0 ? color.gray : rvol <= 1.5 ? color.orange : rvol > 2.0 ? color.green : color.new(color.green, 30)
 
if barstate.islast
    table.cell(rvolDisplay, 0, 0, labelText, bgcolor=labelColor, text_size=txt_size)
 
// === Optional per-bar RVol plot ===
bar_avg_vol = ta.sma(volume[1], vol_len)
bar_volpct  = math.round((volume / bar_avg_vol) * 100)
plot(bar_volpct, color=showbarLine ? color.red : na, linewidth=1, title="Each Bar RVol")

← 返回列表