//+------------------------------------------------------------------+
//|                                  NatusekoProtrader4HStrategy.mq4 |
//|                                                     FORTRADER.RU |
//|MacdBB                                        http://FORTRADER.RU |
//+------------------------------------------------------------------+
//mod 2008fxtsd    ki

#property copyright "FORTRADER.RU"
#property link      "http://FORTRADER.RU"

#property indicator_separate_window
#property indicator_buffers 5

#property indicator_color1 DarkSlateGray
#property indicator_color2 DodgerBlue
#property indicator_color3 CornflowerBlue
#property indicator_color4 DodgerBlue
#property indicator_color5 Red

extern int FastMA       =    5;
extern int SlowMA       =    200;
extern int SigMA        =    3;
extern int MAmode       =    1;
extern int SigMAmode    =    0;

extern int    BBperiod     =    20;
extern double Dev          =    1;

extern bool    MacdHisto   =    true;



double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
double ExtMapBuffer5[];


//----

int init()
 {

   SetIndexStyle(0,DRAW_LINE);  if (MacdHisto)  SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexStyle(2,DRAW_LINE);
   SetIndexStyle(3,DRAW_LINE);
   SetIndexStyle(4,DRAW_LINE);
   
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexBuffer(1,ExtMapBuffer2);
   SetIndexBuffer(2,ExtMapBuffer3);
   SetIndexBuffer(3,ExtMapBuffer4);
   SetIndexBuffer(4,ExtMapBuffer5);

   return(0);
 }

//----


int start()
 {
   int   counted_bars=IndicatorCounted();
   int   i,limit;
         limit=Bars-counted_bars;
   
   if (counted_bars<0) return(-1);
   if (counted_bars>0) counted_bars--;
   
   
   for(i=limit; i>=0; i--)   

   ExtMapBuffer1[i]=iMACD(NULL,0,FastMA,SlowMA,1,PRICE_CLOSE,MODE_MAIN,i);

   
   for(i=limit; i>=0; i--) 
   {
   ExtMapBuffer2[i]=iBandsOnArray(ExtMapBuffer1,0,BBperiod,Dev,0,MODE_UPPER,i);
   ExtMapBuffer3[i]=iBandsOnArray(ExtMapBuffer1,0,BBperiod,Dev,0,MODE_MAIN, i);
   ExtMapBuffer4[i]=iBandsOnArray(ExtMapBuffer1,0,BBperiod,Dev,0,MODE_LOWER,i);
    
   ExtMapBuffer5[i]=   iMAOnArray(ExtMapBuffer1,0,SigMA,0,SigMAmode,i);
   }
 
   return(0);
 }

//----