本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。
//@version=6
indicator("Volume + Average Volume Labels", overlay=false)
// Inputs
length = input.int(20, "Average Volume Period", minval=1)
showLabels = input.bool(true, "Show Volume Labels")
showAvgLabels = input.bool(true, "Show Average Volume Labels")
// Volume calculations
avgVolume = ta.sma(volume, length)
// Candle direction
bullish = close >= open
// Volume bar colors
volColor = bullish ? color.green : color.red
// Plot volume bars and average volume line
plot(volume, title="Volume", style=plot.style_columns, color=volColor)
plot(avgVolume, title="Average Volume", color=color.black, linewidth=2)
// Labels on each volume bar
if showLabels
label.new(bar_index, volume, str.tostring(volume, format.volume),
style=label.style_none,
textcolor=volColor,
size=size.tiny)
if showAvgLabels and not na(avgVolume)
label.new(bar_index, avgVolume, str.tostring(avgVolume, format.volume),
style=label.style_none,
textcolor=color.black,
size=size.tiny)