//+------------------------------------------------------------------+
//|                                                    MA ribbon.mq4 |
//|                                               mladenfx@gmail.com |
//|                                                                  |
//| original idea by Jose Silva                                      |
//+------------------------------------------------------------------+
#property copyright "mladen"
#property link      "mladenfx@gmail.com"

#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 Red
#property indicator_color2 Lime
#property indicator_color3 Red
#property indicator_color4 Lime
//#property indicator_width1 2
//#property indicator_width2 2
//#property indicator_width3 3
//#property indicator_width4 3

//
//
//
//
//

extern int        MA1Period   =89;
extern ENUM_MA_METHOD         MA1Method   =MODE_EMA;
extern ENUM_APPLIED_PRICE         MA1Price    =PRICE_CLOSE;
extern int        MA2Period   =21;
extern ENUM_MA_METHOD        MA2Method   =MODE_EMA;
extern ENUM_APPLIED_PRICE        MA2Price    =PRICE_CLOSE;
extern color      color_Histo1=Red; 
extern color      color_Histo2=Lime; 
extern color      color_Line1=Red; 
extern color      color_Line2=Lime; 
extern int        Size_Line=2;
extern int        Size_Histo=3;
//
//
//
//
//

double buffer1[];
double buffer2[];
double buffer3[];
double buffer4[];

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
//
//
//
//
//

int init()
{
   SetIndexBuffer(0,buffer3); SetIndexStyle(0,DRAW_HISTOGRAM,0,Size_Histo,color_Histo1);
   SetIndexBuffer(1,buffer4); SetIndexStyle(1,DRAW_HISTOGRAM,0,Size_Histo,color_Histo2);
   SetIndexBuffer(2,buffer1);SetIndexStyle(2,DRAW_LINE,0,Size_Line,color_Line1);
   SetIndexBuffer(3,buffer2);SetIndexStyle(3,DRAW_LINE,0,Size_Line,color_Line2);
   return(0);
}
int deinit()
{
   return(0);
}

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
//
//
//
//
//

int start()
{
   int counted_bars=IndicatorCounted();
   int limit,i;
   
   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
           limit=Bars-counted_bars;

   //
   //
   //
   //
   //

   for(i=limit; i>=0; i--)
   {
      buffer1[i] = iMA(NULL,0,MA1Period,0,MA1Method,MA1Price,i);
      buffer2[i] = iMA(NULL,0,MA2Period,0,MA2Method,MA2Price,i);
      buffer3[i] = buffer1[i];
      buffer4[i] = buffer2[i];
   }
   return(0);
}

