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

Lonear Regression Value as Displayed Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
dempsey30338
Posted : Thursday, April 10, 2014 8:33:35 AM
Registered User
Joined: 12/1/2004
Posts: 105

Dear Worden Support,

I will try once more to determine the LR value at any point along the LR line. Previouse answers were that it is not possible. However, the Linear Regression value is displayed in the pop-up dialog box when the pointer mode is used. Therefore, it stands to reason that Worden calculates the value in order to display it. My question is, will you provide me with the formula that is used to calculate the LR value.

Thanks,

dempsey30338

Bruce_L
Posted : Thursday, April 10, 2014 10:06:13 AM


Worden Trainer

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

It is definitely possible to determine the value of any particular point of a linear regression line of price using the techniques given in the Using Linear Regression vs Classical Peaks/Valleys for Divergence Analysis topic.

Specific examples involving the values of the various points of a 6-period linear regression line were given in the Deviation From Linear Regression topic where we explored linear regression lines previously.

If what you want to do is calculate any one of the individual values in a linear regression line, this is definitely possible.

If you want to create a histogram plotting the difference between a moving linear regression and price, this is definitely possible.

What was indicated in the topic was that there really isn't an automated method of plotting these values on the chart to express the difference between the price and the current linear regression line as a histogram (which is what you indicated you wanted to do in the topic).

The reason for this has nothing to do with being able to calculate the values of the linear regession line at any given point. The reason has to do with how Custom PCF Indicators work.

Custom PCF Indicators start calculating at the far left of the data and continue their calculations to the far right of the data. The formulas used are calculated as if that point in the data is the most recent value.

So let us take the 6-period linear regression example from the Deviation From Linear Regression topic again. The difference between the current price and the right end of the linear regression line is:

C - (AVGC6 + 2.5 * (2.5 * C + 1.5 * C1 + .5 * C2 - .5 * C3 - 1.5 * C4 - 2.5 * C5) / 17.5)

So this last bar would get calculated correctly. But this same formula would also be used for the previous bar. What this means is that the formula would effectively be calculated as:

C1 - (AVGC6.1 + 2.5 * (2.5 * C1 + 1.5 * C2 + .5 * C3 - .5 * C4 - 1.5 * C5 - 2.5 * C6) / 17.5)

And this would in fact be the correct value if we wanted the difference between the price at that point and the moving linear regression at that point. But if we want the difference between the price at that point and the value of the current linear regression line at that point, the calculation would have need to have been the following instead:

C1 - (AVGC6 + 1.5 * (2.5 * C + 1.5 * C1 + .5 * C2 - .5 * C3 - 1.5 * C4 - 2.5 * C5) / 17.5)

For this calculation to work, we would need future data. So we would need to be able to write something like the following (which isn't valid syntax):

C - (AVGC6.(-1) + 1.5 * (2.5 * C(-1) + 1.5 * C + .5 * C1 - .5 * C2 - 1.5 * C3 - 2.5 * C4) / 17.5)

We can theoretically get around this by using dates if you are willing to change the formula each and every day. This is the reason I used the qualifier "automated method" in the original response.

As I post this, it is April 10, 2014. This means it would be possible to reference the future data in a Custom PCF Indicator using date syntax instead of the (-1) syntax which isn't valid in the example given above. Just replacing the (-1) instances with dates in that formula would result in:

C - (AVGC6.'04/10/2014' + 1.5 * (2.5 * C'04/10/2014' + 1.5 * C + .5 * C1 - .5 * C2 - 1.5 * C3 - 2.5 * C4) / 17.5)

But this formula would only be correct today for the previous bar. It wouldn't calculate correctly for any other bars. To do this is much more complicated.

What is needed is a formula which can tell which bar is being calculated in some fashion so it knows the correct formula to use for that bar and only calculates that portion of the formula. There isn't a way to make such a formula which doesn't need to be changed each day and the techniques available to us to determine the day actual bar being calculated are somewhat limited and probably won't work for all symbols.

The following works as a Custom PCF Indicator for some but not all symbols to calculate the difference between the closing price at the time and the current 6-period linear regression line along the course of that linear regression line. It checks the open, high, low, close and volume of each bar against specific dates in an attempt to determine which bar is being calculated. In cases where this information is enough, the calculations should be correct, but in cases where this is not enough, the calculations will not be correct.

ABS(O = O'04/10/2014' AND H = H'04/10/2014' AND L = L'04/10/2014' AND C = C'04/10/2014' AND V = V'04/10/2014') * (C'04/10/2014' - (AVGC6.'04/10/2014' + 2.5 * (2.5 * C'04/10/2014' + 1.5 * C'04/09/2014' + .5 * C'04/08/2014' - .5 * C'04/07/2014' - 1.5 * C'04/04/2014' - 2.5 * C'04/03/2014') / 17.5)) + ABS(O = O'04/09/2014' AND H = H'04/09/2014' AND L = L'04/09/2014' AND C = C'04/09/2014' AND V = V'04/09/2014') * (C'04/09/2014' - (AVGC6.'04/10/2014' + 1.5 * (2.5 * C'04/10/2014' + 1.5 * C'04/09/2014' + .5 * C'04/08/2014' - .5 * C'04/07/2014' - 1.5 * C'04/04/2014' - 2.5 * C'04/03/2014') / 17.5)) + ABS(O = O'04/08/2014' AND H = H'04/08/2014' AND L = L'04/08/2014' AND C = C'04/08/2014' AND V = V'04/08/2014') * (C'04/08/2014' - (AVGC6.'04/10/2014' + .5 * (2.5 * C'04/10/2014' + 1.5 * C'04/09/2014' + .5 * C'04/08/2014' - .5 * C'04/07/2014' - 1.5 * C'04/04/2014' - 2.5 * C'04/03/2014') / 17.5)) + ABS(O = O'04/07/2014' AND H = H'04/07/2014' AND L = L'04/07/2014' AND C = C'04/07/2014' AND V = V'04/07/2014') * (C'04/07/2014' - (AVGC6.'04/10/2014' - .5 * (2.5 * C'04/10/2014' + 1.5 * C'04/09/2014' + .5 * C'04/08/2014' - .5 * C'04/07/2014' - 1.5 * C'04/04/2014' - 2.5 * C'04/03/2014') / 17.5)) + ABS(O = O'04/04/2014' AND H = H'04/04/2014' AND L = L'04/04/2014' AND C = C'04/04/2014' AND V = V'04/04/2014') * (C'04/04/2014' - (AVGC6.'04/10/2014' - 1.5 * (2.5 * C'04/10/2014' + 1.5 * C'04/09/2014' + .5 * C'04/08/2014' - .5 * C'04/07/2014' - 1.5 * C'04/04/2014' - 2.5 * C'04/03/2014') / 17.5)) + ABS(O = O'04/03/2014' AND H = H'04/03/2014' AND L = L'04/03/2014' AND C = C'04/03/2014' AND V = V'04/03/2014') * (C'04/03/2014' - (AVGC6.'04/10/2014' - 2.5 * (2.5 * C'04/10/2014' + 1.5 * C'04/09/2014' + .5 * C'04/08/2014' - .5 * C'04/07/2014' - 1.5 * C'04/04/2014' - 2.5 * C'04/03/2014') / 17.5))

But constructing this type of formula on a daily basis is not the sort of thing most customers are going to be either able or willing to do.



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
dempsey30338
Posted : Friday, April 11, 2014 7:14:17 PM
Registered User
Joined: 12/1/2004
Posts: 105

Bruce,

Thanks for your reply. I have reviewed the rely message you sent regarding my question and I fully understand that what I would like to do is not possible using TC2000, V12. However, I have made a layout using Stockfinder 5.0. I would like to send it to you and have your comments about it but I do not know how to submit the layout to you. If you would inform me on how to send it, I will do so.

Thanks,

dempsey30338

Bruce_L
Posted : Tuesday, April 15, 2014 9:55:37 AM


Worden Trainer

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

Please select Help | Send Layout to forward the layout. Please include a description of what the layout is supposed to do and indicate I told you to forward the layout on to me.



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
Bruce_L
Posted : Thursday, April 17, 2014 10:00:02 AM


Worden Trainer

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

Thank you for sending in your layout.

It is quite clever in getting to the information of interest to you in a very straightforward manner. I like that the layout is relatively uncluttered which makes it easier to see the information at a glance instead of needing to concsciously focus on what lines mean what. The color coding seems spot on.

I am impressed that you appear to have constructed your own indicators using Block Diagrams.

Is there something specific you want to try to implement in the layout you haven't been able to do so far? Are there any questions you have which would help you further refine the layout?



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
dempsey30338
Posted : Thursday, April 17, 2014 11:07:56 AM
Registered User
Joined: 12/1/2004
Posts: 105

Bruce,

Thank you for your kind response. I am still in the formative stage in regards to what my next steps will be but at least the foundation is more clear. As usually is the case, the question is still how long the momentum trend will continue and within what deviation boundaries. The truth is that there is no known answer except that statistics of the trend should be known to the investor. We never truly know the future but we would like to have statistics on our side. So, I am considering an effort to determine statistcally how long trends last and within what defined deviation bands. If you have any suggestions, I would appreciate them.

Dempsey30338

Bruce_L
Posted : Thursday, April 17, 2014 1:21:21 PM


Worden Trainer

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

Well part of the beauty of StockFinder is that you might be able to calculate these things directly. If you can define both the start and end of a trend, you should be able to count the number of bars in that trend. You can then keep track of the average length of each trend over time. The key is to come up with a test which can detest the start and end of the trend.

It is possible to sort an array. This means it would be possible to determine a "width" into which a certain percentile rank of prices might fall if you sort by whatever criteria you want to use for the "width".

The Spearman topic has a RealCode example which sorts an array.

 



-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.