Trendlines
It's going to be tricky to program the way the human eye draws trendlines, but one technique that might help you is the following. Identify the price extremes (separating highs and lows) and draw a linear regression line across them. Example:
You can also try this for a support trendline: (this is what I did)
- Get the lows in an array
- Split the array in half so you have the older and the more recent lows separated
- Use a minimum search loop for each low-pair to (a) get the smallest positive angle (b) check if the trendline defined by the angle is not violated by the rest of the lows
- If you have a solution = Win. If you haven't there is probably no trend at all.
- www.mql5.com
Trendlines aren't suppose to be drawn on main chart ?
Thank you very much guys. I really appreciate your response.
which indicator most using in trading system

Hey guys, I am making an EA but I want to include an indicator that will detect a trendline and use it to determine if a trade should be opened. My problem is how I can construct an indicator that will figure what I did with this chart:
How could I have the indicator determine what I just did with only the numbers that I get from the close or open arrays? What would the math be behind this?
Thank you very much.