# AFL Code for S&C Ehlers Windowing Article

Hello Amibroker Community,

John Ehlers wrote an article on Windowing in the latest S&C September issue, but there was no AFL code in the Traders Tips Section.

Tomasz, I also notice that AFL code is being posted less frequently. Other authors are posting code in Think or Swim Scripting and Excel VBA spreadsheets.

As an average user of Amibroker I rely on the AFL code in the S&C Traders tips section. I'm sure there are other Amibroker users who also rely on this code as well.

Are you supporting S&C as you previously have over the past years?

Thanks for all of your help over the years.

Bernard

2 Likes

Maybe he should check if the recent articles are less repetitive than the last year!

1 Like

Here I made AFL functions for Ehlers Windowing

``````/*
TASC SEP 2021
FIR ... Window Indicators
(C) 2021   John F. Ehlers

AFL code (C) 2021 fxshrat@gmail.com
*/
return deg*4*atan(1)/180;
}

function FIR_ROC(filt, len) {
return len/6.28 * (filt-Ref(filt,-1));
}

function FIR_SMA(len) {
return FIR_ROC(MA(C-O,len), len);
}

function FIR_Triangle(len) {
half_len = len/2;
for ( i = 0; i < Min(len, BarCount); i++ ) {
cnt = i+1;
if ( cnt < half_len )	coeff[i] = cnt;
else
if ( cnt == half_len )	coeff[i] = half_len;
else 					coeff[i] = len-i;
}
filt = FIR(C-O,coeff,len);
return FIR_ROC(filt, len);
}

function FIR_Hamming(len, ped) {
for ( i = 0; i < Min(len, BarCount); i++ ) {
idx = 1 - i / (len-1);
}
filt = FIR(C-O,coeff,len);
return FIR_ROC(filt, len);
}

function FIR_Hann(len) {
for ( i = 0; i < Min(len, BarCount); i++ ) {
idx = (len-i) / (len+1);
}
filt = FIR(C-O,coeff,len);
return FIR_ROC(filt, len);
}

len = 20;

x1 = FIR_SMA(len);
Plot( x1, "FIR_SMA", colorOrange );

x2 = FIR_Triangle(len);
Plot( x2, "FIR_Triangle", colorRed );

x3 = FIR_Hamming(len, 10);
Plot( x3, "FIR_Hamming", colorYellow );

x4 = FIR_Hann(len);
Plot( x4, "FIR_Hann", colorAqua );
PlotGrid(0, colorRed);
`````` 15 Likes

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.