Разместил: Дата: 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
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]);
Coef[count] = Distance2[count];
Num = 0;
For count = 0 to Length -1 begin
Num = Num + Coef[count]*Price[count];
SumCoef = SumCoef + Coef[count];
If SumCoef <> 0 then Filt = Num / SumCoef;
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.
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:
Copy all the row 11 values downward and check the values against those in Figure 2