PureBytes Links
Trading Reference Links
|
Sorry ... didn't look at the reference ...
Removing the function, simplifying the code somewhat, adding some
breathing room for the operators and making use of AddColumn's to
investigate the constants one can see that the formula appears to be
doing what it is supposed to as the results can be checked easily
enough against Excel ...
However, the formula for X seems to be dealing with degrees rather
than radians and probably should be changed to read ...
x = (1 - cos(3.14159 * 2 / Length)) / 0.414213562;
--------------------------------------------------
initLength = Param("initLength", 21, 2, 60, 1);
if (initLength < 2)
length = 2;
else
length = initlength;
x = (1 - cos(360 / Length)) / 0.414213562;
u = -x + sqrt(x ^ 2 + 2 * x);
u1 = 1.0 - u;
u1_2 = u1 ^ 2;
u_2 = u ^ 2;
y[0] = C[0];
y[1] = C[1];
for (i = 2; i < BarCount; i++)
{
y[i] = u_2 * C[i] + 2 * u1 * y[i-1] - u1_2 * y[i-2];
}
Plot(y, "twitch", colorWhite);
Plot(C, "Close", colorRed);
Filter = 1;
AddColumn(x, "x", 1.5);
AddColumn(u, "u", 1.5);
AddColumn(u1, "u1", 1.5);
AddColumn(u1_2, "u1_2", 1.5);
AddColumn(u_2, "u_2", 1.5);
AddColumn(y, "y", 1.5);
AddColumn(C, "C", 1.5);
--- In amibroker@xxxxxxxxxxxxxxx, "dalengo" <dalengo@xxxx> wrote:
>
> "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/
|