This is the Ehlers’ adaptive CCI code. The modified John Ehlers version of the CCI adapt the classical CCI period dynamically adapted to the market cycle. It tends to give more better indication as the CCI indicator itself.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
c = 0.5 pri=Customclose CycPart=c If Barindex > 5 Then Smooth=(4*pri+3*pri[1]+2*pri[2]+pri[3])/10 Detrender=(0.0962*Smooth+0.5769*Smooth[2]-0.5769*Smooth[4]-0.0962*Smooth[6])*(0.075*Period[1]+0.54) REM Compute InPhase & Quadrature Components Q1=(0.0962*Detrender+0.5769*Detrender[2]-0.5769*Detrender[4]-0.0962*Detrender[6])*(0.075*Period[1]+0.54) I1=Detrender[3] REM Advance The Phase Of I1 & Q1 By 90 Degrees jI=(0.0962*I1+0.5769*I1[2]-0.5769*I1[4]-0.0962*I1[6])*(0.075*Period[1]+0.54) jQ=(0.0962*Q1+0.5769*Q1[2]-0.5769*Q1[4]-0.0962*Q1[6])*(0.075*Period[1]+0.54) REM Phasor Addition I2=I1-jQ Q2=Q1+jI REM Smooth The I & Q Components I2=0.2*I2+0.8*I2[1] Q2=0.2*Q2+0.8*Q2[1] REM Homodyne Discriminator Re=I2*I2[1]+Q2*Q2[1] Im=I2*Q2[1]-Q2*I2[1] Re=0.2*Re+0.8*Re[1] Im=0.2*Im+0.8*Im[1] If Im <> 0 And Re <> 0 Then Period=360/ATAN(Im/Re) Endif If Period > 1.5*Period[1] Then Period=1.5*Period[1] Endif If Period < 0.67*Period[1] Then Period=0.67*Period[1] Endif If Period < 6 Then Period=6 Endif If Period > 50 Then Period=50 Endif Period=0.2*Period+0.8*Period[1] SmoothPeriod=0.33*Period+0.67*SmoothPeriod[1] Length=Round(CycPart*Period) MP=(High+Low+Close)/3 Avg=0 For count=0 To Length-1 Avg=Avg+MP[count] Next Avg=Avg/Length MD=0 For count=0 To Length-1 MD=MD+ABS(MP[count]-Avg) Next MD=MD/Length If MD <> 0 Then ACCI=(MP-Avg)/(0.015*MD) Endif Endif Return ACCI as "Adaptive CCI",0 |
//indicator from the Kevin Britains archive.
Share this
No information on this site is investment advice or a solicitation to buy or sell any financial instrument. Past performance is not indicative of future results. Trading may expose you to risk of loss greater than your deposits and is only suitable for experienced investors who have sufficient financial means to bear such risk.
ProRealTime ITF files and other attachments :
Filename : download the ITF files
How to import ITF files into ProRealTime platform?
PRC is also on YouTube, subscribe to our channel for exclusive content and tutorials
Thanks for this one, it’s very well regarded. There’s a great 3-part series on using the Adaptive CCI with plenty of examples here:
http://tuckerreport.com/indicators/cci-basic/
Thanks @Saud. Enjoyed the article.
I’ve tried to modify this so I can display on 1min chart with the 5 min chart variant as a separate indicator below. I did this by editing the file to include “Timeframe 5minutes”… Is there a way to alter the code to call the 5 minute values like that but without having to use the timeframe commands?
The purpose being to be able to use it as part of a multi-TF strategy. So, if 1m >0 and 5m>0 etc.
Thanks in advance to anyone able to assist…
No, just create 2 different indicators in this case, one with the timeframe(5 minutes) and one with the original code, so that you have both timeframes visually on the same chart.