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

 
Artyom Trishkin:

I never look at it either. But it does take up useful space...

However, it did come in handy.

 
Artyom Trishkin:

I never look at it either. But it does take up useful space...

No one will be shocked when first there are messages from tester about synchronisation, loading of Expert Advisor etc. with local time, and then there are messages from Expert Advisor and test trading server with test time, sometimes interspersed with messages from tester with local time?
 
Found one of the places where Tester can be accelerated. It turns out that every time Tester compares two prices (e.g. BuyLimit and Tick.ask), it does so via an expensive normalisation. There's no need to do that!
 
Slava:
Will nobody be shocked when first there are messages from tester about synchronization, loading of Expert Advisor, etc. with local time, and then there are messages from Expert Advisor and Test Trading Server with test time, sometimes interspersed with messages from the tester with local time?

Slava, I've been thinking about the best way to organise it. I wanted to suggest that the start time, synchronisation, etc. should be sent first, and then the rest - from the expert and tester with important messages.

Sounds the same to me as you suggested :)

 
fxsaber:
I found one of the places where Tester can be accelerated. It turns out that every time Tester compares two prices (e.g. BuyLimit and Tick.ask), it does so via an expensive normalization. There's no need to do that!

Prices in the Terminal history are not normalised!

bool IsNorm( const double Price )
{
  return(NormalizeDouble(Price, _Digits) == Price);
}

#define  TOSTRING(A) #A + " = " + DoubleToString(A, 16) + " "
#define  PRINT(A) Print(TOSTRING(A) + TOSTRING(NormalizeDouble(A, _Digits)))
#define  ISNORM(A) if (!IsNorm(A)) { PRINT(A); Count++; };

void OnStart()
{
  MqlTick Ticks[];
  
  const int Size = CopyTicksRange(_Symbol, Ticks, COPY_TICKS_ALL, 1000 * (long)D'2019.12.01');
  Print(Size);
  
  for (int i = 0, Count  = 0; (i < Size) && (Count < 10); i++)
  {
    ISNORM(Ticks[i].bid)
    ISNORM(Ticks[i].ask)
    ISNORM(Ticks[i].last)
  }
}


Result (EURUSD, MQ-Beta)

Ticks[i].bid = 1.1024100000000001 NormalizeDouble(Ticks[i].bid,_Digits) = 1.1024099999999999 
Ticks[i].bid = 1.1024100000000001 NormalizeDouble(Ticks[i].bid,_Digits) = 1.1024099999999999 
Ticks[i].bid = 1.1024100000000001 NormalizeDouble(Ticks[i].bid,_Digits) = 1.1024099999999999 
Ticks[i].bid = 1.1024100000000001 NormalizeDouble(Ticks[i].bid,_Digits) = 1.1024099999999999 
Ticks[i].bid = 1.1023100000000001 NormalizeDouble(Ticks[i].bid,_Digits) = 1.1023099999999999 
Ticks[i].bid = 1.1023100000000001 NormalizeDouble(Ticks[i].bid,_Digits) = 1.1023099999999999 
Ticks[i].bid = 1.1023100000000001 NormalizeDouble(Ticks[i].bid,_Digits) = 1.1023099999999999 
Ticks[i].bid = 1.1023100000000001 NormalizeDouble(Ticks[i].bid,_Digits) = 1.1023099999999999 
Ticks[i].bid = 1.1023100000000001 NormalizeDouble(Ticks[i].bid,_Digits) = 1.1023099999999999 
Ticks[i].bid = 1.1023100000000001 NormalizeDouble(Ticks[i].bid,_Digits) = 1.1023099999999999 


How is it possible? An error on the trade server side?

As a consequence, the Tester is driving EAs at crooked prices even on real symbols.


Looks like the problem is that the developers used a different normalisation algorithm.

 
Andrey Khatimlianskii:

Reproduced a bug with an empty value in the intu parameters.

1. Assemble the EA:

2. optimise on anything both parameters:

3. Uncheck enam and optimize only x:

4. Load the 1st optimization cache, then the 2nd optimization cache, run a single run from the results. Instead of -1 we get INT_MAX:


Relevant for all enums starting with -1.

There is a suspicion that when you uncheck t, input is completely disabled
and the t variable contains an uninitializedINT_MAX value instead of an empty one.

 
fxsaber:

Prices in the Terminal history are not normalised!


Result (EURUSD, MQ-Beta)


How is it possible? An error on the trade server side?

As a consequence, the Tester is driving EAs at crooked prices even on real symbols.


Sounds like the problem is that the developers used a different normalisation algorithm.

These are not crooked prices! They are quite normalised. This is very clear from your print

The trade server always uses an epsilon to compare the incoming price to the current price when trading.

Are you aware that the result of <some_real_number>*0.5 may be different from the result of <the_same_real_number>/2.0?

Are you aware that some compilers may replace one operation with another when optimizing code? Moreover, in one case it is replaced and in another case it is not, within the same project. Without declaring a war.

 
Roman:

There is a suspicion that when you uncheck t, input is completely disabled
and the t variable contains an uninitialized INT_MAX value instead of an empty one.

What the reason is inside is not important.

What is important is that they reproduce it and fix it. The bug is old.

 
Slava:

These are not crooked prices! They are quite normalised. This is very clear from your print

The price is normalized only if it passes this condition.

Forum on trading, automated trading systems and strategy tester

MetaTrader 5 strategy tester: bugs, bugs, suggestions for improvement

fxsaber, 2019.12.11 07:47

bool IsNorm( const double Price )
{
  return(NormalizeDouble(Price, _Digits) == Price);
}

The trade server always uses epsilon when trading to compare the incoming price and the current price.

It is correct that the trade server does exactly that.

Are you aware that the result <some_real_number>*0.5 may be different from the result <the_same_real_number>/2.0?

Are you aware that some compilers can replace one operation with another when optimising code? Moreover, in one case replace and in another not, within the same project. Without declaring war.

The answer to both questions is in the affirmative - I am aware.


Once again, the original prices in the Terminal are not normalized. Hence, this situation easily occurs.

Forum on trading, automated trading systems and strategy testing

Non-normalized prices in MT4

fxsaber, 2019.02.20 23:03

But the situation is much worse, and at the same time on MQ-Demo
// 15326434
// wmefo5sa
// MetaQuotes-Demo
void OnStart()
{
  const double Price1 = HistoryOrderSelect(356138100) ? HistoryOrderGetDouble(HistoryOrderGetTicket(0), ORDER_PRICE_CURRENT) : 0;
  const double Price2 = PositionSelectByTicket(356138100) ? PositionGetDouble(POSITION_PRICE_OPEN) : 0;  
  
  Print(Price1 - Price2); // -2.220446049250313e-16
}


The opening price of the current position is not equal to the price of their order/trade.