//+------------------------------------------------------------------+
//|                                                      OsMA+BB.mq4 |
//|                        Copyright 2013, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright 2013, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 DodgerBlue
#property indicator_color2 Blue
#property indicator_color3 Red

//--- input parameters
extern int       FastEMA=12;
extern int       SlowEMA=26;
extern int       Signal=9;
extern int       BollingerPeriod=20;
extern int       BollingerShift=0;
extern int       BollingerDeviation=2;
//--- buffers
double OsMA_Histogram[];
double UpBoll[];
double DownBoll[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_HISTOGRAM,EMPTY,2);
   SetIndexBuffer(0,OsMA_Histogram);
   SetIndexLabel( 0,"OsMA("+FastEMA+","+SlowEMA+","+Signal+")"); 
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,UpBoll);
   SetIndexLabel(1,"Upper Bollinger");
   SetIndexStyle(2,DRAW_LINE);
   SetIndexBuffer(2,DownBoll);
   SetIndexLabel(2,"Lower Bollinger");
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
   for(int i=Bars-counted_bars-1;i>=0;i--)                      // Loop for uncounted bars
     {
      OsMA_Histogram[i]= iOsMA(NULL,0,FastEMA,SlowEMA,Signal,PRICE_CLOSE,i) ;
     }
     
   for(i=Bars-counted_bars-1;i>=0;i--)                      // Loop for uncounted bars
     {
      UpBoll[i]=iBandsOnArray(OsMA_Histogram,0,BollingerPeriod,BollingerDeviation,BollingerShift,MODE_UPPER,i);
      DownBoll[i]=iBandsOnArray(OsMA_Histogram,0,BollingerPeriod,BollingerDeviation,BollingerShift,MODE_LOWER,i);
     
     }
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+