下载MetaTrader 5
要添加评论,请登录注册
需要MetaTrader 5的移动版吗?下载它并进行交易!
leon
94
leon 2009.11.23 09:21 
哪个函数可以算出,已平仓的订单的 赢利点数,与赢利金额?
okwh
1629
okwh 2009.11.23 10:12  
OrderXXXXX()
WFBI
65
WFBI 2009.11.25 09:17  
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
/
要添加评论,请登录注册