how to code a trendline - page 2

 
337252:

I want to know how to code an automatic trendline, what are the steps? i want by using trendline and finding breakout

for example are these below steps reasonable?

1- find the two highest between 1 to 200 candle.

2-draw a line that passes these two points.

3- if price is above the line, delete the object.(it is not valid)

4- if not, it could be a trendline.(that I can use it in my E.A and in next step I will find breakout the trendline for trade).

5-repeat the process 

or other ways for example using fractals, supports and resistance, and so on.

So to get the highest 2 point,

1) Copy the "high" values buffer for the 200 candles, usiñg the

iHighest()

function you can get the highest point for all data copied, for the next point, you could loop through the remaining data to get the highest point or delete the initial highest point from the buffer then use the iHighest function, what works for you. NOTE: you also need the time variables corresponding to where the highs were formed

2) Use the trendline function above to draw your line between those points.

3) you could easily write a function comparing price with the trendline, if is is greater than it, ObjectDelete  delete the line