Download MetaTrader 5

Calculating Swap values in deposit currency

To add comments, please log in or register
Faisal Mahmood
245
Faisal Mahmood  

Hi, I am trying to calculate Swap values in deposit currency, however I find that 

MarketInfo(symbol,MODE_SWAPTYPE) has four possible values, 0 points, 1 Base, 2 Interst, 3 Margin.

 What is the best way to calculate this?

Enrico Lambino
5529
Enrico Lambino  
Faisal Mahmood:

Hi, I am trying to calculate Swap values in deposit currency, however I find that 

MarketInfo(symbol,MODE_SWAPTYPE) has four possible values, 0 points, 1 Base, 2 Interst, 3 Margin.

 What is the best way to calculate this?

The type depends on your broker. You will need the MODE_SWAPLONG and MODE_SWAPSHORT modes for MarketInfo when getting swap. Usually, the swap type used is zero, which is in points, so just multiply the value returned by tick value. But to be honest, I have not yet seen brokers which use the other methods for returning swap.
Jaume Torne
89
Jaume Torne  
   SwapTp=MarketInfo(Symbol(),MODE_SWAPTYPE);
   swapx3=SymbolInfoInteger(Symbol(),SYMBOL_SWAP_ROLLOVER3DAYS);
   string Swap_Type;
   switch(SwapTp)
     {
      case 0:
         Swap_Type="pips";
         break;
      case 1:
         Swap_Type=Symbol();
         break;
      case 2:
         Swap_Type="%";
         break;
      case 3:
         Swap_Type=AccountCurrency();
     }
   string swapx3day;
   switch(swapx3)
     {
      case 0:
         swapx3day="SUNDAY";
         break;
      case 1:
         swapx3day="MONDAY";
         break;
      case 2:
         swapx3day="TUESDAY";
         break;
      case 3:
         swapx3day="WEDNESDAY";
         break;
      case 4:
         swapx3day="THURSDAY";
         break;
      case 5:
         swapx3day="FRIDAY";
         break;
      case 6:
         swapx3day="SATURDAY";
     }
Alain Verleyen
Moderator
32396
Alain Verleyen  

Forum on trading, automated trading systems and testing trading strategies


Hello,

Please use the SRC button when you post code. Thank you.


This time, I edited it for you.


To add comments, please log in or register