//+------------------------------------------------------------------+
//|                                                BBMA By Nbr42.mq4 |
//|                                https://www.forexfactory.com/nbr42|
//+------------------------------------------------------------------+
#property  copyright "Nbr42"
#property  link      "https://www.forexfactory.com/nbr42"

#property indicator_chart_window
#property indicator_buffers 8

extern int  MA1Period   =5,     
            MA1Method   =MODE_LWMA,
            MA1Price    =PRICE_HIGH,
            MA1shift    =0,
            MA2Period   =5,
            MA2Method   =MODE_LWMA,
            MA2Price    =PRICE_LOW,
            MA2shift    =0,
            MA3Period   =10,     
            MA3Method   =MODE_LWMA,
            MA3Price    =PRICE_HIGH,
            MA3shift    =0,
            MA4Period   =10,     
            MA4Method   =MODE_LWMA,
            MA4Price    =PRICE_LOW,
            MA4shift    =0,
            MA5Period   =50,
            MA5Method   =MODE_EMA,
            MA5Price    =PRICE_CLOSE,
            MA5shift    =0,
            BBprd       = 20,
            BBdev       = 2,
            Limit_Bar   = 00;
extern color  BBcol     = clrSkyBlue;
extern color  MAcol     = clrDimGray;
double buffer1[], buffer2[], buffer3[],
       buffer4[], buffer5[], buffer6[],
       buffer7[], buffer8[];

//+------------------------------------------------------------------+
int init()
{
   SetIndexBuffer(0,buffer1); SetIndexStyle(0,DRAW_LINE, 0, 2, clrOrange);
   SetIndexBuffer(1,buffer2); SetIndexStyle(1,DRAW_LINE, 0, 2, clrOrange);
   SetIndexBuffer(2,buffer3); SetIndexStyle(2,DRAW_LINE, 0, 2, clrGainsboro);
   SetIndexBuffer(3,buffer4); SetIndexStyle(3,DRAW_LINE, 0, 2, clrGainsboro);
   SetIndexBuffer(4,buffer5); SetIndexStyle(4,DRAW_LINE, 0, 2, MAcol);
   SetIndexBuffer(5,buffer6); SetIndexStyle(5,DRAW_LINE, 0, 2, BBcol);
   SetIndexBuffer(6,buffer7); SetIndexStyle(6,DRAW_LINE, 0, 2, BBcol);
   SetIndexBuffer(7,buffer8); SetIndexStyle(7,DRAW_LINE, 0, 2, BBcol);
   
   
   return(0);
}
int deinit()
{
   return(0);
}

//+------------------------------------------------------------------+
int start()
{
   int counted_bars=IndicatorCounted();
   if(counted_bars>0) counted_bars--; //---- the latest evaluated bar will be re-evaluated
   int limit= Bars-counted_bars;
   for(int i=limit; i>0; i--)
   {
      buffer1[i] = iMA(NULL,0,MA1Period, MA1shift, MA1Method,MA1Price,i);
      buffer2[i] = iMA(NULL,0,MA2Period, MA2shift, MA2Method,MA2Price,i);
      buffer3[i] = iMA(NULL,0,MA3Period, MA3shift, MA3Method,MA3Price,i);
      buffer4[i] = iMA(NULL,0,MA4Period, MA4shift, MA4Method,MA4Price,i);
      buffer5[i] = iMA(NULL,0,MA5Period, MA5shift, MA5Method,MA5Price,i);
      buffer6[i] = iBands(NULL,0, BBprd, BBdev, 0, PRICE_CLOSE, 0, i);
      buffer7[i] = iBands(NULL,0, BBprd, BBdev, 0, PRICE_CLOSE, 1, i);
      buffer8[i] = iBands(NULL,0, BBprd, BBdev, 0, PRICE_CLOSE, 2, i);
   }
   return(0);
}

