Select By Magic Number ?
Can I select orders by magic number ?
No, you select orders by Ticket Number or position in the trade pool. Then, examine the order to see if it meets other criteria.
As Phy said, you loop through the Orders Collection, look at each one & do stuff accordingly.
The function below just counts the open orders for Symbol & MagicNumber - you could adapt it for OrderClose
Good Luck
-BB-
int ActiveTradesForMagicNumber(string SymbolToCheck, int MagicNumberToCheck)
{
int icnt, itotal, retval;
retval=0;
itotal=OrdersTotal();
for(icnt=0;icnt<itotal;icnt++)
{
OrderSelect(icnt, SELECT_BY_POS, MODE_TRADES);
// check for opened position, symbol & MagicNumber
if(OrderType()<=OP_SELL && OrderSymbol()==SymbolToCheck && OrderMagicNumber()==MagicNumberToCheck)
{
retval++;
//Print("Orders opened : ",retval);
}
}
return(retval);
}
Can I select orders by magic number ?
What I want to do is that:
if order with magic number 111 has a 20 pips DD and order with magic number 333 has 22 pips in profit I want to close both orders. Is this possible ?