Download MetaTrader 5
To add comments, please log in or register
Sell products via the Market and track your sales statistics
Pedro Sanz
53
Pedro Sanz 2015.05.08 05:57 

Hi,

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.

Thanks.

Keith Watford
Moderator
7906
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
959
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
247
Cristiano Konrad 2015.05.12 19:23  
.
Pedro Sanz
53
Pedro Sanz 2015.05.15 11:31  
Thanks guys for the help!
/
To add comments, please log in or register