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

[Metastockusers] Re: need accurate Linear Regression code



PureBytes Links

Trading Reference Links

(2 * Sum(Cum(1) * C,2) - Sum(Cum(1),2)* Sum(C,2)) / 
(2 * Sum(Pwr(Cum(1),2),2) - Pwr(Sum(Cum(1),10),2)) * 
Cum(1) + (Mov(C,2,S) - Mov(Cum(1),2,S) * 
(2 * Sum(Cum(1) * C,2) - Sum(Cum(1),14) * Sum(C,2)) / 
(2 * Sum(Pwr(Cum(1),2),2) - Pwr(Sum(Cum(1),10),2)))









--- In Metastockusers@xxxxxxxxxxxxxxx, "Jose" <josesilva22@xxxx> 
wrote:
> 
> I need the Linear Regression Indicator & Linear Regression Slope 
> formulae.
> 
> The code I've been using (from memory, similar to Corey's code?) 
gives 
> good matching plots with MS v8.01, until I begin using shorter 
> periods.
> 
> 
> Linear Regression Indicator formula
> ===================================
> 
> ---8<------------------------------
> 
> pds:=Input("LinReg periods)",2,2520,14);
> 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);
> LR:=y/z*Cum(1)-y/z*Mov(Cum(1),pds,S)+Mov(x,pds,S);
> 
> LR
> 
> ---8<------------------------------
> 
> 
> Linear Regression Slope formula
> ===============================
> 
> ---8<------------------------------
> 
> pds:=Input("LinRegSlope periods",2,252,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))));
> 
> 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);
> 
> y/z
> 
> ---8<------------------------------
> 
> 
> Using the code above with a 2-period LinReg should match the price 
> plot exactly, but it doesn't.
> 
> Anyone help, please?
> 
> jose '-)


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Inkjet cartridges up to 80% off. HP, Epson, Lexmark--we have your brand.
Free shipping on every order to the U.S. and Canada! Excellent service.
http://www.c1tracking.com/l.asp?cid=5510
http://us.click.yahoo.com/QWB0QC/.eUGAA/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/