各位大老 帮忙看看 跨周期 引用数据 不能得到相应 数据

 
15301h
#property copyright "Copyright 2019, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"

#property indicator_chart_window

#property indicator_buffers                     2
#property indicator_plots                       2

#property indicator_type1                       DRAW_LINE
#property indicator_color1                      clrWhite
#property indicator_width1                      1
#property indicator_label1                      "M15"
double                                                          M15Buffer[];

#property indicator_type2                       DRAW_LINE
#property indicator_color2                      clrYellow
#property indicator_width2                      1
#property indicator_label2                      "M30"
double                                                          M30Buffer[];

/*
#property indicator_type3                       DRAW_LINE
#property indicator_color3                      clrLime
#property indicator_width3                      1
#property indicator_label3                      "H1"
double                                                          M20Buffer[];

#property indicator_type4                       DRAW_LINE
#property indicator_color4                      clrPurple
#property indicator_width4                      1
#property indicator_label4                      "H2"
double                                                          M40Buffer[];
*/


int                                                             M15Handle;
int                                                             M30Handle;
//int                                                           H20Handle;
//int                                                           H40Handle;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+

int OnInit(){
//--- indicator buffers mapping
        SetIndexBuffer( 0, M15Buffer,   INDICATOR_DATA );
        SetIndexBuffer( 1, M30Buffer,   INDICATOR_DATA );
        //SetIndexBuffer( 2, M20Buffer, INDICATOR_DATA );
        //SetIndexBuffer( 3, M40Buffer, INDICATOR_DATA );

        ArraySetAsSeries( M15Buffer, true );
        ArraySetAsSeries( M30Buffer, true );

        M15Handle       = iMA( NULL, PERIOD_M15, 5, 0, MODE_LWMA, PRICE_CLOSE );
        M30Handle       = iMA( NULL, PERIOD_M30, 5, 0, MODE_LWMA, PRICE_CLOSE );


//---
        return(INIT_SUCCEEDED);
}



//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+

int OnCalculate ( const int rates_total,      // 价格[] 数组的大小 
                                  const int prev_calculated,  // 前一次调用处理的柱 
                                  const int begin,            // 有效数据起始位置 
                                  const double& price[]       // 计算的数组 
                                )
{
//---
        // 得到 市场报价中品种数量
        int _curencyNumber = SymbolsTotal( true );
/*
        Print( " 市场把价中品种数量:", _curencyNumber );
        for( int i = 0 ; i < _curencyNumber; i++ ){
                Print( " SymbolName( i, true ) ", i, " ", SymbolName( i, true ) );
        }
*/

        //--- we can copy not all data
        int _toCopy = 0;
        if( prev_calculated > rates_total || prev_calculated < 0 ){
        
         _toCopy = rates_total;

        } else {
        
         _toCopy = rates_total - prev_calculated;
         
                if( prev_calculated > 0 ){
                        _toCopy++;
                }
        }

        FillArrayFromBuffer( M15Buffer, 0, M15Handle, _toCopy );
        FillArrayFromBuffer( M30Buffer, 0, M30Handle, _toCopy );

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

bool FillArrayFromBuffer( double &values[],     // 移动平均值的指标缓冲区 
                                                  int shift,            // 移动 
                                                  int indHandle,        // iMA指标的处理程序 
                                                  int amount            // 复制值的数量 
                                                 ){

        ResetLastError();

        if( CopyBuffer( indHandle, 0, shift, amount, values ) < 0 ){
                PrintFormat("Failed to copy data from the iMA indicator, error code %d",GetLastError());

                return false;
        }

        return true;
}

原因: