Не подает сигнал эксперту?

 
//+------------------------------------------------------------------+
//|                                                    CCI_cross.mq5 |
//|                                  Copyright © 2021, Yordan Lechev |
//|                                            https://www.mql5.com/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2021, Yordan Lechev"
#property version   "1.000"
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_plots   2
//--- plot CCI_Fast
#property indicator_label1  "CCI_Fast"
#property indicator_type1   DRAW_LINE
#property indicator_color1  clrLime
#property indicator_style1  STYLE_SOLID
#property indicator_width1  2
//--- plot CCI_Slow
#property indicator_label2  "CCI_Slow"
#property indicator_type2   DRAW_LINE
#property indicator_color2  clrRed
#property indicator_style2  STYLE_SOLID
#property indicator_width2  2
//--- input parameters
input group             "CCI_Fast"
input int                  Inp_CCI_Fast_period    = 50;                         // CCI_Fast: averaging period
input ENUM_APPLIED_PRICE   Inp_CCI_Fast_period_applied_price  = PRICE_TYPICAL;  // CCI: type of price
input group             "CCI_Slow"
input int                  Inp_CCI_Slow_period    = 200;                        // CCI_Slow: averaging period
input ENUM_APPLIED_PRICE   Inp_CCI_Slow_period_applied_price  = PRICE_TYPICAL;  // CCI: type of price
//--- indicator buffers
double   CCI_FastBuffer[];
double   CCI_SlowBuffer[];
//---
int      handle_iCCI_Fast;                           // variable for storing the handle of the iCCI indicator
int      handle_iCCI_Slow;                           // variable for storing the handle of the iCCI indicator
int      bars_calculated=0;                          // we will keep the number of values in the CCI and CCI indicators
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0,CCI_FastBuffer,INDICATOR_DATA);
   SetIndexBuffer(1,CCI_SlowBuffer,INDICATOR_DATA);
//--- set levels
   IndicatorSetInteger(INDICATOR_LEVELS,2);
//--- set labels for the line
   PlotIndexSetString(0,PLOT_LABEL,"CCI_Fast"+"("+IntegerToString(Inp_CCI_Fast_period)+")");
   PlotIndexSetString(1,PLOT_LABEL,"CCI_Slow"+"("+IntegerToString(Inp_CCI_Slow_period)+")");
//--- number of digits of indicator value
   IndicatorSetInteger(INDICATOR_DIGITS,2);
//--- create handle of the indicator iCCI_Fast
   handle_iCCI_Fast=iCCI(Symbol(),Period(),Inp_CCI_Fast_period,Inp_CCI_Fast_period_applied_price);
//--- if the handle is not created
   if(handle_iCCI_Fast==INVALID_HANDLE)
     {
      //--- tell about the failure and output the error code
      PrintFormat("Failed to create handle of the iCCI_Fast indicator for the symbol %s/%s, error code %d",
                  Symbol(),
                  EnumToString(Period()),
                  GetLastError());
      //--- the indicator is stopped early
      return(INIT_FAILED);
     }
//--- create handle of the indicator iCCI_Slow
   handle_iCCI_Slow=iCCI(Symbol(),Period(),Inp_CCI_Slow_period,Inp_CCI_Slow_period_applied_price);               
//--- if the handle is not created
   if(handle_iCCI_Slow==INVALID_HANDLE)
     {
      //--- tell about the failure and output the error code
      PrintFormat("Failed to create handle of the iCCI_Slow indicator for the symbol %s/%s, error code %d",
                  Symbol(),
                  EnumToString(Period()),
                  GetLastError());
      //--- the indicator is stopped early
      return(INIT_FAILED);
     }
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                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[])
  {
//--- number of values copied from the iCCI_Fast indicator
   int values_to_copy;
//--- determine the number of values calculated in the indicator
   int calculated_cci_fast=BarsCalculated(handle_iCCI_Fast);
   if(calculated_cci_fast<=0)
     {
      PrintFormat("BarsCalculated(CCI_Fast) returned %d, error code %d",calculated_cci_fast,GetLastError());
      return(0);
     }
//--- determine the number of values calculated in the indicator
   int calculated_cci_slow=BarsCalculated(handle_iCCI_Slow);
   if(calculated_cci_slow<=0)
     {
      PrintFormat("BarsCalculated(CCI_Slow) returned %d, error code %d",calculated_cci_slow,GetLastError());
      return(0);
     }
   if(calculated_cci_fast!=calculated_cci_slow)
     {
      PrintFormat("BarsCalculated(CCI_Fast) returned %d, BarsCalculated(CCI_Slow) returned %d",calculated_cci_fast,calculated_cci_slow);
      return(0);
     }
   int calculated=calculated_cci_fast;
//--- if it is the first start of calculation of the indicator or if the number of values in the indicator changed
//--- or if it is necessary to calculated the indicator for two or more bars (it means something has changed in the price history)
   if(prev_calculated==0 || calculated!=bars_calculated || rates_total>prev_calculated+1)
     {
      //--- if the iCCI_Slow array is greater than the number of values in the iCCI_Slow indicator for symbol/period, then we don't copy everything
      //--- otherwise, we copy less than the size of indicator buffers
      if(calculated>rates_total)
         values_to_copy=rates_total;
      else
         values_to_copy=calculated;
     }
   else
     {
      //--- it means that it's not the first time of the indicator calculation, and since the last call of OnCalculate()
      //--- for calculation not more than one bar is added
      values_to_copy=(rates_total-prev_calculated)+1;
     }
//--- fill the CCI_SlowBuffer array with values of the Commodity Channel Index indicator
//--- if FillArrayFromBuffer returns false, it means the information is nor ready yet, quit operation
   if(!FillArrayFromBufferCCI_Slow(CCI_SlowBuffer,handle_iCCI_Slow,values_to_copy))
      return(0);
//--- fill the CCIBuffer array with values of the Commodity Channel Index indicator
//--- if FillArrayFromBuffer returns false, it means the information is nor ready yet, quit operation
   if(!FillArrayFromBufferCCI_Fast(CCI_FastBuffer,handle_iCCI_Fast,values_to_copy))
      return(0);
//--- memorize the number of values in the Commodity Channel Index indicator
   bars_calculated=calculated;
//--- return the prev_calculated value for the next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
//| Filling indicator buffers from the iCCI_Fast indicator                  |
//+------------------------------------------------------------------+
bool FillArrayFromBufferCCI_Fast(double &values[],   // indicator buffer of Commodity Channel Index values
                                 int ind_handle,     // handle of the iCCI indicator
                                 int amount          // number of copied values
                          )
  {
//--- reset error code
   ResetLastError();
//--- fill a part of the iCCI_FastBuffer array with values from the indicator buffer that has 0 index
   if(CopyBuffer(ind_handle,0,0,amount,values)<0)
     {
      //--- if the copying fails, tell the error code
      PrintFormat("Failed to copy data from the iCCI_Fast indicator, error code %d",GetLastError());
      //--- quit with zero result - it means that the indicator is considered as not calculated
      return(false);
     }
//--- everything is fine
   return(true);
  }
//+------------------------------------------------------------------+
//| Filling indicator buffers from the iCCI_Slow indicator                |
//+------------------------------------------------------------------+
bool FillArrayFromBufferCCI_Slow(double &values[],  // indicator buffer of Commodity Channel Index values
                                 int ind_handle,    // handle of the iCCI indicator
                                 int amount         // number of copied values
                           )
  {
//--- reset error code
   ResetLastError();
//--- fill a part of the iCCI_SlowBuffer array with values from the indicator buffer that has 0 index
   if(CopyBuffer(ind_handle,0,0,amount,values)<0)
     {
      //--- if the copying fails, tell the error code
      PrintFormat("Failed to copy data from the iCCI_Slow indicator, error code %d",GetLastError());
      //--- quit with zero result - it means that the indicator is considered as not calculated
      return(false);
     }
//--- everything is fine
   return(true);
  }
//+------------------------------------------------------------------+
//| Indicator deinitialization function                              |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
   if(handle_iCCI_Fast!=INVALID_HANDLE)
      IndicatorRelease(handle_iCCI_Fast);
   if(handle_iCCI_Slow!=INVALID_HANDLE)
      IndicatorRelease(handle_iCCI_Slow);
  }
//+------------------------------------------------------------------+
 
Yordan Lechev:

почему не подаёт- всё нормально подаёт

Снимок 

 
//+------------------------------------------------------------------+
//| Search trading signals                                           |
//+------------------------------------------------------------------+
bool SearchTradingSignals(void)
  {
   if(m_prev_bars==m_last_deal_in) // on one bar - only one deal
      return(true);
   if(!TimeControlHourMinute())
      return(true);
   double CCI_fast[],CCI_slow[];
   ArraySetAsSeries(CCI_fast,true);
   ArraySetAsSeries(CCI_slow,true);
   int start_pos=0,count=6;
   if(!iGetArray(handle_iCustom,0,start_pos,count,CCI_fast) || !iGetArray(handle_iCustom,0,start_pos,count,CCI_slow))
      return(false);
//--
   int size_need_position=ArraySize(SPosition);
   if(CCI_fast[m_bar_current+1]<CCI_slow[m_bar_current+1] && CCI_fast[m_bar_current]>CCI_slow[m_bar_current])
        {
         if(!InpReverse)
           {
            if(InpTradeMode!=sell)
              {
               ArrayResize(SPosition,size_need_position+1);
               SPosition[size_need_position].pos_type=POSITION_TYPE_BUY;
               if(InpPrintLog)
                  Print(__FILE__," ",__FUNCTION__,", OK: ","Signal BUY");
               return(true);
              }
           }
         else
           {
            if(InpTradeMode!=buy)
              {
               ArrayResize(SPosition,size_need_position+1);
               SPosition[size_need_position].pos_type=POSITION_TYPE_SELL;
               if(InpPrintLog)
                  Print(__FILE__," ",__FUNCTION__,", OK: ","Signal SELL");
               return(true);
              }
           }
        }
   if(CCI_fast[m_bar_current+1]>CCI_slow[m_bar_current+1] && CCI_fast[m_bar_current]<CCI_slow[m_bar_current])
        {
         if(!InpReverse)
           {
            if(InpTradeMode!=buy)
              {
               ArrayResize(SPosition,size_need_position+1);
               SPosition[size_need_position].pos_type=POSITION_TYPE_SELL;
               if(InpPrintLog)
                  Print(__FILE__," ",__FUNCTION__,", OK: ","Signal SELL");
               return(true);
              }
           }
         else
           {
            if(InpTradeMode!=sell)
              {
               ArrayResize(SPosition,size_need_position+1);
               SPosition[size_need_position].pos_type=POSITION_TYPE_BUY;
               if(InpPrintLog)
                  Print(__FILE__," ",__FUNCTION__,", OK: ","Signal BUY");
               return(true);
              }
           }
        }
//---
   return(true);
  }

Очевидно проблема в роботе ...

 

Очевидно проблема в роботе ...