MT5/mql5 reported and confirmed bugs.

 

I will use this topic to post reported bugs to Metaquotes in a centralized place. Please DON'T POST here without contacting me in private firstly. I don't want this topic to become garbage and polluted by useless discussion. So contact me first please, we will check together if the bug is confirmed and the bug report is correctly done. Thank you.

If you have a confirmed bug with a solid technical report about it, just post it. The bug needs to be reproducible. Fake bug, poorly detailed bug's report will be considered as spam.

Spam and posts not respecting the above rules will be deleted.

 

Build 2890. Moderate.

Using strategy tester symbol custom settings, most of the time doesn't work, at least for Margin Rate which is the setting I am currently working with.

Code attached. Using these settings :

Give this result :

Sometimes it works (first time ?) :


 

Reported by James Cater.

Build 2890 (but it's old issue). Minor.

A line is not drawn (on MT4 it is drawn).


Files:
 

Build 2890 (and previous). Moderate, but very annoying and time consuming.

You launch a backtest, you interrupt it, then you launch it again (eventually changing a parameter) and it stops immediately, with a "Disconnected" message in the log.

Actually it is doing it also when a test was finished normally.


 

Build 2875/2892.

No disk space error when there are plenty of space.


 

Reported by amrali.

Build 2895. Checked and confirmed.

Forum on trading, automated trading systems and testing trading strategies

Bug: function MathSample() does not generate correct results

amrali, 2020.12.05 02:51

The function MathSample() (defined in <Math\Stat\Math.mqh>) does not generate correct random samples.


This a fix for the include file <Math\Stat\Math.mqh>:

bool MathSample(const int &array[],const int count,int &result[])
  {
   int size=ArraySize(array);
//--- check array size
   if(size==0)
      return false;
//--- prepare target array and calculate values
   if(ArraySize(result)<count)
      if(ArrayResize(result,count)!=count)
         return(false);
   for(int i=0; i<count; i++)
     {
      ///////int ind=(int)(count-1)*MathRand()/32767;
      int ind=(int)(size*MathRand()/32768.0);
      result[i]=array[ind];
     }
//---
   return true;
  }


bool MathSample(const int &array[],const int count,const bool replace,int &result[])
  {
//--- unique values not needed
   ///////if(!replace)
   if(replace)
      return MathSample(array,count,result);
   int size=ArraySize(array);
   if(size==0 || count>size)
      return(false);
//--- prepare target array
   if(ArraySize(result)<count)
      if(ArrayResize(result,count)!=count)
         return(false);
//--- unique values needed, prepare indices
   int indices[];
/*
   MathSequenceByCount(0,count-1,count,indices);
   int swaps=size/2;
   int max_v=count-1;
   for(int i=0; i<swaps; i++)
     {
      //--- select random indices and swap them
      int ind1=(int)max_v*MathRand()/32767;
      int ind2=(int)max_v*MathRand()/32767;
      int t=indices[ind1];
      indices[ind1]=indices[ind2];
      indices[ind2]=t;
     }
*/
   MathSequenceByCount(0,size-1,size,indices);
//--- Fisher-Yates algorithm
//--- https://bost.ocks.org/mike/shuffle/compare.html
   for(int i=size-1; i > 0; --i)
     {
      //--- pick a random index j = [0, i]
      int j = (int)((i+1)*MathRand()/32768.0);
      int t=indices[i];
      indices[i]=indices[j];
      indices[j]=t;
     }
//--- select data according to indices
   for(int i=0; i<count; i++)
      result[i]=array[indices[i]];
//---
   return true;
  }

According to the online documentation:

The replace=true argument allows performing random sampling of the elements with replacement back to the original sequence.


This is a script file to test the original and fixed include files.

//+------------------------------------------------------------------+
//|                                              MathSample_test.mq5 |
//|                        Copyright 2018, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2018, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property script_show_inputs

//#include <Math\Stat\Math.mqh>
#include "Math_fix.mqh"

input int  population=9;
input int  samplesize=4;     // sample size
input bool replacement=true; // replacement (repetition is allowed)
input int  num_draws=10;     // number of draws
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnStart()
  {
   PrintFormat("MathSample(population=%i,samplesize=%i,replacement=%s)",population,samplesize,replacement?"true":"false");

//--- prepare the population array
   int array[];
   MathSequenceByCount(1,population,population,array);

//--- initialize the generator of random numbers
   MathSrand(GetTickCount()^(uint)ChartID());

//--- draw 10 simple random samples
   int result[];
   for(int i=0; i<num_draws; i++)
      if(MathSample(array,samplesize,replacement,result))
         ArrayPrint(result);
  }
//+------------------------------------------------------------------+

//sample output using the original header <Math\Stat\Math.mqh>
/*
MathSample_demo (CHFJPY,M1)   MathSample(population=9,samplesize=4,replacement=true)
MathSample_demo (CHFJPY,M1)   3 2 1 4
MathSample_demo (CHFJPY,M1)   3 2 1 4
MathSample_demo (CHFJPY,M1)   1 2 3 4
MathSample_demo (CHFJPY,M1)   2 3 1 4
MathSample_demo (CHFJPY,M1)   3 1 2 4
MathSample_demo (CHFJPY,M1)   2 1 3 4
MathSample_demo (CHFJPY,M1)   1 3 2 4
MathSample_demo (CHFJPY,M1)   3 2 1 4
MathSample_demo (CHFJPY,M1)   1 2 3 4
MathSample_demo (CHFJPY,M1)   3 2 1 4
MathSample_demo (CHFJPY,M1)   MathSample(population=9,samplesize=4,replacement=false)
MathSample_demo (CHFJPY,M1)   2 3 1 2
MathSample_demo (CHFJPY,M1)   1 2 3 2
MathSample_demo (CHFJPY,M1)   1 2 3 3
MathSample_demo (CHFJPY,M1)   3 2 1 3
MathSample_demo (CHFJPY,M1)   1 3 1 1
MathSample_demo (CHFJPY,M1)   2 3 1 1
MathSample_demo (CHFJPY,M1)   2 3 3 3
MathSample_demo (CHFJPY,M1)   2 3 1 3
MathSample_demo (CHFJPY,M1)   3 3 1 1
MathSample_demo (CHFJPY,M1)   3 2 1 3
*/

//sample output using the fixed header "Math_fix.mqh""
/*
MathSample_demo (CHFJPY,M1)   MathSample(population=9,samplesize=4,replacement=true)
MathSample_demo (CHFJPY,M1)   6 5 1 7
MathSample_demo (CHFJPY,M1)   4 2 1 6
MathSample_demo (CHFJPY,M1)   3 3 7 1
MathSample_demo (CHFJPY,M1)   9 5 4 2
MathSample_demo (CHFJPY,M1)   2 7 3 5
MathSample_demo (CHFJPY,M1)   5 3 5 4
MathSample_demo (CHFJPY,M1)   3 7 3 8
MathSample_demo (CHFJPY,M1)   9 9 4 9
MathSample_demo (CHFJPY,M1)   7 1 2 5
MathSample_demo (CHFJPY,M1)   5 7 6 5
MathSample_demo (CHFJPY,M1)   MathSample(population=9,samplesize=4,replacement=false)
MathSample_demo (CHFJPY,M1)   6 4 8 1
MathSample_demo (CHFJPY,M1)   5 1 6 9
MathSample_demo (CHFJPY,M1)   4 9 2 6
MathSample_demo (CHFJPY,M1)   1 8 4 6
MathSample_demo (CHFJPY,M1)   4 8 9 7
MathSample_demo (CHFJPY,M1)   3 8 4 7
MathSample_demo (CHFJPY,M1)   2 3 4 7
MathSample_demo (CHFJPY,M1)   1 7 3 4
MathSample_demo (CHFJPY,M1)   9 4 7 8
MathSample_demo (CHFJPY,M1)   1 9 2 5
*/

Code available in the original topic. Fixed in build 3191.

 

Forum on trading, automated trading systems and testing trading strategies

MT5/mql5 reported and confirmed bugs.

Alain Verleyen, 2021.04.23 15:37

Build 2885/2890. Minor.

In the Strategy Tester, when exporting test symbol settings, the JSon file contains a bug on "Volume limit".


Fixed in build 2896.


 

Forum on trading, automated trading systems and testing trading strategies

MT5/mql5 reported and confirmed bugs.

Alain Verleyen, 2021.04.23 17:35

Build 2890. MetaEditor. Moderate.

Profiler on real data for indicator doesn't work. It starts but do nothing when stopped.

There is no Profiler tab.
Fixed in build 2896.
 

Build 2875 and 2903.

Bug reported by @Rafael Caetano Pinto in this thread.

Account : XPMT5-Demo ( I can provide login/password).

Running a backest (Strategy Tester settings attached as a set file, but it's actually an ini, I changed the extension to be able to attach it), we got systematically this error :

2021.05.08 09:21:49.740    Core 01    not enough available memory, 1364 Mb used, 5975 Mb available, maximal available block is 5975 Mb

This memory is not allocated by the EA. The EA is using 49 symbols, by removing some of them it's possible to avoid the error. By changing the testing dates, it's also possible to avoid the error.

 
Alain Verleyen:

Build 2903, but it's an old one. MetaEditor. This is a small but very annoying bug.

The account currency in Debug settings is not saved, each time you restart MetaEditor, you have to set it again.

1. Change the currency in Tools->Options :

2. Close MetaEditor.

3. Restart MetaEditor and check the settings, it ALWAYS go back to USD.


Thank you. Fixed.

 

Forum on trading, automated trading systems and testing trading strategies

MT5/mql5 reported and confirmed bugs.

Alain Verleyen, 2021.05.08 09:47

Build 2903, but it's an old one. MetaEditor. This is a small but very annoying bug.

The account currency in Debug settings is not saved, each time you restart MetaEditor, you have to set it again.

1. Change the currency in Tools->Options :

2. Close MetaEditor.

3. Restart MetaEditor and check the settings, it ALWAYS go back to USD.


Fixed in beta build 2905.
Reason: