//+------------------------------------------------------------------+
//平盈利
//+------------------------------------------------------------------+
void sub_closeprofit()
{
int totalOrders = OrdersTotal();
bool result;
for(int i = totalOrders - 1; i >= 0; i--)
{
if(OrderSelect(i, SELECT_BY_POS,MODE_TRADES))
{
if(OrderSymbol() == Symbol())
{
int type = OrderType();
RefreshRates();
switch(type)
{
case OP_BUY : if ( (OrderProfit()+OrderCommission()+) >0.01 ) result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), slippage);
continue;
case OP_SELL : if ( (OrderProfit()+OrderCommission()+) >0.01 ) result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), slippage);
}
}
}
}
} |