The OrdersTotal() function returns the total number of of open orders in the pool regardless of their symbol, magic number or anything else. It will therefore include open buys and sells from other EAs as well.
Originally Posted by BillR
You need to select your orders relating to just this EA and count them. You could do that through a function similar to this at the end of your code.
You would then introduce a rule to do whatever you wanted according to the value returned by this function:
int MyOrdersTotal(int Magic)
int total = OrdersTotal();
for (int cnt = 0 ; cnt < total ; cnt++)
if (OrderMagicNumber() == Magic && OrderSymbol()==Symbol())
The function will return the total open orders for this EA. You might want to modify it to just return a count of open buy or open sell orders.
if(MyOrdersTotal(Magic)==//you need to fill this in yorself;