#property copyright "DREW"
#property link      "joinme@yandex.ru"

int dDay = 0;

int init()
{
   return(0);
}

int deinit()
{
   return(0);
}

int start()
{
   if(Hour() == 23)
   {
      double MidPrev = (iOpen(NULL,PERIOD_H1,1) + iClose(NULL,PERIOD_H1,1)) / 2;
      double MidCur = (iOpen(NULL,PERIOD_H1,0) + iClose(NULL,PERIOD_H1,0)) / 2;
      
      if(MidPrev > MidCur) // BUY
      {
         if((OrdersTotal() == 0) && (dDay != Day()))
         {
            OrderSend(Symbol(),OP_BUY,1,Ask,3,0,Ask+0.0050,"",2,0,Blue);
            dDay = Day();
         }
      }

      if(MidPrev < MidCur) // SELL
      {
         if((OrdersTotal() == 0) && (dDay != Day()))
         {
            OrderSend(Symbol(),OP_SELL,1,Bid,3,0,Bid-0.0050,"",1,0,Red);
            dDay = Day();
         }         
      }
   }  

   return(0);
}


