/*
*********************************************************************
Displays the European & US trading sessions on the chart.
*********************************************************************
*/

#property indicator_chart_window
#property indicator_buffers 6
#property indicator_color1 Wheat
#property indicator_color2 Wheat
#property indicator_color3 White
#property indicator_color4 White
#property indicator_color5 Pink
#property indicator_color6 Pink


extern double offset = -4;

double europe1[];
double europe2[];
double us1[];
double us2[];
double overlap1[];
double overlap2[];

int init() {
   
   IndicatorBuffers(6);
   
   SetIndexStyle(0,DRAW_HISTOGRAM, 0, 5, indicator_color1);
   SetIndexBuffer(0, europe1);
   SetIndexLabel(0,"European session");
   
   SetIndexStyle(1,DRAW_HISTOGRAM, 0, 5, indicator_color2);
   SetIndexBuffer(1, europe2);
   SetIndexLabel(1,"European session");
   
   SetIndexStyle(2,DRAW_HISTOGRAM, 0, 5, indicator_color3);
   SetIndexBuffer(2, us1);
   SetIndexLabel(2,"US session");
   
   SetIndexStyle(3,DRAW_HISTOGRAM, 0, 5, indicator_color4);
   SetIndexBuffer(3, us2);
   SetIndexLabel(3,"US session");
   
   SetIndexStyle(4,DRAW_HISTOGRAM, 0, 5, indicator_color5);
   SetIndexBuffer(4, overlap1);
   SetIndexLabel(4,"No session");
   
   SetIndexStyle(5,DRAW_HISTOGRAM, 0, 5, indicator_color6);
   SetIndexBuffer(5, overlap2);
   SetIndexLabel(5,"No session");
   
   return(0);

}

int start() {
   
   int   counted_bars=IndicatorCounted();
   int   limit = Bars-counted_bars;
   int   i;
   
   for (i=limit; i>=0; i--) {
      if (TimeHour(Time[i]) >= 11+offset && TimeHour(Time[i]) <= 15+offset) {
      
         europe1[i]=1000;
         europe2[i]=0;
      
      } else if (TimeHour(Time[i]) >= 16+offset && TimeHour(Time[i]) <= 19+offset) {
      
         overlap1[i]=1000;
         overlap2[i]=0;
      
      } else if (TimeHour(Time[i]) >= 20+offset && TimeHour(Time[i]) <= 25+offset) {
      
         us1[i]=1000;
         us2[i]=0;
               
      }
  
      
   }
      
   return(0);

}