Warm tip: This article is reproduced from stackoverflow.com, please click
alert mql4

How to add an alert to mql4 EA

发布于 2020-06-22 13:38:58

Hi I have an EA and I add my Alert function into OnTick()

this is the code

int one=1;
int two=2;
if(Symbol()=="AUDCAD" && one<two){Alert("Buy ",Symbol());}

The alert function but It reapeats every single second...how can I modify to obtain the alrt once a time?

Questioner
valeria ace
Viewed
40
TheLastStark 2020-04-04 13:30

If you want to receive the alert only once, use the following code

int one=1;
int two=2;
static bool hasAlerted = false;
if(Symbol()=="AUDCAD" && one<two && !hasAlerted){
   Alert("Buy ",Symbol()); 
   hasAlerted=true;
}