0

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?

1 Answers1

0

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;
}
TheLastStark
  • 770
  • 5
  • 18
  • I would really appreciate it if you could please help me with a question I asked https://stackoverflow.com/questions/61132974/how-can-i-recognise-programmatically-when-an-up-down-arrow-is-drawn-on-a-chart – BBNN Apr 10 '20 at 07:37