Hello,
this is my first sharing in ProRealCode.
I’ve converted the Adaptive Cycle Indicator from TradingView, that was coded by LazyBear: https://it.tradingview.com/script/3lV1e3ci-Ehlers-Adaptive-Cyber-Cycle-Indicator-LazyBear/
Feel free to contact me if you find bug or share the corrections.
Happy Trading.
This is the code for the indicator Adaptive Cyber Cycle:
src=(high+low)/2
a=.07
s = (src + 2*src[1] + 2*src[2] + src[3])/6.0
if barindex < 7 then
c = (src - 2*src[1] + src[2])/4
ac = (src-2*src[1]+src[2])/4
endif
if barindex > 7 then
c = ((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])
q1 = (.0962*c + 0.5769*c[2] - 0.5769*c[4] - .0962*c[6])*(0.5+.08*ip[1])
I1 = c[3]
if q1 <> 0 and q1[1] <> 0 then
dp1 = (I1/q1 - I1[1]/q1[1]) / (1 + I1*I1[1]/(q1*q1[1]))
else
dp1 = 0
endif
if dp1 < 0.1 then
dp2 = 0.1
else
if dp1 > 1.1 then
dp2 = 1.1
else
dp2 = dp1
endif
endif
myFNMED1 = CALL "[FN] MED"[dp2[2], dp2[3], dp2[4]]
md = CALL "[FN] MED"[dp2, dp2[1], myFNMED1]
if md = 0 then
dc = 15
else
dc = 6.28318 / md + 0.5
endif
ip = .33*dc + .67*ip[1]
p = .15*ip + .85*p[1]
a1 = 2/(p+1)
ac = ((1-0.5*a1)*(1-0.5*a)*(s-2*s[1]+s[2])+2*(1-a1)*ac[1]-(1-a1)*(1-a1)*ac[2])
t = ac[1]
endif
return ac as "Adaptive Cyber Cycle", t as "ACC[1]", 0 as "0"
You need also to code the function “[FN] MED” called in the script.
return (x+y+z) - min(x,min(y,z)) - max(x,max(y,z))
You must be logged in to post a comment.
bonjour, PRT me demande de réduire la période d'adaptive cyber Cycle suite à de fort ralentissement de l'appli. Lorsque je rajoute "defparam calculateonlastbars = 200" Les 2 courbes disparaissent. Uniquement la ligne horizontale 0. Comment je peux faire ? merci
thank you for the code. coded as per above, I encounter an error "unexpected character" (i.e. "ip" in line q1 = (.0962*c + 0.5769*c[2] - 0.5769*c[4] - .0962*c[6])*(0.5+.08*ip[1]) i suspect that may be because it ( ip) has not been previously defined. can you help please?? thank you
Hi Alain, in the comment there's a version that does not require the call function, and is more fast, but don't expect good performance, prorealcode was not built with performance in mind.
Hello people,
i've made a little modification in the code for eliminate the function call. Now the indicator should work much faster.
Enjoy.
// @author Pietro Fontana // Kudos to LazyBear to made it in TradingView src=typicalprice a=.07 s = (src + 2*src[1] + 2*src[2] + src[3])/6.0 if barindex < 7 then c = (src - 2*src[1] + src[2])/4 ac = (src-2*src[1]+src[2])/4 endif if barindex > 7 then c = ((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]) q1 = (.0962*c + 0.5769*c[2] - 0.5769*c[4] - .0962*c[6])*(0.5+.08*ip[1]) I1 = c[3] if q1 <> 0 and q1[1] <> 0 then dp1 = (I1/q1 - I1[1]/q1[1]) / (1 + I1*I1[1]/(q1*q1[1])) else dp1 = 0 endif if dp1 < 0.1 then dp2 = 0.1 else if dp1 > 1.1 then dp2 = 1.1 else dp2 = dp1 endif endif myFNMED1 = (dp2[2] + dp2[3] + dp2[4]) - min(dp2[2],min(dp2[3], dp2[4])) - max(dp2[2],min(dp2[3], dp2[4])) md = (dp2 + dp2[1] + myFNMED1) - min(dp2,min(dp2[1], myFNMED1)) - max(dp2,min(dp2[1], myFNMED1)) if md = 0 then dc = 15 else dc = 6.28318 / md + 0.5 endif ip = .33*dc + .67*ip[1] p = .15*ip + .85*p[1] a1 = 2/(p+1) ac = ((1-0.5*a1)*(1-0.5*a)*(s-2*s[1]+s[2])+2*(1-a1)*ac[1]-(1-a1)*(1-a1)*ac[2]) t = ac[1] endif return ac as "Adaptive Cyber Cycle", t as "ACC[1]", 0 as "0"
Hi Ale,
the use is similar to other oscillator, mainly divergence.
In this link you will find some graphical example from lazybear that explain pretty well the use: https://it.tradingview.com/script/3lV1e3ci-Ehlers-Adaptive-Cyber-Cycle-Indicator-LazyBear/
Regards.
christophe11560, i've coded this a long time ago for a different version of the PRT, i'm not using PRT anymore. Have you tried with the code that i've posted in the comment, not the one that you can download? It's faster. @Gianluca, sorry but i don't use PRT anymore, anyway what you linked is another indicator i think. Best regards.