Bonjour,
Voici une variante tenant compte du détail qu'il faillait connaître le profit par jour. J'ai assumé qu'il s'agissait de la journée en cours. La fonction vérifie donc le numéro magique pour s'assurer qu'il s'agit d'un trade effectué par l'EA en question et vérifie également la date. J'ignore si tu voulais que le calcul se fasse sur les trades clôturés ou également sur ceux ouverts.
Fonction pour les trades clôturés.
Code:
double fProfitPips()
{
int iCnt;
double dProfit = 0;
for(iCnt = 0; iCnt < OrdersTotal(); iCnt++)
{
OrderSelect(iCnt, SELECT_BY_POS, MODE_HISTORY);
if(OrderMagicNumber() == iMagic && TimeDay(OrderOpenTime) == Day())
{
if(OrderType() == OP_BUY)
dProfit += (OrderClosePrice()-OrderOpenPrice())/MarketInfo(OrderSymbol(),MODE_POINT);
if(OrderType() == OP_SELL)
dProfit += (OrderOpenPrice()-OrderClosePrice())/MarketInfo(OrderSymbol(),MODE_POINT);
}
}
return(dProfit);
}
Fonction pour les trades ouverts.
Code:
double fProfitPips()
{
int iCnt;
double dProfit = 0;
for(iCnt = 0; iCnt < OrdersTotal(); iCnt++)
{
OrderSelect(iCnt, SELECT_BY_POS, MODE_TRADES);
if(OrderMagicNumber() == iMagic && TimeDay(OrderOpenTime) == Day())
{
if(OrderType() == OP_BUY)
dProfit += (Ask-OrderOpenPrice())/MarketInfo(OrderSymbol(),MODE_POINT);
if(OrderType() == OP_SELL)
dProfit += (OrderOpenPrice()-Bid)/MarketInfo(OrderSymbol(),MODE_POINT);
}
}
return(dProfit);
}
Bonne journée