MT5 : DRAW_COLOR_LINE error, help needed!

 

Hello, I've been modifying the dema example indicator and I dont understand what I'm doing wrong, I've read and re-read references but I still dont get it. Please help!

I've tried both  setting #property   parameters and what you see in the code below, what am I doing wrong ?

//+------------------------------------------------------------------+
//|                                                         DEMA.mq5 |
//|                   Copyright 2009-2017, MetaQuotes Software Corp. |
//|                                              http://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright   "2009-2017, MetaQuotes Software Corp."
#property link        "http: //www.mql5.com"
#property description "Double Exponential Moving Average"
#include <MovingAverages.mqh>
//--- indicator settings
#property indicator_chart_window
#property indicator_buffers 30
#property indicator_plots   10

#property indicator_applied_price PRICE_CLOSE
//--- input parameters
input int InpPeriodEMA = 10;                            // EMA period
input int InpShift     = 0;                             // Indicator's shift
//--- indicator buffers
double DemaBuffer[];
double Ema[];
double EmaOfEma[];
double EmaOfEmaColor[];

double DemaBuffer2[];
double Ema2[];
double EmaOfEma2[];
double EmaOfEmaColor2[];

double DemaBuffer3[];
double Ema3[];
double EmaOfEma3[];
double EmaOfEmaColor3[];


double DemaBuffer4[];
double Ema4[];
double EmaOfEma4[];
double EmaOfEmaColor4[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
void OnInit()
{
//--- indicator buffers mapping
    SetIndexBuffer(0, DemaBuffer, INDICATOR_DATA);
    SetIndexBuffer(1, EmaOfEmaColor, INDICATOR_COLOR_INDEX);
    SetIndexBuffer(2, Ema, INDICATOR_CALCULATIONS);
    SetIndexBuffer(3, EmaOfEma, INDICATOR_CALCULATIONS);

    PlotIndexSetInteger(0, PLOT_DRAW_TYPE, DRAW_COLOR_LINE);
    PlotIndexSetInteger(0, PLOT_LINE_STYLE, STYLE_SOLID);
    PlotIndexSetInteger(0, PLOT_LINE_WIDTH, 2);
    PlotIndexSetInteger(0, PLOT_COLOR_INDEXES, 3);
    PlotIndexSetInteger(0, PLOT_LINE_COLOR, 0, clrGray);
    PlotIndexSetInteger(0, PLOT_LINE_COLOR, 1, clrDeepPink);
    PlotIndexSetInteger(0, PLOT_LINE_COLOR, 2, clrYellowGreen);
    PlotIndexSetString(0, PLOT_LABEL, "DEMA_1");
    PlotIndexSetInteger(0, PLOT_DRAW_BEGIN, 2 * InpPeriodEMA - 2);
    PlotIndexSetInteger(0, PLOT_SHIFT, InpShift);

    SetIndexBuffer(4, DemaBuffer2, INDICATOR_DATA);
    SetIndexBuffer(5, EmaOfEmaColor2, INDICATOR_COLOR_INDEX);
    SetIndexBuffer(6, Ema2, INDICATOR_CALCULATIONS);
    SetIndexBuffer(7, EmaOfEma2, INDICATOR_CALCULATIONS);

    PlotIndexSetInteger(4, PLOT_DRAW_TYPE, DRAW_COLOR_LINE);
    PlotIndexSetInteger(4, PLOT_LINE_STYLE, STYLE_SOLID);
    PlotIndexSetInteger(4, PLOT_LINE_WIDTH, 2);
    PlotIndexSetInteger(4, PLOT_COLOR_INDEXES, 3);
    PlotIndexSetInteger(4, PLOT_LINE_COLOR, 0, clrGray);
    PlotIndexSetInteger(4, PLOT_LINE_COLOR, 1, clrDeepPink);
    PlotIndexSetInteger(4, PLOT_LINE_COLOR, 2, clrYellowGreen);
    PlotIndexSetString(4, PLOT_LABEL, "DEMA_2");
    PlotIndexSetInteger(4, PLOT_DRAW_BEGIN, 2 * InpPeriodEMA - 2);
    PlotIndexSetInteger(4, PLOT_SHIFT, InpShift);

    SetIndexBuffer(8, DemaBuffer3, INDICATOR_DATA);
    SetIndexBuffer(9, EmaOfEmaColor3, INDICATOR_COLOR_INDEX);
    SetIndexBuffer(10, Ema3, INDICATOR_CALCULATIONS);
    SetIndexBuffer(11, EmaOfEma3, INDICATOR_CALCULATIONS);

    PlotIndexSetInteger(8, PLOT_DRAW_TYPE, DRAW_COLOR_LINE);
    PlotIndexSetInteger(8, PLOT_LINE_STYLE, STYLE_SOLID);
    PlotIndexSetInteger(8, PLOT_LINE_WIDTH, 2);
    PlotIndexSetInteger(8, PLOT_COLOR_INDEXES, 3);
    PlotIndexSetInteger(8, PLOT_LINE_COLOR, 0, clrGray);
    PlotIndexSetInteger(8, PLOT_LINE_COLOR, 1, clrDeepPink);
    PlotIndexSetInteger(8, PLOT_LINE_COLOR, 2, clrYellowGreen);
    PlotIndexSetString(8, PLOT_LABEL, "DEMA_3");
    PlotIndexSetInteger(8, PLOT_DRAW_BEGIN, 2 * InpPeriodEMA - 2);
    PlotIndexSetInteger(8, PLOT_SHIFT, InpShift);

    SetIndexBuffer(12, DemaBuffer4, INDICATOR_DATA);
    SetIndexBuffer(13, EmaOfEmaColor4, INDICATOR_COLOR_INDEX);
    SetIndexBuffer(14, Ema4, INDICATOR_CALCULATIONS);
    SetIndexBuffer(15, EmaOfEma4, INDICATOR_CALCULATIONS);

    PlotIndexSetInteger(12, PLOT_DRAW_TYPE, DRAW_COLOR_LINE);
    PlotIndexSetInteger(12, PLOT_LINE_STYLE, STYLE_SOLID);
    PlotIndexSetInteger(12, PLOT_LINE_WIDTH, 2);
    PlotIndexSetInteger(12, PLOT_COLOR_INDEXES, 3);
    PlotIndexSetInteger(12, PLOT_LINE_COLOR, 0, clrGray);
    PlotIndexSetInteger(12, PLOT_LINE_COLOR, 1, clrDeepPink);
    PlotIndexSetInteger(12, PLOT_LINE_COLOR, 2, clrYellowGreen);
    PlotIndexSetString(12, PLOT_LABEL, "DEMA_4");
    PlotIndexSetInteger(12, PLOT_DRAW_BEGIN, 2 * InpPeriodEMA - 2);
    PlotIndexSetInteger(12, PLOT_SHIFT, InpShift);

//--- name for indicator label
    IndicatorSetString(INDICATOR_SHORTNAME, "DEMA(" + string(InpPeriodEMA) + ")");
//--- name for index label
}
//+------------------------------------------------------------------+
//| Double Exponential Moving Average                                |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const int begin,
                const double &price[])
{
//--- check for data
    if (rates_total < 2 * InpPeriodEMA - 2)
        return(0);
//---
    int limit;
    if (prev_calculated == 0)
        limit = 0;
    else
        limit = prev_calculated - 1;



    double InpPeriodEMAx  = InpPeriodEMA;
    double InpPeriodEMAx2 = InpPeriodEMA * 2;
    double InpPeriodEMAx3 = InpPeriodEMA * 3;
    double InpPeriodEMAx4 = InpPeriodEMA / 2;

//--- calculate EMA
    ExponentialMAOnBuffer(rates_total, prev_calculated, 0, InpPeriodEMAx, price, Ema);
//--- calculate EMA on EMA array
    ExponentialMAOnBuffer(rates_total, prev_calculated, InpPeriodEMAx - 1, InpPeriodEMAx, Ema, EmaOfEma);

    //--- calculate EMA
    ExponentialMAOnBuffer(rates_total, prev_calculated, 0, InpPeriodEMAx2, price, Ema2);
//--- calculate EMA on EMA array
    ExponentialMAOnBuffer(rates_total, prev_calculated, InpPeriodEMAx2 - 1, InpPeriodEMAx2, Ema2, EmaOfEma2);

    //--- calculate EMA
    ExponentialMAOnBuffer(rates_total, prev_calculated, 0, InpPeriodEMAx3, price, Ema3);
//--- calculate EMA on EMA array
    ExponentialMAOnBuffer(rates_total, prev_calculated, InpPeriodEMAx3 - 1, InpPeriodEMAx3, Ema3, EmaOfEma3);

    //--- calculate EMA
    ExponentialMAOnBuffer(rates_total, prev_calculated, 0, InpPeriodEMAx4, price, Ema4);
//--- calculate EMA on EMA array
    ExponentialMAOnBuffer(rates_total, prev_calculated, InpPeriodEMAx4 - 1, InpPeriodEMAx4, Ema4, EmaOfEma4);

//--- calculate DEMA
    for (int i = limit; i < rates_total && !IsStopped(); i++)
    {
        DemaBuffer[i]    = 2 * Ema[i] - EmaOfEma[i];
        EmaOfEmaColor[i] = (i > 0) ? (DemaBuffer[i] > DemaBuffer[i - 1]) ? 2 : (DemaBuffer[i] < DemaBuffer[i - 1]) ? 1 : EmaOfEmaColor[i - 1] : 0;

        DemaBuffer2[i]    = 2 * Ema2[i] - EmaOfEma2[i];
        EmaOfEmaColor2[i] = (i > 0) ? (DemaBuffer2[i] > DemaBuffer2[i - 1]) ? 2 : (DemaBuffer2[i] < DemaBuffer2[i - 1]) ? 1 : EmaOfEmaColor2[i - 1] : 0;

        DemaBuffer3[i]    = 2 * Ema3[i] - EmaOfEma3[i];
        EmaOfEmaColor3[i] = (i > 0) ? (DemaBuffer3[i] > DemaBuffer3[i - 1]) ? 2 : (DemaBuffer3[i] < DemaBuffer3[i - 1]) ? 1 : EmaOfEmaColor3[i - 1] : 0;

        DemaBuffer4[i]    = 2 * Ema4[i] - EmaOfEma4[i];
        EmaOfEmaColor4[i] = (i > 0) ? (DemaBuffer4[i] > DemaBuffer4[i - 1]) ? 2 : (DemaBuffer4[i] < DemaBuffer4[i - 1]) ? 1 : EmaOfEmaColor4[i - 1] : 0;
    }
//--- OnCalculate done. Return new prev_calculated.
    return(rates_total);
}
//+------------------------------------------------------------------+
 
Never Mind, Fixed it!!!
Reason: