HELP!! How To Make EA Start Trading At 8:00 GMT??

 

Hi -


I sure hope someone can help me.... I have an EA that allows the user to defined the maximum number of trades to take per day... the problem is those trades begin at midnight and I'd like for it to start the trading at a different time, namely 8:00 GMT.. Here is the pertinent code:


extern int MaxTradesPerDay = 3;


if (MaxTradesPerDay > EMPTY) {
datetime midnight = iTime(0, PERIOD_D1, 0);
int countOrdersToday = countOrdersFrom(midnight);
if (countOrdersToday >= MaxTradesPerDay) {
common = false;
}
}


I'd like to modify it where the EA starts trading at 8:00 GMT instead of at midnight (00:00). Seems to me that it would be as easy as adding the appropriate offset amount to the datetime midnight variable but I dont know. Help! Thanks much in advance.


Keith

 
First you must query the Hour() operator to see what value it returns --- it depends on who your broker is; Alpari UK returns a value equal to the hour in Central Europe



if(Hour()-1<8) // Start trading at 8AM GMT

{
return(0);
}
if(Hour()-1>16) // Stop trading at 5PM GMT --- Note: 16 is 4PM but the value must "greater than" 16, thus when the value 18 is returned by Hour(), the equation Hour()-1 is greater than 16
{
return(0);
}
//=====Place body of EA below here ====================================
//
 
FXtrader2008:
First you must query the Hour() operator to see what value it returns --- it depends on who your broker is; Alpari UK returns a value equal to the hour in Central Europe



if(Hour()-1<8) // Start trading at 8AM GMT

{
return(0);
}
if(Hour()-1>16) // Stop trading at 5PM GMT --- Note: 16 is 4PM but the value must "greater than" 16, thus when the value 18 is returned by Hour(), the equation Hour()-1 is greater than 16
{
return(0);
}
//=====Place body of EA below here ====================================
//



FXtrader2008: You're the Best !!!! Thanks.

Reason: