PureBytes Links
Trading Reference Links
|
Roy, both LinRegInd and LinRegSlp plot within a fraction of
MetaStock's LRI and LRS values on my charts, minor inaccuracies
courtesy of the Cum(1) errors accumulated by MetaStock.
Applying the same exact code with an external dll which calculates
values using double-precision numbers, the LRI & LRS values match
precisely.
So basically, it just comes down to replacing Cum(1) to get around
MetaStock's inadequacies. ;)
jose '-)
--- In equismetastock@xxxxxxxxxxxxxxx, "Roy Larsen" <rlarsen@xxxx>
wrote:
> Hi Jose
>
> > Roy, maybe this will help:
>
> No, not at first glance anyway. Neither LinRegInd nor LinRegSlp
appear to agree with the standard
> MetaStock LR and LRS values, but besidesthat I want to get away from
using Cum(1). Tom has
> demonstrated (if I understand his code correctly) that it's not
necessary to cumulate anything from
> bar one. A 21 period LR only needs the 21 most recent bars of data
to calculate, surely. I reason
> that LRS should not need any more bars than that either.
>
> Thanks
>
> Roy
>
> > =======================
> > Lin Reg Indicator/Slope
> > =======================
> > ---8<---------------------------
> >
> > { User inputs }
> > plot:=Input("[1]LinReg Indicator, [2]LinReg Slope)",1,2,1);
> > pds:=Input("LinReg periods)",2,2520,21);
> > x:=Input("use Open=1, High=2, Low=3, Close=4, Volume=5",1,5,4);
> > x:=If(x=1,O,If(x=2,H,If(x=3,L,If(x=4,C,V))));
> >
> > { Linear Regression components }
> > y:=pds*Sum(Cum(1)*x,pds)
> > -Sum(Cum(1),pds)*Sum(x,pds);
> > z:=pds*Sum(Pwr(Cum(1),2),pds)
> > -Pwr(Sum(Cum(1),pds),2);
> >
> > { Linear Regression Slope }
> > z:=If(z=0,.000001,z);
> > LinRegSlp:=y/z;
> >
> > {Linear Regression Indicator (LinReg end-point)}
> > LinRegInd:=LinRegSlp*Cum(1)
> > -LinRegSlp*Mov(Cum(1),pds,S)+Mov(x,pds,S);
> >
> > { Plot }
> > If(plot=1,LinRegInd,LinRegSlp)
> >
> > ---8<---------------------------
> >
> >
> > jose '-)
> >
> >
> > --- In equismetastock@xxxxxxxxxxxxxxx, "Roy Larsen" <rlarsen@xxxx>
> > wrote:
> > > Hi All
> > >
> > > Can anyone help with the mathematical relationship between
Linear
> > Regression and Linear Regression
> > > Slope. I have found that the formula created by Tom (Sprunger)
for
> > Linear Regression, using a pseudo
> > > loop, to be more true to the standard Linear Regression
indicator in
> > MetaStock than the common LR
> > > formula using a number of Cum() functions. I would like to carry
> > that greater accuracy through to a
> > > Linear Regression Slope indicator for plotting the weekly value
on
> > daily charts.
> > >
> > > Any assistance would be appreciated.
> > >
> > > Thanks
> > >
> > > Roy
> >
> >
> >
> >
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
> >
------------------------ Yahoo! Groups Sponsor --------------------~-->
Yahoo! Domains - Claim yours for only $14.70
http://us.click.yahoo.com/Z1wmxD/DREIAA/yQLSAA/BefplB/TM
--------------------------------------------------------------------~->
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/equismetastock/
<*> To unsubscribe from this group, send an email to:
equismetastock-unsubscribe@xxxxxxxxxxxxxxx
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|