//+------------------------------------------------------------------+
//|                     #SRDC_Indicator.mq4
//+------------------------------------------------------------------+
#property  indicator_chart_window
#property  indicator_buffers 6
#property  indicator_color1  Silver
#property  indicator_color2  Silver
#property  indicator_color3  Lime
#property  indicator_color4  Red
#property  indicator_color5  Silver
#property  indicator_color6  Silver

double LastHigh, LastLow;
int StartTime = 0, PrevDay = 0;

double Fib2upBuffer[];
double Fib1upBuffer[];
double HighBuffer[];
double LowBuffer[];
double Fib1dnBuffer[];
double Fib2dnBuffer[];

int init()
{
   IndicatorBuffers(6);

   SetIndexStyle(0, DRAW_LINE,STYLE_DOT,1);
   SetIndexBuffer(0, Fib2upBuffer);

   SetIndexStyle(1, DRAW_LINE,STYLE_DOT,1);
   SetIndexBuffer(1, Fib1upBuffer);

   SetIndexStyle(2, DRAW_LINE,STYLE_DOT,1);
   SetIndexBuffer(2, HighBuffer);

   SetIndexStyle(3, DRAW_LINE,STYLE_DOT,1);
   SetIndexBuffer(3, LowBuffer);

   SetIndexStyle(4, DRAW_LINE,STYLE_DOT,1);
   SetIndexBuffer(4, Fib1dnBuffer);

   SetIndexStyle(5, DRAW_LINE,STYLE_DOT,1);
   SetIndexBuffer(5, Fib2dnBuffer);

   return(0);
}

int deinit()
{

   return(0);

}

int start()
{
   int i,j,limit,dayx;
   
   int counted_bars=IndicatorCounted();

   if(counted_bars<0) return(-1); //---- check for possible errors
   if(counted_bars>0) counted_bars--; //---- last counted bar will be recounted

   limit=Bars-counted_bars;
   dayx = 1; 
   for(i=0;i<=limit+Period();i++)
   {
      if (TimeHour(iTime(NULL,0,i)) < TimeHour(iTime(NULL,0,i+1)) &&
          TimeMinute(iTime(NULL,0,i)) == 0)
      {dayx++;}

      LastHigh = iHigh(NULL,PERIOD_D1,dayx);
      LastLow = iLow(NULL,PERIOD_D1,dayx);
      
      HighBuffer[i] = LastHigh;
      LowBuffer[i] = LastLow;
      Fib1upBuffer[i] = LastHigh+(21*Point);
      Fib2upBuffer[i] = LastHigh+(34*Point);
      Fib1dnBuffer[i] = LastLow-(21*Point);
      Fib2dnBuffer[i] = LastLow-(34*Point);
   }
//   Comment(iHigh(NULL,PERIOD_D1,1),"\n",iHigh(NULL,PERIOD_D1,2));   
   return(0);
}
//+------------------------------------------------------------------+

