Back to TS code links
Laguerre Filter 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.

{Laguerre Filter (four elements) with FIR filter for comparison -
//// From 'Cybernetic Analysis for Stocks and Futures' by John Ehlers //// code compiled by dn}
// plot in the price region

Input: Price((H+L)/2), gamma(.8);

Var: L0(0), L1(0), L2(0), L3(0), Filt(0), FIR(0);

L0=(1-gamma)*Price+gamma*L0[1];
L1=-gamma*L0+L0[1]+gamma*L1[1];
L2=-gamma*L1+L1[1]+gamma*L2[1];
L3=-gamma*L2+L2[1]+gamma*L3[1];
FIlt=(L0+2*L1+2*L1+L3)/6;
FIR=(Price+2*Price[1]+2*Price[2]+Price[3])/6;
Plot1(Filt,"Filt",Blue);
Plot2(FIR,"FIR",Green);

{The green generalized finite impulse response filter (FIR) has very little lag but is very whippy.
The Laguerre filter (same length) has virtually the same crossing signals but is much smoother due
to the introduction of the dampening factor (gamma).
If you set gamma to 0 Laguerre will be identical to the FIR filter.
This filter can be used to dampen other indicators with similar results.}