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

Poker_player

Active Trader
Jul 26, 2017
10
1
29
21
1605976146157.png
here is USDJPY short open and closed at SL.

1605976193856.png
1605976214977.png
1605976230219.png

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

Administrator
Staff member
Nov 30, 2008
14,435
647
144
Odessa
www.earnforex.com
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

Active Trader
Jul 26, 2017
10
1
29
21
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.
1606066997543.png

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

Administrator
Staff member
Nov 30, 2008
14,435
647
144
Odessa
www.earnforex.com
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

Active Trader
Jul 26, 2017
10
1
29
21
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

Administrator
Staff member
Nov 30, 2008
14,435
647
144
Odessa
www.earnforex.com
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.
 

Enivid

Administrator
Staff member
Nov 30, 2008
14,435
647
144
Odessa
www.earnforex.com
They don't match because Strategy Tester doesn't use the latest swap value to calculate swaps during backtests but rather uses some unknown value. You can find that value (and check whether it is fixed) by running some backtests to take several experimental trades that last only one day (and incur only one swap payment) on several different days.