PureBytes Links
Trading Reference Links
|
Excuse me but this is elementary school math.
y = a + b * x
a is a intercept (in AFL LinRegIntercept)
b is a slope (in AFL LinRegSlope)
The AFL formula:
x = Cum(1);
lastx = LastValue( x );
Daysback = 10;
aa = LastValue( LinRegIntercept( Close, Daysback) );
bb = LastValue( LinRegSlope( Close, Daysback ) );
y = aa + bb * ( x - (Lastx - DaysBack) );
Plot( Close, "Close", colorBlack, styleCandle );
Plot( y, "LinReg", colorRed );
If you want only the last bar display you can use:
x = Cum(1);
lastx = LastValue( x );
Daysback = 10;
aa = LastValue( LinRegIntercept( Close, Daysback) );
bb = LastValue( LinRegSlope( Close, Daysback ) );
y = Aa + bb * ( x - (Lastx - DaysBack) );
Plot( Close, "Close", colorBlack, styleCandle );
Plot( IIf( x >= (lastx - Daysback), y, -1e10 ), "LinReg", colorRed );
Best regards,
Tomasz Janeczko
amibroker.com
----- Original Message -----
From: "Herman van den Bergen" <psytek@xxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Monday, October 14, 2002 8:49 PM
Subject: RE: [amibroker] Re: linear regression
> Hello,
>
> I think Don is looking for the straight line LinReg equation, there have
> been a few versions posted but they all had some problems under certain
> conditions.
>
> It would be nice to have a straight line LinReg from point A to B formula,
> anybody good in math?
>
> Best regards,
> Herman.
>
> > -----Original Message-----
> > From: gillesdeprez [mailto:gillesdeprez@x...]
> > Sent: 14 October, 2002 2:05 AM
> > To: amibroker@xxxxxxxxxxxxxxx
> > Subject: [amibroker] Re: linear regression
> >
> >
> > Hello,
> > I think the function LinearReg (Array, Period) came with the 4.14
> > version;
> > Friendly,
> > Gilles
> >
> >
> > --- In amibroker@xxxx, "doedau" <doed@xxxx> wrote:
> > > Hi,
> > > My version of AB (4.02)has slope of linear regression line
> > > (linregslope) not the line of linear regression itself. Have I
> > missed
> > > it, has anyone written afl for it, or is it in a later version? I
> > see
> > > references to regression in latest version but my maths not up to
> > > knowing if this is the same thing as conventional linear regression.
> > > Many thanks for any help in advance. Regards, Don.
> >
> >
> >
> > Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx
> > (Web page: http://groups.yahoo.com/group/amiquote/messages/)
> >
> > Check group FAQ at:
> http://groups.yahoo.com/group/amibroker/files/groupfaq.html
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
>
>
>
>
> Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx
> (Web page: http://groups.yahoo.com/group/amiquote/messages/)
>
> Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
>
|