Comparing 2 ways to delete pending order

 

Hi,

I opened 2 pending order and after the other is filled I want to delete the other one. To do so,

1. I loop into PositionsTotal() and finding if there's an open trade,
2. loop into OrdersTotal() and delete it if there's an open position.

While I looked into the internet I found another way to do it, it compares Balance and Equity.

By doing this, if there's one pending order being filled then the balance and equity would not be equal and delete the pending order. Has anyone using this kind of way and does this has disadvantage over my way?

//comparing account balance and equity balance
if(AccountInfoDouble(ACCOUNT_BALANCE) != AccountInfoDouble(ACCOUNT_EQUITY)
        //delete pending order HERE
 
Luandre Ezra:

Hi,

I opened 2 pending order and after the other is filled I want to delete the other one. To do so,

1. I loop into PositionsTotal() and finding if there's an open trade,
2. loop into OrdersTotal() and delete it if there's an open position.

While I looked into the internet I found another way to do it, it compares Balance and Equity.

By doing this, if there's one pending order being filled then the balance and equity would not be equal and delete the pending order. Has anyone using this kind of way and does this has disadvantage over my way?

The account information is global so you cannot be sure which instance of the EA( in case multiple are running ) opened a position. So I won't use that method.
 
Navdeep Singh #:
The account information is global so you cannot be sure which instance of the EA( in case multiple are running ) opened a position. So I won't use that method.

I see I forgot about that. Thanks for the answer

Reason: