Back to TS code links
    Stochastic Cyber Cycle indicator from John Ehlers
Back to Ehlers links


Anyone using information or codes on these pages does so at their own risk - no guarantees of stability or profitability are claimed. These codes are all for testing purposes only.

//// Ehl Stochastic Cyber Cycle
//// From 'Cybernetic Analysis for Stocks and Futures' by John Ehlers
//// code compiled by dn

Inputs: Price((H+L)/2);
Var{Inputs}: alpha(.07),Len(8),CCdelimiter(80);
vars: Smooth(0),Cycle(0),MaxCycle(0),MinCycle(0);
Smooth=(Price+2*Price[1]+2*Price[2]+Price[3])/6;
Cycle=(1-.5*alpha)*(1-.5*alpha)*(Smooth-2*Smooth[1]+Smooth[2])+2*(1-alpha)*Cycle[1]-(1-alpha)*(1-alpha)*Cycle[1];
If currentbar <7 then Cycle=(Price-2*Price[1]+Price[2])/4;
MaxCycle = Highest (Cycle, Len);
MinCycle = Lowest (Cycle, Len);
If MaxCycle <> MinCycle then Value1 = (Cycle - MinCycle) / (MaxCycle - MinCycle);
Value2 = (4*Value1 + 3*Value1[1] + 2*Value1[2] + Value1[3]) / 10;
Value2 = 2*(Value2 - .5);
Plot1 (Value2, "Cycle",blue);
Plot2 (.96*(Value2[1] + .02), "Trigger",green);
Plot3 (0, "Ref"); Plot4 (CCdelimiter*+.01,"CCextreme",green); Plot5 (CCdelimiter*-.01,"CCextreme",green);