Download MetaTrader 5

CheckResultProfit always returns 0

To add comments, please log in or register
Trade like successful traders - subscribe to their signals!
Didier Vally
264
Didier Vally 2015.07.29 11:58 

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
264
Didier Vally 2015.07.29 17:19  

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

Stanislav Korotky
17885
Stanislav Korotky 2015.07.29 19:45  
Please, provide the logs.
Didier Vally
264
Didier Vally 2015.07.30 14:38  
Stanislav Korotky:
Please, provide the logs.

Hi

Do you mean the logs of trades ?

Alain Verleyen
Moderator
30727
Alain Verleyen 2015.07.30 14:40  
trader77330:

Hi

Do you mean the logs of trades ?

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

Ok thanks for the clue.

Didier Vally
264
Didier Vally 2015.07.30 15:19  

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