Download MetaTrader 5

Trendlines

To add comments, please log in or register
Carry on your private correspondence in your profile. It is secure!
NoCool14
239
NoCool14 2013.11.14 01:00 

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:


Chart with lines

 

 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. 

Daniel Bosman
316
Daniel Bosman 2013.11.23 16:26  

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:


Gabor Schnierer
172
Gabor Schnierer 2013.11.23 19:44  

You can also try this for a support trendline: (this is what I did)

  1. Get the lows in an array
  2. Split the array in half so you have the older and the more recent lows separated
  3. 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
  4. If you have a solution = Win. If you haven't there is probably no trend at all.
BTW I am not sure if an indicator would be the best solution for you. I'd rather use a script that draws trendlines on your chart. (See OBJ_TREND in help.)

Documentation on MQL5: Standard Constants, Enumerations and Structures / Objects Constants / Object Types
Documentation on MQL5: Standard Constants, Enumerations and Structures / Objects Constants / Object Types
  • www.mql5.com
Standard Constants, Enumerations and Structures / Objects Constants / Object Types - Documentation on MQL5
Alain Verleyen
Moderator
30755
Alain Verleyen 2013.11.23 20:40  
bananiel:

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:


Trendlines aren't suppose to be drawn on main chart ?
Daniel Bosman
316
Daniel Bosman 2013.11.24 16:32  
angevoyageur:
Trendlines aren't suppose to be drawn on main chart ?
In a free market you can draw them wherever you want. My suggestion could be done on the main chart too, but I don't have examples of it.
NoCool14
239
NoCool14 2013.12.05 10:42  

Thank you very much guys. I really appreciate your response.

george1234
811
george1234 2013.12.14 05:30  

which indicator most using in trading system

Sergey Golubev
Moderator
93777
Sergey Golubev 2013.12.14 06:12  
price is most used
To add comments, please log in or register