Navigation:Home > Content >

CloseOnTime_(2).mq4

Time: 2012-12-08 | Download file:CloseOnTime_(2).mq4

//+------------------------------------------------------------------+
//|                                                  CloseOnTime.mq4 |
//|                                           Ким Игорь В. aka KimIV |
//|                                              http://www.kimiv.ru |
//+------------------------------------------------------------------+
#property copyright "Ким Игорь В. aka KimIV"
#property link      "http://www.kimiv.ru"

//---- input parameters
extern int       CloseHour=23;
extern int       CloseMinute=55;

int start() {
  int cnt, ticket, total;
  if (Hour() == CloseHour && Minute() >= CloseMinute) {
    total=OrdersTotal();
    for (cnt=0; cnt < total ;cnt++) {
      if (OrderType() == OP_BUY) {
        OrderClose(OrderTicket(), OrderLots(), Bid, 3, Yellow);
        return(0); // exit
      }
      if (OrderType() == OP_SELL) {
        OrderClose(OrderTicket(), OrderLots(), Ask, 3, Yellow);
        return(0); // exit
      }
    }
  } 
  return(0);
}
//+------------------------------------------------------------------+
--------------020300040205050204090306--

Recommend