MetaTrader 5 Strategy Tester: bugs, bugs, suggestions for improvement - page 16

 
fxsaber:
If these are the correct formulas


The Tester calculates these figures very differently. I have striking differences in the results between these formulas and what the Tester shows (apart from the profit).

I suggest that we get to the bottom of this. The snag is exactly what MT5 considers a profitable trade.

const double Profit = OrderProfit() + OrderCommission() + OrderSwap();

Remove one, or both at once, and compare.

Or here (if above does not help) remove "="

if (Profit >= 0)
 
Slava:

What are we discussing now? Disabling agents or allowing characters to be used in testing/optimisation?

If there are two problems, we should probably discuss and solve both. Or is it impossible ?

1. Why there is a disabling of agents after optimization is done.

2. What is the reason why the automatic addition of characters to the tester is stopped?

 
Artyom Trishkin:

Remove one, or both at once, and compare.

Or here (if above doesn't help) remove "="

This is how MT5 works out

double ProfitPlus = 0;  // Профит неотрицательных закрытых позиций.
double ProfitMinus = 0; // Профит отрицательных закрытых позиций.

int AmountPlus = 0;  // Количество неотрицательных закрытых позиций.
int AmountMinus = 0; // Количество отрицательных закрытых позиций.

for (int i = OrdersHistoryTotal() - 1; i >= 0; i--)
  if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY) && (OrderType() <= OP_SELL))
  {
    const double Profit = OrderProfit()+ (OrderCommission() / 2) + OrderSwap();
    
    if (Profit >= 0)
    {
      ProfitPlus += Profit;
      AmountPlus++;
    }
    else
    {
      ProfitMinus += Profit;
      AmountMinus++;
    }      

    ProfitMinus += OrderCommission() / 2;
  }

const double PF = ProfitMinus ? -ProfitPlus / ProfitMinus : DBL_MAX; // Профит-фактор.
const double Profit = ProfitPlus + ProfitMinus;                      // Профит

I.e. in MT5 you can close a position and get a loss (the balance before opening is less than the balance after closing). But in this case the MT5-Tester (terminal has not checked) will consider this trade as profitable.


For example, MT5_PF = 1.89 and MT4_PF = 2.01.

 
fxsaber:
If these are the right formulas


The Tester calculates these figures very differently. I have striking differences in the results between these formulas and what the Tester shows (except for the profit).

I propose to make it clear. The snag is what MT5 considers a profitable trade.

Why is there a const modifier here ?

const double Profit = OrderProfit() + OrderCommission() + OrderSwap();

When this variable leaves scope, it will probably be re-initialized... imho, const is not needed


If we remove OrderCommission() + OrderSwap() ? - we're talking about profit on trades, not commission ?

SZZ: as an option, the tester can work with the balance, if the order is closed, the balance has changed, compare it with the old balance, in general, i can't guess.... , i have not found the source, but there is an articlehttps://www.mql5.com/ru/articles/4226 with the same profit calculation, but i haven't read it.

Пользовательский тестер стратегий на основе быстрых математических вычислений
Пользовательский тестер стратегий на основе быстрых математических вычислений
  • www.mql5.com
Тестер стратегий, предоставляемый MetaTrader 5, имеет мощный функционал для решения разнообразных задач. С его помощью можно тестировать как сложные стратегии торговли корзинами инструментов, так и одиночные стратегии с простыми правилами входов и выходов. Однако такой обширный функционал нам пригождается далеко не всегда. Часто нам просто...
 
Igor Makanu:

Why is there a const modifier here?

You need to calculate the Profit variable at all iterations of the loop , although it's possible that when this variable leaves the scope, it will be re-initialized... imho, you don't need const.

It will be recreated. Everything is correct there.

What if I remove OrderCommission() + OrderSwap() ? - we are talking about profit by trades, not by commission ?

MT5 formula is given above. This creates serious distortions when calculating the PF of scalping TSs. And how can it be that PF depends on the platform? It has to be unambiguous.

 
zevs1980:
This problem has already been raised by me in earlier builds branches. It was never fixed. Found my crutch. I disable some of the agents (3 of 10 in my case) and enable them after 0 iteration, and everything goes fine. Sometimes, though, some agents do stop in the process, but rarely, the solution algorithm is the same.

It's a pity, but manual steering is not an option. I have automatic optimisation.

 
KENT3004:

If there are two problems, perhaps both should be discussed and solved. Or is that impossible?

1. Why agents are disconnected after optimisation.

2. What is the reason why the automatic addition of characters to the tester is stopped?

1. See the tester logs, it's all there.

2. it's already fixed. But until you have a build with fixes, you can use drag-drop (we didn't discuss why character addition stopped, we discussed how you can still test in these conditions)

 
fxsaber:

I run single runs alternately on each custom symbol. From a certain point it is impossible to see the path to them in the Tester, but they are still selectable via drag and drop from the Market Watch. Then after a while this doesn't work either: you can select either a normal symbol, or only one custom symbol. The others are not possible. The animation below shows this situation.


Reproduced and corrected. Thank you.
 
Slava:

1. See the tester logs, it's all there.

2. it's already fixed. But until you have a build with fixes, you can use drag-drop (we didn't discuss why character addition stopped, we discussed how you can still test in these conditions)

Thanks for your promptness and helpful advice. I dare to "report" one minor but inconvenient detail. The start/stop button covers the tools/tester button, which makes you have to do extra things. Not very convenient though.
 
Edgar:
During genetic optimization I use a lot of parameters. As soon as number of variants becomes so large that it shows up in scientific notation (6.8768769e+21), optimization continues with half of agents (4 out of 8) after generation 0. No mention of this in the logs. Optimization itself runs fine, but with half load, twice as long.

The behaviour is not always reproduced, which may be why it is not being corrected. Yesterday I had it, today I don't. Maybe it depends on the EA too. I have it with frames. The size of ex5 is about 0.5 Mb. I have 8 Gb of memory. Intel i7, 4 cores, 8 threads. Divorced. Unsupervised.