Download MetaTrader 5
To add comments, please log in or register
Create interesting Forum topics concerning the automated trading!
mar
1143
mar 2016.02.22 08:03 

Hello,

right now I am checking all objects on each tick and if the object is a horizontal line starting with the keyword 'alert' and it is touched by the current price, it sends an alert to my smartphone. Works perfect so far. Now I sent it to a friend and he has a lot of charts open and uses a lot of objects like texts, labels etc... he told me that my indicator slowed everything down very much that he can't use it. I didn't have any problem but I don't use too many objects. So I can imagine that looping through all objects on all charts on every tick could be too much for MT4.

Is there any other way to create an alarm? Maybe by some chartevent I don't know yet? The normal alarm isn't useful because it only displays an alert. But can this alert maybe cause some kind of event that I can use to send a notification?

Thanks! 

Keith Watford
Moderator
7979
Keith Watford 2016.02.22 08:53  

Loop through all the objects in init and save the alert values in an array. If necessary use 2 arrays, one for alerts for hitting price from below, the other from above.

For hitting price from below, sort the array in ascending order and when checking whether the price has been hit within a loop, start at the lowest. If price has been hit, issue the alert. If it hasn't, break the loop as you know that the higher prices cannot have been hit. Maybe name the line "alertUp"+DoubleToStr(price,Digits), then you can work out which line to delete when its level has been hit.

When it has been hit, remove the line and remove its element from the array.

Use OnChartEvent to detect when a new line has been added. add to the array and re-sort it.

mar
1143
mar 2016.02.22 16:45  

Awesome idea! I'll do that. Thanks GumRai!

/
To add comments, please log in or register