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: 213
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: 213
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 3 guests