Download MetaTrader 5
To add comments, please log in or register
Publish your application in the Market - 7 million potential clients will see it
Stephen Reynolds
484
Stephen Reynolds 2016.03.09 20:50 

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);
} 










Vasyl Nosal
18218
Vasyl Nosal 2016.03.09 22:02  

Delete

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

   { 

Stephen Reynolds
484
Stephen Reynolds 2016.03.10 10:22  
eevviill:

Delete

   { 

Thanks for that it works.
/
To add comments, please log in or register