//+------------------------------------------------------------------+
//|                                                 i-DayofWayke.mq4 |
//|                      Copyright © 2009, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2010, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"
#property indicator_chart_window

extern string     xxxxxxxxxxxxxxxxxxxõxxxxxxxxxx="---------------------------------------------------------";
extern int    font_size = 20;
extern string font_name = "Elzevir";
extern color  text_color= Lime;

int i,limit;
string StrDay;
datetime BeginBarDay;
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int init() 
  {
   if(font_name=="")font_name = "Times New Roman";
   if(font_size==0) font_size = 20;
   return(0);
  }
//+------------------------------------------------------------------+
int deinit() 
  {
   for(i=0; i<=iBarShift(Symbol(),PERIOD_D1,iTime(Symbol(),PERIOD_D1,Bars)); i++) ObjectDelete(TimeToStr(iTime(Symbol(),PERIOD_D1,i),TIME_DATE|TIME_SECONDS));  Comment("");
   return(0);
  }
//+------------------------------------------------------------------+
void start() 
  {
   if(Period()>1440)return;
//----
   limit=Bars-IndicatorCounted()-1;
   Alert(limit);
//+------------------------------------------------------------------+  
   for(i=limit; i>=0; i--)
     {
      if(i!=0)datetime time_txt=Time[i-PERIOD_D1/Period()/2]; else time_txt=Time[0];
      if(BeginBarDay!=iTime(Symbol(),PERIOD_D1,iBarShift(Symbol(),PERIOD_D1,Time[i])))
        {
         BeginBarDay=iTime(Symbol(),PERIOD_D1,iBarShift(Symbol(),PERIOD_D1,Time[i]));
         StrDay=day(TimeDayOfWeek(Time[i]));
         ObjectCreate(TimeToStr(BeginBarDay,TIME_DATE|TIME_SECONDS),OBJ_TEXT,0,time_txt,iOpen(_Symbol,PERIOD_D1,iBarShift(_Symbol,PERIOD_D1,Time[i])));
         ObjectSetText(TimeToStr(BeginBarDay,TIME_DATE|TIME_SECONDS),StrDay,font_size,font_name,text_color);
        }
      if(i==0 && BeginBarDay+43200>Time[0])
        {
         ObjectDelete(TimeToStr(BeginBarDay,TIME_DATE|TIME_SECONDS));
         ObjectCreate(TimeToStr(BeginBarDay,TIME_DATE|TIME_SECONDS),OBJ_TEXT,0,time_txt,iOpen(_Symbol,PERIOD_D1,iBarShift(_Symbol,PERIOD_D1,Time[i])));
         ObjectSetText(TimeToStr(BeginBarDay,TIME_DATE|TIME_SECONDS),StrDay,font_size,font_name,text_color);
        }
     }
  }
//+------------------------------------------------------------------+
string day(int TimeDayOfWeek_)
  {
   switch(TimeDayOfWeek_)
     {
      case 0:   return("Âñ.");
      case 1:   return("Ïí.");
      case 2:   return("Âò.");
      case 3:   return("Ñð.");
      case 4:   return("×ò.");
      case 5:   return("Ïò.");
      case 6:   return("Ñá.");
     }
   return("");
  }
//+------------------------------------------------------------------+
