//+------------------------------------------------------------------+
//|                                            day_time_function.mq4 |
//|                               Copyright © 2010, Dennis Hamiilton |
//|                                              ramble_32@yahoo.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2010, Dennis Hamiilton"
#property link      "ramble_32@yahoo.com"

//+------------------------------------------------------------------+
// int order_send()                                                  |
// {                                                                 |
//   int o_send=2;                                                   |
//   if(use_trading_sessions) #include <day_time_function.mqh>       |
//   return(o_send);                                                 |
// }                                                                 |
// ... Include in EA ...                                             |
//+------------------------------------------------------------------+
//----
  int total_shift=gmt_shift;
  if(daylight_savings) total_shift=gmt_shift+1;
  int asian_open=0+total_shift, asian_close=8 +total_shift;
  int euro_open=6 +total_shift, euro_close=16 +total_shift;
  int ny_open=12  +total_shift, ny_close=21   +total_shift;
//----
  if(DayOfWeek()==0) // sunday
  {
     if(asian_daily){ asian_open=sun_asian_open; asian_close=sun_asian_close; }
     if(euro_daily) { euro_open=sun_euro_open;   euro_close=sun_euro_close; }
     if(ny_daily)   { ny_open=sun_ny_open;       ny_close=sun_ny_close; }
//---
     if(!t_day[0]){ t_day[0]=true; mtd_time=TimeCurrent(); t_day[5]=false; }
  }
  if(DayOfWeek()==1) // monday
  {
     if(asian_daily){ asian_open=mon_asian_open; asian_close=mon_asian_close; }
     if(euro_daily) { euro_open=mon_euro_open;   euro_close=mon_euro_close; }
     if(ny_daily)   { ny_open=mon_ny_open;       ny_close=mon_ny_close; }
//---
     if(!t_day[1]){ t_day[1]=true; mtd_time=TimeCurrent(); t_day[0]=false; }
  }
  if(DayOfWeek()==2) // tuesday
  {
     if(asian_daily){ asian_open=tue_asian_open; asian_close=tue_asian_close; }
     if(euro_daily) { euro_open=tue_euro_open;   euro_close=tue_euro_close; }
     if(ny_daily)   { ny_open=tue_ny_open;       ny_close=tue_ny_close; }
//---
     if(!t_day[2]){ t_day[2]=true; mtd_time=TimeCurrent(); t_day[1]=false; }
  }
  if(DayOfWeek()==3) // wednesday
  {
     if(asian_daily){ asian_open=wed_asian_open; asian_close=wed_asian_close; }
     if(euro_daily) { euro_open=wed_euro_open;   euro_close=wed_euro_close; }
     if(ny_daily)   { ny_open=wed_ny_open;       ny_close=wed_ny_close; }
//---
     if(!t_day[3]){ t_day[3]=true; mtd_time=TimeCurrent(); t_day[2]=false; }
  }
  if(DayOfWeek()==4) // thursday
  {
     if(asian_daily){ asian_open=thu_asian_open; asian_close=thu_asian_close; }
     if(euro_daily) { euro_open=thu_euro_open;   euro_close=thu_euro_close; }
     if(ny_daily)   { ny_open=thu_ny_open;       ny_close=thu_ny_close; }
//---
     if(!t_day[4]){ t_day[4]=true; mtd_time=TimeCurrent(); t_day[3]=false; }
  }
  if(DayOfWeek()==5) // friday
  {
     if(asian_daily){ asian_open=fri_asian_open; asian_close=fri_asian_close; }
     if(euro_daily) { euro_open=fri_euro_open;   euro_close=fri_euro_close; }
     if(ny_daily)   { ny_open=fri_ny_open;       ny_close=fri_ny_close; }
//---
     if(!t_day[5]){ t_day[5]=true; mtd_time=TimeCurrent(); t_day[4]=false; }
  }
//----
  bool o_time=false;
  if(asian_session && Hour()>=asian_open && Hour()<=asian_close) o_time=true;
  if(euro_session  && Hour()>=euro_open  && Hour()<=euro_close)  o_time=true;
  if(ny_session    && Hour()>=ny_open    && Hour()<=ny_close)    o_time=true;
//----
  if(o_time){ if(signal()==buy) o_send=0; if(signal()==sell) o_send=1; }