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

extern int dDay;

int init()
{
   return(0);
}

int deinit()
{
   return(0);
}

int start()
{
   bool isBUY = false, isSELL = false;
   
   if((Hour() == 8) && (Minute() == 0))
   {
      if(iOpen(NULL, PERIOD_H1, 1) < iClose(NULL, PERIOD_H1, 1)) isBUY = true;
      if(iOpen(NULL, PERIOD_H1, 1) > iClose(NULL, PERIOD_H1, 1)) isSELL = true;
   }
   
   if(OrdersTotal() == 0)
   {
      if(isBUY)
      {
         OrderSend(Symbol(),OP_BUY,1,Ask,3,0,Ask+0.0033,"",2,0,Blue);
         dDay = Day();
      }
      if(isSELL)
      {
         OrderSend(Symbol(),OP_SELL,1,Bid,3,0,Bid-0.0033,"",1,0,Red);
         dDay = Day();
      }
   }
   
   int total,cnt;
   if((OrdersTotal() == 1) && (Hour() == 0))
   {
      total = OrdersTotal();
      for(cnt=0;cnt<total;cnt++)
      {  
         OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);         
         if(OrderType()==OP_BUY)
         {
            OrderClose(OrderTicket(), OrderLots(), Ask, 3, Blue);
         }
         if(OrderType()==OP_SELL)
         {
            OrderClose(OrderTicket(), OrderLots(), Bid, 3, Red);
         }
      }
   }   
   
   return(0);
}



