EA not playing sound, please help

 

I am trying to write a EA that stops for a few seconds after the close of every bar.

Here is the code, it pauses after the bar close but does not play sound, any help appreciated.

Thanks

_______________________________________________

extern int secsToPause = 5;
int last_time = -1;



int init()
  {
   
   return(0);
  }



int start()
{  
   if (secsToPause > 0) pause_now();



                
return(0);
}




void pause_now() {

if (Period() == PERIOD_D1) int cur_time = TimeDay(iTime(NULL, 0,0));
if (Period() == PERIOD_H4)  cur_time = TimeHour(iTime(NULL, 0,0)) / 4;
if (Period() == PERIOD_H1)  cur_time = TimeHour(iTime(NULL, 0,0)) ;
if (Period() == PERIOD_M15)  cur_time = TimeMinute(iTime(NULL, 0,0))  / 15;

Alert("Playing sound");

Sleep(500);
PlaySound("ok.wav");

  
if (last_time != cur_time){

    
  int i = 0;
  while (i < secsToPause*100000000) {
  i++;

  }
  
last_time = cur_time;
  }

  
return(0);
}

 
iinself:

I am trying to write a EA that stops for a few seconds after the close of every bar.

Here is the code, it pauses after the bar close but does not play sound, any help appreciated.

Thanks

_______________________________________________

Are you testing this live/demo or in the Strategy Tester ? sounds are not played in the Strategy Tester: Testing Features and Limits in MetaTrader 4
 
RaptorUK:
Are you testing this live/demo or in the Strategy Tester ? sounds are not played in the Strategy Tester: Testing Features and Limits in MetaTrader 4


Thanks RaptorUK.

I am trying it in the Strategy tester - basically I don't want to keep starring at the screen till the start of the next bar. So some sound notification at the end of the bar would help.

Is there any way to do that in the Strategy tester.

Thanks

 
iinself:


Thanks RaptorUK.

I am trying it in the Strategy tester - basically I don't want to keep starring at the screen till the start of the next bar. So some sound notification at the end of the bar would help.

Is there any way to do that in the Strategy tester.

Thanks

Not with standard mql4 functions, sounds aren't played from the Strategy Tester, you might be able to do it with WinAPI calls.
 
RaptorUK:
Not with standard mql4 functions, sounds aren't played from the Strategy Tester, you might be able to do it with WinAPI calls.


Ok, thanks