Pietro Fontana

Ehlers - Adaptive Cyber Cycle

Category: Indicators By: Pietro Fontana Created: June 1, 2017, 10:13 AM
June 1, 2017, 10:13 AM
Indicators
12 Comments
Ehlers - Adaptive Cyber Cycle

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))

Download
Filename: Adaptive-Cyber-Cycle.itf
Downloads: 306
Download
Filename: FN-MED.itf
Downloads: 193
Pietro Fontana
Pietro Fontana Average
Code artist, my biography is a blank page waiting to be scripted. Imagine a bio so awesome it hasn't been coded yet.
Author’s Profile

Comments

Pietro Fontana
6 years ago
#

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.

christophe11560
6 years ago
#

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

Gianluca
8 years ago
#

Hello there is a new version, is it possible to translate it? https://www.tradingview.com/script/CPLfkmht-Ehlers-Stochastic-Cyber-Cycle/

Halan
8 years ago
#

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

Alai-n
9 years ago
#

Ok thank you Pietro...

Alai-n
9 years ago
#

Hello ... What does FN-MED mean exactly in the code complement? It is a mess to load the indicator!

Pietro Fontana
9 years ago
#

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.

johnb9999
9 years ago
#

Just a suggestion, not an expert, what happens if the barindex = 7

Pietro Fontana
9 years ago
#

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"

 

Nicolas
9 years ago
#

Very cool! Thanks a lot for the update! much appreciated :)

Pietro Fontana
9 years ago
#

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.

ALE
ALE
9 years ago
#

Hello Pietro

thanks for your code, could you suggest to use it?

ProRealCode ProRealCode
Loading...