Автор:
Разместил:   Дата: 2005-12-27 17:01
Комментарии: (0)   Рейтинг:

Distance Coefficient Ehlers Filter by John Ehlers

Here is some EasyLanguage code I developed to compute the filters presented in my article in this issue, "Nonlinear Ehlers Filters."

Next is the EasyLanguage code to compute the distance coefficient Ehlers filter also presented in my article in this issue, "Nonlinear Ehlers Filters":

Type : Indicator, Name : Distance Coefficient Ehlers Filter

Inputs: Price((H+L)/2),
      Length(15);

Vars:   count(0),
       LookBack(0),
       SumCoef(0),
       Num(0),
       Filt(0);

Array:  Coef[25](0),
       Distance2[25](0);

For count = 0 to Length - 1 begin
   Distance2[count] = 0;
   For LookBack = 1 to Length begin
       Distance2[count] = Distance2[count] + (Price[count] - Price[count
        + LookBack])*(Price[count] - Price[count + LookBack]);
   end;
   Coef[count] = Distance2[count];
end;
Num = 0;
SumCoef =0;
For count = 0 to Length -1 begin
   Num = Num + Coef[count]*Price[count];
   SumCoef = SumCoef + Coef[count];
end;
If SumCoef <> 0 then Filt = Num / SumCoef;

Plot1(Filt, "Ehlers");




The TradeStation code for a distance coefficient can also be used in the nonlinear Ehlers filter. If you'd rather use a spreadsheet, an example of the TradeStation code for a distance coefficient can be seen in Excel form in Figure 2.

FIGURE 2: DISTANCE COEFFICIENT. This spreadsheet computes the squared difference between the current price and the price five bars back, and then squares it to get a more responsive Ehlers filter value.


MICROSOFT EXCEL

To compute the filter in Excel, first compute the squared differences from the current price as:

E7 = (D7-D6)^2+(D7-D5)^2+(D7-D4)^2+(D7-D3)^2+(D7-D2)^2

As soon as you have five values of the squared difference, compute, in F11:

F11 =D7*E7+D8*E8+D9*E9+D10*E10+D11*E11
Then,

G11 =SUM(E7:E11)

H11 =F11/G11

Copy all the row 11 values downward and check the values against those in Figure 2


 
Реклама:

Rambler's Top100

Страница создана за 0.03 секунды