Page 1 of 1

Extend line of "core.drawLine"

PostPosted: Fri Jul 07, 2017 1:55 pm
by Cactus
Hello.
Can someone provide code as to how to extend a line of core.drawLine?
For example, I have:
Code: Select all
core.drawLine(Line, core.range(x_1, x_2), y_1, x_1, y_2, x_2, color);

Which is 2 points, (x_1 and y_1) and (x_2 and y_2)
X is date
Y is price
This draws a line between those two points.

Now I want to see the line in the future (beyond x_2 point)
What must I do to have a line drawn (extended) with accurate slope to find out price x time in the future? (to the most recent bar will suffice)

I am trying to use http://www.fxcodebase.com/documents/Ind ... ation.html but no luck

Re: Extend line of "core.drawLine"

PostPosted: Sat Jul 08, 2017 7:53 am
by Cactus
Ok I have done it to do what I want, get the Y1 value correctly.
Code:
Code: Select all
        a1, c1= math2d.lineEquation (index_1, value.rate_1, index_2, value.rate_2);       
        Y1= GetYofABCLine(size, a1, c1);       
        core.drawLine(out, core.range(index_1, index_2), value.rate_1, index_1 , value.rate_2, index_2,core.rgb(255, 0, 0));   
        core.drawLine(out, core.range(index_2, size), value.rate_2, index_2, Y1, size,core.rgb(0, 144, 0));

Screenshot of what I meant: (grey line is marketscope line object drawn by hand, dotted grey line is the extended line, the value I wanted to calculate)
The indicator can now draw a line on two points automatically (red line) and extends it too and give a output stream value (green line)

autoline.png
normalline.png

Re: Extend line of "core.drawLine"

PostPosted: Tue Mar 24, 2020 1:34 am
by dtb71fxcm
I really like what you did, exactly what I'm looking for!

Question though -- what is the function GetYofABCLine in your code ?

Code: Select all
Y1= GetYofABCLine(size, a1, c1);

Re: Extend line of "core.drawLine"

PostPosted: Tue Mar 24, 2020 9:10 am
by Apprentice
Can you provide the code example?

Re: Extend line of "core.drawLine"

PostPosted: Tue May 26, 2020 8:11 pm
by Cactus
dtb71fxcm wrote:I really like what you did, exactly what I'm looking for!

Question though -- what is the function GetYofABCLine in your code ?

Code: Select all
Y1= GetYofABCLine(size, a1, c1);

It is from the function collection thread line equation that Apprentice posted on Thu Mar 14, 2013 3:46 am. Very useful http://23.62.344a.static.theplanet.com/code/viewtopic.php?p=56538&sid=a80604dc94e74654e2c0b74d01125512#p56538