CheckResultProfit always returns 0

 

Hello all

I'm learning MQL5, and in my code CheckResultProfit always return 0.

What I do is :

trade.Buy(0.1);

then after some ticks :

trade.Sell(0.1);

         int tradeResultRetcode = trade.ResultRetcode();
         Print("tradeResultRetcode=" + tradeResultRetcode);
         if (tradeResultRetcode == TRADE_RETCODE_DONE)
         {
            Print("tradeResultRetcode = TRADE_RETCODE_DONE <=> OK");
         }


After that (and the problem is even if I do it before the sell call) :

         double tradeResultProfit = trade.CheckResultProfit();
         Print("Profit = ", tradeResultProfit);


And the output is always 0.0

Please any help welcome :)

Have a nice day

Files:
 

I think this is a bug in MQL5. Maybe but I'll search more.

 
Please, provide the logs.
 
Stanislav Korotky:
Please, provide the logs.

Hi

Do you mean the logs of trades ?

 
trader77330:

Hi

Do you mean the logs of trades ?

That's a bug in Ctrade class, please report it to ServiceDesk.
 
Alain Verleyen:
That's a bug in Ctrade class, please report it to ServiceDesk.

Ok thanks for the clue.

 

I should say that in order to check the profit after a trade I use the following technique :


double balanceAfterTrade = getAccountBalance();
double balanceDiff = balanceAfterTrade - balanceBeforeTrade;

double getAccountBalance()

{

    CAccountInfo ca;

    return ca.Balance();

}

Reason: