подскажите почему не работает SendMail

 

подскажите почему не работает SendMail 

//+---------------------------------------------------------------------------------+
//+ MA2_Signal                                                                      +
//+ Индикатор сигналов при пересечении 2-х средних                                  +
//+                                                                                 +
//+ Внешние параметры:                                                              +
//+  ExtPeriodFastMA - период быстой средней                                        +
//+  ExtPeriodSlowMA - период медленной средней                                     +
//+  ExtModeFastMA   - режим быстой средней                                         +
//+  ExtModeSlowMA   - режим медленной средней                                      +
//+   Режимы: 0 = SMA, 1 = EMA, 2 = SMMA (сглаженная), 3 = LWMA (взвешенная)        +
//+  ExtPriceFastMA  - цена быстой средней                                          +
//+  ExtPriceSlowMA  - цена медленной средней                                       +
//+   Цены: 0 = Close, 1 = Open, 2 = High, 3 = Low, 4 = HL/2, 5 = HLC/3, 6 = HLCC/4 +
//+---------------------------------------------------------------------------------+
#property copyright "Copyright © 2006, Karakurt"
#property link      ""

//---- Определение индикаторов
#property indicator_chart_window
#property indicator_buffers 4
//---- Цвета
#property indicator_color1 Magenta // 5
#property indicator_color2 Blue        // 7
#property indicator_color3 MediumBlue
#property indicator_color4 Tomato

//---- Параметры
extern int    ExtPeriodFastMA = 5;
extern int    ExtPeriodSlowMA = 7;
extern int    ExtModeFastMA   = 1; // 0 = SMA, 1 = EMA, 2 = SMMA, 3 = LWMA
extern int    ExtModeSlowMA   = 1; // 0 = SMA, 1 = EMA, 2 = SMMA, 3 = LWMA
extern int    ExtPriceFastMA  = 0; // 0 = Close, 1 = Open, 2 = High, 3 = Low, 4 = HL/2, 5 = HLC/3, 6 = HLCC/4
extern int    ExtPriceSlowMA  = 1; // 0 = Close, 1 = Open, 2 = High, 3 = Low, 4 = HL/2, 5 = HLC/3, 6 = HLCC/4
extern string ExtSoundFileName = "";
extern bool ActiveSignal=true;
extern double NormalizeAccuracy = 0.0000;


//---- Буферы
double FastMA[];
double SlowMA[];
double CrossUp[];
double CrossDown[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
{
  //---- Установка параметров прорисовки
  //     Средние
  SetIndexStyle( 0, DRAW_LINE );
  SetIndexStyle( 1, DRAW_LINE );
  //     Сигналы
  SetIndexStyle( 2, DRAW_ARROW, EMPTY );
  SetIndexArrow( 2, 233 );
  SetIndexStyle( 3, DRAW_ARROW, EMPTY );
  SetIndexArrow( 3, 234 );
  //---- Задание буферов
  SetIndexBuffer( 0, FastMA    );
  SetIndexBuffer( 1, SlowMA    );
  SetIndexBuffer( 2, CrossUp   );
  SetIndexBuffer( 3, CrossDown );
  
  IndicatorDigits( MarketInfo( Symbol(), MODE_DIGITS ) );
  
  //---- Название и метки
  IndicatorShortName( "MA2_Signal(" + ExtPeriodFastMA + "," + ExtPeriodSlowMA );
  SetIndexLabel( 0, "MA" + ExtPeriodFastMA );
  SetIndexLabel( 1, "MA" + ExtPeriodSlowMA );
  SetIndexLabel( 2, "Buy"  );
  SetIndexLabel( 3, "Sell" );
  
  return ( 0 );
}

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
{
  static bool bBuy  = False;
  static bool bSell = False;
    
  bool   bConditionUp;
  bool   bConditionDown;
  double Range;
  double AvgRange;
  int    iLimit;
  int    i;
  int    counter;
  int    counted_bars = IndicatorCounted();
  
  
  //---- check for possible errors
  if ( counted_bars < 0 )
    return ( -1 );
  
  //---- last counted bar will be recounted
  if ( counted_bars > 0 ) counted_bars--;
  
  iLimit = Bars - counted_bars;
  
  for ( i = 0; i <= iLimit; i++ ) {
    FastMA[i] = iMA( NULL, 0, ExtPeriodFastMA, 0, ExtModeFastMA, ExtPriceFastMA, i );
    SlowMA[i] = iMA( NULL, 0, ExtPeriodSlowMA, 0, ExtModeSlowMA, ExtPriceSlowMA, i );
  }
  
  for ( i = 1; i <= iLimit; i++ ) {
    AvgRange = 0;
    for ( counter = i; counter <= i + 9; counter++ ) {
      AvgRange += MathAbs( High[ counter ] - Low[ counter ] );
    }
    Range = AvgRange/10;
    
    /*if ( i == 0 ) {
      bConditionUp   = ( FastMA[i  ] > SlowMA[i  ] ) &&
                       ( FastMA[i+1] < SlowMA[i+1] ); // пересечение вверх
      bConditionDown = ( FastMA[i  ] < SlowMA[i  ] ) &&
                       ( FastMA[i+1] > SlowMA[i+1] ); // пересечение вниз
    }
    else {*/

      bConditionUp   = ( FastMA[i] >= SlowMA[i] ) &&
                       ( FastMA[i+1] <= SlowMA[i+1] ) &&
                       ( FastMA[i-1] >= SlowMA[i-1] )&& // пересечение вверх
                       ( NormalizeDouble(FastMA[i-1]- FastMA[i+1],4)>=NormalizeAccuracy);
      bConditionDown = ( FastMA[i] <= SlowMA[i] ) &&
                       ( FastMA[i+1] >= SlowMA[i+1] ) &&
                       ( FastMA[i-1] <= SlowMA[i-1] ) && // пересечение вниз
                       ( NormalizeDouble(FastMA[i+1]- FastMA[i-1],4)>=NormalizeAccuracy);
    //}
    
    
                      
                      
    
    if ( bConditionUp )
    CrossUp[i] = Low[i] - Range * 0.5;
    else if ( bConditionDown )
    CrossDown[i] = High[i] + Range * 0.5;
    
    if ( !bBuy && bConditionUp ) {
      // Флаги
      bBuy  = True;  // установка флага покупки
      bSell = False; // сброс флага продажи
      
      //CrossUp[i] = Low[i] - Range * 0.5;    
      // Сигналы
      if ( i < 2 && ActiveSignal == True ) {
          SendMail("Terminal MT4",(Symbol(),Period(),"Buy Signal "));
          Alert (Symbol()," ",Period(),"M  Achtung BUY "); // звуковой сигнал
        if ( ExtSoundFileName != "" )
          PlaySound( ExtSoundFileName );
          
      
    }
    else if ( !bSell && bConditionDown ) {
      // Флаги
      bSell = True;  // установка флага продажи
      bBuy  = False; // сброс флага покупки
      
      //CrossDown[i] = High[i] + Range * 0.5;
      // Сигналы
     if ( i < 2 && ActiveSignal == True) {
        CrossDown[i] = High[i] + Range * 0.5;
        SendMail("Terminal MT4",(Symbol(),Period(),"Buy Signal "));
        Alert (Symbol()," ",Period(),"M   Achtung SELL "); // звуковой сигнал
        if ( ExtSoundFileName != "" )
          PlaySound( ExtSoundFileName ); }
          
      }
    }
  }
return ( 0 );
}
Файлы:
 
Разрешите в настройках отправку почты.
 
Rosh :
Разрешите в настройках отправку почты.

Отправка почты разрешена, тестовое сообщение приходит.

Может код с ошибкой?

 
Тривиальный совет - вставьте Print() непосредственно перед функцией SendMail(). Это позволит существенно продвинуться в поиске причины.
Причина обращения: