MT4 Terminal duplicating orders sent by my Expert Advisor

 

I read in here: https://www.mql5.com/en/forum/145356 that someone had the same problem in build 500 and also in build 600. I have the build 600 and I'm having the same issue.

My Expert Advisor is sending the orders just once but the terminal is opening the orders twice. Have anyone had the same problem before? It only happens at 00:00hs. when my broker ( Alpari UK) says it's a new day . Because at any other time when I see the issue I just close the duplicated stop order and I shut the Chart off and then I open a new chart and put the EA again on the chart but nothings weird happens in there. 

I'm putting part of my code below so you can check out. I don't know if it has to do with my code or my broker or anything else.

 

This is my code: 

 

if( now != iTime(NULL,PERIOD_D1,0) )
   {
   now = iTime(NULL,PERIOD_D1,0);
  
    if(iOpen(NULL,PERIOD_D1,0)<ma)
     {
         ticket=OrderSend(...);
                 
         if(ticket>0)
           {
            Comment("EA is going Bullish");
           }
         else Print("Error opening SELL STOP order : ",GetLastError()); 
         return(0); 
        }
Alert: MT4 Terminal Duplicating Orders Sent by Experts - MQL4 forum
  • www.mql5.com
Alert: MT4 Terminal Duplicating Orders Sent by Experts - MQL4 forum
 

Forum on trading, automated trading systems and testing trading strategies


Hello,

Please use the SRC button when you post code. Thank you.



 
henlatourrette:

I read in here: https://www.mql5.com/en/forum/145356 that someone had the same problem in build 500 and also in build 600. I have the build 600 and I'm having the same issue.

My Expert Advisor is sending the orders just once but the terminal is opening the orders twice. Have anyone had the same problem before? It only happens at 00:00hs. when my broker ( Alpari UK) says it's a new day . Because at any other time when I see the issue I just close the duplicated stop order and I shut the Chart off and then I open a new chart and put the EA again on the chart but nothings weird happens in there. 

I'm putting part of my code below so you can check out. I don't know if it has to do with my code or my broker or anything else.

 

How is initialized now variable before this code ? Can you please show the logs with the dupicated orders ?

 
angevoyageur:

How is initialized now variable before this code ? Can you please show the logs with the dupicated orders ?

The now variable is defined globally as Datetime now;

Here are the logs:

Journal Log
-----------

2014.09.11 20:58:50.963    '1675816': order was opened : #704358148 sell stop 0.12 EURUSD at 1.28729 sl: 1.28829 tp: 1.27229
2014.09.11 20:58:50.666    '1675816': pending order sell stop 0.12 EURUSD at 1.28729 sl: 1.28829 tp: 1.27229
2014.09.11 07:41:05.093    '1675816': previous successful authorization performed from 69.28.92.249
2014.09.11 07:41:04.703    '1675816': login

Journal Log - Repeated orders



Experts Log
------------

2014.09.11 20:58:50.994    TheStream EURUSD,Daily: open #704358148 sell stop 0.12 EURUSD at 1.28729 sl: 1.28829 tp: 1.27229 ok

Experts Log - Repeated Orders problem


Everything looks good until that point, but then I see at the chart that there's another order that I don't know where it came from! As you can see at the following image, the repeated order #704358160 was placed at the same time.

Trades - repeated orders problem

 
try add comment to the pending order in your EA and see if repeated order is from same EA. Also note that there are exclamation marks/signs in the expert log.
 
henlatourrette:

The now variable is defined globally as Datetime now;

Here are the logs:

Journal Log
-----------

2014.09.11 20:58:50.963    '1675816': order was opened : #704358148 sell stop 0.12 EURUSD at 1.28729 sl: 1.28829 tp: 1.27229
2014.09.11 20:58:50.666    '1675816': pending order sell stop 0.12 EURUSD at 1.28729 sl: 1.28829 tp: 1.27229
2014.09.11 07:41:05.093    '1675816': previous successful authorization performed from 69.28.92.249
2014.09.11 07:41:04.703    '1675816': login




Experts Log
------------

2014.09.11 20:58:50.994    TheStream EURUSD,Daily: open #704358148 sell stop 0.12 EURUSD at 1.28729 sl: 1.28829 tp: 1.27229 ok



Everything looks good until that point, but then I see at the chart that there's another order that I don't know where it came from! As you can see at the following image, the repeated order #704358160 was placed at the same time.


So the #704358160 order doesn't appear in the Experts/Journal logs ?

Which broker/server are you using ? Demo or real ?

Can you check if this order (#704358160) was placed with a magic number (place your mouse this trade on trade tab) :

Here magic is 123540

 
angevoyageur:

So the #704358160 order doesn't appear in the Experts/Journal logs ?

Which broker/server are you using ? Demo or real ?

Can you check if this order (#704358160) was placed with a magic number (place your mouse this trade on trade tab) :

Here magic is 123540

Thanks angevoyageur, I had to delete the "extra" order manually so I'll have wait until next occurrence to check the magic number - probably on monday. 

The broker is AlpariUK and the server is AlpariUK-Demo-Market , it's a demo account

 

Hey guys, I hope you're still following this... Check this out, I think I saw the ghost.

I set the Magic Number to "1" and I found it on the log as "id 1":

Live EA


However, when I hover my mouse on the order that came from nowhere, I see the Default Magic Number of the EA - which is 432437

Ghost Order


Now, let me explain you what I did when this problem started. It was sunday evening and I logged to my VPS to check if it was everything ok before the trading week starts, but there was a problem - with I don't know what - and I had to restart the VPS.

When I re-started the VPS I also restarted the MT4 client and , to be sure, I closed the EURUSD chart window and opened a new one and I attached the EA again to the chart.

So, what I think that is happening is that the EA is running twice at the same time. That's why I see the same comment but different Magic Numbers.

However, I don't know how to remove the "Ghost EA" from there as it doesn't even appear in the logs. Any idea? What I'm gonna try right now is to uninstall and install the MT4 again. Not the best solution but the only one I have in mind right now.

 
henlatourrette:

Hey guys, I hope you're still following this... Check this out, I think I saw the ghost.

I set the Magic Number to "1" and I found it on the log as "id 1":


However, when I hover my mouse on the order that came from nowhere, I see the Default Magic Number of the EA - which is 432437


---deleted---

Suppose there is no other EA running, did you try to track this Magic Number (432437) in the EA?

 
henlatourrette:

Hey guys, I hope you're still following this... Check this out, I think I saw the ghost.

I set the Magic Number to "1" and I found it on the log as "id 1":


However, when I hover my mouse on the order that came from nowhere, I see the Default Magic Number of the EA - which is 432437


Now, let me explain you what I did when this problem started. It was sunday evening and I logged to my VPS to check if it was everything ok before the trading week starts, but there was a problem - with I don't know what - and I had to restart the VPS.

When I re-started the VPS I also restarted the MT4 client and , to be sure, I closed the EURUSD chart window and opened a new one and I attached the EA again to the chart.

So, what I think that is happening is that the EA is running twice at the same time. That's why I see the same comment but different Magic Numbers.

However, I don't know how to remove the "Ghost EA" from there as it doesn't even appear in the logs. Any idea? What I'm gonna try right now is to uninstall and install the MT4 again. Not the best solution but the only one I have in mind right now.

My conclusion is also that a second EA is running. I guess it's a VPS issue, but difficult to be sure. Let us know if you find something.
 
henlatourrette:

Hey guys, I hope you're still following this... Check this out, I think I saw the ghost.

I set the Magic Number to "1" and I found it on the log as "id 1":


However, when I hover my mouse on the order that came from nowhere, I see the Default Magic Number of the EA - which is 432437


Now, let me explain you what I did when this problem started. It was sunday evening and I logged to my VPS to check if it was everything ok before the trading week starts, but there was a problem - with I don't know what - and I had to restart the VPS.

When I re-started the VPS I also restarted the MT4 client and , to be sure, I closed the EURUSD chart window and opened a new one and I attached the EA again to the chart.

So, what I think that is happening is that the EA is running twice at the same time. That's why I see the same comment but different Magic Numbers.

However, I don't know how to remove the "Ghost EA" from there as it doesn't even appear in the logs. Any idea? What I'm gonna try right now is to uninstall and install the MT4 again. Not the best solution but the only one I have in mind right now.

I am having the same problems (order already opened correctly - from the signal and then opened again with the same size) after the VPS issues.

Using Roboforex and their VPS server.

Reason: