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

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: 305
Download
Filename: FN-MED.itf
Downloads: 193
Pietro Fontana Average
Currently debugging life, so my bio is on hold. Check back after the next commit for an update.
Author’s Profile

Comments

Logo Logo
Loading...