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

Re: [amibroker] Re: What's Wrong With This Line?



PureBytes Links

Trading Reference Links

In the help for linregintercept is this code for plotting the line
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 );


If you just want the linear reg values plotted, like a moving average just
use
Plot( LinearReg( close, 10 ), "LinReg", colorRed );


-- 
Cheers
Graham
AB-Write >< Professional AFL Writing Service
Yes, I write AFL code to your requirements
http://www.aflwriting.com

On 18/11/06, Charles J. Dudek <trader@xxxxxxxxxxxxxx> wrote:
>
> OK, so how do I fix it?  Do I have to write some code that will
> calculate a least squares regression from scratch?  I think that will
> be really hairy to try to figure out.  Are there any examples of
> formulas written to do the same thing or something similar?  None of
> the linearreg formulas on the AB website helped.
>
> --- In amibroker@xxxxxxxxxxxxxxx, "Fred" <ftonetti@xxx> wrote:
> >
> > From the doc ...
> >
> > SYNTAX  LinRegIntercept( ARRAY, periods )
> >
> > RETURNS ARRAY
> >
> > --- In amibroker@xxxxxxxxxxxxxxx, "Charles J. Dudek" <trader@>
> > wrote:
> > >
> > > And how do I fix it.  I'm getting a type mismatch error, but I
> > can't
> > > see where I'm trying to put an entire array into one cell.
> > >
> > > aL[i]   =  LinRegIntercept( C [i] , Longcount[i] );
> > >
> > > Does LinRegIntercept create an array?  If so, how do I get around
> > > that?  I'm trying to create trendlines at various points throughout
> > > the history that start and end based on other calculations.  This
> > is
> > > driving me CRAZY!!!
> > >
> > > Are there any examples of this kind of thing I could refer to?  I
> > know
> > > I could use LineArray, but I also need to calculate standard
> > > deviations based on the same periods, so I don't think that will
> > help
> > > me, will it?
> > >
> > > Chuck
> > >
> >
>
>
>
>
>
> 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 NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
> http://www.amibroker.com/devlog/
>
> For other support material please check also:
> http://www.amibroker.com/support.html
>
> Yahoo! Groups Links
>
>
>
>
>

Content-Description: "AVG certification"
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.409 / Virus Database: 268.14.11/542 - Release Date: 11/20/2006