Volume Highlighter in main by RSU
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © rsu9111

//@version=5
indicator("Volume Highlighter in main by RSU",overlay=true,scale=scale.none)

avgleg=input.int(60, "Vol Avg Len", minval=5, maxval=200, step=1)
tshow = input.bool(true, "On/Off show turnover")

v=volume
avg = ta.sma(v,avgleg)
std = ta.stdev(v,avgleg)
largeV = (v-avg) > 4*std


plot(avg,color=color.new(color.gray,avgleg)) 
plot(v,style=plot.style_columns,color=largeV?color.new(color.yellow,0):close>close[1]?v>=avg?color.new(color.green,30):color.new(color.green,85):v>=avg?color.new(color.red,30):color.new(color.red,85),histbase=0)
plot(avg*20,show_last=1,editable=false,color=color.new(color.white,100))

r=v/1000000*hl2
rinfo=str.tostring(r,"#.##M")+syminfo.currency
if r>10000
    rinfo:=str.tostring(r/10000,"#.##B")+syminfo.currency
if tshow
    s=label.new(time,0,text=rinfo,color=color.new(#8D8D8D,50),style=label.style_label_lower_left,xloc=xloc.bar_time,textalign=text.align_left)
    label.set_x(s, label.get_x(s) + (time-time[1])*5)
    label.delete(s[1])



