//@version=5
indicator("ultra Bands", overlay=true, max_lines_count=500, max_bars_back = 500)
src=input(hlc3,title="source")
len=input.int(50,title="lenght", maxval=500)
cr(x, y) =>
z = 0.0
weight = 0.0
for i = 0 to y-1
z:=z + x[i]*((y-1)/2+1-math.abs(i-(y-1)/2))
z/(((y+1)/2)*(y+1)/2)
cr= cr(src,2*len-1)
width=2
//plot(cr, color= #cf0202, linewidth=width,offset=-len+1)
dizii = array.new_float(500)
for k=0 to len-1
sum=0.0
for i=0 to 2*len-2-k
sum +=(len-math.abs(len-1-k-i))*src[i]/(len*len-k*(k+1)/2)
array.set(dizii,k, sum )
mult = input.float(2.0, minval=0.001, maxval=50, title="StdDev")
dev = mult * ta.stdev(src, len)
upper = cr + cr(dev, 2*len-1)
lower = cr - cr(dev, 2*len-1)
cu = input.color(color.rgb(255, 137, 137), "upper band color")
cl = input.color(color.rgb(137, 255, 97), "lower band color")
plot(lower, color= cl, offset=1-len, linewidth=2, display = display.pane)
plot(upper, color= cu, offset=1-len, linewidth=2, display = display.pane)