OPEN-SOURCE SCRIPT

Volume Percentage

122
//version=5
indicator("Volume Percentage", overlay=false)

// Input for the length of the period to calculate average volume
length = input.int(20, title="Average Volume Length", minval=1)

// Calculate the average volume over the specified length
avg_volume = ta.sma(volume, length)

// Calculate the volume percentage
volume_percent = (volume / avg_volume) * 100

// Plot the volume percentage
plot(volume_percent, title="Volume %", color=color.blue, linewidth=2)

// Optional: Add a horizontal line for 100% (baseline)
hline(100, title="100% Baseline", color=color.gray, linestyle=hline.style_dotted)

// Display the volume percentage value on the chart
label_text = "Vol %: " + str.tostring(volume_percent, "#.##") + "%"
label.new(bar_index, volume_percent, label_text, style=label.style_label_down, color=color.blue, textcolor=color.white)

免責聲明

這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。