Вопрос по функции PlaySound - страница 2

 

В последней строчке была ошибка (опечатка наверное)

if(BufferDn[0]>0 || BufferUp[0]|>0)  PlaySound("alert.wav");

 убрал ее 

if(BufferDn[0]>0 || BufferUp[0]>0)  PlaySound("alert.wav");

но звук долбит по каждому изменению цены.

А можно ли программу прогнать step-by-step? Может, есть дебагер какой-нибудь, как в Visual Studio

 
//+------------------------------------------------------------------+
//|                                                   T3MA_ALARM.mq4 |
//|                                     Copyright © 2011, Martingeil |
//|                                                    fx.09@mail.ru | 
//+------------------------------------------------------------------+
//исправленный Martingeil, теперь можно в тестере увидеть его стрелки.
#property copyright "Copyright © 2011, Martingeil"
#property link      "fx.09@mail.ru"

//---- indicator settings
#property  indicator_chart_window
#property  indicator_buffers 2
#property  indicator_color1  Blue
#property  indicator_color2  Red
//---- indicator parameters
extern int  period = 4; //12
extern int  shift  = 0; //сдвиг по бару

extern bool Alert_ON = true;  
extern bool Sound_ON = true;  

extern string 
   Name_Sound_UP = "alert.wav",
   Name_Sound_DN = "alert2.wav";
//---- indicator buffers
double BufferUp[],BufferDn[];
//---- 
int q,st=5;
string ex_Name = "T3MA_ALARM";
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   IndicatorBuffers(2);
//---- drawing settings
   SetIndexStyle(0,DRAW_ARROW,2);
   SetIndexArrow(0,233);
   SetIndexStyle(1,DRAW_ARROW,2);
   SetIndexArrow(1,234);   
   
   SetIndexBuffer(0,BufferUp);//стрелка синяя верх
   SetIndexBuffer(1,BufferDn);//стрелка красная вниз
//---- name for DataWindow and indicator subwindow label
   IndicatorShortName("T3MA-ALARM ("+period+")");
//---- initialization done
if(Digits==3 || Digits==5) q=10; 
st=st*q;
return(0);}

int deinit()
{
ObjectDelete("low");
ObjectDelete("high");  
}  
//+----------------------------------------------------------------------+
//| Moving Average of Oscillator                                         |
//+----------------------------------------------------------------------+
int start()
  {
//---- ArraySetAsSeries --------------------------------------------------  
double Ma[500],MaOn[500];
double y0[500],y1[500],y2[500];
int    i,limit=ArraySize(Ma); 
ArraySetAsSeries(Ma,true);
//---- IndicatorCounted --------------------------------------------------
int    counted_bars=IndicatorCounted();
int    limit1=Bars-counted_bars;
       if (limit1>1){limit1=Bars-period-1;} 
//---- EMA --------------------------------------------------------------- 
for(i=limit1; i>=0; i--)  Ma[i]  =iMA(NULL,0,period,0,MODE_EMA,PRICE_CLOSE,i);
for(i=limit1; i>=0; i--)  MaOn[i]=iMAOnArray(Ma,limit,period,0,MODE_EMA,i); 
   
for(i=limit1; i>=0; i--)
   {   
       y0[i+shift]=MaOn[i+shift];
       y1[i+1+shift]=MaOn[i+1+shift];
       y2[i+2+shift]=MaOn[i+2+shift];
       
       static string Trend = "NO";
       if(y0[i+shift]-y1[i+1+shift]<0 && y1[i+1+shift]-y2[i+2+shift]>0){BufferDn[i+1]=High[i+1]+st*Point; Trend = "UP";}
       if(y0[i+shift]-y1[i+1+shift]>0 && y1[i+1+shift]-y2[i+2+shift]<0){BufferUp[i+1]=Low[i+1]-st*Point;  Trend = "DN";}
       warning_for_trader(Trend);

//---- Signal Trend Up || Dn ---------------------------------------------   
       if(y0[i]-y1[i+1]>0) Comment ("\n SWAPLONG = ",MarketInfo(Symbol(),MODE_SWAPLONG),
   "   SWAPSHORT = ",MarketInfo(Symbol(),MODE_SWAPSHORT),"\n BUY TREND ",DoubleToStr(Close[i],Digits));
      
       else if(y0[i]-y1[i+1]<0) Comment ("\n SWAPLONG = ",MarketInfo(Symbol(),MODE_SWAPLONG),
   "   SWAPSHORT = ",MarketInfo(Symbol(),MODE_SWAPSHORT),"\n SELL TREND ",DoubleToStr(Close[i],Digits)); 
   } 


//---- done
return(0);}
//+---------------------------------------------------------------------+
//+-------
//+------------------------------------------------------------------+
//| перевод ТФ в текстовый формат              2011.04.19 
//+------------------------------------------------------------------+
string txt_TF( int _TF) {  
   string _Txt_TF;
   switch(_TF) {
      case PERIOD_M1:  _Txt_TF = "M1";  break;
      case PERIOD_M5:  _Txt_TF = "M5";  break;
      case PERIOD_M15: _Txt_TF = "M15"; break;
      case PERIOD_M30: _Txt_TF = "M30"; break;
      case PERIOD_H1:  _Txt_TF = "H1";  break;
      case PERIOD_H4:  _Txt_TF = "H4";  break;
      case PERIOD_D1:  _Txt_TF = "D1";  break;
      case PERIOD_W1:  _Txt_TF = "W1";  break;
      case PERIOD_MN1: _Txt_TF = "MN1"; break;
      default: Alert("Неверно установлен ТФ " + _TF); break;
   }
//-----------------   
   return(_Txt_TF);
}
//+------------------------------------------------------------------+
//+-------
//+-------
//+------------------------------------------------------------------+
//|   valenok2003@mail.ru                                12.11.2012
//+------------------------------------------------------------------+
//| warning_for_trader() оповещение трейдера
//| Требует:
//| - строку направления тренда - "UP" или "DN"
//+------------------------------------------------------------------+
void warning_for_trader(string _Trend) {
   string _Function = "warning_for_trader():";
//-----------------  
   string _Txt_Alert; 
   static bool 
      _FIRST_LAUNCH = true, // не позволяет сигналить при установке индюка на окно или при изменении ТФ окна
      _FLAG_UP = true, 
      _FLAG_DOWN = true;
   static int _PreviosTime = 0;
//----------------- 
   if(_FIRST_LAUNCH){
      _FIRST_LAUNCH = false; 
      _PreviosTime = Time[0];
      if(_Trend == "UP")_FLAG_UP = false;
      if(_Trend == "DN")_FLAG_DOWN = false;
   }
   if(Time[0] != _PreviosTime)   {
      _PreviosTime = Time[0];
      if(_Trend == "UP" && _FLAG_UP){
         _Txt_Alert = "UP " + txt_TF(Period())+" "+Symbol();
         output_alert_or_sound(_Trend, Name_Sound_UP);
         _FLAG_UP = false; 
         _FLAG_DOWN = true;
      }
      if(_Trend == "DN" && _FLAG_DOWN){
         _Txt_Alert = "DN " + txt_TF(Period())+" "+Symbol();
         output_alert_or_sound(_Trend, Name_Sound_DN);
         _FLAG_UP = true; 
         _FLAG_DOWN = false;
      }
   }  
//-----------------   
  return; 
}
//+------------------------------------------------------------------+
//+-------
//+-------
//+------------------------------------------------------------------+
//|   valenok2003@mail.ru                                29.10.2012
//+------------------------------------------------------------------+
//| output_alert_or_sound() вывод Алерта
//| 
//| Требует:
//| - тренд
//| - имя звукового файла 
//+------------------------------------------------------------------+
void output_alert_or_sound(string _Trend, string _Name_Sound) {
   string _Function = "output_alert_or_sound():";
//----------------- 
   string _Txt_Alert;
//----------------- 
   if(Alert_ON) {
      _Txt_Alert = _Trend + " " + txt_TF(Period())+" "+Symbol()+" "+ex_Name;
      Alert(_Txt_Alert);
   }
   else {
      if(Sound_ON) {
         PlaySound(_Name_Sound);
         Print(_Trend + " - ПРОИЗВЕДЕНО ЗВУКОВОЕ ОПОВЕЩЕНИЕ"); 
      }    
   }
//-----------------   
   return;
}
//+------------------------------------------------------------------+
//+-------


Звуковые файлы воспроизводятся только ПРИ ВЫКЛЮЧЕННОМ АЛЕРТЕ
Причина обращения: