Build 482 Orderstotal() reports wrong Total - page 2

 

I have several EAs that loop in init() for weeks and I never experienced anything strange. Except that editor bug, which crashes every looped EA during compile. 

 
Bremsford:


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 have build 482 installed and OrdersTotal() reports the correct number of open (pending and market) orders.

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 

I agree with RaptorUK.  Init() is not the correct place for the code that is in OrdersTotalCheckc2.mq4.  If you are using that code, place it in start() and remove the while operator and sleep() so the code is processed on each tick.

Regarding your OrderClose() loop in OrdersTotalrCheck.mq4, you should read Loops and Closing or Deleting Orders.  Your loop needs to count down, not up.

Also, read What are Function return values ? How do I use them ?.  How do you know your OrderClose() succeeds or fails without checking the return code?

Just one last thing: no need to call MarketInfo() to get the ask and bid prices and digits for the current symbol.  Those values are stored in the predefined variables Ask, Bid, and Digits.

 
Thirteen:

I have build 482 installed and OrdersTotal() reports the correct number of open (pending and market) orders.

I agree with RaptorUK.  Init() is not the correct place for the code that is in OrdersTotalCheckc2.mq4.  If you are using that code, place it in start() and remove the while operator and sleep() so the code is processed on each tick.

Regarding your OrderClose() loop in OrdersTotalrCheck.mq4, you should read Loops and Closing or Deleting Orders.  Your loop needs to count down, not up.

Also, read What are Function return values ? How do I use them ?.  How do you know your OrderClose() succeeds or fails without checking the return code?

Just one last thing: no need to call MarketInfo() to get the ask and bid prices and digits for the current symbol.  Those values are stored in the predefined variables Ask, Bid, and Digits.


The code is only an example of showing that OrdersTotal() in Build 482 returns the wrong value. This does not happen in any other build I have used over the last 4 years. This code is not used in live. But does prove that OrdersTotal() fails. As I explained earlier the loop in Init() is not the issue.

I do not care if the part close failed, its only to prove OrdersTotal() fails.

 

Thanks 

 
Bremsford:


The code is only an example of showing that OrdersTotal() in Build 482 returns the wrong value. 

What other builds have you tried your test code with ?
 
Bremsford: As I explained earlier the loop in Init() is not the issue.

It IS an issue. Just because you use to get away with it doesn't mean you can with this build or a future build. Don't violate the documentation and complain about things not working.

At a minimum, you are combining issues. Solve the issue pointed. THEN retest and verify and show us.

 
RaptorUK:
What other builds have you tried your test code with ?


I have not used the test code on any other build, only my live code

 

Thanks

 
WHRoeder:

It IS an issue. Just because you use to get away with it doesn't mean you can with this build or a future build. Don't violate the documentation and complain about things not working.

At a minimum, you are combining issues. Solve the issue pointed. THEN retest and verify and show us.


Point taken, I have changed the code and will retest on Monday

 

Thanks

 
Bremsford:


Point taken, I have changed the code and will retest on Monday

I moved the code to within start() and the same symptom happened,  then I changed it so that OrdersTotal() was called just once per tick and the symptom went away . . .  I'll test your original code with an earlier build on Sunday night,  I suggest you do the same.
 
RaptorUK:
I moved the code to within start() and the same symptom happened,  then I changed it so that OrdersTotal() was called just once per tick and the symptom went away . . .  I'll test your original code with an earlier build on Sunday night,  I suggest you do the same.


Thank you, I will do that.

 

Thanks

 
RaptorUK:
I moved the code to within start() and the same symptom happened,  then I changed it so that OrdersTotal() was called just once per tick and the symptom went away . . .  I'll test your original code with an earlier build on Sunday night,  I suggest you do the same.

I just tested this on Build 445 and I am still occasionally getting the Alerts,  I am using your original code.  

Perhaps the 2 EAs are getting in each others way,  when the OrderClose() happens on the server the locally held information about the open trade has to be updated,  if OrdersTotal() is called while the information is being updated then perhaps this is when the issue occurs . . .  I did notice that the Alert only happened while the trade was in profit and the trade was being partially closed.

Reason: