# Cycle Dynamic Composite Average

637 7
This MA uses the formula of simple cycle indicator to find 2 cycles periods length's .
The CDCA is the result of 8 different ma to control and filter the price. The regression line is the signal , don t need to look candles, but just the cross between MA and reg lin.
```//@version=2
//by Marco
//This MA use the formula of simple cycle indicator to find 2 cycle' s length. Take half cycle as Ma lenght, and ER to control volability;
// There are 8 different ma to control and filter the price. The regression line is the signal , don t need to look candles, but just the cross
//between MA and reg lin.
study(title="Cycle Dynamic Composite Average",shorttitle="CDCA", overlay=true)
length =10
src=close
a=input(.08,step=0.001, title="short cycle :Alpha1")
aa=input(0.03,step=0.001,title="long cycles: Alpha2")
s = (src + 2*src[1] + 2*src[2] + src[3])/6.0
c = n<7?(src - 2*src[1] + src[2])/4.0:((1 - 0.5*a)*(1 - 0.5*a)*(s - 2*s[1] + s[2]) + 2*(1-a)*c[1] - (1 - a)*(1-a)*c[2])
c2 = n<7?(src - 2*src[1] + src[2])/4.0:((1 - 0.5*aa)*(1 - 0.5*aa)*(s - 2*s[1] + s[2]) + 2*(1-aa)*c2[1] - (1 - aa)*(1-aa)*c2[2])
q1 = (.0962*c + 0.5769*c[2] - 0.5769*c[4] - .0962*c[6])*(0.5+.08*nz(ip[1]))
q2 = (.0962*c2 + 0.5769*c2[2] - 0.5769*c2[4] - .0962*c2[6])*(0.5+.08*nz(ip2[1]))
I1 = c[3]
I2 = c2[3]
dp_ = iff(q1 != 0 and q1[1] != 0, (I1/q1 - I1[1]/q1[1]) / (1 + I1*I1[1]/(q1*q1[1])),0)
dp_2 = iff(q2 != 0 and q2[1] != 0, (I2/q2 - I2[1]/q2[1]) / (1 + I2*I2[1]/(q2*q2[1])),0)
dp = iff(dp_ < 0.1, 0.1, iff(dp_ > 1.1, 1.1, dp_))
dp2 = iff(dp_2 < 0.1, 0.1, iff(dp_2 > 1.1, 1.1, dp_2))
med(x,y,z) => (x+y+z) - min(x,min(y,z)) - max(x,max(y,z))
md = med(dp,dp[1], med(dp[2], dp[3], dp[4]))
md2 = med(dp2,dp2[1], med(dp2[2], dp2[3], dp2[4]))
dc = iff(md == 0, 15, 6.28318 / md + 0.5)
dc2 = iff(md2 == 0, 15, 6.28318 / md2 + 0.5)
ip = .33*dc + .67*nz(ip[1])
ip2 = .33*dc2 + .67*nz(ip2[1])
p = .15*ip + .85*nz(p[1])
p2 = .15*ip2 + .85*nz(p2[1])
//
a1 = 2.0/(p + 1)
a2=2.0/(p/2+ 1)
b1=5/p2
b2=5/p2/2
//
mul=input(.7,step=0.1,title="Power Alpha")
diff=abs(close[0]-close[1])
signal=abs(close-close[length])
noise=sum(diff, length)
ER=noise!=0 ? signal/noise : 1
SC=pow((ER*(a1-a2)+a2),mul)
SC1=pow((ER*(b1-b2)+b2),mul)
q=a2
out=nz(out[1],src)+SC*(src-nz(out[1],src))
outz=nz(outz[1],src)+SC1*(src-nz(outz[1],src))
nl=q*out+(1-q)*nz(nl[1])
//
mg = na(mg[1]) ? ema(src, length) : mg[1] + (src - mg[1]) / (p* pow(src/mg[1], 4))
mg2 = na(mg2[1]) ? ema(src, length) : mg2[1] + (src - mg2[1]) / (p/2* pow(src/mg2[1], 4))
mg3 = na(mg3[1]) ? ema(src, length) : mg3[1] + (src - mg3[1]) / (p2* pow(src/mg3[1], 4))
mg4 = na(mg4[1]) ? ema(src, 1) : mg4[1] + (src - mg4[1]) / (p2/2* pow(src/mg4[1], 4))
//
price =close
len = 14
FC =p/2
SCa =p
ss=2*p
len1 = len/2
w = log(2/(ss+1))
H1 = highest(high,len1)
L1 = lowest(low,len1)
N1 = (H1-L1)/len1
H2 = highest(high,len)[len1]
L2 = lowest(low,len)[len1]
N2 = (H2-L2)/len1
H3 = highest(high,len)
L3 = lowest(low,len)
N3 = (H3-L3)/len
dimen1 = (log(N1+N2)-log(N3))/log(2)
dimen = iff(N1>0 and N2>0 and N3>0,dimen1,nz(dimen1[1]))
alpha1 = exp(w*(dimen-1))
oldalpha = alpha1>1?1:(alpha1<0.01?0.01:alpha1)
oldN = (2-oldalpha)/oldalpha
N = (((SCa-FC)*(oldN-1))/(SCa-1))+FC
alpha_ = 2/(N+1)
alpha = alpha_<2/(SCa+1)?2/(SCa+1):(alpha_>1?1:alpha_)
outt = (1-alpha)*nz(outt[1]) + alpha*price
//Super Dynamic Composite Avarege (SDCA)
sdca=sqrt((pow(mg,2)+pow(mg3,2)+pow(out,2)+pow(nl,2)+pow(outt,2)+pow(outz,2)+pow(mg2,2)+pow(mg4,2))/8)
plot(sdca,color=lime,linewidth=2,title="SDCA")
pr=input(15,title="Regr Lin Len")
ofs=input(5,title="Regr Lin Offset")
lrl=linreg(sdca,pr,ofs)
plot(lrl,color=red)
///bgcolor(sdca>lrl?green:red,transp=65)
```
Hi @MarcoValente, is this indicator influenced from the work of John Ehlers? Are there any books that helped in making this?
Regards
HI Marco; Thanks a lot for taking the time to answer my question.
Hi; On the following line of code, where the values for X,Y,Z are coming from? med(x,y,z) => (x+y+z) - min(x,min(y,z)) - max(x,max(y,z)) Thanks.
syracusepro
Hi , X Y Z are not real value , they are parameter usued to create an algo, they are change on the next 2 line. They are angles value using on the cycle indicator , which is where I get that part of formula. Thank you to ask
Thank you for making this available
Thanks !

Thanks for sharing!!!!!!!!!!! Excellent !!!!!!!!!
EN English
EN English (UK)
EN English (IN)
DE Deutsch
FR Français
ES Español
IT Italiano
PL Polski
TR Türkçe
RU Русский
PT Português
ID Bahasa Indonesia
MS Bahasa Melayu
TH ภาษาไทย
VI Tiếng Việt
JA 日本語
KO 한국어
ZH 简体中文
ZH 繁體中文
AR العربية
Home Stock Screener Forex Signal Finder Cryptocurrency Signal Finder Economic Calendar How It Works Chart Features House Rules Moderators Website & Broker Solutions Widgets Stock Charting Library Feature Request Blog & News FAQ Help & Wiki Twitter