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

[Metastockusers] Re: need accurate Linear Regression code



PureBytes Links

Trading Reference Links

Ok, I've fixed the 2-period LinReg issue, but now there are 
discrepancies with the MetaStock LinReg Indicator, noticeable at 
shorter periods.

It seems to me that my version is the correct one.

Feedback, please?

j '-)


LinReg Indicator/Slope formula
==============================
 
---8<-------------------------

{©Copyright 2003 Jose Silva}
{josesilva22@xxxxxxxxx}

pds:=Input("LinReg periods)",2,2520,5)-1;
plot:=Input("plot: Indicator=1, Slope=2",1,2,1);
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))));

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);
z:=If(z=0,.000001,z);

LRS:=y/z;
LR:=
LRS*Cum(1)-LRS*Mov(Cum(1),pds,S)+Mov(x,pds,S);

If(plot=1,LR,0);
If(plot=1,LR,LRS)

---8<-------------------------



------------------------ Yahoo! Groups Sponsor ---------------------~-->
Save up to 80% on top-quality inkjet cartridges and get your order fast!
FREE shipping on orders $50 or more to the US & Canada. Shop at Myinks.com!
http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/v2G7ND/KfUGAA/ySSFAA/zMEolB/TM
---------------------------------------------------------------------~->

To unsubscribe from this group, send an email to:
Metastockusers-unsubscribe@xxxxxxxxxxx

 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/