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

Linear Regression Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
sageofhalo
Posted : Tuesday, October 23, 2018 3:39:00 PM
Platinum Customer Platinum Customer

Joined: 2/24/2013
Posts: 16

Hello,

I want to call the value of a linear regression slope of indicator that is a child of a 200 exponential moving average of price.  Is there any way to call this value in Real Code.  I can't seem to figure out how to call it and the math would be quite complex to do manually best as I can figure.

Thank you,

Connor

Bruce_L
Posted : Tuesday, October 23, 2018 3:49:58 PM


Worden Trainer

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

You should be able to just drag and drop the Linear Regression Slope of Indicator indicator into the RealCode Editor to create a reference you can use. The line beginning '# LRS was created this way.

 

'|******************************************************************
'|*** StockFinder RealCode Indicator - Version 5.0 www.worden.com 
'|*** Copy and paste this header and code into StockFinder *********
'|*** Indicator:Charted Indicator Example
'|******************************************************************
'# LRS = chart.LinearRegressionSlope.3
Plot = LRS.Value


-Bruce
Personal Criteria Formulas
TC2000 Support Articles
sageofhalo
Posted : Tuesday, October 23, 2018 3:59:35 PM
Platinum Customer Platinum Customer

Joined: 2/24/2013
Posts: 16

Oh I did not know that was possible. Thank you... that opens a lot of doors for me.

Honestly thank you so much!

sageofhalo
Posted : Wednesday, October 24, 2018 1:22:23 AM
Platinum Customer Platinum Customer

Joined: 2/24/2013
Posts: 16

Ok new problem. >.<

My condition doesn't seem to refer to historical data correctly.

For example:

'# LRS = chart.LinearRegressionSlope.3

If LRS.value(0) > LRS.value(1) Then
Pass
End If
 
 
This code causes the condition to return true somewhat randomly.  It never shows pass when it shouldn't but it is missing a lot of bars where it should show pass.
 
The actual condition I'm writing is more complex but this is the first issue I'm up against in getting it to work.
 
Can you call historical data from an imported indicator?  Is my syntax wrong?
 
Thank you,
Connor
StockGuy
Posted : Wednesday, October 24, 2018 10:13:44 AM

Administration

Joined: 9/30/2004
Posts: 9,187

I'm seeing correct results on this end. What period are you using for the LRS? 

sageofhalo
Posted : Wednesday, October 24, 2018 10:24:53 AM
Platinum Customer Platinum Customer

Joined: 2/24/2013
Posts: 16

The period is 14.  Its odd it just shows up sporadically.  Always correct but is missing lots of bars that should be correct too.

 

StockGuy
Posted : Wednesday, October 24, 2018 10:27:11 AM

Administration

Joined: 9/30/2004
Posts: 9,187

OK, can you send a screenshot to support@tc2000.com?

sageofhalo
Posted : Wednesday, October 24, 2018 11:13:06 AM
Platinum Customer Platinum Customer

Joined: 2/24/2013
Posts: 16

Will do.

sageofhalo
Posted : Friday, October 26, 2018 10:31:36 AM
Platinum Customer Platinum Customer

Joined: 2/24/2013
Posts: 16

End result was that the linear regression was rounding to the hundredths place (0.00) in the calculations concerning the condition.  The solution was to open the block diagram from the edit menu of the condition and insert a "Multiply by Value" block and set it to a big enough number to bring the value of the LR into a range where rounding didn't cause issues.  In my case I had to use 1000-10000 for the two LRs in my condition.

 

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.