LazyScalp Volume in Currency AVG
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Aleksandr400

//@version=5
indicator("LazyScalp Volume in Currency AVG", shorttitle = "Volume in Currency AVG", overlay = false, format = format.volume)

avgType = input.string("SMA", "Avg type", options = ["SMA", "EMA", "RMA", "WMA"], group="PARAMETERS")
length = input.int(30, "Length of avg", minval=5, maxval=1000, step=1, group="PARAMETERS")
barCoef = input.float(4, "Avg size coef:", minval=-0.1, maxval=100, step=1, group="PARAMETERS")
barFilter = input.float(1.0, "Candle size filter (%)", minval=0.1, maxval=10, step=0.1, group="PARAMETERS")
candleMeasureType = input.string("Open / Close", "Candle measure type", options = ["Open / Close", "High / Low"], group="PARAMETERS")
longColor = input.color(#26a69a, "Long color", group="COLUMN STYLE")
shortColor = input.color(#ef5350, "Short color", group="COLUMN STYLE")
columnTransp = input.int(50, "Column transparency", minval=0, maxval=100, step=1, group="COLUMN STYLE")
avgLineColor = input.color(#ffffff, "Avg line color", group="AVG LINE STYLE")
avgLineTransp = input.int(50, "Avg line transparency", minval=0, maxval=100, step=1, group="AVG LINE STYLE")
multipAvgLineColor = input.color(#ffb74d, "Avg line color", group="AVG LINE STYLE")
multipAvgLineTransp = input.int(50, "Avg line transparency", minval=0, maxval=100, step=1, group="AVG LINE STYLE")
highlightBars = input.bool(true, "Highlight candles", group="ALERT STYLE")
alertBarColor = input.color(#ffb74d, "Candle color", group="ALERT STYLE")
highlightColumns = input.bool(true, "Highlight columns", group="ALERT STYLE")
alertColor = input.color(#ffb74d, "Column color", group="ALERT STYLE")
alertTransp = input.int(0, "Column transparency", minval=0, maxval=100, step=1, group="ALERT STYLE")


vol = close * volume

volAvg = ta.sma(vol, length)

if avgType == "EMA"
    volAvg := ta.ema(vol, length)
if avgType == "RMA"
    volAvg := ta.rma(vol, length)
if avgType == "WMA"
    volAvg := ta.wma(vol, length)

multipVolAvg = volAvg * barCoef

barSize = math.abs(math.round((open - close)/open * 100, 2))

if candleMeasureType == "High / Low"
    barSize := math.round((high - low)/high * 100, 2)

palette = close[1] > close ? shortColor : longColor

volColor = vol > multipVolAvg and barSize > barFilter and highlightColumns ? color.new(alertColor, alertTransp) : color.new(palette, columnTransp)

barcolor(vol > multipVolAvg and barSize > barFilter and highlightBars ? color.new(alertBarColor, 0) : na)

plot(vol, style = plot.style_columns, color = volColor)

plot(multipVolAvg, color = color.new(multipAvgLineColor, multipAvgLineTransp))

plot(volAvg, color = color.new(avgLineColor, avgLineTransp))

if vol > multipVolAvg and barSize > barFilter
    alert("BIG VOL " + syminfo.ticker, alert.freq_once_per_bar)
    





