Bug: Additional Ticket opened. Asked for 1 and received 2

 

Hi,

I'm pretty advanced by now using EA, and I'm automating my trading through them,

I'm working with 3 different brokers all through MT4 (Alpari, Forex.com, ActivTrades) and out of 3 months of trading, this has happened once on each one.

I request to open an order, and receive the ticket I requested, but then I notice that 2 tickets where opened instead.

I have prints just before the function call OrderSend and I see the order I send but in the Journal there are 2 orders!

I'm suspecting that there is a bug in the MT4 but the brokers are saying that they received 2 orders from my IP.

This is what my log looks like:

Expert log

09:55:55 EURUSD,M1: Received OrderSend Command

09:55:55 EURUSD,M1: Calling OrderSend(EURGBP,1,0.02000000,0.86800000,0,0.00000000,0.00000000)

09:55:57 EURUSD,M1: open #21688623 sell 0.02 EURGBP at 0.8680 ok

09:55:57 EURUSD,M1: ParseCommand (string)result=21688623.00000000

09:55:57 EURUSD,M1: send() is OK.

Journal Log

09:55:56 'xxx': instant order sell 0.02 EURGBP at 0.8680 sl: 0.0000 tp: 0.0000

09:55:56 'xxx': request was accepted by server

09:55:56 'xxx': request in process

09:55:57 'xxx': order was opened : #21688623 sell 0.02 EURGBP at 0.8680 sl: 0.0000 tp: 0.0000


09:55:57 'xxx': instant order sell 0.02 EURGBP at 0.8680 sl: 0.0000 tp: 0.0000

09:55:58 'xxx': request was accepted by server

09:55:58 'xxx': request in process

09:55:59 'xxx': order was opened : #21688628 sell 0.02 EURGBP at 0.8680 sl: 0.0000 tp: 0.0000



Has anyone experienced this is the past?

Help!!

 
JamesMadden:

Hi,

I'm pretty advanced by now using EA, and I'm automating my trading through them,

I'm working with 3 different brokers all through MT4 (Alpari, Forex.com, ActivTrades) and out of 3 months of trading, this has happened once on each one.

I request to open an order, and receive the ticket I requested, but then I notice that 2 tickets where opened instead.

I have prints just before the function call OrderSend and I see the order I send but in the Journal there are 2 orders!

I'm suspecting that there is a bug in the MT4 but the brokers are saying that they received 2 orders from my IP.


Has anyone experienced this is the past?

Apparently, but without a way of reproducing this issue on demand it's hard for anyone else to investigate.

https://www.mql5.com/en/forum/145356

 

JamesMadden:

09:55:56 'xxx': instant order sell 0.02 EURGBP at 0.8680 sl: 0.0000 tp: 0.0000

09:55:56 'xxx': request was accepted by server

09:55:57 'xxx': instant order sell 0.02 EURGBP at 0.8680 sl: 0.0000 tp: 0.0000

09:55:58 'xxx': request was accepted by server

Obviously it was sent twice.

  1. Code is broken.
  2. Same EA running on multiple charts. Sort the chart bar alphabetically (Drag) Chart Bar
  3. two terminals running the same EA/broker and or in the same directory.
 

Hi RaptorUk,

Thank you for the Link! This is exactly what's happening to me.

I will read more about it there.

Hi WHRoeder,

I'm not sure what you mean about the code being broken,

but if the EA was running on multiple charts, or two terminals on the same directory, this would happen all the time or at least more frequently.

What I'm experiencing here is that after 3 months, this happened only 3 times, and once on each broker.

In fact, I saw in the link Raptor sent me that you posted there as well that you think there is a problem with the EA.

I have proved as you suggested that I send my order only once, which brings me to conclude that there is a bug in the MT4.

 

What proof have you shown?

You have shown no code. Do you report all errors? that would eliminate - context busy.

Did you verify only one EA per pair? that would eliminate multiple charts, but different time frames means it would not "happen all the time or more frequently.

How did you verify only one terminal per directory per broker?

 
JamesMadden:


I have proved as you suggested that I send my order only once, which brings me to conclude that there is a bug in the MT4.

How have you proven this ? with such an infrequent occurrence it can be very, very hard to prove . . . sometimes it can take a long time to track down what is actually happening, it took me a year to understand my error 130 issue.
 
Hi guys, No disrespect and it's not personal. We are trying to make things better. I've been programming real time embedded systems for ten years so I feel confident about my debugging capabilities. The script I use to send orders to the market hasn't changed since late last year and I've never experienced this before. Then in the past month this happened three times on three different brokers. The link you were so kind to share completed my assumption, when they mentioned that there was a build release during the past two months which is the only thing that has changed. All my api calls have a print just before and after I call them and I have three sets of logs showing that the ea log is calling once and the journal log is sending twice. This is very important to me so I would be happy to sit down with the mql4 team and help them reproduce, but would recommend they use a build with more debug information.
 
JamesMadden:
Hi guys, No disrespect and it's not personal.

Indeed, we are all after the same thing, understanding of what is causing your issue.

There was another case similar where the user was saying a similar thing, turned out he had 2 terminals running despite being adamant that he didn't . . . not saying that you do just that everyone can miss things.

 
RaptorUK:

Indeed, we are all after the same thing, understanding of what is causing your issue.

There was another case similar where the user was saying a similar thing, turned out he had 2 terminals running despite being adamant that he didn't . . . not saying that you do just that everyone can miss things.


Thanks, will keep you posted
 
JamesMadden:

Thanks, will keep you posted
I suggest you to add a comment when you send an order. This comment would contain a unique identifier of your EA. Something like ComputerID+Symbol+Period+WindowHandle. You have to investigate to find a way to get a unique ComputerID. When the problem still occurs, you only have to check comment field to prove your EA only send 1 order and receive 2 tickets, or to prove the issue is related to what RaptorUK or WHRoeder are talking about.
 
angevoyageur:
I suggest you to add a comment when you send an order. This comment would contain a unique identifier of your EA. Something like ComputerID+Symbol+Period+WindowHandle. You have to investigate to find a way to get a unique ComputerID. When the problem still occurs, you only have to check comment field to prove your EA only send 1 order and receive 2 tickets, or to prove the issue is related to what RaptorUK or WHRoeder are talking about.


Hey,

That's actually a good idea, I'll give it a go and see I can reproduce it with this comment. perhaps use a timestamp with millisecond resolution.

Reason: