//------------------------------------------------------------------
//
//------------------------------------------------------------------
#property copyright "mladen"
#property link      ""

#property indicator_chart_window
#property indicator_buffers 6
#property indicator_color1  clrLimeGreen
#property indicator_color2  clrSilver
#property indicator_color3  clrOrange
#property indicator_style2  STYLE_DOT
#property strict

//
//
//
//
//

extern int PeriodUp    = 60; // Upper band period
extern int PeriodDown  = 4;  // Lower band period

double up[],dn[],mi[];

//------------------------------------------------------------------
//
//------------------------------------------------------------------
//
//
//
//
//

int init()
{
   SetIndexBuffer(0,up);
   SetIndexBuffer(1,mi);
   SetIndexBuffer(2,dn);
   return(0);
}
int deinit() { return(0); }


//------------------------------------------------------------------
//
//------------------------------------------------------------------
//
//
//
//
//

int start()
{
   int counted_bars=IndicatorCounted();
      if(counted_bars<0) return(-1);
      if(counted_bars>0) counted_bars--;
         int limit = MathMin(Bars-counted_bars,Bars-1);

   //
   //
   //
   //
   //
   
   for(int i=limit; i>=0; i--)
   {
      up[i] = High[iHighest(NULL,0,MODE_HIGH,PeriodUp  ,i)];
      dn[i] = Low [iLowest (NULL,0,MODE_LOW ,PeriodDown,i)];
      mi[i] = (up[i]+dn[i])/2.0;
   }      
   return(0);
}
