Question: Difference between account basket and OrderProfit

 

Hi all,

assume that i'm trading in one pair and doing backtest with an ea.. Ea calculating current basket like the code below;


CurrentBasket=AccountEquity()-AccountBalance();


also ea calculating pair profit with codes below;


double ProfitCheck()
{
   double profit=0;
   int total  = OrdersTotal();
      for (int cnt = total-1 ; cnt >=0 ; cnt--)
      {
         OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
         if(AllSymbols)
            profit+=OrderProfit();
         else if(OrderSymbol()==Symbol())
            profit+=OrderProfit();
      }
   return(profit);        
}

the question is, after a while, basket value is getting higher than the pair profit (as i said, assume that it's only one pair in the basket, there is no another position at all).. why is this difference occurs.. I thought that may be MT4 backtest also calculates swaps and comissions so how can i add these details to the profit to make it equal to the basket?? if it's happens from a different thing, what is it and how can i fixx it??


adding a screenshot which first line is basket value and the last line is pair profit.. There is almost 22$ difference..



Thanx in advance..

 
tildenkatz: Hi all, assume that i'm trading in one pair and doing backtest with an ea.. Ea calculating current basket like the code below; also ea calculating pair profit with codes below; the question is, after a while, basket value is getting higher than the pair profit (as i said, assume that it's only one pair in the basket, there is no another position at all).. why is this difference occurs.. I thought that may be MT4 backtest also calculates swaps and comissions so how can i add these details to the profit to make it equal to the basket?? if it's happens from a different thing, what is it and how can i fixx it?? adding a screenshot which first line is basket value and the last line is pair profit.. There is almost 22$ difference..Thanx in advance..

In your code you did not factor in Commissions and Swaps — OrderCommission and OrderSwap.

 
Fernando Carreiro #:

In your code you did not factor in Commissions and Swaps — OrderCommission and OrderSwap.

Fernando, thank you for your reply;

seems like it's ok with very very small difference, thank you so much..


profit+=OrderProfit()+(OrderSwap())+(OrderCommission());



 

Total Profit is OrderProfit() + OrderSwap() + OrderCommission(). Some brokers don't use the Commission/Swap fields. Instead, they add balance entries. (Maybe related to Government required accounting/tax laws.)
          "balance" orders in account history - Day Trading Techniques - MQL4 programming forum (2017)

Broker History
FXCM Commission - <TICKET>
Rollover - <TICKET>
? >R/O - 1,000 EUR/USD @0.52
? #<ticket>  N/A
OANDA Balance update
Financing (Swap: One entry for all open orders.)
 
William Roeder #:

Total Profit is OrderProfit() + OrderSwap() + OrderCommission(). Some brokers don't use the Commission/Swap fields. Instead, they add balance entries. (Maybe related to Government required accounting/tax laws.)
          "balance" orders in account history - Day Trading Techniques - MQL4 programming forum (2017)

Broker History
FXCM Commission - <TICKET>
Rollover - <TICKET>
? >R/O - 1,000 EUR/USD @0.52
? #<ticket>  N/A
OANDA Balance update
Financing (Swap: One entry for all open orders.)
Thank you so much William..