Relative Volume Indicator
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Kaspricci

//@version=5
indicator("Relative Volume Indicator", shorttitle="Volume%")

toolTipLength = "Define the number of bars to find the highest volume"
toolTipThreshold = "Set a threshold to differentiate high and low volume. Value between 0 and 1."
toolTipSmoothhing = "Define the length for applying simple movering average to volume."

volLength = input.int(240, title="Length", minval=1, tooltip=toolTipLength)
volSmthLength = input.int(3, title="Smoothing", minval=1, tooltip=toolTipSmoothhing)
volThreshold = input.float(0.2, title="Threshold", minval=0.01, maxval=1, step=0.05, tooltip=toolTipThreshold)

vh = ta.highest(volume, volLength)

val = math.round(ta.sma(volume / vh, volSmthLength), 2)

barColor = val < volThreshold ? color.silver : color.teal

plot(val, color=barColor, style=plot.style_columns, title="Volume")
hline(volThreshold, color=color.gray, linestyle=hline.style_dashed, title="Threshold")

hline(1, color=color.new(color.white, 100), title="Upper Limit") // blind line to avoid automatic scaling
