//////////////////////////////// Trend Envelopppes
timePeriod=14
Deviation=0.01
price=customclose
dsma = WeightedAverage[timePeriod](price)
valuesLow = (1 - deviation / 100) * dsma
valuesHigh = (1 + deviation / 100) * dsma
inputs=price
if (inputs > valuesHigh) then
trend = 1
elsif (inputs < valuesLow) then
trend = -1
endif
if (trend > 0) then
alpha1=0
if ( valuesLow < valuesLow[1]) then
valuesLow = valuesLow[1]
endif
if trend[1]>0 then
outputs0 = valuesLow
outputs1 = valueshigh
alpha0 = 255
else
drawtext("long",barindex,low, dialog,bold,18) coloured(65,105,225)
endif
else
alpha0=0
if (valuesHigh > valuesHigh[1]) then
valuesHigh = valuesHigh[1]
endif
if trend[1]<0 then
outputs1 = valuesHigh
outputs0 = valueslow
alpha1 = 255
else
drawtext("short",barindex,high,dialog,bold,18) coloured(255,0,0)
endif
endif
return outputs0 coloured(65,105,225,alpha0) style(line,4), outputs1 coloured(255,0,0,alpha1) style(line,4)