Download software Tutorial videos
Subscription & data-feed pricing Class schedule


New account application Trading resources
Margin rates Stock & option commissions

Attention: Discussion forums are read-only for extended maintenance until further notice.
Welcome Guest, please sign in to participate in a discussion. Search | Active Topics |

a PCF that will simulate linear regression Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
genzmann
Posted : Monday, January 21, 2013 12:45:18 PM
Registered User
Joined: 10/19/2004
Posts: 5

I'm interested in a PCF that will simulate a linear regression trend line .I would like to find stocks that are in an up trend in the last 30 days.Can you help?

Bruce_L
Posted : Monday, January 21, 2013 12:52:28 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138

An Indicator Formula for the right end point of a 30-Period Linear Regression Line could be written as:

AVGC30 + 14.5 * (14.5 * C + 13.5 * C1 + 12.5 * C2 + 11.5 * C3 + 10.5 * C4 + 9.5 * C5 + 8.5 * C6 + 7.5 * C7 + 6.5 * C8 + 5.5 * C9 + 4.5 * C10 + 3.5 * C11 + 2.5 * C12 + 1.5 * C13 + 0.5 * C14 - 0.5 * C15 - 1.5 * C16 - 2.5 * C17 - 3.5 * C18 - 4.5 * C19 - 5.5 * C20 - 6.5 * C21 - 7.5 * C22 - 8.5 * C23 - 9.5 * C24 - 10.5 * C25 - 11.5 * C26 - 12.5 * C27 - 13.5 * C28 - 14.5 * C29) / 2247.5

We are interested primarily the linear regression slope portion of the formula which constitutes everything from the first parenthesis on:

(14.5 * C + 13.5 * C1 + 12.5 * C2 + 11.5 * C3 + 10.5 * C4 + 9.5 * C5 + 8.5 * C6 + 7.5 * C7 + 6.5 * C8 + 5.5 * C9 + 4.5 * C10 + 3.5 * C11 + 2.5 * C12 + 1.5 * C13 + 0.5 * C14 - 0.5 * C15 - 1.5 * C16 - 2.5 * C17 - 3.5 * C18 - 4.5 * C19 - 5.5 * C20 - 6.5 * C21 - 7.5 * C22 - 8.5 * C23 - 9.5 * C24 - 10.5 * C25 - 11.5 * C26 - 12.5 * C27 - 13.5 * C28 - 14.5 * C29) / 2247.5

You could add a > 0 to the end of this to check for a positive linear regression slope:

(14.5 * C + 13.5 * C1 + 12.5 * C2 + 11.5 * C3 + 10.5 * C4 + 9.5 * C5 + 8.5 * C6 + 7.5 * C7 + 6.5 * C8 + 5.5 * C9 + 4.5 * C10 + 3.5 * C11 + 2.5 * C12 + 1.5 * C13 + 0.5 * C14 - 0.5 * C15 - 1.5 * C16 - 2.5 * C17 - 3.5 * C18 - 4.5 * C19 - 5.5 * C20 - 6.5 * C21 - 7.5 * C22 - 8.5 * C23 - 9.5 * C24 - 10.5 * C25 - 11.5 * C26 - 12.5 * C27 - 13.5 * C28 - 14.5 * C29) / 2247.5 > 0

It is theoretically possible for the net change over the period to be negative even though the linear regression slope is positive however. So you may want to check for that as well. Adding that along with adjusting the linear regression slope formula slightly to make it a bit shorter and eliminate the denominator would result in:

C > C29 AND 29 * (C - C29) + 27 * (C1 - C28) + 25 * (C2 -C27) + 23 * (C3 - C26) + 21 * (C4 - C25) + 19 * (C5 - C24) + 17 * (C6 - C23) + 15 * (C7 - C22) + 13 * (C8 - C21) + 11 * (C9 - C20) + 9 * (C10 - C19) + 7 * (C11 - C18) + 5 * (C12 - C17) + 3 * (C13 - C16) + C14 > C15

Using Linear Regression vs Classical Peaks/Valleys for Divergence Analysis



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
Users browsing this topic
Guest-1

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.