| Welcome Guest, please sign in to participate in a discussion. | Search | Active Topics | |
Registered User Joined: 3/16/2005 Posts: 15
|
I used the following to calculate 50 day linear regression:
100 * (EXP((24.5 * LOG(C10 ) + 23.5 * LOG(C11) + 22.5 * LOG(C12) + 21.5 * LOG(C13) + 20.5 * LOG(C14) + 19.5 * LOG(C15) + 18.5 * LOG(C16) + 17.5 * LOG(C17) + 16.5 * LOG(C18) + 15.5 * LOG(C19) + 14.5 * LOG(C20) + 13.5 * LOG(C21) + 12.5 * LOG(C22) + 11.5 * LOG(C23) + 10.5 * LOG(C24) + 9.5 * LOG(C25) + 8.5 * LOG(C26) + 7.5 * LOG(C27) + 6.5 * LOG(C28) + 5.5 * LOG(C29) + 4.5 * LOG(C30) + 3.5 * LOG(C31) + 2.5 * LOG(C32) + 1.5 * LOG(C33) + .5 * LOG(C34) - .5 * LOG(C35) - 1.5 * LOG(C36) - 2.5 * LOG(C37) - 3.5 * LOG(C38) - 4.5 * LOG(C39) - 5.5 * LOG(C40) - 6.5 * LOG(C41) - 7.5 * LOG(C42) - 8.5 * LOG(C43) - 9.5 * LOG(C44) - 10.5 * LOG(C45) - 11.5 * LOG(C46) - 12.5 * LOG(C47) - 13.5 * LOG(C48) - 14.5 * LOG(C49) - 15.5 * LOG(C50) - 16.5 * LOG(C51) - 17.5 * LOG(C52) - 18.5 * LOG(C53) - 19.5 * LOG(C54) - 20.5 * LOG(C55) - 21.5 * LOG(C56) - 22.5 * LOG(C57) - 23.5 * LOG(C58) - 24.5 * LOG(C59)) / 10412.5) - 1) / ((MAXH62 / MINL62) ^ (1 / 61) - 1) / 61
and then recently used the following to calculate 10 day linear regression:
(10 * ((1 * C10) + (2 * C9) + (3 * C8) + (4 * C7) + (5 * C6) + (6 * C5) + (7 * C4) + (8 * C3) + (9 * C2) + (10 * C1)) - (1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10) * (C + C1 + C2 + C3 + C4 + C5 + C6 + C7 + C8 + C9)) / (10 * (1 + 4 + 9 + 16 + 25 + 36 + 49 + 64 + 81 + 100) - ((1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10) * (1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10)))
The second was based on
a=(n*E(x*y)-((Ex)*(Ey))/(n*E(x^2)-((Ex)^2))
Where: a = slope
n = number of days in the regression
E = the sum of all the data points
^ = raised to a power of
x = data points 1-2-3…n
y = the given indicator data points
I'm not sure what the first was based on, but the two look significantly different. Can anyone explain the differences and if one is preferrable over the other?
Thanks in advance
John
|
|

 Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
Your first formula is not a 50-Day Linear Regression. It is a Personal Criteria Formula to approximate the Visual Slope Sort of 50-Period Linear Regression with an Extension of 10 on Logarithmic Charts.
Pointer mode data box and visual slope discrepency
PCF LR50 Visual Slope vs Linear Regression - 50 bar period Sort Method Channel
Your second formula appears to be incorrect in that you are using C10 through C1 in one portion and C through C9 in the other portion. Correcting this results in a formula for the Slope of the current 10-Period Linear Regression Line:
(10 * ((1 * C9) + (2 * C8) + (3 * C7) + (4 * C6) + (5 * C5) + (6 * C4) + (7 * C3) + (8 * C2) + (9 * C1) + (10 * C)) - (1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10) * (C + C1 + C2 + C3 + C4 + C5 + C6 + C7 + C8 + C9)) / (10 * (1 + 4 + 9 + 16 + 25 + 36 + 49 + 64 + 81 + 100) - ((1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10) * (1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10)))
But it is way longer than it needs to be as the following PCF would return the same result:
(9 * (C - C9) + 7 * (C1 - C8) + 5 * (C2 - C7) + 3 * (C3 - C6) + C4 - C5) / 165
You may wish to review the following:
Using Linear Regression vs Classical Peaks/Valleys for Divergence Analysis
Linear regression channel calculations
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 3/16/2005 Posts: 15
|
Thanks Bruce. My memory must be going with age. I see that I had gone through a variation of this question with you before. I created that second calculation as a result of substituting 10 days for the 4 day formula that I had run across as follows:
The formula for gradient or slope of a linear regression is as
follows:
a=(n*E(x*y)-((Ex)*(Ey))/(n*E(x^2)-((Ex)^2))
Where: a = slope
n = number of days in the regression
E = the sum of all the data points
^ = raised to a power of
x = data points 1-2-3…n
y = the given indicator data points
So for a 4 day regression:
x = data points 1-2-3-4
Ex = (1+2+3+4) = 10
E(x^2) = (1+4+9+16) =30
(Ex)^2 = (1+2+3+4) ^2 = 10^2 =100
y = the indicator data points
(so that if the indicator were C or (price today):
Ey = (C+C1+C2+C3)
E(x*y) = ((1*C3)+(2*C2)+(3*C1)+(4*C))
So to plug it all into the formula:
(4*((1*C3)+(2*C2)+(3*C1)+(4*C))-10*(C+C1+C2+C3))/(4*30)-100
or
{4*((1*C3)+(2*C2)+(3*C1)+(4*C))-10*(C+C1+C2+C3))/20
10 days
(10*((1*C10)+(2*C9)+(3*C8)+(4*C7)+(5*C6)+(6*C5)+(7*C4)+(8*C3)+(9*C2)+(10*C1))-(1+2+3+4+5+6+7+8+9+10)*(C+C1+C2+C3+C4+C5+C6+C7+C8+C9))/(10*(1+4+9+16+25+36+49+64+81+100))
-((1+2+3+4+5+6+7+8+9+10)*(1+2+3+4+5+6+7+8+9+10)))
You are right about the error and I'll correct it. But could you provide me with a 10 day version of your
original logarithmic PCF.
Thanks again
John
|
|

 Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
Personal Criteria Formula to approximate the Visual Slope Sort of a 10-Period Linear Regression on Logarithmic Charts:
100 * (EXP((4.5 * LOG(C ) + 3.5 * LOG(C1) + 2.5 * LOG(C2) + 1.5 * LOG(C3) + .5 * LOG(C4) - .5 * LOG(C5) - 1.5 * LOG(C6) - 2.5 * LOG(C7) - 3.5 * LOG(C8) - 4.5 * LOG(C9)) / 82.5) - 1) / ((MAXH12 / MINL12) ^ (1 / 11) - 1) / 11
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 1/20/2007 Posts: 9
|
Hello! I need help creating a PCF to scan for stocks crossing it's 50 day linear regression to the upside...
Chepo.
|
|

 Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
chepopr,
If you mean Price is above the current Linear Regression today but at or below yesterday's Linear Regression yesterday then please try the following:
C > AVGC50 + 24.5 * (24.5 * C + 23.5 * C1 + 22.5 * C2 + 21.5 * C3 + 20.5 * C4 + 19.5 * C5 + 18.5 * C6 + 17.5 * C7 + 16.5 * C8 + 15.5 * C9 + 14.5 * C10 + 13.5 * C11 + 12.5 * C12 + 11.5 * C13 + 10.5 * C14 + 9.5 * C15 + 8.5 * C16 + 7.5 * C17 + 6.5 * C18 + 5.5 * C19 + 4.5 * C20 + 3.5 * C21 + 2.5 * C22 + 1.5 * C23 + .5 * C24 - .5 * C25 - 1.5 * C26 - 2.5 * C27 - 3.5 * C28 - 4.5 * C29 - 5.5 * C30 - 6.5 * C31 - 7.5 * C32 - 8.5 * C33 - 9.5 * C34 - 10.5 * C35 - 11.5 * C36 - 12.5 * C37 - 13.5 * C38 - 14.5 * C39 - 15.5 * C40 - 16.5 * C41 - 17.5 * C42 - 18.5 * C43 - 19.5 * C44 - 20.5 * C45 - 21.5 * C46 - 22.5 * C47 - 23.5 * C48 - 24.5 * C49) / 10412.5 AND C1 <= AVGC50.1 + 24.5 * (24.5 * C1 + 23.5 * C2 + 22.5 * C3 + 21.5 * C4 + 20.5 * C5 + 19.5 * C6 + 18.5 * C7 + 17.5 * C8 + 16.5 * C9 + 15.5 * C10 + 14.5 * C11 + 13.5 * C12 + 12.5 * C13 + 11.5 * C14 + 10.5 * C15 + 9.5 * C16 + 8.5 * C17 + 7.5 * C18 + 6.5 * C19 + 5.5 * C20 + 4.5 * C21 + 3.5 * C22 + 2.5 * C23 + 1.5 * C24 + .5 * C25 - .5 * C26 - 1.5 * C27 - 2.5 * C28 - 3.5 * C29 - 4.5 * C30 - 5.5 * C31 - 6.5 * C32 - 7.5 * C33 - 8.5 * C34 - 9.5 * C35 - 10.5 * C36 - 11.5 * C37 - 12.5 * C38 - 13.5 * C39 - 14.5 * C40 - 15.5 * C41 - 16.5 * C42 - 17.5 * C43 - 18.5 * C44 - 19.5 * C45 - 20.5 * C46 - 21.5 * C47 - 22.5 * C48 - 23.5 * C49 - 24.5 * C50) / 10412.5
If you mean Price is above the current Linear Regression today and yesterday's Price is visually at or below the current Linear Regression then please try the following instead:
C > AVGC50 + 24.5 * (24.5 * C + 23.5 * C1 + 22.5 * C2 + 21.5 * C3 + 20.5 * C4 + 19.5 * C5 + 18.5 * C6 + 17.5 * C7 + 16.5 * C8 + 15.5 * C9 + 14.5 * C10 + 13.5 * C11 + 12.5 * C12 + 11.5 * C13 + 10.5 * C14 + 9.5 * C15 + 8.5 * C16 + 7.5 * C17 + 6.5 * C18 + 5.5 * C19 + 4.5 * C20 + 3.5 * C21 + 2.5 * C22 + 1.5 * C23 + .5 * C24 - .5 * C25 - 1.5 * C26 - 2.5 * C27 - 3.5 * C28 - 4.5 * C29 - 5.5 * C30 - 6.5 * C31 - 7.5 * C32 - 8.5 * C33 - 9.5 * C34 - 10.5 * C35 - 11.5 * C36 - 12.5 * C37 - 13.5 * C38 - 14.5 * C39 - 15.5 * C40 - 16.5 * C41 - 17.5 * C42 - 18.5 * C43 - 19.5 * C44 - 20.5 * C45 - 21.5 * C46 - 22.5 * C47 - 23.5 * C48 - 24.5 * C49) / 10412.5 AND C1 <= AVGC50 + 23.5 * (24.5 * C + 23.5 * C1 + 22.5 * C2 + 21.5 * C3 + 20.5 * C4 + 19.5 * C5 + 18.5 * C6 + 17.5 * C7 + 16.5 * C8 + 15.5 * C9 + 14.5 * C10 + 13.5 * C11 + 12.5 * C12 + 11.5 * C13 + 10.5 * C14 + 9.5 * C15 + 8.5 * C16 + 7.5 * C17 + 6.5 * C18 + 5.5 * C19 + 4.5 * C20 + 3.5 * C21 + 2.5 * C22 + 1.5 * C23 + .5 * C24 - .5 * C25 - 1.5 * C26 - 2.5 * C27 - 3.5 * C28 - 4.5 * C29 - 5.5 * C30 - 6.5 * C31 - 7.5 * C32 - 8.5 * C33 - 9.5 * C34 - 10.5 * C35 - 11.5 * C36 - 12.5 * C37 - 13.5 * C38 - 14.5 * C39 - 15.5 * C40 - 16.5 * C41 - 17.5 * C42 - 18.5 * C43 - 19.5 * C44 - 20.5 * C45 - 21.5 * C46 - 22.5 * C47 - 23.5 * C48 - 24.5 * C49) / 10412.5
Using Linear Regression vs Classical Peaks/Valleys for Divergence Analysis
How to create a Personal Criteria Forumula (PCF)
PCF Formula Descriptions
Handy PCF example formulas to help you learn the syntax of PCFs!
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
|
Guest-1 |