Setting Indicator Buffers number and Set colours

 
I am trying to set Indicator buffers and make the Moving Averages a specific colour but its not working only 1 buffer is set "MA 1" and the colour is black
//+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
//| Ultimate Indicator.mq4                                                      
//| Copyright 2023, BLAC.                                                                           
//| https://www.blac.cc                                                                             
//+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
#property                             copyright                   "Copyright 2023, BLAC."
#property                             link                        "https://www.blac.cc"
#property                             version                     "1.000"
#property                             indicator_chart_window 

//+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
color                                MAColours[]                = { clrYellow,clrAqua,clrPink,clrLime,clrPurple,clrChocolate,clrBlue };

//+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
//--- MA input parameters
const  input  string                  MAPeriod                  = "5,13,20";                 //MA Periods
const  input  ENUM_MA_METHOD          MAMethod                  = MODE_SMA;                  //MA Method 
const  input  int                     MAShift                   = 0;                         //MA Shift
const  input  ENUM_LINE_STYLE         MAStyle                   = STYLE_SOLID;               //MA Style
const  input  int                     MAWidth                   = 1;                         //MA Width
const  input  ENUM_APPLIED_PRICE      MAPrice                   = PRICE_CLOSE;               //MA Apply Price

// Define indicator buffers
string                                maperiods[]; 
double                                mabuffer1[],  mabuffer2[], mabuffer3[], mabuffer4[], mabuffer5[], mabuffer6[], mabuffer7[];

int                                   decimals;
string                                market; 
ENUM_TIMEFRAMES                       timeframe;
//+------------------------------------------------------------------+ 
//| Custom indicator initialization function                         | 
//+------------------------------------------------------------------+ 
int OnInit() 
  {
      int  MATotalBuffers = StringSplit(MAPeriod,',',maperiods);
      if(MATotalBuffers < 2 || MATotalBuffers > 7)
         {
            if(MATotalBuffers < 2)Alert("MA Periods Less than 2 Kindly Check");
            if(MATotalBuffers > 7)Alert("MA Periods More than 7 Kindly Check");
            return (INIT_FAILED);
         }
      
      int  BufferSize     = MATotalBuffers;
      if(IndicatorBuffers(BufferSize))Alert("Buffers ",BufferSize);
      
      for(int m = 0; m < MATotalBuffers; m++)
         {
            if(m == 0)SetIndexBuffer(m,mabuffer1);
            else if(m == 1)SetIndexBuffer(m,mabuffer2);
            else if(m == 2)SetIndexBuffer(m,mabuffer3);
            else if(m == 3)SetIndexBuffer(m,mabuffer4);
            else if(m == 4)SetIndexBuffer(m,mabuffer5);
            else if(m == 5)SetIndexBuffer(m,mabuffer6);
            else if(m == 6)SetIndexBuffer(m,mabuffer7);
             
            SetIndexStyle (m,DRAW_LINE); 
            SetIndexLabel (m,"MA " + IntegerToString(m + 1)); 
            
            PlotIndexSetInteger(m,PLOT_LINE_COLOR,MAColours[m]);
            PlotIndexSetInteger(m,PLOT_LINE_STYLE,MAStyle);
            PlotIndexSetInteger(m,PLOT_LINE_WIDTH,MAWidth);
         }
      
      market                = _Symbol;
      timeframe             = PERIOD_CURRENT;
      decimals              = SymbolInfoInteger(market,SYMBOL_DIGITS);
      IndicatorSetInteger(INDICATOR_DIGITS,decimals);
      
      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[]) 
  { 
      int begin = rates_total - 1 - MathMin(prev_calculated, rates_total - 1); 
    
      for(int i = begin; i >= 0; i--) 
        {
            for(int m = 0; m < ArraySize(maperiods); m++)
               {
                  if(m == 0)mabuffer1[i] = iMA(market,timeframe,maperiods[m],MAShift,MAMethod,MAPrice,i);
                  else if(m == 1)mabuffer2[i] = iMA(market,timeframe,maperiods[m],MAShift,MAMethod,MAPrice,i);
                  else if(m == 2)mabuffer3[i] = iMA(market,timeframe,maperiods[m],MAShift,MAMethod,MAPrice,i);
                  else if(m == 3)mabuffer4[i] = iMA(market,timeframe,maperiods[m],MAShift,MAMethod,MAPrice,i);
                  else if(m == 4)mabuffer5[i] = iMA(market,timeframe,maperiods[m],MAShift,MAMethod,MAPrice,i);
                  else if(m == 5)mabuffer6[i] = iMA(market,timeframe,maperiods[m],MAShift,MAMethod,MAPrice,i);
                  else if(m == 6)mabuffer7[i] = iMA(market,timeframe,maperiods[m],MAShift,MAMethod,MAPrice,i);
               }
        } 
    
      return(rates_total); 
  } 
//+------------------------------------------------------------------+
 
Where did you tell the terminal how many visible buffers you have and how many total?
 
William Roeder #:
Where did you tell the terminal how many visible buffers you have and how many total?
Thanks for the reply here I have used IndicatorBuffers()
      int  MATotalBuffers = StringSplit(MAPeriod,',',maperiods);
      if(MATotalBuffers < 2 || MATotalBuffers > 7)
         {
            if(MATotalBuffers < 2)Alert("MA Periods Less than 2 Kindly Check");
            if(MATotalBuffers > 7)Alert("MA Periods More than 7 Kindly Check");
            return (INIT_FAILED);
         }
      
      int  BufferSize     = MATotalBuffers;
      if(IndicatorBuffers(BufferSize))Alert("Buffers ",BufferSize);
      else if(!IndicatorBuffers(BufferSize))Alert("Failed ");
Reason: