bar alert

 
Hi

the code below suppose to sound the alarm once an inside bar is formed and suppose to sound it 5 times, but it only sounds it once, can someone please look at it and suggest a fix.

thanks a lot

//+------------------------------------------------------------------+
//| alerts.mq4 |
//| Copyright © 2007, MetaQuotes Software Corp. |
//| https://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"

#property indicator_chart_window
//---- input parameters
extern int inside=1;//1 once inside, 2 twice inside, else unArmed.
extern int out_direction=2; //1 out_up, -1 out_down, 0 either, else unArmed.
int snooze = 5;

int inside_once_fired = 0;
string inside_once_alarm = "insideOnce.wav";
int inside_twice_fired = 0;
string inside_twice_alarm = "insideTwice.wav";
string out_up_alert = "outUp.wav";
int out_up_fired = 0;
string out_down_alert = "outDown.wav";
int out_down_fired = 0;
string out_bar = "outBar.wav";
int out_fired = 0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{

int tickCount = GetTickCount();
int counted_bars = IndicatorCounted();
if(counted_bars < 0) return (-1);
if(counted_bars > 0) counted_bars--; //last bar recounted
int i;
int shift = Bars - counted_bars - 1; // initially 2408, then 1, once closed it becomes 2, once a tick is received it turns 1
Comment(inside_once_fired+" "+shift);
if(shift >= 2){
for(i = shift; i > 1; i--)
{
if( inside==1 && Low[1]>=Low[2] && High[1]<=High[2] ){while( inside_once_fired < snooze ){PlaySound(inside_once_alarm); inside_once_fired++; while(GetTickCount() < tickCount + 1000) {}} }
else if( inside==2 && Low[1]>=Low[2] && High[1]<=High[2] && Low[2]>=Low[3] && High[2]<=High[3] ){while( inside_twice_fired < snooze ){ PlaySound(inside_twice_alarm); inside_twice_fired++; while(GetTickCount() < tickCount + 1000) {}} }
}
}
else if(shift == 1){
if(out_direction == 1 && Low[0] < Low[1] && Bid > High[1])while( out_up_fired < snooze ){PlaySound(out_up_alert);out_up_fired++; while(GetTickCount() < tickCount + 1000) {}}
else if( out_direction == -1 && High[0] < High[1] && Bid < Low[1]) while( out_down_fired < snooze ){PlaySound(out_down_alert);out_down_fired++; while(GetTickCount() < tickCount + 1000) {}}
else if( out_direction == 0 && ( (Low[0] < Low[1] && Bid > High[1])|| (High[0] > High[1] && Bid < Low[1]))) while( out_fired < snooze ){PlaySound(out_bar);out_fired++; while(GetTickCount() < tickCount + 1000) {}}

}
//----
return(0);
}
//+------------------------------------------------------------------+
 
That's hard to read, but are you updating tickCount?
 
if( inside==1 && Low[1]>=Low[2] && High[1]<=High[2] ){
while( inside_once_fired < snooze ){
PlaySound(inside_once_alarm);
inside_once_fired++;
while(GetTickCount() < tickCount + 1000) {}
}
}

hope this looks better
 
ahha, you mean the line at the beginning of the start function which says
int tickCount = GetTickCount();

where does that suppose to go?
 
You keep referencing it later to see if that amount of time has passed. but you never "reset the timer"