PureBytes Links
Trading Reference Links
|
I grabbed this from the excel example, NOT the easylanguage reference.
Try this:
-------------------------
Price = (H+L)/2;
CoefLookback = 5;
Coef = (Price-Ref(Price, -1))^2+(Price-Ref(Price,
-2))^2+(Price-Ref(Price, -3))^2+(Price-Ref(Price,
-4))^2+(Price-Ref(Price, -5))^2;
SumCoef=0;
SumCoefPrice=0;
for(i=0; i < CoefLookback; i++) {
SumCoef = SumCoef + Ref(Coef, -i);
SumCoefPrice = SumCoefPrice + (Ref(Coef, -i) * Ref(Price, -i));
}
DCEF = SumCoefPrice / SumCoef;
Plot(Close, "Close", colorBlack, styleLine);
Plot(DCEF, "NonLinear Ehlers Filter", IIf(Close>DCEF, colorGreen,
colorRed), styleLine);
-----------------------------
--- In amibroker@xxxxxxxxxxxxxxx, "ricko8294_98" <ricko@xxxx> wrote:
>
> What? with all the talent out there, is there no one to come to my
> rescue?
>
> I would appreciate someone pointing out what is wrong with my code
> Thanks
> Rick
>
> --- In amibroker@xxxxxxxxxxxxxxx, "ricko8294_98" <ricko@xxxx> wrote:
> >
> > Hello
> > I have been trying for several days to try to translate the
> > TradeStation code for Ehlers Distant Coefficient Filter and can't
> > seem to get it to work. I seem to just get a straight line
> >
> > If someone has the AmiBroker code for it, or can translate this for
> > me I would be most appreciative
> >
> > TradeStation Code:
> > 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");
> > ***********************
> >
> > My attempt to translate this is as follows:
> >
> > // Ehler's Distant Coefficient Filter
> >
> > Pr = (H+L)/2;
> > Length = 27;
> > for(i = 0; i < Length -1; i++)
> > {
> > d2[i] = 0;
> > for(Lb = 1; Lb < Length; Lb++)
> > {
> > d2[i] = d2[i] + (Pr[i] - Pr[i + Lb])^2;
> > }
> > Coef[i] = d2[i];
> > }
> > num = 0;
> > Sumcoef = 0;
> > for(i=0;i < Length -1; i++)
> > {
> > num = num + Coef[i] * Pr[i];
> > Sumcoef = Sumcoef + Coef[i];
> > }
> >
> > Filt = Nz(num / Sumcoef);
> > Plot(Filt,"Filt",colorGreen);
> >
> > TIA
> > Rick
------------------------ Yahoo! Groups Sponsor --------------------~-->
$9.95 domain names from Yahoo!. Register anything.
http://us.click.yahoo.com/J8kdrA/y20IAA/yQLSAA/GHeqlB/TM
--------------------------------------------------------------------~->
Check AmiBroker web page at:
http://www.amibroker.com/
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/amibroker/
<*> To unsubscribe from this group, send an email to:
amibroker-unsubscribe@xxxxxxxxxxxxxxx
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|