Stock Portfolio Organizer

The ultimate porfolio management solution.

Shares, Margin, CFD's, Futures and Forex
EOD and Realtime
Dividends and Trust Distributions
And Much More ....
For Portfolio Manager Click Here

WiseTrader Toolbox

#1 Selling Amibroker Plugin featuring:

Advanced Adaptive Indicators
Advanced Pattern Exploration
Neural Networks
And Much More ....
Find Out More Here

Adaptive Laguerre Filter from John Ehlers for Amibroker (AFL)
kaiji
almost 15 years ago
Amibroker (AFL)

Rating:
5 / 5 (Votes 1)
Tags:
amibroker, function

Laguerre Filtering, in its adaptive version (alpha is automaticaly adapted depending the error of filtering). Can be applied to RSI or any other data.

Similar Indicators / Formulas

Percent Rank
Submitted by genkumag almost 13 years ago
Time Left for each bar
Submitted by novicetraders over 14 years ago
Last Thursday Of The Month
Submitted by sahasra over 13 years ago
Visible Min and Max Value Demo
Submitted by kaiji almost 15 years ago
Chandelier Exit Functions
Submitted by kaiji almost 15 years ago
Averages Functions Include
Submitted by demon about 14 years ago

Indicator / Formula

Copy & Paste Friendly
//---------------------------------------------------------------------------------------------------------------
//
//
// Adaptive Laguerre Filter, from John Ehlers
// Link : http://www.mesasoftware.com/Papers/Time%20Warp%20Without%20Space%20Travel.exe
// Another works from Ehlers : http://www.mesasoftware.com/technicalpapers.htm
//
// Description :
// Laguerre Filtering, in its adaptive Version (alpha is automaticaly adapted depending the error of filtering).
// Can be apply to RSI OR any other datas 
// To do :
// - Kautz Filter, they are generic Name for Laguerre Filter AND treats complex signals (use amplitude AND phase)
//
// Coding author: Mich.
//
//---------------------------------------------------------------------------------------------------------------
//

function ALFilter(price, length, medianlong) {
  result=price;
  L0 = price;
  L1 = price;
  L2 = price;
  L3 = price;
  coef=0.5;
  Diff=0;
  HH=0.1;
  LL=0;
  alpha=0.5;
  
  for(i = 1+length; i < BarCount; i++) {
    Diff[i] = abs(price[i] - result[i-1]);
    HH[i] = Diff[i];
    LL[i] = Diff[i];
  
    for(j = 0; j < (length-1); j++) {
      if (Diff[i-j] > HH[i]) HH[i] = Diff[i-j];
      if (Diff[i-j] < LL[i]) LL[i] = Diff[i-j];
    }
  
    if ( (i > length) AND (HH[i] - LL[i] != 0) ) {
      coeftemp=(Diff - LL) / (HH - LL);
      mlen = medianlong;
      for(k = mlen - 1; k >= 0; k--) temparray[k] = coeftemp[i + k - (mlen - 1)];
      temp=0;
      for(k = mlen - 1; k > 0; k--) {
        for (j = mlen - 1; j > 0; j--) {
          if (temparray[j-1] > temparray[j]) {
            temp = temparray[j-1];
            temparray[j-1] = temparray[j];
            temparray[j] = temp;
          }
        }
      }
      coef[i] = temparray[(mlen/2)-0.5];  
      //----- End median calculation
    } // end main IF
  
    alpha=coef[i];
    L0[i] = alpha*price[i] + (1 - alpha)*L0[i-1];
    L1[i] = -(1 - alpha)*L0[i] + L0[i-1] + (1 - alpha)*L1[i-1];
    L2[i] = -(1 - alpha)*L1[i] + L1[i-1] + (1 - alpha)*L2[i-1];
    L3[i] = -(1 - alpha)*L2[i] + L2[i-1] + (1 - alpha)*L3[i-1];
    result[i] = (L0[i] + 2*L1[i] + 2*L2[i] + L3[i]) / 6;
  }// end main  FOR
  return result; 
} 


/* DEMO */

SetBarsRequired(2000,2000);

P = ParamField("Price field",-1);
periods = Param( "Periods", 20, 1, 40, 1 );
periodsmedian = Param( "Periods Median", 5, 1, 40, 1 );

Plot( ALFilter(P,periods,periodsmedian), "Adaptive Laguerre Filter",
ParamColor( "Adaptive Laguerre Filter", colorCycle ), ParamStyle("Style")  );

1 comments

1. ford7k

hi

I like to use ALF with two variables like
ALF AND ALF
The first one was in code given above.
The sceond one I wanted.
When you select 8 in place of 20, do we have to use only 2 for the second factor?
for 20,they use 5
for 8, do i ned to use 2(one fourth of 8?)

can somebody post the ALF CODE for two variables please
mail me if you dont mind
regards
ford7k@yahoo.com

Leave Comment

Please login here to leave a comment.

Back