logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
essemkay  
#1 Posted : Friday, July 10, 2015 4:07:05 PM(UTC)
essemkay

Rank: Member

Groups: Registered, Registered Users, Unverified Users
Joined: 1/1/2013(UTC)
Posts: 21

Thanks: 4 times
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

mstt  
#2 Posted : Friday, July 10, 2015 8:22:37 PM(UTC)
mstt

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 7/25/2005(UTC)
Posts: 1,042

Was thanked: 57 time(s) in 54 post(s)
Hi essemkay These two formulas are derived from formulas created by Joe Sharp as shown in the January 2000 issue of TASC magazine. Get hold of the article and you'll see that his Modified Moving Average gives the same result as Linear Regression. The second formula generates a signal that's exactly the same as Linear Regression Slope. There's another version of LR and LRS discrete code that's been around for a long time that makes extensive use of the Cum() function. That formula, however, loses accuracy when used on large amounts of data and eventually becomes quite useless. Roy {Modified Moving Average} {Linear Regression} {TASC January 2000 by Joe Sharp} n:=20; tn:=Mov(C,n,S); s1:=((n-1)/2)*C + ((n-3)/2)*Ref(C,-1) + ((n-5)/2)*Ref(C,-2) + ((n-7)/2)*Ref(C,-3) + ((n-9)/2)*Ref(C,-4) + ((n-11)/2)*Ref(C,-5) + ((n-13)/2)*Ref(C,-6) + ((n-15)/2)*Ref(C,-7) + ((n-17)/2)*Ref(C,-8) + ((n-19)/2)*Ref(C,-9) + ((n-21)/2)*Ref(C,-10) + ((n-23)/2)*Ref(C,-11) + ((n-25)/2)*Ref(C,-12) + ((n-27)/2)*Ref(C,-13) + ((n-29)/2)*Ref(C,-14) + ((n-31)/2)*Ref(C,-15) + ((n-33)/2)*Ref(C,-16) + ((n-35)/2)*Ref(C,-17) + ((n-37)/2)*Ref(C,-18) + ((n-39)/2)*Ref(C,-19); tn+(6*s1)/((n+1)*n); {Modified Moving Average Slope} {Linear Regression Slope} {MMA - TASC Jan 2000 by Joe Sharp} n:=20; tn:=Mov(C,n,S); s1:=((n-1)/2)*C + ((n-3)/2)*Ref(C,-1) + ((n-5)/2)*Ref(C,-2) + ((n-7)/2)*Ref(C,-3) + ((n-9)/2)*Ref(C,-4) + ((n-11)/2)*Ref(C,-5) + ((n-13)/2)*Ref(C,-6) + ((n-15)/2)*Ref(C,-7) + ((n-17)/2)*Ref(C,-8) + ((n-19)/2)*Ref(C,-9) + ((n-21)/2)*Ref(C,-10) + ((n-23)/2)*Ref(C,-11) + ((n-25)/2)*Ref(C,-12) + ((n-27)/2)*Ref(C,-13) + ((n-29)/2)*Ref(C,-14) + ((n-31)/2)*Ref(C,-15) + ((n-33)/2)*Ref(C,-16) + ((n-35)/2)*Ref(C,-17) + ((n-37)/2)*Ref(C,-18) + ((n-39)/2)*Ref(C,-19); LR:=tn+6*S1/(n+1)/n; 2*(LR-tn)/(n-1);
thanks 1 user thanked mstt for this useful post.
essemkay on 7/11/2015(UTC)
mstt  
#3 Posted : Saturday, July 11, 2015 11:50:09 PM(UTC)
mstt

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 7/25/2005(UTC)
Posts: 1,042

Was thanked: 57 time(s) in 54 post(s)
Here's another version that allows the user to set the number of Periods parameter between 2 and 40. MetaStock's restriction of 40 numeric values is somewhat of a pain, but a rather clumsy way around this as used here is to add or subtract numbers smaller than 40 to create values greater than 40. Roy {Modified Moving Average} {Linear Regression} {TASC January 2000 article by Joe Sharp} {MetaStock code by Roy Larsen, 11/7/2115} N:=Input("MMA Periods",2,40,20); M:=Mov(C,N,S); X:=((N-1)/2)*C +(N>1)*((N-3)/2)*Ref(C,-1) +(N>2)*((N-5)/2)*Ref(C,-2) +(N>3)*((N-7)/2)*Ref(C,-3) +(N>4)*((N-9)/2)*Ref(C,-4) +(N>5)*((N-11)/2)*Ref(C,-5) +(N>6)*((N-13)/2)*Ref(C,-6) +(N>7)*((N-15)/2)*Ref(C,-7) +(N>8)*((N-17)/2)*Ref(C,-8) +(N>9)*((N-19)/2)*Ref(C,-9) +(N>10)*((N-21)/2)*Ref(C,-10) +(N>11)*((N-23)/2)*Ref(C,-11) +(N>12)*((N-25)/2)*Ref(C,-12) +(N>13)*((N-27)/2)*Ref(C,-13) +(N>14)*((N-29)/2)*Ref(C,-14) +(N>15)*((N-31)/2)*Ref(C,-15) +(N>16)*((N-33)/2)*Ref(C,-16) +(N>17)*((N-35)/2)*Ref(C,-17) +(N>18)*((N-37)/2)*Ref(C,-18) +(N>19)*((N-37-2)/2)*Ref(C,-19) +(N>20)*((N-37-4)/2)*Ref(C,-20) +(N>21)*((N-37-6)/2)*Ref(C,-21) +(N>22)*((N-37-8)/2)*Ref(C,-22) +(N>23)*((N-37-10)/2)*Ref(C,-23) +(N>24)*((N-37-12)/2)*Ref(C,-24) +(N>25)*((N-37-14)/2)*Ref(C,-25) +(N>26)*((N-37-16)/2)*Ref(C,-26) +(N>27)*((N-37-18)/2)*Ref(C,-27) +(N>28)*((N-37-20)/2)*Ref(C,-28) +(N>29)*((N-37-22)/2)*Ref(C,-29) +(N>30)*((N-37-24)/2)*Ref(C,-30) +(N>31)*((N-37-26)/2)*Ref(C,-31) +(N>32)*((N-37-28)/2)*Ref(C,-32) +(N>33)*((N-37-30)/2)*Ref(C,-33) +(N>34)*((N-37-32)/2)*Ref(C,-34) +(N>35)*((N-37-34)/2)*Ref(C,-35) +(N>36)*((N-37-36)/2)*Ref(C,-36) +(N>37)*((N-37-37-1)/2)*Ref(C,-37) +(N>(37+1))*((N-37-37-3)/2)*Ref(C,-37-1) +(N>(37+2))*((N-37-37-5)/2)*Ref(C,-37-2); M+(6*X)/((N+1)*N);
mstt  
#4 Posted : Sunday, July 12, 2015 2:19:35 AM(UTC)
mstt

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 7/25/2005(UTC)
Posts: 1,042

Was thanked: 57 time(s) in 54 post(s)
And here's the equivalent of Linear Regression Slope. Roy {Modified Moving Average Slope} {Linear Regression Slope} {TASC January 2000 article by Joe Sharp} {MetaStock code by Roy Larsen, 11/7/2115} N:=Input("MMA Periods",2,40,20); M:=Mov(C,N,S); X:=((N-1)/2)*C +(N>1)*((N-3)/2)*Ref(C,-1) +(N>2)*((N-5)/2)*Ref(C,-2) +(N>3)*((N-7)/2)*Ref(C,-3) +(N>4)*((N-9)/2)*Ref(C,-4) +(N>5)*((N-11)/2)*Ref(C,-5) +(N>6)*((N-13)/2)*Ref(C,-6) +(N>7)*((N-15)/2)*Ref(C,-7) +(N>8)*((N-17)/2)*Ref(C,-8) +(N>9)*((N-19)/2)*Ref(C,-9) +(N>10)*((N-21)/2)*Ref(C,-10) +(N>11)*((N-23)/2)*Ref(C,-11) +(N>12)*((N-25)/2)*Ref(C,-12) +(N>13)*((N-27)/2)*Ref(C,-13) +(N>14)*((N-29)/2)*Ref(C,-14) +(N>15)*((N-31)/2)*Ref(C,-15) +(N>16)*((N-33)/2)*Ref(C,-16) +(N>17)*((N-35)/2)*Ref(C,-17) +(N>18)*((N-37)/2)*Ref(C,-18) +(N>19)*((N-37-2)/2)*Ref(C,-19) +(N>20)*((N-37-4)/2)*Ref(C,-20) +(N>21)*((N-37-6)/2)*Ref(C,-21) +(N>22)*((N-37-8)/2)*Ref(C,-22) +(N>23)*((N-37-10)/2)*Ref(C,-23) +(N>24)*((N-37-12)/2)*Ref(C,-24) +(N>25)*((N-37-14)/2)*Ref(C,-25) +(N>26)*((N-37-16)/2)*Ref(C,-26) +(N>27)*((N-37-18)/2)*Ref(C,-27) +(N>28)*((N-37-20)/2)*Ref(C,-28) +(N>29)*((N-37-22)/2)*Ref(C,-29) +(N>30)*((N-37-24)/2)*Ref(C,-30) +(N>31)*((N-37-26)/2)*Ref(C,-31) +(N>32)*((N-37-28)/2)*Ref(C,-32) +(N>33)*((N-37-30)/2)*Ref(C,-33) +(N>34)*((N-37-32)/2)*Ref(C,-34) +(N>35)*((N-37-34)/2)*Ref(C,-35) +(N>36)*((N-37-36)/2)*Ref(C,-36) +(N>37)*((N-37-37-1)/2)*Ref(C,-37) +(N>(37+1))*((N-37-37-3)/2)*Ref(C,-37-1) +(N>(37+2))*((N-37-37-5)/2)*Ref(C,-37-2); LR:=M+(6*X)/((N+1)*N); 2*(LR-M)/(N-1);
Users browsing this topic
Guest (Hidden)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.