PPO
fastLength = 12//input(12, minval=1),
slowLength= 26 //input(26,minval=1)
//signalLength= 9 //input(9,minval=1)
smoother = 2 //input(2,minval=1)
source = customclose
P = (AverageTrueRange[2](close))
fastMA = average[fastLength,1](source)
slowMA = average[slowLength,1](source)
mmacd = fastMA - slowMA
macd2=(mmacd/slowMA)*100
d = average[smoother](macd2) // smoothing PPO
bullishPrice = low
priceMins = (bullishPrice > bullishPrice[1] and bullishPrice[1] < bullishPrice[2]) or (low[1] = low[2] and low[1] < low and low[1] < low[3]) or (low[1] = low[2] and low[1] = low[3] and low[1] < low and low[1] < low[4]) or (low[1] = low[2] and low[1] = low[3] and low[1] and low[1] = low[4] and low[1] < low and low[1] < low[5]) // this line identifies bottoms and plateaus in the price
oscMins= d > d[1] and d[1] < d[2] // this line identifies bottoms in the PPO
BottomPointsInPPO = oscMins
bearishPrice = high
priceMax = (bearishPrice < bearishPrice[1] and bearishPrice[1] > bearishPrice[2]) or (high[1] = high[2] and high[1] > high and high[1] > high[3]) or( high[1] = high[2] and high[1] = high[3] and high[1] > high and high[1] > high[4]) or (high[1] = high[2] and high[1] = high[3] and high[1] and high[1] = high[4] and high[1] > high and high[1] > high[5]) // this line identifies tops in the price
oscMax = d < d[1] and d[1] > d[2] // this line identifies tops in the PPO
TopPointsInPPO = oscMax
//bulldiv= BottomPointsInPPO ? d[1] : na // plots dots at bottoms in the PPO
if BottomPointsInPPo then
drawtext("●",barindex[1],low-P[2],dialog,bold,22) coloured(32,0,192)
endif
//beardiv= TopPointsInPPO ? d[1]: na // plots dots at tops in the PPO
if TopPointsInPPO then
drawtext("●",barindex[1],high+P[2],dialog,bold,22) coloured(255,0,0)
endif
Trend
//////////////////////////////// Trend Envelopppes
timePeriod=14
Deviation=0.1
price1=customclose
dsma = WeightedAverage[timePeriod](price1)
valuesHigh = (1 + deviation / 100) * dsma
valuesLow = (1 - deviation / 100) * dsma
inputs=price1
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
endif
else
alpha0=0
if (valuesHigh > valuesHigh[1]) then
valuesHigh = valuesHigh[1]
endif
if trend[1]<0 then
outputs1 = valuesHigh
outputs0 = valueslow
alpha1 = 255
endif
endif