Download MetaTrader 5

EA won't send simultaneous orders in one tick (backtest)

To add comments, please log in or register
Guillermo
94
Guillermo  

Hi, I'm making an EA which can work with a set of given configurations independently. As of now, I have been testing with two differents configurations, A and B.

With configuration A alone, for a given time period, a total of 113 operations are made.
With configuration B alone, for the same time period, a total of 130 operations are made.
When working with both A and B at the same time (they are independent) a total of 240 operations are made, instead of the expected 243 (113 + 130).

There are three missing operations. Looking at the results, I have noticed that at a given exact same time, separately, A and B send the same order. But when working with both at the same time, only one order is sent.

I found this post https://forum.mql4.com/31967#318154 , but its from 2010. I'm both changing the magic number and calling RefreshRates() in each configuration, but its still sending only one order.

What am I doing wrong? I would like to avoid changing order lot size.

Thank you. 

Keith Watford
Moderator
9643
Keith Watford  
Have you written in the code to print an error report if an OrderSend fails?
Guillermo
94
Guillermo  

I wasn't doing it, but because of your comment I was able to find the error...

The thing is that I was working with a reused wrapper function of OrderSend instead of sending it directly, and that function was checking if a trade had already been opened at that time... Can you believe yesterday I spent the whole day trying to solve that issue? And it comes down to the easiest thing, which I think would have taken me much more time, since I wasn't expecting the wrapper to be checking for that...

Thank you GumRai! Have a nice day.

To add comments, please log in or register