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

[amibroker] Re: (fred #2) EasyLanguage question



PureBytes Links

Trading Reference Links

"Read your statements one at a time ONCE AND ONLY ONCE and tell me "
OK, lets do that::

y1=y2=P[0]   // y,y1,y2 in my AFL are numbers, not arrays
____________________________________
procedure::
y = u_2* P[i]+2*u1*y1-u1_2*y2;
y2=y1;
y1=y;
====================================
Run it from i=1 to N-1::

i=1
y = u_2* P[1]+2*u1*y1-u1_2*y2;
y2=y1  /* =P[0] */;
y1=y   /* =tw[1], #1 array member that we got here;

i=2
y = u_2* P[2]+2*u1*y1-u1_2*y2; //NB: here y1=tw[1], y2=P[0] 
y2=y1 // =tw[1] ;
y1=y  // =tw[2],  #2 array member that we got at this step};
      // here we get tw[2] as a function of tw[1], etc.
.......

as we see, tw[i+1] depends on tw[i] (and P[i+1], ...)
I would call this autoregression, or a recursive relation (wikipedia)

Is that correct? I refer to my code in #93076::
/////////////////////////////////////////////////////
function twitch(price,initLength)
// alex-- ARMA(2) "twitch" v.2 simplified
{
length = x = u = u1 = u1_2 = u_2 =0;
y=y1=y2=0;
if ( initLength < 2 ) length = 2; else length = initlength;


x =(1- cos(360/Length))/0.414213562;
u =-x + sqrt(x*x+2*x);
u1 = 1.0-u;
u1_2 =u1*u1;
u_2 =u*u;
y1 =price[0];
y2 =y1;
tw = Cum(0);
for ( i = 1; i < BarCount; i++ )
{
y = u_2* price[i]+2*u1*y1-u1_2*y2;
y2=y1;
y1=y;
tw[i]=y;
}
return tw;
}

initL = Param("init",3,2,50,1);
tw = twitch(C,initL);

Plot(tw,"twitch",1,1);
Plot(C,"c",1,64);


--- In amibroker@xxxxxxxxxxxxxxx, "Fred" <ftonetti@xxxx> wrote:
>
> Read your statements one at a time ONCE AND ONLY ONCE and tell me 
> where you see recursion ...
> 
> --- In amibroker@xxxxxxxxxxxxxxx, "dalengo" <dalengo@xxxx> wrote:
> >
> > could you please take a look at msg #93076.
> > this is a simple recursion, constructs a moving average.
> > do you see any problem with the code? it should do what 
> > TS code does. Code below does not...
> > ?
> > 






------------------------ Yahoo! Groups Sponsor --------------------~--> 
Try Online Currency Trading with GFT. Free 50K Demo. Trade 
24 Hours. Commission-Free. 
http://us.click.yahoo.com/RvFikB/9M2KAA/U1CZAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com

For other support material please check also:
http://www.amibroker.com/support.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/