Download MetaTrader 5

Only one trade per day

To add comments, please log in or register
user_123
172
user_123 2011.12.26 22:09 

Hello everybody,

i'am new with mql5 and i have some problems to write the function, which check for me if the EA already have trade on this day. I will be very grateful if somebody can have a look at my code. Thank you very much!

bool DoWeHaveAlreadyOneTradeToday(){
   MqlDateTime today;
   datetime NullUhr;
   datetime now= TimeCurrent(today);
   int year = today.year;
   int month = today.mon;
   int day = today.day;
   NullUhr = StringToTime(string(year)+"."+string(month)+"."+string(day)+" 00:00");
   HistorySelect(NullUhr, now);
   uint total= HistoryDealsTotal();
   
   for(uint i=0;i<total;i++){
      ulong ticket=HistoryDealGetTicket(i);
      string symbol=HistoryDealGetString(ticket,DEAL_SYMBOL);
      datetime time =(datetime)HistoryDealGetInteger(ticket,DEAL_TIME);
      if(time>NullUhr){
            return true;
      }
      else{
            return false;
      }     
   }
   return false;
  }
Andriy Moraru
1261
Andriy Moraru 2011.12.27 10:13  

Remove this:

      else{
            return false;
      }     
To add comments, please log in or register