Limit Number of Trades

To add comments, please log in or register
Marius Ovidiu Sunzuiana
483
Marius Ovidiu Sunzuiana  

     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 ? 

mwfx108
9
mwfx108  

Have a look at the TimeHour() function.

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

Have a look at the TimeHour() function.

Thanks :)
To add comments, please log in or register