Hello i am trying to include this type of moving average(elastic volume weighted moving average)
evwma = 0.0
evwma := ((volumeSum - volume) * nz(evwma[1]) + volume * src) / volumeSum
into my indicator (VWGSV) where the upper forumula must replace vwma function
//@version=4
study(shorttitle="VWGSV", title="Greatest swing value",overlay=true)
src = input(open)
lenght = input(4, minval=1 ,title="lenght")
multi = input (1.8,title="multiplier")
hx= if src>close[1]
close[1]
else
src
lx= if src<close[1]
close[1]
else
src
hg= (high-hx)
lg= (lx-low)
bgsv = (vwma(hg,lenght))*multi+hx
sgsv= lx-(vwma(lg,lenght))*multi
plot(bgsv,offset=1, color=color.green)
plot(sgsv,offset=1, color=color.red)
what i tried is something like this (sorry no coding experience at all...)
//@version=4
study(shorttitle="VWGSV", title="Greatest swing value",overlay=true)
src = input(open)
lenght = input(4, minval=1 ,title="lenght")
multi = input (1.8,title="multiplier")
volumeSum = sum(volume, lenght)
hx= if src>close[1]
close[1]
else
src
lx= if src<close[1]
close[1]
else
src
hg= (high-hx)
lg= (lx-low)
hevwma = 0.0
levwma = 0.0
hevwma := ((volumeSum - volume) * nz(hevwma[1]) + volume * hx) / volumeSum
levwma := ((volumeSum - volume) * nz(levwma[1]) + volume * lx) / volumeSum
bgsv = hevwma*multi+hx
sgsv= lx-levwma*multi
plot(series=bgsv,offset=1, color=color.green)
plot(series=sgsv,offset=1, color=color.red)
this is what i tried
hevwma = 0.0
levwma = 0.0
hevwma := ((volumeSum - volume) * nz(hevwma[1]) + volume * hx) / volumeSum
levwma := ((volumeSum - volume) * nz(levwma[1]) + volume * lx) / volumeSum
bgsv = round(hevwma)*multi+hx
sgsv= lx-round(levwma)*multi
I think is because the formula i am trying to integrate gives me a float value but i need it to be integer and i tried to convert it to integer somehow but with no success. Please help me , i need the somehow to get a result like in the picture attached