Chips Average Line (volume price) 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("Chips Average Line by RSU",overlay=true)


short_term_len=input.int(30, "short term len", minval=5, maxval=500, step=1)

m_show = input.bool(true, "On/Off medium term line")
medium_term_len=input.int(60, "medium term len", minval=5, maxval=500, step=1)

l_show = input.bool(true, "On/Off long term line")
long_term_len=input.int(200, "medium term len", minval=5, maxval=500, step=1)

smooth_len=input.int(3,"smooth_len",options=[1,2,3,4,5])
//
//Function
//
chipsline(len)=>
    newvolume=(hl2-close)*(hl2-close)*volume
    totalVol=math.sum(newvolume,len)
    math.sum(newvolume*close,len)/totalVol

chipsline_s=ta.ema(chipsline(short_term_len),smooth_len)
chipsline_m=ta.ema(chipsline(medium_term_len),smooth_len)
chipsline_l=ta.ema(chipsline(long_term_len),smooth_len)

col12 = hl2 >= chipsline_s
color_UP=color.new(color.blue,25)
color_Down=color.new(color.gray,50)
color2 = col12 ? color_UP : color_Down
//
//Plot
//
plot(chipsline_s,linewidth=2,linewidth=2,color=color2,title="short_term")
plot(m_show?chipsline_m:na,linewidth=2,color=color.new(color.purple,70),title="medium_term")
plot(l_show?chipsline_l:na,linewidth=2,color=color.new(color.blue,70),title="long_term")



