多单全部平仓的写法
函数执行多单全部平仓。void CloseBuys(int MagicNumber, int Slippage)
{
for(int i = 0; i < OrdersTotal(); i++)
{
// already closed
if(OrderSelect(i, SELECT_BY_POS) == false) continue;
// not current symbol
if(OrderSymbol() != Symbol()) continue;
// order was opened in another way
if(OrderMagicNumber() != MagicNumber) continue;
if(OrderType() == OP_BUY)
{
if(OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, Blue))
{
i--;
}
RefreshRates();
}
}
}
页:
[1]