My EA does a double entry - page 6

 
doshur:
Any updates from the service desk?
Not yet.
 
angevoyageur:
Not yet.

Hi,

Any news from service desk yet? 

 
doshur:

Hi,

Any news from service desk yet? 

You can be sure that I will post the reply here if I get one.

Personally I am not yet come to reproduce the problem.

 

My EA generates signal very slowly and today it made a trade.

No issue with the lot size after I use the new code however I cannot confirmed that the new code is working. 

 
doshur:

My EA generates signal very slowly and today it made a trade.

No issue with the lot size after I use the new code however I cannot confirmed that the new code is working. 

Hi doshur,

No reply from ServiceDesk yet. However your issue is "disturbing" me Can you confirm you get this problem of double trades on a real account and not a demo ? (I can't reproduce this issue on my demo account).

Also by checking once more your posts, I now remark this log :

Forum on trading, automated trading systems and testing trading strategies

My EA does a double entry

doshur, 2013.12.21 03:21

...

From the journal

2013.12.20 08:35:01 Trades '800****': deal #27731692 buy 0.01 EURUSD at 1.36354 done (based on order #40018327) DEAL2 - Entry 3

2013.12.20 08:35:01 Trades '800****': exchange buy 0.01 EURUSD at market placed for execution in 331 ms DEAL2 - Entry 2

2013.12.20 08:35:01 Trades '800****': deal #27731691 buy 0.01 EURUSD at 1.36353 done (based on order #40018326) DEAL 1 - Entry 3

2013.12.20 08:35:00 Trades '800****': exchange buy 0.01 EURUSD at market DEAL2 - Entry 1

2013.12.20 08:35:00 Trades '800****': exchange buy 0.01 EURUSD at market placed for execution in 313 ms DEAL1 - Entry 2

2013.12.20 08:35:00 Trades '800****': exchange buy 0.01 EURUSD at market  DEAL1 - Entry 1

If I understand correctly, it confirms that the issue is that PositionSelect() is still false, while a new position is being opened. Indeed, you can see that 1 trade results in 3 entries, and the second deal is initiated before the third entry for deal 1 arrives (confirmation of the new deal/position).

About the workaround using Sleep() function, I am not satisfy with this as there is no way to know which delay to use. Of course more this delay is great, less is the chance to get a "double trade", but still it's possible. So I am still searching a better solution.


 
angevoyageur:

About the workaround using Sleep() function, I am not satisfy with this as there is no way to know which delay to use. Of course more this delay is great, less is the chance to get a "double trade", but still it's possible. So I am still searching a better solution.

Sorry if I'm wrong as I just arrived here in this topic, but looks like this code could be a better workaround than just Sleep(), and would help identify the problem and the real necessary delay value:

bool fatalError=false; // atention: declare this as global

....

if (fatalError==false) {
  if (m_Trade.PositionOpen(Symbol(), ORDER_TYPE_BUY, LotSize, Price, 0, 0)) {
    Print("Position opened in ", Symbol());
    int maxTimeout=0;
    while (!PositionSelect(Symbol())) {
       Sleep(100);
       maxTimeout++;
       if (maxTimeout>100) {
          Print("### PositionSelect fatal error!");
          fatalError=true;
          break;
       }
    }
    Print("--> PositionSelect delay=",maxTimeout*100);
    break;
  }
}
 
angevoyageur:

Hi doshur,

No reply from ServiceDesk yet. However your issue is "disturbing" me Can you confirm you get this problem of double trades on a real account and not a demo ? (I can't reproduce this issue on my demo account).

Also by checking once more your posts, I now remark this log :

If I understand correctly, it confirms that the issue is that PositionSelect() is still false, while a new position is being opened. Indeed, you can see that 1 trade results in 3 entries, and the second deal is initiated before the third entry for deal 1 arrives (confirmation of the new deal/position).

About the workaround using Sleep() function, I am not satisfy with this as there is no way to know which delay to use. Of course more this delay is great, less is the chance to get a "double trade", but still it's possible. So I am still searching a better solution.


Yes. Im using a real account
One more trade done. No double entry. Maybe my new code works?
Documentation on MQL5: Standard Constants, Enumerations and Structures / Environment State / Account Properties
Documentation on MQL5: Standard Constants, Enumerations and Structures / Environment State / Account Properties
  • www.mql5.com
Standard Constants, Enumerations and Structures / Environment State / Account Properties - Documentation on MQL5
 
figurelli:

Sorry if I'm wrong as I just arrived here in this topic, but looks like this code could be a better workaround than just Sleep(), and would help identify the problem and the real necessary delay value:

Interesting idea. I will use it to identify the problem, but I don't like the Sleep() function Though each one is free to choose his solution.

Thank you.

Documentation on MQL5: Common Functions / Sleep
Documentation on MQL5: Common Functions / Sleep
  • www.mql5.com
Common Functions / Sleep - Documentation on MQL5
 
angevoyageur:

Interesting idea. I will use it to identify the problem, but I don't like the Sleep() function Though each one is free to choose his solution.

Thank you.

You are welcome, this solution is just a workaround, I don't like Sleep too, since you will loose ticks. Probably semaphore/flags or even state machines would be safer/efficient/elegant.
 
figurelli:
You are welcome, this solution is just a workaround, I don't like Sleep too, since you will loose ticks. Probably semaphore/flags or even state machines would be safer/efficient/elegant.
My tests with your solution show that PositionSelect() is sometime true right after PositionOpen (maxcount=0) , or false (maxcount=1). So there is obviously a delay. It would be interesting if someone can test it on a real account.
Documentation on MQL5: Standard Constants, Enumerations and Structures / Environment State / Account Properties
Documentation on MQL5: Standard Constants, Enumerations and Structures / Environment State / Account Properties
  • www.mql5.com
Standard Constants, Enumerations and Structures / Environment State / Account Properties - Documentation on MQL5