# Where is my calculation mistake? Backtesting loss does not match calculation.

#### Poker_player

here is USDJPY short open and closed at SL.

So dayly swap eats 6.15 usd. Account is in usd. From jan 22 to feb 6 it has been 17 swaps.
There is no commision.
So my math is 6.15*17+52.5=157.05

but position loss is 175.48.

What am I missing?
I am not sure if swap usd per lot is changing based on usdjpy price. Maybe I should use different, not 6.15 ? How to calculate it if so?

#### Enivid

Staff member
In theory, swaps are modeled in MT4 Strategy Tester using the current rates. In practice, I noticed that they work quite well for USD pairs, but are completely off for non-USD pairs.

In your case, you have an entry price at 109.870 and exit at 109.939. Your rate-based loss is 69 points or 0.79 x 69 x 100 = 5,451 yen. This is 5,451 / 109.939 = 49.58 USD.

175.48 - 49.58 = 125.9 USD, presumably taken by the swaps.

From January 22 till February 6 is 16 days (not sure why you say 17). Let's use nominal swap (in pips) to calculate the swaps: 16 x 8.077 x 0.79 = 102.09. 102.09 x 100 / 109.939 = 92.86 USD.

Even if we adjust the swap days to 18 (because apparently January 22 is Wednesday, which is a triple-swap day), we would arrive only at 104.47 USD.

Obviously, Strategy Tester is using some other value in its calculations.

By the way, you are using a very old version of PSC - you might want to update it.

#### Poker_player

In theory, swaps are modeled in MT4 Strategy Tester using the current rates. In practice, I noticed that they work quite well for USD pairs, but are completely off for non-USD pairs.

In your case, you have an entry price at 109.870 and exit at 109.939. Your rate-based loss is 69 points or 0.79 x 69 x 100 = 5,451 yen. This is 5,451 / 109.939 = 49.58 USD.

175.48 - 49.58 = 125.9 USD, presumably taken by the swaps.

From January 22 till February 6 is 16 days (not sure why you say 17). Let's use nominal swap (in pips) to calculate the swaps: 16 x 8.077 x 0.79 = 102.09. 102.09 x 100 / 109.939 = 92.86 USD.

Even if we adjust the swap days to 18 (because apparently January 22 is Wednesday, which is a triple-swap day), we would arrive only at 104.47 USD.

Obviously, Strategy Tester is using some other value in its calculations.

By the way, you are using a very old version of PSC - you might want to update it.

I have counted many times - its 17 swaps. Where is my mistake?

About swaps off - so you mean pair which does not end with USD does incorrect swaps and nobody is fixing this? And everybody are testing with incorrect swaps? Platform is so popular, it is really weird if nobody is fixing this.

So then only way to have correct calculations is for each position to code loss calculation myself?

#### Enivid

Staff member
I have counted many times - its 17 swaps. Where is my mistake?
Your trade is closed at 06:28 on February 6 - that's before the swap is collected (24:00).

If you search MQL5 forums about the issue, you will notice the topics (like this one) discussing the issue - Strategy Tester's swaps are historically incorrect.

#### Poker_player

Your trade is closed at 06:28 on February 6 - that's before the swap is collected (24:00).

If you search MQL5 forums about the issue, you will notice the topics (like this one) discussing the issue - Strategy Tester's swaps are historically incorrect.
Yes, I did not include on feb 6 day ending.
Monday to tuesday - 1
Tuesday to wednesday - 1
wednesday to thursday - 3
next is 6:28
If I would include thursday (6), there would be 1 more. I mean would be thursday to friday swap.

They are not historically accurate, but as in the thread writes:
So your 10 year back test will use the rates of today for the whole period.
But my calculations do not match to loss size by backtest even if I use todays swap for all backtested trades.

#### Enivid

Staff member
Yes, I did not include on feb 6 day ending.
Monday to tuesday - 1
Tuesday to wednesday - 1
wednesday to thursday - 3
next is 6:28
If I would include thursday (6), there would be 1 more. I mean would be thursday to friday swap.
Yes, you are right. I miscalculated the days.

So your 10 year back test will use the rates of today for the whole period.
It looks like this is true only for USD pairs.

#### Poker_player

Yes, you are right. I miscalculated the days.

It looks like this is true only for USD pairs.
Yea. So still question is why my calculations do not match.