MT5/mql5 reported and confirmed bugs. - page 2

 

Forum on trading, automated trading systems and testing trading strategies

Bug in working with resources (#resource).

Julian Jaeger, 2021.05.05 16:58

Hi, 

I am facing an issue in working with resources (#resource) . When I include a csv as string resource, compile and then test it in the tester the string resource is only available once. After that, the string is empty unless I restart MT5 (or recompile). The problem affects only the backtest but not optimization. With optimization enabled it works. 


Looks like a bug or am I missing something? (I'm not experienced with #resource). 


Here an example that illustrates the issue (example.csv file needs to be in same folder as EA):

//+------------------------------------------------------------------+
//|                                   issue_workingWithResources.mq5 |
//|                                  Copyright 2021, MetaQuotes Ltd. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021, MetaQuotes Ltd."
#property link      "https://www.mql5.com"
#property version   "1.00"

#resource "example.csv" as string example_resource
string example_arr[];
int example_arr_size;

input bool example_setting = true;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---

   StringSplit(example_resource, '\n', example_arr); 
   example_arr_size=ArraySize(example_arr);
   if(example_arr_size > 0)
     {
       Print("example_resource contains a string: \n", example_resource);
       ArrayPrint(example_arr);
     } 
   else
     {
      Print("example_arr is empty");
      Print("example_resource contains:", example_resource);
     }
//---
   return(INIT_SUCCEEDED);
  }

//custom_max returns 1 if resource is available.
double OnTester(void)
  {
   int ret = 0;
   if(example_arr_size > 0)
     {  
       ret = 1;
     }    
   Print("example_resource contains a string: \n", example_resource);
   return(ret);
  }

Fixed in beta build 2905.

 

Build 2875/2890. Minor, but annoying.

When using the Strategy Tester symbol's custom specifications the session time settings are used and prevent to trade, though it doesn't happen with default settings.


I customizes ONLY the swap values. But I am working with a broker using Sunday candle, at some points he wants to close a trade a Sunday at 22:00 (there was a tick), and it failed :

This doesn't happen with default symbol specification (which are the same except the swaps).


As a workaround change the session time to allow trading from 21:00 for example :

Then all is working as expected.

 

Again about "no disk space in ticks generating function" error.

Build 2875/2920. Major.

Running a multi currencies EA on 28 pairs, real ticks.

All ticks taking 6.7 GB on the HDD.


113 GB available at the start. Running the test lead after some minutes to the disk being fully filled with temp files:

QG    2    20:16:22.235    Core 05    pass 16 tested with error "no disk space in ticks generating function" in 0:06:42.371 + history synchronization 0:00:31.674
JF    0    20:16:22.241    Core 05    optimization pass 16 returned to queue
GQ    0    20:16:22.244    Core 05    connection closed

And the test never ends, I had to stop it manually.

Is that normal to use so much disk space ?

 
Alain Verleyen:

Running a multi currencies EA on 28 pairs, real ticks.

All ticks taking 6.7 GB on the HDD.

113 GB available at the start. Running the test lead after some minutes to the disk being fully filled with temp files:

Is that normal to use so much disk space ?

The compression ratio in the tkc-files is more than 20. Therefore, the unpacking is more than 20 times more tkc-files.

 
fxsaber:

The compression ratio in the tkc-files is more than 20. Therefore, the unpacking is more than 20 times more tkc-files.

Thank you but I don't think that's the explanation because the disk space used is depending of the number of agents used.

I run the same test as above, but using only 1 agent.

So 6.7 GB of packed data becomes 30.8 GB unpacked ? including bars data I guess.


I also run the test but for a shorter period of time.

Which correspond to Strategy tester bases/.../ticks :

So the optimization using 6 agents use 100 GB distributed as :


 

Build 2875/2920. Major.

The Strategy Tester is calculating profit wrongly, not always, but regularly. Multi-symbols EA (28 forex symbols), running on EURUSD.

Example of an AUDUSD sell position :

It reported -474.60 EUR (account is in EUR) loss.

Let's calculate it :


From 0.71208 to 0.72293 is 0.01085, 108.5 pips or 1085 ticks (points) in loss. The volume is 0.5. It's an AUDUSD position, so USD is the profit currency, the account being EUR, we need to convert USD to EUR, so use EURUSD quote (Bid 1.13743/Ask 1.13751) at that time. That gives a tickvalue of 0.8791131...

So the position P/L is :  number of ticks x tick value x volume = -1085 * 0.8791131... * 0.5 = -476.92 EUR

MT5 returns at that time a tick value of 0.874827... which corresponds to a EURUSD quote of 1.14307 which is coming from nowhere.

This example is using Metaquotes-Demo server and 1 Minute OHLC but it happens on any server and also with real ticks.

All needed code and settings are at disposal for the developers.

 
Alain Verleyen:

Build 2875/2920. Major.

The Strategy Tester is calculating profit wrongly, not always, but regularly. Multi-symbols EA (28 forex symbols), running on EURUSD.

Example of an AUDUSD sell position :

It reported -474.60 EUR (account is in EUR) loss.

Let's calculate it :


From 0.71208 to 0.72293 is 0.01085, 108.5 pips or 1085 ticks (points) in loss. The volume is 0.5. It's an AUDUSD position, so USD is the profit currency, the account being EUR, we need to convert USD to EUR, so use EURUSD quote (Bid 1.13743/Ask 1.13751) at that time. That gives a tickvalue of 0.8791131...

So the position P/L is :  number of ticks x tick value x volume = -1085 * 0.8791131... * 0.5 = -476.92 EUR

MT5 returns at that time a tick value of 0.874827... which corresponds to a EURUSD quote of 1.14307 which is coming from nowhere.

This example is using Metaquotes-Demo server and 1 Minute OHLC but it happens on any server and also with real ticks.

All needed code and settings are at disposal for the developers.

There is special defend in the tester against endless loop of Trade or TradeTransactions events.

If TradeTransaction event fired then this event will be processed not in just time (as in real life). It can be fired one or more ticks before appropriate trade transaction

 
Slava:

There is special defend in the tester against endless loop of Trade or TradeTransactions events.

If TradeTransaction event fired then this event will be processed not in just time (as in real life). It can be fired one or more ticks before appropriate trade transaction

Thanks for this explanation.

However, that doesn't explain the problem. Here is an example, using OnTick() ONLY.

2021.05.21 12:04:06.999    Core 01    2019.01.27 22:00:01   CHFJPY: Different PROFIT at close 2019.01.27 22:00:01. BUY Volume = 0.50 Ticks = -3473 (110.269000-113.742000) Conversion symbol : EURJPY
2021.05.21 12:04:06.999    Core 01    2019.01.27 22:00:01   CHFJPY: Different PROFIT. MT5 = -1344.88 EUR Estimated tickvalue = 0.774477, conversion rate = 129.119327
2021.05.21 12:04:06.999    Core 01    2019.01.27 22:00:01   CHFJPY: Different PROFIT. Custom calculation = -1389.88 EUR Tickvalue = 0.800391 Conversion : bid = 124.939000 ask = 124.948000 at 2019.01.25 21:57:55

The difference is huge, sometimes it's small, sometimes there are no difference.

Details and code at disposal.

 

Forum on trading, automated trading systems and testing trading strategies

MT5/mql5 reported and confirmed bugs.

Alain Verleyen, 2021.05.14 13:23

Build 2875/2890. Minor, but annoying.

When using the Strategy Tester symbol's custom specifications the session time settings are used and prevent to trade, though it doesn't happen with default settings.


I customizes ONLY the swap values. But I am working with a broker using Sunday candle, at some points he wants to close a trade a Sunday at 22:00 (there was a tick), and it failed :

This doesn't happen with default symbol specification (which are the same except the swaps).


As a workaround change the session time to allow trading from 21:00 for example :

Then all is working as expected.

Fixed on build 2940, by enabling session checking in all cases (so for "standard" symbols and custom symbols).

 

MT5 build 3021 beta, Strategy Tester with "Random delay", wrongly trigger requote error. MeteQuotes-demo server.

Instant execution is used, so "Deviation" parameter should work and requote only occurs when the maximum deviation (100 points) is exceeded.

But a slippage of 6 points results in a requote. This is a bug.