Linear regression indicator & slope formula

#1
Hi all

What is the Metastock 10.1 Formula indicator for

Linear Regression Indicator &
Linear Regression Slope

The formula not provide in metastock.

Thanx in advance

:)
 

rkkarnani

Well-Known Member
#2
No idea for specifically what is there in MS 10.1 but the formula below would work in it :

***********************************************

MetaStock -> Tools -> Indicator Builder -> New
Copy and paste formula below.


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

{ Linear Regression Indicator/Slope MS formula }
{ Precision accumulation errors courtesy of
MetaStock's Cum() single-precision function }
{ ©Copyright 2003-2004 Jose Silva }
{ For private use only }


{ User inputs }
pds:=Input("Linear Regression periods",
2,2520,21);
plot:=Input("Linear Regression: [1]Indicator, [2]Slope",1,2,1);
x:=Input("[1]Open, [2]High, [3]Low, [4]Close, [5]WgtCl, [6]P",1,6,4);
x:=If(x=1,O,If(x=2,H,If(x=3,L,If(x=5,WC(),If(x=6,P,C)))));

{ Lin Reg Slope }
counter:=Cum(1)-pds;
y:=pds*Sum(counter*x,pds)
-Sum(counter,pds)*Sum(x,pds);
z:=pds*Sum(Pwr(counter,2),pds)
-Pwr(Sum(counter,pds),2);
z:=
LastValue(ValueWhen(1,Cum(IsDefined(z))=1,z));
LRS:=y/z;

{ Lin Reg Indicator - LR trendline end point }
LRI:=LRS*pds-LRS*(pds+1)/2+Mov(x,pds,S);

{ Lin Reg trendline start point }
LRstart:=Ref(LRI-LRS*(pds-1),pds-1);

{ Plot }
If(plot=1,LRI,LRS)

---8<---------------------------
 
#6
No idea for specifically what is there in MS 10.1 but the formula below would work in it :

***********************************************

MetaStock -> Tools -> Indicator Builder -> New
Copy and paste formula below.


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

{ Linear Regression Indicator/Slope MS formula }
{ Precision accumulation errors courtesy of
MetaStock's Cum() single-precision function }
{ ©Copyright 2003-2004 Jose Silva }
{ For private use only }


{ User inputs }
pds:=Input("Linear Regression periods",
2,2520,21);
plot:=Input("Linear Regression: [1]Indicator, [2]Slope",1,2,1);
x:=Input("[1]Open, [2]High, [3]Low, [4]Close, [5]WgtCl, [6]P",1,6,4);
x:=If(x=1,O,If(x=2,H,If(x=3,L,If(x=5,WC(),If(x=6,P,C)))));

{ Lin Reg Slope }
counter:=Cum(1)-pds;
y:=pds*Sum(counter*x,pds)
-Sum(counter,pds)*Sum(x,pds);
z:=pds*Sum(Pwr(counter,2),pds)
-Pwr(Sum(counter,pds),2);
z:=
LastValue(ValueWhen(1,Cum(IsDefined(z))=1,z));
LRS:=y/z;

{ Lin Reg Indicator - LR trendline end point }
LRI:=LRS*pds-LRS*(pds+1)/2+Mov(x,pds,S);

{ Lin Reg trendline start point }
LRstart:=Ref(LRI-LRS*(pds-1),pds-1);

{ Plot }
If(plot=1,LRI,LRS)

---8<---------------------------
Do you have it for Amibroker
 

Similar threads

Zerodha – Open Paperless Account

Open online account with Zerodha. Free delivery trading and Max Rs 20 for Intraday, F&O, Currency and Commodity Trading. Intraday High leverage with MIS, CO and BO.

Name:Phone:
Email:City:
State:
Are you a day trader?