Error Sending Pending Order for Selected Currency Pair at a specific time

 
Hi. I have program a straddling EA that executes pending order at selected date and time for 1 or more currency pair. Here is the problem. The EA sometimes works and sometimes it does not work. Its like nothing happen. And the execution time for each currency pair differs from each other. I did not get any message error from the Server/Brokers, the MT4 just lie idle. Below is my code:
//---- input parameters

//Setup the Buy and Sell instruction
extern bool      Buy=true;
extern bool      Sell=true;

//Setup the Currency Pair to trade
extern bool      SymbolAUDUSD=true;
extern bool      SymbolNZDUSD=true;
extern bool      SymbolUSDJPY=true;
extern bool      SymbolEURUSD=true;
extern bool      SymbolGBPUSD=true;

//Setup the Currency Pair and its execution time, expiry and close all orders functions
extern double    AUDUSDExtPips=10;
extern double    AUDUSDExtTP=60;
extern double    AUDUSDExtSL=10;
extern double    AUDUSD_Lots=1;
extern datetime  AUDUSD_ExDate=D'2011.01.21 17:00';
extern double    AUDUSD_ClosePending=2;
extern datetime  AUDUSD_CloseOrder=D'2011.01.21 17:00';

extern double    NZDUSDExtPips=10;
extern double    NZDUSDExtTP=60;
extern double    NZDUSDExtSL=10;
extern double    NZDUSD_Lots=1;
extern datetime  NZDUSD_ExDate=D'2011.01.21 17:00';
extern double    NZDUSD_ClosePending=2;
extern datetime  NZDUSD_CloseOrder=D'2011.01.21 17:00';

extern double    USDJPYExtPips=10;
extern double    USDJPYExtTP=60;
extern double    USDJPYExtSL=10;
extern double    USDJPY_Lots=1;
extern datetime  USDJPY_ExDate=D'2011.01.21 16:00';
extern double    USDJPY_ClosePending=2;
extern datetime  USDJPY_CloseOrder=D'2011.01.21 16:39';

extern double    EURUSDExtPips=10;
extern double    EURUSDExtTP=60;
extern double    EURUSDExtSL=10;
extern double    EURUSD_Lots=1;
extern datetime  EURUSD_ExDate=D'2011.01.21 16:00';
extern double    EURUSD_ClosePending=2;
extern datetime  EURUSD_CloseOrder=D'2011.01.23 16:39';

extern double    GBPUSDExtPips=10;
extern double    GBPUSDExtTP=60;
extern double    GBPUSDExtSL=10;
extern double    GBPUSD_Lots=1;
extern datetime  GBPUSD_ExDate=D'2011.01.21 16:00';
extern double    GBPUSD_ClosePending=2;
extern datetime  GBPUSD_CloseOrder=D'2011.01.23 16:39';

//Variable Declaration
int AUDUSDbuy_orders=0;
int AUDUSDsell_orders=0;
int AUDUSDticketbuy;
int AUDUSDticketsell;
int AUDUSDticketclose;
double AUDUSDClosePrice;

int EURUSDbuy_orders=0;
int EURUSDsell_orders=0;
int EURUSDticketbuy;
int EURUSDticketsell;
int EURUSDticketclose;
double EURUSDClosePrice;

int GBPUSDbuy_orders=0;
int GBPUSDsell_orders=0;
int GBPUSDticketbuy;
int GBPUSDticketsell;
int GBPUSDticketclose;
double GBPUSDClosePrice;

int NZDUSDbuy_orders=0;
int NZDUSDsell_orders=0;
int NZDUSDticketbuy;
int NZDUSDticketsell;
int NZDUSDticketclose;
double NZDUSDClosePrice;

int USDJPYbuy_orders=0;
int USDJPYsell_orders=0;
int USDJPYticketbuy;
int USDJPYticketsell;
int USDJPYticketclose;
double USDJPYClosePrice;

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
{

//Send Pending Order based on date and time and selected currency pair to trade
if (TimeCurrent() == AUDUSD_ExDate && SymbolAUDUSD == true) SOAUDUSD();
if (TimeCurrent() == EURUSD_ExDate && SymbolEURUSD == true) SOEURUSD();
if (TimeCurrent() == GBPUSD_ExDate && SymbolGBPUSD == true) SOGBPUSD();
if (TimeCurrent() == NZDUSD_ExDate && SymbolNZDUSD == true) SONZDUSD();
if (TimeCurrent() == USDJPY_ExDate && SymbolUSDJPY == true) SOUSDJPY();

//Close Open Position
if (TimeLocal() == AUDUSD_CloseOrder+(BrokerGMT+8)*3600) COAUDUSD();
if (TimeLocal() == EURUSD_CloseOrder+(BrokerGMT+8)*3600) COEURUSD();
if (TimeLocal() == GBPUSD_CloseOrder+(BrokerGMT+8)*3600) COGBPUSD();
if (TimeLocal() == NZDUSD_CloseOrder+(BrokerGMT+8)*3600) CONZDUSD();
if (TimeLocal() == USDJPY_CloseOrder+(BrokerGMT+8)*3600) COUSDJPY();

return(0);
}
//+------------------------------------------------------------------+

Anything that I have missed out? Hope anyone out there that can help.

Thanks in advance.

 

I'd be wary of using EXACT time comparisons. Should there a 2 second gap in ticks, you might miss an open or close.

Also, it may be obvious but ...

.. you are aware, I presume, that this EA will only ever make one trade per currency ever, until restarted?

.. the open & close times use different time zones

 
brewmanz:

I'd be wary of using EXACT time comparisons. Should there a 2 second gap in ticks, you might miss an open or close.

Also, it may be obvious but ...

.. you are aware, I presume, that this EA will only ever make one trade per currency ever, until restarted?

.. the open & close times use different time zones

Hi brewmanz. You are right. It is programmed to make 1 trade per currency until it is restarted. And yes, it can be programmed to execute at different timezone. Anyway, thanks for the info. I have changed the time comparison to >= and it works perfectly. Didnt realize that there is a gap in ticks. Thanks again.