//+------------------------------------------------------------------+
//|                     #SRDC_Indicator.mq4
//+------------------------------------------------------------------+
#property  indicator_chart_window
#property  indicator_buffers 8
#property  indicator_color1  Silver
#property  indicator_color2  Silver
#property  indicator_color3  Silver
#property  indicator_color4  Lime
#property  indicator_color5  Red
#property  indicator_color6  Silver
#property  indicator_color7  Silver
#property  indicator_color8  Silver

extern int StartTime = 0;
double LastHigh, LastLow, Lower=9, Higher=0;
int PrevDay = 0;

double Fib3upBuffer[];
double Fib2upBuffer[];
double Fib1upBuffer[];
double HighBuffer[];
double LowBuffer[];
double Fib1dnBuffer[];
double Fib2dnBuffer[];
double Fib3dnBuffer[];

int init()
{
   IndicatorBuffers(8);

   SetIndexStyle(0, DRAW_LINE,STYLE_DOT,1);
   SetIndexBuffer(0, Fib3upBuffer);

   SetIndexStyle(1, DRAW_LINE,STYLE_DOT,1);
   SetIndexBuffer(1, Fib2upBuffer);

   SetIndexStyle(2, DRAW_LINE,STYLE_DOT,1);
   SetIndexBuffer(2, Fib1upBuffer);

   SetIndexStyle(3, DRAW_LINE,STYLE_DOT,1);
   SetIndexBuffer(3, HighBuffer);

   SetIndexStyle(4, DRAW_LINE,STYLE_DOT,1);
   SetIndexBuffer(4, LowBuffer);

   SetIndexStyle(5, DRAW_LINE,STYLE_DOT,1);
   SetIndexBuffer(5, Fib1dnBuffer);

   SetIndexStyle(6, DRAW_LINE,STYLE_DOT,1);
   SetIndexBuffer(6, Fib2dnBuffer);

   SetIndexStyle(7, DRAW_LINE,STYLE_DOT,1);
   SetIndexBuffer(7, 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;

   for(i=limit;i>=0;i--)
   {
      if (iHigh(NULL,0,i+1) > Higher)
         {Higher = iHigh(NULL,0,i+1);} 

      if (iLow(NULL,0,i+1) < Lower)
         {Lower = iLow(NULL,0,i+1);} 

      if (TimeHour(iTime(NULL,0,i)) == StartTime && TimeMinute(iTime(NULL,0,i)) == 0)
      {
         LastHigh = Higher;
         LastLow = Lower;
         Higher = 0;
         Lower = 9;
      }   
      
      HighBuffer[i] = LastHigh;
      LowBuffer[i] = LastLow;
      Fib1upBuffer[i] = LastHigh+(21*Point);
      Fib2upBuffer[i] = LastHigh+(34*Point);
      Fib3upBuffer[i] = LastHigh+(55*Point);
      Fib1dnBuffer[i] = LastLow-(21*Point);
      Fib2dnBuffer[i] = LastLow-(34*Point);
      Fib3dnBuffer[i] = LastLow-(55*Point);
   }
//   Comment(iHigh(NULL,PERIOD_D1,1),"\n",iHigh(NULL,PERIOD_D1,2));   
   return(0);
}
//+------------------------------------------------------------------+

