Dont understand why I cant here PlaySound()

 

In the following Indicator I fail to see why I cant here the PlaySound sounfile ive assigned to the SoundFile object?

Also it appears to overun my CPU?

// Turning Pivot Alarms On/Off Input Variables
input string SoundFile = "alert.wav";

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,  // size of input time series     (here it starts 1001 on 00:00 and continues)
                const int prev_calculated, // bars handled in previous call  (here it returns 0 on 00:00 and 1001 on 00:30 and continues)
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
{

   int bars = rates_total - 1;   
   if(prev_calculated > 0) bars = rates_total - prev_calculated;  
   
        for(int i = bars; i >= 1; i--)  
   {

      if(Close[i] > Open[i]) 
      {
         PlaySound(SoundFile);
      }

      if(Close[i] < Open[i]) 
      {
         PlaySound(SoundFile);
      }

//--- return value of rates_total for next call
   return(rates_total);
} 










 

Delete

 for(int i = bars; i >= 1; i--)   

   { 

 
eevviill:

Delete

   { 

Thanks for that it works.
Reason: