MQ4 Alert once on 5 mins bar

 

Hello All

Is there any way to write a indicator in MQ4 which will just alert once per bar on a cross. I am writing a indicator to alert me when a oscillar is crossing up or down on 50 just once is it every possible. I am lost.

Would be really nice if you can help me with an examplz

I am struck on this for days.

Please help

Regards

Adler

 
adler2:

Hello All

Is there any way to write a indicator in MQ4 which will just alert once per bar on a cross. I am writing a indicator to alert me when a oscillar is crossing up or down on 50 just once is it every possible. I am lost.

Would be really nice if you can help me with an examplz

I am struck on this for days.

Please help

Regards

Adler

adler2,

You may try something this:


bool NewBar()

{

   static datetime lastbar;

   datetime curbar = Time[0];

   if(lastbar!=curbar)

   {

      lastbar=curbar;

      return (true);

   }

   else return(false);

}


if(NewBar())

{

if(your conditions here)

{

Alert("Signal alert");

}

}

 
robofx.org wrote >>

adler2,

You may try something this:

bool NewBar()

{

static datetime lastbar;

datetime curbar = Time[0];

if(lastbar!=curbar)

{

lastbar=curbar;

return (true);

}

else return(false);

}

if(NewBar())

{

if(your conditions here)

{

Alert("Signal alert");

}

}

Thanks mate, much appreciated seems to work, thanks

Reason: