Code for basic Linnear Regression Line
Forums › ProRealTime English forum › ProBuilder support › Code for basic Linnear Regression Line
- This topic has 10 replies, 4 voices, and was last updated 7 years ago by Nobody.
-
-
09/25/2017 at 9:21 AM #47181
Hi!
Does anyone have the basic default code for creating the Linnear Regression Line the way its drawn by default in PRT? Also if one knows the containing codes for the RAFF and Standard Error lines that are drawn by PRT Defaults.
I have managed to get the second point x and y axis as it is the last bar of (n) periods linnear regression – but i dont know how to find the first x and y axis.
I am aware of this indicator: https://www.prorealcode.com/prorealtime-indicators/triple-raff-channel-projection-on-price/ but it does not contain the specific code i am looking for and does not help with my idea.
So if anyone knows the code for the linnear regression line it would be greatly appreciated!
//Viktor
09/25/2017 at 9:48 AM #47196You can find everything needed and a full example on how to draw a line from linear regression coordinates, in this indicator: https://www.prorealcode.com/prorealtime-indicators/regression-channel-sketcher/
09/25/2017 at 10:13 AM #47212I have read that one but several times but still dont get it.
Is
1y1 = 1.5*std[p](high)+z1the basics for finding coordinates? In this case high. Is it always 1.5 times the standard deviation of (n)?
Also it does not explain calculation for Raff and Standard error.
As you can guess i lack some mathematical skillz, but learn quick so im just trying to understand the logic.
Thanks for your patience and understanding.
09/25/2017 at 10:35 AM #47222I have now once again used the specific code you forwarded (but using (close) and only 1 line) – and it does not translate into the same result as just drawing a Linnear Regression Line over said period.
Im really confused
09/25/2017 at 4:24 PM #47290Another example:
12345678910defparam drawonlastbaronly=truep=62z1 = linearregression[p]DRAWSEGMENT(barindex-p,z1[p],barindex,z1)RETURNIn the attached screenshot, you have the automatic trendline plotted by the platform (violet one) and the one from the code (the black one). Because I took the Close for the linearregression indicator, there is a little difference with the two points I chose to draw the linear regression line, but that’s how it goes.
09/25/2017 at 6:40 PM #47296Thank you for your answer!
However, it still does not translate to a correctly drawn linear regression line like the one drawn by default. Please see attached picture. Maybe i am doing something wrong?
Red Line = Default Linear Regression Line, 62 bars
White = Line from this code:
12345678910defparam drawonlastbaronly=truep=62z1 = linearregression[p]DRAWSEGMENT(barindex-p,z1[p],barindex,z1)RETURNAs you can see its way off. If i just want to make a line exactly like the one the program draws for me – what should i write?
Would greatly appreciate a solution!
Thanks!
Viktor
Edit: The X1 axis is correct but the Y1 (in this case z1[p]) give the wrong coordinate
09/28/2017 at 7:00 PM #47717Is there no one that has the code to copy the linear regression line drawn by PRT?
10/11/2017 at 9:30 AM #49014I am still looking for the answer to this. If anyone knows it would be appreciated.
01/12/2018 at 5:31 PM #5922901/12/2018 at 6:26 PM #59242PRT software is proprietary much like Windows or MacOS and it is (and is likely not to ever be) open to the public.
01/12/2018 at 9:37 PM #59304 -
AuthorPosts
Find exclusive trading pro-tools on