//PRC_Volatility Cycle Breakout | indicator
//03.10.2017
//Nicolas @ http://www.prorealcode.com
//Sharing ProRealTime knowledge
//— parameters
//InpBandsPeriod=18 // Period
//Smooth=2 // Smoothness
//cp=10 // Fractals periods
//change=0.1 // Percent change to modify the upper/lower channel
//— end of parameters
//Cycle
StdDev = std[InpBandsPeriod](close)
highindex = highest[InpBandsPeriod](StdDev)[1]
lowindex = lowest[InpBandsPeriod](StdDev)[1]
if barindex>InpBandsPeriod then
VolDer = (StdDev-highindex)/(highindex-lowindex)
VolSmooth = average[Smooth](VolDer)
if VolSmooth>0 then
VolSmooth = 0
elsif VolSmooth<-1.0 then
VolSmooth = -1.0
endif
endif
//fractals
if high[cp] >= highest[2*cp+1](high) then
LH = 1
else
LH = 0
endif
if low[cp] <= lowest[2*cp+1](low) then
LL = -1
else
LL = 0
endif
if LH = 1 then
TOPy = high[cp]
endif
if LL = -1 then
BOTy = low[cp]
endif
//channel
if VolSmooth = -1.0 then //no volatility
if abs(TOPy-upperchannel)/close>change/100 then
upperchannel = TOPy
endif
if abs(BOTy-lowerchannel)/close>change/100 then
lowerchannel = BOTy
endif
endif
//KAMA200
fastperiod = 2
slowperiod = 30
Period = 200
Fastest = 2 / (FastPeriod + 1)
Slowest = 2 / (SlowPeriod + 1)
if barindex < Period+1 then
Kama=close
else
Num = abs(close-close[Period])
Den = summation[Period](abs(close-close[1]))
ER = Num / Den
Alpha = SQUARE(ER *(Fastest – Slowest )+ Slowest)
KAMA = (Alpha * Close) + ((1 -Alpha)* Kama[1])
endif
if (KAMA > KAMA[1]) then
r = 100
g = 150
elsif (KAMA < KAMA[1]) then
r = 150
g = 100
endif
RETURN upperchannel coloured(r,g,100) as “upper channel”, lowerchannel coloured(r,g,100) as “lower channel”
en gras, mon ajout mais bon ça ne change rien.