Alert after every candle close

ogwedhi

Trader
Apr 8, 2021
2
0
6
38
Visit site
Hi I followed the tutorial to add alerts. it works but it displays alert popup after every candle close. How can I change it to display just once
 

Attachments

  • flamo.mq5
    15.5 KB · Views: 1

Enivid

Administrator
Staff member
Nov 30, 2008
15,634
734
144
Odessa
www.earnforex.com
The arrow array (arrowar) you are checking for a Buy alert isn't zero by default. When there is no arrow, the array's value is EMPTY_VALUE. So, you need to change > 0 to != EMPTY_VALUE.

However, this won't fix everything for you.

You also need to check color array (arrowcl you are checking for a Sell alert) to determine whether it is a Buy or Sell signal.

arrowar assumes a non-empty value whenever there is any signal at all - be it Buy or Sell. Then the arrowcl array is changed based on whether it is a Buy (0) or Sell (1), so your two conditions have to look like this:

MQL5:
if ((arrowar[rates_total - 1 - TriggerCandle] != EMPTY_VALUE) && (arrowcl[rates_total - 1 - TriggerCandle] == 0) && ((TriggerCandle > 0) || ((TriggerCandle == 0) && (LastAlertDirection != 1))))

MQL5:
if ((arrowar[rates_total - 1 - TriggerCandle] != EMPTY_VALUE) && (arrowcl[rates_total - 1 - TriggerCandle] == 1) && ((TriggerCandle > 0) || ((TriggerCandle == 0) && (LastAlertDirection != -1))))