defparam drawonlastbaronly=true
DEFPARAM CalculateOnLastBars = 5300
Voffset = pipsize
timeframe(weekly)
uw= BollingerUp[20](Close)
lw= Bollingerdown[20](Close)
syD = (SUMMATION[19](Close)[1] + uw)/20
syD2 = (SUMMATION[19](Close)[1] + lw)/20
sy2D = (SUMMATION[19](SQUARE(Close))[1] + (SQUARE(uw)))/20
sy2D2 = (SUMMATION[19](SQUARE(Close))[1] + (SQUARE(lw)))/20
newSTDD = SQRT(sy2D-syD*syD)
newSTDD2 = SQRT(sy2D2-syD2*syD2)
avgD = (summation[19](Close)[1] + uw)/20
avgD2 = (summation[19](Close)[1] + lw)/20
uw1 = round(avgD+newSTDD*2)
lw1 = round(lw)
uw2 = round(uw)
lw2 = round(avgD2-newSTDD2*2)
sma20w = average[20](Close)
if Close > sma20w then
uwe = uw1
lwe = lw1
elsif Close < sma20w then
lwe = lw2
uwe = uw2
Endif
Timeframe(Daily)
//Up
DRAWTEXT("UW",barindex+2,uw,SansSerif,Bold,10)coloured(150,150,150)
DRAWTEXT("#uwe#",barindex+7,uw,SansSerif,Bold,10)coloured(150,150,150)
drawsegment(barindex+3,uw,barindex+4,uw) coloured(76,166,107)
//Down
DRAWTEXT("LW",barindex+2,lw,SansSerif,Bold,10)coloured(150,150,150)
DRAWTEXT("#lwe#",barindex+7,lw,SansSerif,Bold,10)coloured(150,150,150)
drawsegment(barindex+3,lw,barindex+4,lw) coloured(76,166,107)
RETURN