哪个函数可以算出,已平仓的订单的 赢利点数,与赢利金额?
OrderXXXXX()
int CheckProfits(double lots, int Goal, bool Current, double InitialPrice)
{
int profit=0, cpt;
if(Current)//return current profit
{
for(cpt=0;cpt<OrdersTotal();cpt++)
{
OrderSelect(cpt, SELECT_BY_POS, MODE_TRADES);
if(OrderSymbol()==Symbol() && StrToDouble(OrderComment())==InitialPrice)
{
if(OrderType()==OP_BUY) profit+=(Bid-OrderOpenPrice())/Point*OrderLots()/lots;
if(OrderType()==OP_SELL) profit+=(OrderOpenPrice()-Ask)/Point*OrderLots()/lots;
}
}
return(profit);
}
else
{
if(Goal==OP_BUY)
{
for(cpt=0;cpt<OrdersTotal();cpt++)
{
OrderSelect(cpt, SELECT_BY_POS, MODE_TRADES);
if(OrderSymbol()==Symbol() && StrToDouble(OrderComment())==InitialPrice)
{
if(OrderType()==OP_BUY) profit+=(OrderTakeProfit()-OrderOpenPrice())/Point*OrderLots()/lots;
if(OrderType()==OP_SELL) profit-=(OrderStopLoss()-OrderOpenPrice())/Point*OrderLots()/lots;
if(OrderType()==OP_BUYSTOP) profit+=(OrderTakeProfit()-OrderOpenPrice())/Point*OrderLots()/lots;
}
}
return(profit);
}
else
{
for(cpt=0;cpt<OrdersTotal();cpt++)
{
OrderSelect(cpt, SELECT_BY_POS, MODE_TRADES);
if(OrderSymbol()==Symbol() && StrToDouble(OrderComment())==InitialPrice)
{
if(OrderType()==OP_BUY) profit-=(OrderOpenPrice()-OrderStopLoss())/Point*OrderLots()/lots;
if(OrderType()==OP_SELL) profit+=(OrderOpenPrice()-OrderTakeProfit())/Point*OrderLots()/lots;
if(OrderType()==OP_SELLSTOP) profit+=(OrderOpenPrice()-OrderTakeProfit())/Point*OrderLots()/lots;
}
}
return(profit);
}
}
}
有 不了解的的地方请联系QQ:1031130533
{
int profit=0, cpt;
if(Current)//return current profit
{
for(cpt=0;cpt<OrdersTotal();cpt++)
{
OrderSelect(cpt, SELECT_BY_POS, MODE_TRADES);
if(OrderSymbol()==Symbol() && StrToDouble(OrderComment())==InitialPrice)
{
if(OrderType()==OP_BUY) profit+=(Bid-OrderOpenPrice())/Point*OrderLots()/lots;
if(OrderType()==OP_SELL) profit+=(OrderOpenPrice()-Ask)/Point*OrderLots()/lots;
}
}
return(profit);
}
else
{
if(Goal==OP_BUY)
{
for(cpt=0;cpt<OrdersTotal();cpt++)
{
OrderSelect(cpt, SELECT_BY_POS, MODE_TRADES);
if(OrderSymbol()==Symbol() && StrToDouble(OrderComment())==InitialPrice)
{
if(OrderType()==OP_BUY) profit+=(OrderTakeProfit()-OrderOpenPrice())/Point*OrderLots()/lots;
if(OrderType()==OP_SELL) profit-=(OrderStopLoss()-OrderOpenPrice())/Point*OrderLots()/lots;
if(OrderType()==OP_BUYSTOP) profit+=(OrderTakeProfit()-OrderOpenPrice())/Point*OrderLots()/lots;
}
}
return(profit);
}
else
{
for(cpt=0;cpt<OrdersTotal();cpt++)
{
OrderSelect(cpt, SELECT_BY_POS, MODE_TRADES);
if(OrderSymbol()==Symbol() && StrToDouble(OrderComment())==InitialPrice)
{
if(OrderType()==OP_BUY) profit-=(OrderOpenPrice()-OrderStopLoss())/Point*OrderLots()/lots;
if(OrderType()==OP_SELL) profit+=(OrderOpenPrice()-OrderTakeProfit())/Point*OrderLots()/lots;
if(OrderType()==OP_SELLSTOP) profit+=(OrderOpenPrice()-OrderTakeProfit())/Point*OrderLots()/lots;
}
}
return(profit);
}
}
}
有 不了解的的地方请联系QQ:1031130533