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

Re: [amibroker] Re: Ehler's Distant Coefficient Filter



PureBytes Links

Trading Reference Links

hello I jump quickly in the question,
download indicator.dll

/* Distant Coefficient Nonlinear Ehlers Filters */
/* Consult April 2001 TASC for details */
/* AFL implementation by Tomasz Janeczko */
/* Use automatic scaling and middle grid */
/* and show dates */
/* Requires AmiBroker 3.60 or higher */
/* VBScript version */

periods = 15;
mprice = (High + Low)/2;

Plot(scNLEF(scMp(),15),"",colorGreen,1);
Plot(C,"",colorBlack,64);


/* Distant Coefficient is calculated here using AFL scripting */
/*
EnableScript("vbscript");
coef = mprice;

<%
mprice = AFL( "mprice" )
coef = AFL( "coef" )
periods = AFL( "periods" )

for i = periods To UBound( mprice )
  coef( i ) = 0
  for k = 1 To periods
    coef( i ) = coef( i ) + ( mprice( i ) - mprice( i - k ) )^2
Next
Next
AFL("coef") = coef
%>

Plot( Sum( coef * mprice, periods )/Sum( coef, periods ),"",colorRed,1);

*/
/*
EnableScript("jscript");
mprice = (High + Low)/2;
nRange=15;

<%
function GetArray( Name )
{return VBArray( AFL( Name ) ).toArray();}
mprice = GetArray( "mprice" );
y = new Array();
nRange= AFL.Var( "nRange");

for( i = 0; i < mprice.length; i++ )
   {
   y[i] = 0;
   nk = i>nRange ? nRange : i;
   for( k=1; k<=nk; k++)
   y[i] = y[i] + Math.pow(mprice[i] - mprice[i-k],2) ;
   }
AFL("y") = y ;

%>

Graph1= Sum( y * mprice, nRange )/Sum( y, nRange );
Graph1Style = 1;
Graph1Color= 4;


*/

>
> It's also been posted on the Amibroker Library, if anyone has trouble
> with the word wrapping.
>
>
>
> --- In amibroker@xxxxxxxxxxxxxxx, "Christoper" <turkey@xxxx> wrote:
> >
> > 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
>
>
>
>
>
> Check AmiBroker web page at:
> http://www.amibroker.com/
>
> Check group FAQ at: 
> http://groups.yahoo.com/group/amibroker/files/groupfaq.html
>
>
> *Yahoo! Groups Sponsor*
> ADVERTISEMENT
> click here 
> <http://us.ard.yahoo.com/SIG=129pu4c9n/M=298184.5584357.6650215.3001176/D=groups/S=1705632198:HM/EXP=1100580808/A=2426685/R=0/SIG=11eslo8dq/*http://www.netflix.com/Default?mqso=60185401> 
>
>
>
> ------------------------------------------------------------------------
> *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
>       <mailto:amibroker-unsubscribe@xxxxxxxxxxxxxxx?subject=Unsubscribe>
>        
>     * Your use of Yahoo! Groups is subject to the Yahoo! Terms of
>       Service <http://docs.yahoo.com/info/terms/>.
>
>
>
>
> __________ Information NOD32 1.876 (20040924) __________
>
> Ce message a ete verifie par NOD32 Antivirus System.
> http://www.nod32.com




[Non-text portions of this message have been removed]



------------------------ 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/