Limit Number of Trades

 

     If I want to limit trades for example 100 trades from 1 PM to 3PM how can I code ? I did this:

     string StartDate="13:00";

     string EndDate="15:00";

     OnTick()

      {

          string date1=StrToTime(StartDate);

          string date2=StrToTime(EndDate);

         if(TimeCurrent()>=date1 %% TimeCurrent() <=date2)

           //  ... enable the EA for open position

} 

     The Ea does not see the time interval condition it trades also out of this interval specified. Which solution shall I do ? 

 

Have a look at the TimeHour() function.

datetime timeCurrent = TimeCurrent();
if (TimeHour(timeCurrent) >= 13 && TimeHour(timeCurrent) < 15)
{
  DoSomething();
}
 
mwfx108:

Have a look at the TimeHour() function.

Thanks :)