I tried adding this code to stop the alerts from sounding continuiously. They should only sound once for each candle. If a new candle starts, then it should be reset and allowed to sound again.
Any ideas on what is wrong with the code?
// Store the start time of the most recent bar which has been examined, in a static variable which persists
// across calls to start() - but ***not*** across reloads of the EA...
static int MostRecentBarStart = 0;
.....
.....
int counted_bars = IndicatorCounted();
int i;
int limit;
if(counted_bars < 0)
return(-1);
if(counted_bars > 0)
counted_bars--;
if (Point==0.00001) iDigits=5;
if (Point==0.001) iDigits=3;
limit = Bars - counted_bars;
for(i=0; i<=limit; i++)
{
// See if this bar is newif (Time[0] > MostRecentBarStart)
{
// Store the time of the current bar, preventing further action during this bar
MostRecentBarStart = Time[0];
//...process potential signals hereif (Bid > iBands(Symbol(),NULL, 20, 2, 0, PRICE_CLOSE, MODE_UPPER, 0)) {Alert( "Event "+Symbol());}
if (Bid < iBands(Symbol(),NULL, 20, 2, 0, PRICE_CLOSE, MODE_LOWER, 0)) {Alert( "Event "+Symbol());}
}
.....
.....
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
I tried adding this code to stop the alerts from sounding continuiously. They should only sound once for each candle. If a new candle starts, then it should be reset and allowed to sound again.
Any ideas on what is wrong with the code?