Download MetaTrader 5

CheckResultProfit always returns 0

To add comments, please log in or register
Didier Vally
156
Didier Vally  

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:
Didier Vally
156
Didier Vally  

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

Stanislav Korotky
22861
Stanislav Korotky  
Please, provide the logs.
Didier Vally
156
Didier Vally  
Stanislav Korotky:
Please, provide the logs.

Hi

Do you mean the logs of trades ?

Alain Verleyen
Moderator
33807
Alain Verleyen  
trader77330:

Hi

Do you mean the logs of trades ?

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

Ok thanks for the clue.

Didier Vally
156
Didier Vally  

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();

}

To add comments, please log in or register