Download MetaTrader 5

Recognize a line in chart

To add comments, please log in or register
Launch your trading signal. Make profit from paid subscription!
Pedro Sanz
Pedro Sanz 2015.05.08 05:57 


This question might sound basic...

What can I do in my EA if I would like to be able to recognize a line in my chart.

I mean, the idea would be to draw (by hand) a line in a chart in MT4, then the EA shold trigger an alert when, for example, the price touches this line.

Not really sure if that can be achieved.


Keith Watford
Keith Watford 2015.05.08 06:32  

You could code the EA to search for a particular named object

Then you could draw a line and rename it so that the EA will find it and act accordingly 

honest_knave 2015.05.08 21:13  

Yep, that's pretty much the way I do it (I get the EA to create the line for me either automatically or on button push, but no real difference).

Have a double variable that stores the price of said line.

Run code in OnChartEvent() to see if the line has moved, and update accordingly.

Run code in OnTick() to check where price is relative to the stored value. 

Cristiano Konrad
Cristiano Konrad 2015.05.12 19:23  
Pedro Sanz
Pedro Sanz 2015.05.15 11:31  
Thanks guys for the help!
To add comments, please log in or register