Can't get swap fees in percentage terms

 

Hi,


I have issues to get swap fees in percentage terms when using the strategy tester. Everything is fine with swap fees in points though.


As an exemple, here are two transactions I performed "in real" (with a demo account):

(see transactions.png)


For both symbols (gold with swap fees in points and [nq100] with swap fees in percentage terms) I bought a volume of 25 on 15/06/2021 that I sold on 16/06/2021. Swap fees appear (-404.25 for gold and -30.43 for [nq100]).


I created a program (see below) that reproduces these two transactions (at more or less the same time but profit does not matter). Here is what I get:


gold: (see GOLD.png)


[nq100]: (see nq100.png)


While the swap fees is the same for gold (in points) there is nothing in percentage terms.


Do you have any idea where this can come from, or if this is a bug in MT?


Many thanks.


Program that reproduces the transactions:

Program that reproduces the transactions:
#include <Trade\Trade.mqh>

bool positionOpened = false;
CTrade trade;

//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
   MqlTick tick;
   SymbolInfoTick(_Symbol, tick);

   MqlDateTime time;
   TimeToStruct(tick.time, time);

// Open position on May 10
   if(time.mon == 6 && time.day == 15 && time.hour == 14 && time.min == 48 && !positionOpened)
     {
      bool openSuccessed = trade.PositionOpen(_Symbol, ORDER_TYPE_BUY, 25, tick.ask, 0, 0);
      if(openSuccessed)
        {
         positionOpened = true;
        }
     }

// Close position on May 20
   if(time.mon == 6 && time.day == 16 && time.hour == 15 && time.min == 03 && positionOpened)
     {
      bool closeSuccessed = trade.PositionClose(_Symbol);
      if(closeSuccessed)
        {
         positionOpened = false;
        }
     }
  }

//+------------------------------------------------------------------+
//| TradeTransaction function                                        |
//+------------------------------------------------------------------+
void OnTradeTransaction(const MqlTradeTransaction& trans,
                        const MqlTradeRequest& request,
                        const MqlTradeResult& result)
  {
   ulong dealTicket = trans.deal;

   ulong position = trans.position;
   bool positionSelected = HistorySelectByPosition(position);

   long entry = HistoryDealGetInteger(dealTicket, DEAL_ENTRY);
   double swap = HistoryDealGetDouble(dealTicket, DEAL_SWAP);
   double profit = HistoryDealGetDouble(dealTicket, DEAL_PROFIT);

// Print position results when it gets closed
   if(entry == DEAL_ENTRY_OUT)
     {
      Print("Profit = " + DoubleToString(profit));
      Print("Swap Fee = " + DoubleToString(swap));
     }

  }
//+------------------------------------------------------------------+

Files:
GOLD.png  28 kb
nq100.png  33 kb
Reason: