Having a delay problem in the execution of my EA.

 

Dear All,

I started using the MT4 platform developing my personal EA recently. Now, they are working well especially with the backtest facility.

But the problem I'm facing is when my EA is working on real time with my broker (practice or live) accounts: sometimes my EA takes a bid delay to respond. So that I should intervene to reinitialize or to reboot it manually.

So, I would be very grateful if someone knows the problem and can help me.

Regards.

LM. 

 

mersni1: sometimes my EA takes a bid delay to respond.

So that I should intervene to reinitialize or to reboot it manually.

  1. "Doesn't work" is meaningless - just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires - meaningless. There are no mind readers here.
    What do you mean a bid delay. It takes time to open trades, depends on the broker and especially during news. Seconds to a minute is reasonable.
  2. If you mean beyond that, and it's not because you were disconnected, it's because of your code. Restarting changes nothing. You have to fix your code. Beyond that we can't help because: there are no mind readers here. You have provided no specifics or code.
 
WHRoeder:

mersni1: sometimes my EA takes a bid delay to respond.

So that I should intervene to reinitialize or to reboot it manually.

  1. "Doesn't work" is meaningless - just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires - meaningless. There are no mind readers here.
    What do you mean a bid delay. It takes time to open trades, depends on the broker and especially during news. Seconds to a minute is reasonable.
  2. If you mean beyond that, and it's not because you were disconnected, it's because of your code. Restarting changes nothing. You have to fix your code. Beyond that we can't help because: there are no mind readers here. You have provided no specifics or code.

First, thank you for your answer.

1. By "bid delay" I meant "big delay. Sorry for the typing error.

2. By "doesn't work" I meant: when I launch my EA on EURUSD graph for example to execute successive orders, the 1srt order is executed normally but the following ones take generally a certain delay (some minutes/hours, sometime no execution at all...)

3. I'm attaching herewith an example of mql4 file. Can you please check it on EURUSD graph with M1 timeframe. I would like just to add that I'm working with a powerful PC and an Optical Fiber connection.

Thank you for your help & Best Regards.

LM.

Files:
ea_02.mq4  5 kb
 
mersni1:

First, thank you for your answer.

1. By "bid delay" I meant "big delay. Sorry for the typing error.

2. By "doesn't work" I meant: when I launch my EA on EURUSD graph for example to execute successive orders, the 1srt order is executed normally but the following ones take generally a certain delay (some minutes/hours, sometime no execution at all...)

3. I'm attaching herewith an example of mql4 file. Can you please check it on EURUSD graph with M1 timeframe. I would like just to add that I'm working with a powerful PC and an Optical Fiber connection.

Thank you for your help & Best Regards.

LM.

 

expert run one time per bar (if time frame is M1, one time per minute).
 
mersni1: 1srt order is executed normally but the following ones take generally a certain delay (some minutes/hours, sometime no execution at all...
extern bool   FlagBuy=false;
extern bool   FlagSell=false;
int OpenedOrder; // 1=Buy , 2=Sell

int init(){
OpenedOrder=FALSE; // What does this mean to you?

:
// OpenedOrder==0 total==0 first time it opens a sell
if ((!FlagSell) && (OpenedOrder!=2) && (TotalOrder(MagicNumber) < MaxOrders)) {
  OpenSell(); FlagSell=true;  FlagBuy=false;}                                  

// next FlagSell=true, FlagBuy=false OpenedOrders==2 total=1 so it opens a buy
if ((!FlagBuy) && (OpenedOrder!=1) && (TotalOrder(MagicNumber) < MaxOrders)) {
  OpenBuy(); FlagBuy=true; FlagSell=false; }                                  

// here FlagSell==false, FlagBuy==true OpenedOrders==1 total=2

// when an order (either a buy or sell) has closed (total=1 < 2=Max,) it opens another sell
if ((!FlagSell) && (OpenedOrder!=2) && (TotalOrder(MagicNumber) < MaxOrders)) {

// Two orders are open this never executes.
if ((!FlagBuy) && (OpenedOrder!=1) && (TotalOrder(MagicNumber) < MaxOrders)) {
 
WHRoeder:
I think it's not a problem of code since my EA works correctly in the backtest, as I said. It seems more for a connection reasons or latency time.
Reason: