技术指标后半段无法显示

 
//+------------------------------------------------------------------+
//|                                                          ATR.mq4 |
//|                   Copyright 2005-2014, MetaQuotes Software Corp. |
//|                                              http://www.mql4.com |
//+------------------------------------------------------------------+
#property copyright   "2005-2014, MetaQuotes Software Corp."
#property link        "http://www.mql4.com"
#property description "Average True Range with EMA Channel"
#property strict

//--- indicator settings
#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1  White
#property indicator_color2  White
#property indicator_color3  Yellow // Color for EMA line
//--- input parameter
input int InpAtrPeriod = 35; // ATR Period
input int InpEmaPeriod = 35; // EMA Period
//--- buffers
double ExtATRBuffer[];
double ExtTRBuffer[];
double ATRC1[];
double ATRC2[];
double EMA[];

extern bool CalculateOnBarClose = true; // Flag to control if calculation is done on new bar only
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit(void)
{
    string short_name;
    //--- indicator buffers mapping
    IndicatorBuffers(5); // Total 5 buffers used
    IndicatorDigits(Digits);
    //--- indicator lines
    SetIndexBuffer(0, ATRC1);
    SetIndexStyle(0, DRAW_LINE);
    SetIndexBuffer(1, ATRC2);
    SetIndexStyle(1, DRAW_LINE);
    SetIndexBuffer(2, EMA);
    SetIndexStyle(2, DRAW_LINE);
    SetIndexBuffer(3, ExtATRBuffer);
    SetIndexStyle(3, DRAW_NONE); // No drawing
    SetIndexBuffer(4, ExtTRBuffer);
    SetIndexStyle(4, DRAW_NONE); // No drawing
    //--- name for DataWindow and indicator subwindow label
    short_name = "ATR Channel with EMA";
    IndicatorShortName(short_name);
    SetIndexLabel(0, short_name + " (Upper)");
    SetIndexLabel(1, short_name + " (Lower)");
    SetIndexLabel(2, "EMA");
    //--- check for input parameter
    if (InpAtrPeriod <= 0 || InpEmaPeriod <= 0)
    {
        Print("Wrong input parameter ATR Period or EMA Period");
        return (INIT_FAILED);
    }
    //---
    SetIndexDrawBegin(0, InpAtrPeriod);
    SetIndexDrawBegin(1, InpAtrPeriod);
    SetIndexDrawBegin(2, InpEmaPeriod);
    //---
    return (INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Average True Range and EMA Channel calculation                   |
//+------------------------------------------------------------------+
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[])
{
    int i, limit;
      
    //--- check for bars count and input parameter
    if (rates_total <= InpAtrPeriod || InpAtrPeriod <= 0 || InpEmaPeriod <= 0)
        return (0);
    //--- counting from 0 to rates_total
    ArraySetAsSeries(ExtATRBuffer, true);
    ArraySetAsSeries(ExtTRBuffer, true);
    ArraySetAsSeries(ATRC1, true);
    ArraySetAsSeries(ATRC2, true);
    ArraySetAsSeries(EMA, true);
    ArraySetAsSeries(open, true);
    ArraySetAsSeries(high, true);
    ArraySetAsSeries(low, true);
    ArraySetAsSeries(close, true);
    //--- preliminary calculations
   
    if (prev_calculated == 0)
    {
        ExtTRBuffer[0] = 0.0;
        ExtATRBuffer[0] = 0.0;
        //--- filling out the array of True Range values for each period
        for (i = 1; i < rates_total; i++)
            ExtTRBuffer[i] = MathMax(high[i], close[i - 1]) - MathMin(low[i], close[i - 1]);
        //--- first AtrPeriod values of the indicator are not calculated
        double firstValue = 0.0;
        for (i = 1; i <= InpAtrPeriod; i++)
        {
            ExtATRBuffer[i] = 0.0;
            firstValue += ExtTRBuffer[i];
        }
        //--- calculating the first value of the indicator
        firstValue /= InpAtrPeriod;
        ExtATRBuffer[InpAtrPeriod] = firstValue;
        limit = InpAtrPeriod + 1;
    }
    else
        limit = prev_calculated - 1;

    //--- the main loop of calculations for ATR
    for (i = limit; i < rates_total; i++)
    {
        ExtTRBuffer[i] = MathMax(high[i], close[i - 1]) - MathMin(low[i], close[i - 1]);
        ExtATRBuffer[i] = (ExtATRBuffer[i - 1] * (InpAtrPeriod - 1) + ExtTRBuffer[i]) / InpAtrPeriod; // SMMA
    }
    
    //--- calculate EMA
    for (i = limit; i < rates_total; i++)
    {
        EMA[i] = iMA(NULL, 0, InpEmaPeriod, 0, MODE_EMA, PRICE_CLOSE, i);
    }

    //--- calculate ATR channels using EMA and ATR values
    for (i = limit; i < rates_total; i++)
    {
        ATRC1[i] = EMA[i] + 0.5 * ExtATRBuffer[i];
        ATRC2[i] = EMA[i] - 0.5 * ExtATRBuffer[i];
    }

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

这段MT4代码的画线部分为什么没有把后半段显示出来,一直调试都无法发现原因,请大佬帮我解决一下。

 
这不是程序员 看不懂吧