# How much rollover (swap) will pay? Calculation example in mt5.

7

• Hi,

For the start, I'm just joined to this server and I'm an absolute newbie in forex at all. So please, don't kill me if will ask some stupid question and remember a saying "no stupid questions exists, only answers" ;) :)

So trying to learn "mql5" basics - (i have some programming background - other languages):

• using mt5
• account currency is USD
• the swap (rollover) cost is defined in points
• broker is 5-digit broker

Looking for a way, how to calculate with mql5 script the swap, (in USD cents) what i will pay when holding a position overnight.

My current mql5 script is the next:

```#include <Trade\SymbolInfo.mqh>

void OnStart() {

CSymbolInfo sym;  // symbol informations object
sym.Name( ChartSymbol() ); // get the object for the current chart symbol

if( sym.SwapMode() == SYMBOL_SWAP_MODE_POINTS) {

double lot = 0.1;

double swapUSD_long = sym.SwapLong() * 0;   // need help here
double swapUSD_short = sym.SwapShort() * 0; // need help here
// multiplied by zero only for testing - need help how to calculate the swap in USD

PrintFormat(
"symbol: %s swap_long: %.2f swap_short: %.2f swapUSD_long: %.2f swapUSD_short: %.2f",
sym.Name(),
sym.SwapLong(),
sym.SwapShort(),
swapUSD_long,
swapUSD_short
);
}
}```

When attaching the above script to for example: 'EURAUD" it prints to the terminal:

symbol: EURAUD swap_long: -10.80 swap_short: 6.80 swapUSD_long: 0.00 swapUSD_short: 0.00

so here is a 10.8 points swap for long pos. How to convert this to "USD" (my account currecy?) with mql5? For this (probably need) somewhat to get:

• calculate the point value in AUD - it is equivalent of sym.TickValue() ???
• calculate the swap value in AUD. ( point value * sym.SwapLong() )
• get the right pair with acc.curr (e.g. AUDUSD in this case) - havent idea how in mql5
• get it's rate
• and finally: swap_cost_in_usd = swap_in_aud * rate

Can someone give some insights how to do this?