多张单时平所有单,所有单子保本盈利平单
double ALL_sell_Profit=0;
double ALL_buy_Profit=0;
for(int i=0;i<OrdersTotal();i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)
{
if(OrderType()==OP_SELL)
{
ALL_sell_Profit=ALL_sell_Profit+OrderProfit();
}
if(OrderType()==OP_BUY)
{
ALL_buy_Profit=ALL_buy_Profit+OrderProfit();
}
if(OrderType()>1)
{
Print("挂单");
//OrderDelete(OrderTicket());
}
}
}
Print("所有空单盈利"+DoubleToStr(ALL_sell_Profit,2));
Print("所有多单盈利"+DoubleToStr(ALL_buy_Profit,2));
页:
[1]