[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Re: Ehler's Distant Coefficient Filter



PureBytes Links

Trading Reference Links


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 --------------------~--> 
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/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/