How can I restrict the number of opened positions excluding pending orders

 
How can I restrict the number of opened positions not including pending orders
 
Mafeng:
How can I restrict the number of opened positions not including pending orders

Hi Mafeng,

Count them. Iterate through OrdersTotal() of opened and pending orders, using OrderSelect() and any trading function you want to use, count only opened order using OrderType() OP_BUY and OP_SELL. If the count are more or equal that what you allowed then don't open any order.

 
onewithzachy:

Hi Mafeng,

Count them. Iterate through OrdersTotal() of opened and pending orders, using OrderSelect() and any trading function you want to use, count only opened order using OrderType() OP_BUY and OP_SELL. If the count are more or equal that what you allowed then don't open any order.


how do i used the order select?

 
Mafeng:

how do i used the order select?

Hi Mafeng,

Like the answers from your previous topic https://www.mql5.com/en/forum/140389

 
Mafeng: how do i used the order select?

Use this

or