Welcome Guest, please sign in to participate in a discussion. Search | Active Topics |

Slope of linear regression and comparison symbol data in PFC Topic Rating:
Previous Topic · Next Topic Watch this topic · Print this topic ·
BradG
Posted : Tuesday, January 31, 2006 3:58:48 PM
Registered User
Joined: 4/7/2005
Posts: 14
The following is an excerpt from "Sir Laptop's" submission on 3/2/00. I am trying to duplicate his approach in TC2005 but have hit a couple of roadblocks and I wonder if someone could point me in the right direction:

========================
As an example of one trading scheme: include on the log price chart for a real stock, a line showing the daily price of a model increasing at a fixed rate of 500%/year, and a linear regression line for the short term performance of the real stock. I select stocks where the slope of the regression line is greater than that of the model, meaning the stock is growing faster than 500%/year. Then I divide the stock prices by the model prices and take short (10 day) and long (40 day) moving averages of this ratio. I buy stocks where the 10-day is well above the 40 day, and sell when the 10-day crosses below the 40 day (meaning the price is no longer increasing by at least 500%/year).
=========================

I have added FX400 as the comparison symbol on a tab, and a 10-bar linear regression of price as an indicator. By searching through your support database (thank you, Jim Dean, for your extensive contributions), I built a PFC that calculates the slope of the LR line. The formula I'm using is: (4.5 * C + 3.5 * C1 + 2.5 * C2 + 1.5 * C3 + .5 * C4 - .5 * C5 - 1.5 * C6 - 2.5 * C7 - 3.5 * C8 - 4.5 * C9) / 82.5.

When I sort a watch list by the PFC, I should see that all the stocks that have a LR slope of the same number have LR lines that are parallel to each other. I thought the problem might be related to different screen scaling for different securities, but it still seems like the slope of the LR line relative to the FX400 line should be similar for different securities which have the same calculated slope. For example, the value of the PFC for OS and IX on 1/30/06 is .85, so their LR lines should be parallel to each other, (or at least similar, relative to the FX400 line on each security) but they aren't. In fact the LR line for IX is pointing down (slope is negative). I'm using logrithmic scaling, but I don't know what I'm doing wrong. (That's the first question).

The second question is: How do I access the comparison symbol in a PFC? I see in the help files that I can sort by the difference between two indicators but I haven't been able to find anything in the help files on the subject of using comparison symbol data in PFC's (So that I can "divide the stock prices by the model prices and take short (10 day) and long (40 day) moving averages of this ratio").

Thanks for whatever help you can provide.
Bruce_L
Posted : Tuesday, January 31, 2006 4:13:06 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
The LR Slope from the formula is expressed as dollars/period, not as a percentage of either the symbols value or chart height. For the lines to be parallel, they would need to cover the same percentage of chart height. The formula for this would vary by zoom.

TeleChart's Personal Criteria Formula Language does not currently have a way of referencing another symbol. Indicator Sorts do not currently have this ability either. I do not know of a way of doing what you are suggesting in your second question in TeleChart.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
BradG
Posted : Tuesday, January 31, 2006 5:36:49 PM
Registered User
Joined: 4/7/2005
Posts: 14
Ok, thanks for your quick response. I'll try to find another way to skin this cat.

Brad Gamble
jynkin
Posted : Tuesday, January 31, 2006 5:46:53 PM
Registered User
Joined: 10/7/2004
Posts: 286
Here is something you might try BHGamble,

Below is an LR30 slope divided by it's 20 day average. This can give you an approximate standardization of slope for all ranges of stocks, from penny stocks to hundred dollar stocks. The result will be expressed as the slope percentage of the 20d average.

A fixed rate of 500% per year comes out to 1.98 per day. ....500/252days per year. A fixed rate of 200% per year comes out to .79 per day....200/252=.79 You can either put parentheses around this formula and add an >1.98 or >.79. Or you can make it a PCF as it is and install it into a scan, setting the window to actual value, then sliding the window adjuster to the value you want.

Also if you want to use the ten day slope formula you have at the top, just replace the existing LR30 slope portion. (it ends with the 2247.5 number) You could also use a shorter divison average if you wanted.

sincerely,
jynkin

(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 / (AVGC20 + .01)
Craig_S
Posted : Tuesday, January 31, 2006 6:36:29 PM


Worden Trainer

Joined: 10/1/2004
Posts: 18,819
Here is another thing to check out:

Using Linear Regression Sorts to Help Spot Divergences

- Craig
Here to Help!
jynkin
Posted : Tuesday, January 31, 2006 7:49:17 PM
Registered User
Joined: 10/7/2004
Posts: 286
This formula is the same as the above formula, except pushed back 20 days. But I get an error message on it: "not enough data to calculate" And I have no idea why. If I take out from * C48 - 14.5 * C49....to the end, then it calculates properly. But the whole formula as it is below just gives me that error message.

??
Thanks,
jynkin

(14.5 * C20 + 13.5 * C21 + 12.5 * C22 + 11.5 * C23 + 10.5 * C24 + 9.5 * C25 + 8.5 * C26 + 7.5 * C27 + 6.5 * C28 + 5.5 * C29 + 4.5 * C30 + 3.5 * C31 + 2.5 * C32 + 1.5 * C33 + 0.5 * C34 - 0.5 * C35 - 1.5 * C36 - 2.5 * C37 - 3.5 * C38 - 4.5 * C39 - 5.5 * C40 - 6.5 * C41 - 7.5 * C42 - 8.5 * C43 - 9.5 * C44 - 10.5 * C45 - 11.5 * C46 - 12.5 * C47 - 13.5 * C48 - 14.5 * C49) / 2247.5 / (AVGC20.20 + .01)
Bruce_L
Posted : Tuesday, January 31, 2006 8:13:14 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
jynkin,
I don't get any errors. Are you viewing or testing with a symbol that doesn't have at least 50 periods of data?

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
jynkin
Posted : Tuesday, January 31, 2006 8:22:05 PM
Registered User
Joined: 10/7/2004
Posts: 286

well that's exactly it... I had UARM in the test box....a recent IPO without enough just as the error message said.

thanks again,
jynkin
bustermu
Posted : Tuesday, January 31, 2006 8:24:07 PM
Registered User
Joined: 1/1/2005
Posts: 2,645
Your problem is that you are calculating Linear Regression Slope on Arithmetic Scale, but your observations are all on Logarithmic Scale. Do your calculations on Logarithmic Scale and all should be fine.

Thanks,
Jim Murphy
jynkin
Posted : Tuesday, January 31, 2006 8:35:10 PM
Registered User
Joined: 10/7/2004
Posts: 286

Doing calculations and formulas on a logarithmic scale is a bit beyond me, though I have no doubt that it is a bit more precise. But for things like slope over a period of 30 days, I doubt it makes that much difference. I just want to collect a list of stocks that have done exceptionally well over a 30 day period.

Sincerely,
jynkin
bustermu
Posted : Tuesday, January 31, 2006 9:37:36 PM
Registered User
Joined: 1/1/2005
Posts: 2,645
QUOTE (jynkin)

Doing calculations and formulas on a logarithmic scale is a bit beyond me, though I have no doubt that it is a bit more precise. But for things like slope over a period of 30 days, I doubt it makes that much difference.


It all depends on what you are interested in. A $100 stock increasing $0.10 per day has the same slope on the Arthmetic Scale as a $1 stock increasing $0.10 per day. A $100 stock increasing at 100% per year compounded daily has the same slope on the Logarithmetic Scale as a $1 stock increasing at 100% per year compounded daily.

Thanks,
Jim Murphy
jynkin
Posted : Tuesday, January 31, 2006 9:42:13 PM
Registered User
Joined: 10/7/2004
Posts: 286
These formulas return a real percentage number when preceded by 100*, such as included below.

100*(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 / (AVGC20 + .01)

100*(14.5 * C20 + 13.5 * C21 + 12.5 * C22 + 11.5 * C23 + 10.5 * C24 + 9.5 * C25 + 8.5 * C26 + 7.5 * C27 + 6.5 * C28 + 5.5 * C29 + 4.5 * C30 + 3.5 * C31 + 2.5 * C32 + 1.5 * C33 + 0.5 * C34 - 0.5 * C35 - 1.5 * C36 - 2.5 * C37 - 3.5 * C38 - 4.5 * C39 - 5.5 * C40 - 6.5 * C41 - 7.5 * C42 - 8.5 * C43 - 9.5 * C44 - 10.5 * C45 - 11.5 * C46 - 12.5 * C47 - 13.5 * C48 - 14.5 * C49) / 2247.5 / (AVGC20.20 + .01)


Yes, that is true that a simple slope is not comparable over all stocks with widely varying prices. Which is why I use as a divisor, the 20d average. The corrected formulas above put them in the correct percentage format by adding the 100* to the numerator. And I believe they are applicable to all stocks, from penny stocks to 100 dollar stocks.

Sincerely,
jynkin
bustermu
Posted : Wednesday, February 1, 2006 8:09:15 AM
Registered User
Joined: 1/1/2005
Posts: 2,645
Suppose we are observing observing stocks with a Linear Regression Line of Period 10 (LR10) applied. The Comparison Symbol is FX500 and we are on Logarithmic Scale.

A PCF for the annual percentage increase compounded daily of the LR10 Line is:

100*(EXP(252*(4.5*LOG(C0)+3.5*LOG(C1)+2.5*LOG(C2)+1.5*LOG(C3)
+0.5*LOG(C4)-0.5*LOG(C5)-1.5*LOG(C6)-2.5*LOG(C7)-3.5*LOG(C8)
-4.5*LOG(C9))/82.5)-1)

The number 252 has been used for the number of trading days per year.

You will notice that the PCF will read a little low on the FX curves. That is because of slight inaccuracies in the FX curves and their use of 253 days per year.

The PCF can be used to sort a WatchList or in an EasyScan with appropriate limits applied or just to read the annual percentage increase of the LR10 Line on Logarithmic Scale as you please.

Thanks,
Jim Murphy
jynkin
Posted : Wednesday, February 1, 2006 9:01:41 AM
Registered User
Joined: 10/7/2004
Posts: 286

Thanks Jim....for that logarithmic formula. I guess to expand it out to a 30 day time frame, one would just expand the coefficients out to +/- 14.5 on days from C0 to C29 and a divisor of 2247.5?

sincerely,
jynkin

bustermu
Posted : Wednesday, February 1, 2006 9:40:57 AM
Registered User
Joined: 1/1/2005
Posts: 2,645
jynkin,

That is correct. I did not check the divisor.

Thanks,
Jim Murphy
jynkin
Posted : Thursday, February 2, 2006 8:22:13 AM
Registered User
Joined: 10/7/2004
Posts: 286

Do Logarithmic formulas take longer for a computer to process than their respective counter parts. ....perhaps not an issue with the LR10 formulation posted above by bustermu, but what if I created a LR56 logarithmic formula. Would that consume considerably more processing time than a 56LR formula in the format like those I posted above on January 31 at 9:42 pm?

sincerely,
jynkin
BradG
Posted : Friday, February 3, 2006 12:51:14 AM
Registered User
Joined: 4/7/2005
Posts: 14
Thanks Jim and jynkin for your help. That log formula will keep me busy testing ideas for weeks. I have to admit that when you sent your first comment about doing the calcs on a log basis, I started doing some research on how to do that, and gave myself a headache!
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.