Extend line of "core.drawLine"

Moderator: admin

Extend line of "core.drawLine"

Postby Cactus » Fri Jul 07, 2017 1:55 pm

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
Never chase the money, let the money come to me
User avatar
Cactus
FXCodeBase: Graduate
 
Posts: 242
Joined: Fri Feb 19, 2016 11:46 am
Location: Errywhere

Re: Extend line of "core.drawLine"

Postby Cactus » Sat Jul 08, 2017 7:53 am

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
Never chase the money, let the money come to me
User avatar
Cactus
FXCodeBase: Graduate
 
Posts: 242
Joined: Fri Feb 19, 2016 11:46 am
Location: Errywhere

Re: Extend line of "core.drawLine"

Postby dtb71fxcm » Tue Mar 24, 2020 1:34 am

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);
User avatar
dtb71fxcm
 
Posts: 44
Joined: Sat May 05, 2012 9:28 pm

Re: Extend line of "core.drawLine"

Postby Apprentice » Tue Mar 24, 2020 9:10 am

Can you provide the code example?
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36341
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: Extend line of "core.drawLine"

Postby Cactus » Tue May 26, 2020 8:11 pm

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
Never chase the money, let the money come to me
User avatar
Cactus
FXCodeBase: Graduate
 
Posts: 242
Joined: Fri Feb 19, 2016 11:46 am
Location: Errywhere


Return to Indicator Development

Who is online

Users browsing this forum: No registered users and 13 guests