Download MetaTrader 5

Build 482 Orderstotal() reports wrong Total

To add comments, please log in or register
Mark James Carlton
106
Mark James Carlton  

Hi All,

 

I believe i have a bug in Build 482, 

If I open an order, and do partial closes using my EA after doing these several times, OrdersTotal reports that there are NO open tickets, but there is.

Anyone had this issue, any idea how else I can know if there is an open order? 

I run over 300 MT4s at a time and rely on OrdersTotal to know if any still have open trades, this is an extremely dangerous situation for me.

I have never had this problem in 4 years until build 482.

 

Thanks

Simon Gniadkowski
Moderator
18017
Simon Gniadkowski  
Bremsford:

Hi All,

 

I believe i have a bug in Build 482, 

If I open an order, and do partial closes using my EA after doing these several times, OrdersTotal reports that there are NO open tickets, but there is.

Anyone had this issue, any idea how else I can know if there is an open order? 

I run over 300 MT4s at a time and rely on OrdersTotal to know if any still have open trades, this is an extremely dangerous situation for me.

I have never had this problem in 4 years until build 482.

Please provide a script/EA and instructions to reproduce this issue.
Mark James Carlton
106
Mark James Carlton  
RaptorUK:
Please provide a script/EA and instructions to reproduce this issue.


Thank you for the quick response, My code is complex and spread across multiple servers, so no point in giving you that. I will write something to reproduce it and send to you ASAP.

Thanks 

Mark James Carlton
106
Mark James Carlton  

Hi,

Took a while but have worked out that the order needs to be in profit for OrdersTotal() to report wrong and I also think the lot size below 0.5 but have not tested enough to confirm that bit. I have run this now 5 times and each time OrdersTotal() reports 0 orders and you can clearly see the order is still there.

I have attached 2 EA´s, the first "OrdersTotal Check.mq4", will enter an order at 1 lot, wait for it to get into profit, then on each tick, reduce the lot size by 0.01

The second EA  "OrdersTotalCheck 2.mq4", monitors orderstotal and alerts when it is 0

To load these, add "OrdersTotal Check.mq4" to a chart, once it has entered an order, open a second chart and add  "OrdersTotalCheck 2.mq4"

Then its just a matter of waiting for the order to go in to profit and watching the lot size decrease. Eventually you should get an alert to say that Orderstotal=0 and you will be able to see the order is still there.

 

Thanks

PS it will not let me add 2 files, I´ll send this then add the other 

Files:
Mark James Carlton
106
Mark James Carlton  
Second File 
Files:
Simon Gniadkowski
Moderator
18017
Simon Gniadkowski  
Bremsford:

Hi,

Took a while but have worked out that the order needs to be in profit for OrdersTotal() to report wrong and I also think the lot size below 0.5 but have not tested enough to confirm that bit. I have run this now 5 times and each time OrdersTotal() reports 0 orders and you can clearly see the order is still there.

I have attached 2 EA´s, the first "OrdersTotal Check.mq4", will enter an order at 1 lot, wait for it to get into profit, then on each tick, reduce the lot size by 0.01

The second EA  "OrdersTotalCheck 2.mq4", monitors orderstotal and alerts when it is 0

To load these, add "OrdersTotal Check.mq4" to a chart, once it has entered an order, open a second chart and add  "OrdersTotalCheck 2.mq4"

Then its just a matter of waiting for the order to go in to profit and watching the lot size decrease. Eventually you should get an alert to say that Orderstotal=0 and you will be able to see the order is still there.

I'll take a look at this properly in a little while,  but one comment,  you should not be sleeping in init(),  move the check of OrdersTotal() to start(), it is expected that  init() will execute and be returned from in a few seconds,  it has been stated by others that if this does not happen "strange things" can happen.
Mark James Carlton
106
Mark James Carlton  
RaptorUK:
I'll take a look at this properly in a little while,  but one comment,  you should not be sleeping in init(),  move the check of OrdersTotal() to start(), it is expected that  init() will execute and be returned from in a few seconds,  it has been stated by others that if this does not happen "strange things" can happen.


Thanks for the tip, my main code does not use init(), i just used in this example, so understand the point, but sure that´s not the issue

 

Thanks 

Ex Ovo Omnia
3216
Ex Ovo Omnia  

Just an idea. I did not try, though.

If I see you checking for OrdersTotal() in a loop, I would try to add RefreshRates() to the cycle. Just to ensure they did not include the OrdersTotal() to this refresh in 482.

Simon Gniadkowski
Moderator
18017
Simon Gniadkowski  
Bremsford:

Hi,

Took a while but have worked out that the order needs to be in profit for OrdersTotal() to report wrong and I also think the lot size below 0.5 but have not tested enough to confirm that bit. I have run this now 5 times and each time OrdersTotal() reports 0 orders and you can clearly see the order is still there.

I have attached 2 EA´s, the first "OrdersTotal Check.mq4", will enter an order at 1 lot, wait for it to get into profit, then on each tick, reduce the lot size by 0.01

The second EA  "OrdersTotalCheck 2.mq4", monitors orderstotal and alerts when it is 0

To load these, add "OrdersTotal Check.mq4" to a chart, once it has entered an order, open a second chart and add  "OrdersTotalCheck 2.mq4"

Then its just a matter of waiting for the order to go in to profit and watching the lot size decrease. Eventually you should get an alert to say that Orderstotal=0 and you will be able to see the order is still there.

 

Thanks

PS it will not let me add 2 files, I´ll send this then add the other 

I get the alert when the lot size is over 0.9 . . .  I suspect you may be calling OrdersTotal()  too often.
GreenMoney
379
GreenMoney  
RaptorUK:
... it is expected that  init() will execute and be returned from in a few seconds

See my test to the contrary here.

it has been stated by others that if this does not happen "strange things" can happen. 

Could you tell me where that was said and under what circumstances?  Thanks.  :)

Simon Gniadkowski
Moderator
18017
Simon Gniadkowski  
Thirteen:

See my test to the contrary here.

Could you tell me where that was said and under what circumstances?  Thanks.  :)

For example: https://www.mql5.com/en/forum/133615
123
To add comments, please log in or register