MT5/mql5 reported and confirmed bugs. - page 9

 
Alain Verleyen #:

Annoying bug with ME 3211, using the debugger with some Watches.

We get "Expression could not be evaluated" with a Watch on a class member, though using "this" the value can be seen.

The problem is somehow related to the presence of public member (string, static ?). If one of them is commented, then the watch value is ok.

Code attached.

I confirm it's fixed in beta 3247.
 

I won't call this a bug because i may be missing something (in computer science in general) but here goes : 

i downloaded about 220 million ticks stored in MqlTick array on Mt5 .

I open a bin file FILE_WRITE|FILE_BIN (just those) and call FileWriteArray(file_handle,tick,0,WHOLE_ARRAY) (or ArraySize() instead of WHOLE_ARRAY)

I use FileClose at the end , i don't call FileFlush .

The output file contains 7 million entries only

Thank you

 
Lorentzos Roussos #:

I won't call this a bug because i may be missing something (in computer science in general) but here goes : 

i downloaded about 220 million ticks stored in MqlTick array on Mt5 .

I open a bin file FILE_WRITE|FILE_BIN (just those) and call FileWriteArray(file_handle,tick,0,WHOLE_ARRAY) (or ArraySize() instead of WHOLE_ARRAY)

I use FileClose at the end , i don't call FileFlush .

The output file contains 7 million entries only

Thank you

You should probably read the initial post before posting here.

No code, no log, no data, no screenshot, no procedure. That's not a bug report and it's not the place to post here.

 
Alain Verleyen #:

You should probably read the initial post before posting here.

No code, no log, no data, no screenshot, no procedure. That's not a bug report and it's not the place to post here.

Sorry . Here's the data :

Simplified : 

There seems to be a size cutoff when writing a structures array with write array to a file . 

here is the code (takes time , writes gigabytes ) 

enum rm{runmode_write=0,//WRITE
runmode_read=1//READ
};
input rm runmode=runmode_write;//Run mode : 
input int items=22000000;//items : 
bool tested=false,has_timer=false;
//test structure 
  struct test_structure
  {
  datetime time;
  int      i;
  double   price;
           test_structure(void){reset();}
      void reset(){time=0;i=0;price=0.0;}
      void set(datetime _time,int _i,double _price){time=_time;i=_i;price=_price;}
      void save(int file_handle){
           FileWriteLong(file_handle,time);
           FileWriteInteger(file_handle,i,INT_VALUE);
           FileWriteDouble(file_handle,price);
           }
      void load(int file_handle){
           reset();
           time=(datetime)FileReadLong(file_handle);
           i=(int)FileReadInteger(file_handle);
           price=(double)FileReadDouble(file_handle);
           }
  };
  test_structure TEST_STRUCT[];
  double         TEST_DOUBLE[];
int OnInit()
  {
  has_timer=EventSetMillisecondTimer(140);
  if(!has_timer){Alert("can't set timer");return(INIT_FAILED);} 
  return(INIT_SUCCEEDED);
  }

void OnTimer()
  {
  /*
  Test premise : 
  step 1 : save a ton of data by calling Write Array on both the structure and the primitive array
  step 2 : save a ton of data by calling save on each item individually
  step 3 : (recompile with appropriate switch) read those files and return the array sizes 
  So , our switch 0 is write , 1 is read
  */
  EventKillTimer();
  int sweets=(int)runmode;
  //our filenames 
    string folder="ForumTest";
    string array_save_name="ArraySave";
    string per_item_save_name="EachItemSave";
    string structure_name="_Struct";
    string primitive_name="_Double";
    string extention=".box";
    
    string message="You are about to run write mode , continue ?";
    if(sweets==1){message="You are about to run read mode , continue ?";}
    int resp=MessageBox(message,"Hi",MB_YESNO);
    if(resp==IDNO){sweets=2;Print("Aborted");ExpertRemove();}
  //save
    if(sweets==0){
    //fill up our data 
      //roll around in bars until fill
        int this_chart_bars=iBars(_Symbol,_Period);
          //rates 
          MqlRates rates[];
          int pullrates=CopyRates(_Symbol,_Period,0,this_chart_bars,rates);        
        if(this_chart_bars<1000||pullrates<1000){
        Alert("Low # of bars");
        ExpertRemove();
        }
        else{
        int i=0;
        int f=0;
        //presize 
        ArrayResize(TEST_DOUBLE,items,0);
        ArrayResize(TEST_STRUCT,items,0);
        //fill 
          while(f<items){
          Comment("Collecting "+IntegerToString(f)+"/"+IntegerToString(items));
          i++;
          if(i>this_chart_bars){i=1;}
          f++;
          TEST_DOUBLE[f-1]=rates[i-1].close;
          TEST_STRUCT[f-1].set(rates[i-1].time,i-1,rates[i-1].close);          
          }
        //fill ends here 
        //1.Write with Write Array 
          Comment("Saving 1a");
          //1a :: the double array
            string location=folder+"\\"+array_save_name+primitive_name+extention;
            if(FileIsExist(location)){FileDelete(location);}
            int fh=FileOpen(location,FILE_WRITE|FILE_BIN);
            if(fh!=INVALID_HANDLE){
            FileWriteArray(fh,TEST_DOUBLE,0,WHOLE_ARRAY);
            FileClose(fh);
            }else{Print("Cannot create file : "+location);}
          Comment("Saving 1b");  
          //1b :: the struct array 
            location=folder+"\\"+array_save_name+structure_name+extention;
            if(FileIsExist(location)){FileDelete(location);}
            fh=FileOpen(location,FILE_WRITE|FILE_BIN);
            if(fh!=INVALID_HANDLE){
            FileWriteArray(fh,TEST_STRUCT,0,WHOLE_ARRAY);
            FileClose(fh);
            }else{Print("Cannot create file : "+location);}
        //2.Write with Each Item individually 
          Comment("Saving 2a");
          //2a :: the double array 
            location=folder+"\\"+per_item_save_name+primitive_name+extention;
            if(FileIsExist(location)){FileDelete(location);}
            fh=FileOpen(location,FILE_WRITE|FILE_BIN);
            if(fh!=INVALID_HANDLE){
            FileWriteInteger(fh,ArraySize(TEST_DOUBLE),INT_VALUE);
            for(int j=0;j<ArraySize(TEST_DOUBLE);j++){
            FileWriteDouble(fh,TEST_DOUBLE[j]);}
            FileClose(fh);
            }else{Print("Cannot create file : "+location);}            
          //2b :: the struct array 
           Comment("Saving 2b");
            location=folder+"\\"+per_item_save_name+structure_name+extention;
            if(FileIsExist(location)){FileDelete(location);}
            fh=FileOpen(location,FILE_WRITE|FILE_BIN);
            if(fh!=INVALID_HANDLE){
            FileWriteInteger(fh,ArraySize(TEST_STRUCT),INT_VALUE);
            for(int j=0;j<ArraySize(TEST_STRUCT);j++){
            TEST_STRUCT[j].save(fh);}
            FileClose(fh);
            }else{Print("Cannot create file : "+location);}             
        }
    Print("WRITE MODE FINISHED");ExpertRemove();
    }//save ends here 
  //read  
    else if(sweets==1){
    //1 read array    w primitive
    Comment("Loading 1");
      string location=folder+"\\"+array_save_name+primitive_name+extention;
      if(FileIsExist(location)){
      int fh=FileOpen(location,FILE_READ|FILE_BIN);
      if(fh!=INVALID_HANDLE){
      FileReadArray(fh,TEST_DOUBLE,0,WHOLE_ARRAY);
      Print("TEST_DOUBLE "+IntegerToString(ArraySize(TEST_DOUBLE))+" items with read array");
      FileClose(fh);
      }else{Print("Cannot open file "+location);}
      }else{Print("File "+location+" does not exist");}
    //2 per item read w primitive
    Comment("Loading 2");
      ArrayFree(TEST_DOUBLE);
      location=folder+"\\"+per_item_save_name+primitive_name+extention;
      if(FileIsExist(location)){
      int fh=FileOpen(location,FILE_READ|FILE_BIN);
      if(fh!=INVALID_HANDLE){
      int total=(int)FileReadInteger(fh,INT_VALUE);
      if(total>0){ArrayResize(TEST_DOUBLE,total,0);
      for(int j=0;j<total;j++){
      TEST_DOUBLE[j]=(double)FileReadDouble(fh);}}
      Print("TEST DOUBLE read "+IntegerToString(ArraySize(TEST_DOUBLE))+" items, read individually");
      FileClose(fh);
      }else{Print("Cannot open file "+location);}
      }else{Print("File "+location+" does not exist");}    
    //3 read array    w structure
    Comment("Loading 3");
      location=folder+"\\"+array_save_name+structure_name+extention;
      if(FileIsExist(location)){
      int fh=FileOpen(location,FILE_READ|FILE_BIN);
      if(fh!=INVALID_HANDLE){
      FileReadArray(fh,TEST_STRUCT,0,WHOLE_ARRAY);
      Print("TEST_STRUCT "+IntegerToString(ArraySize(TEST_STRUCT))+" items with read array");
      FileClose(fh);
      }else{Print("Cannot open file "+location);}
      }else{Print("File "+location+" does not exist");}      
    //4 per item read w structure
    Comment("Loading 4");
      ArrayFree(TEST_STRUCT);
      location=folder+"\\"+per_item_save_name+structure_name+extention;
      if(FileIsExist(location)){
      int fh=FileOpen(location,FILE_READ|FILE_BIN);
      if(fh!=INVALID_HANDLE){
      int total=(int)FileReadInteger(fh,INT_VALUE);
      if(total>0){ArrayResize(TEST_STRUCT,total,0);
      for(int j=0;j<total;j++){TEST_STRUCT[j].load(fh);}}
      Print("TEST_STRUCT "+IntegerToString(ArraySize(TEST_STRUCT))+" items, read individually");
      FileClose(fh);
      }else{Print("Cannot open file "+location);}
      }else{Print("File "+location+" does not exist");}        
    Print("READ MODE FINISHED");ExpertRemove();
    }
  }

void OnDeinit(const int reason)
  {
  if(has_timer){EventKillTimer();}   
  ArrayFree(TEST_DOUBLE);
  ArrayFree(TEST_STRUCT);
  }
void OnTick(){}
void OnChartEvent(const int id,const long &lparam,const double &dparam,const string &sparam){}

And some screenshots so you don't have to run the code :

Array Save Double is the file written with WriteArray on array of double type

Array Save Struct is the file written with WriteArray on array of struct type

Each Item Save Double is the file written by saving each item in the array (write double in this case)

Each Item Save Struct is the file written by saving each struct in the array in sequence 

Build 3211 

Cheers

 
Lorentzos Roussos #:

Sorry . Here's the data :

Build 3211

b3250.

You are about to run read mode , continue ?
TEST_DOUBLE 22000000 items with read array
TEST DOUBLE read 22000000 items, read individually
TEST_STRUCT 22000000 items with read array
TEST_STRUCT 22000000 items, read individually
READ MODE FINISHED
 
fxsaber #:

b3250.

My results are the same as yours.

 
fxsaber #:

b3250.

Yes 22 million items works on 3211 too .

If you have 40mins and 8gigs try 220 million

 
Lorentzos Roussos #:

try 220 million

Error localization: https://www.mql5.com/ru/forum/392424/page3#comment_30105762

 
amrali #:

MQL5 implements a bad historic algorithm for conversion double -> str. That is why the forum is full of questions about floating point numbers weirdness.

Here is a proof of my point of view that it is as bug in the implementaion

I don't think you are right. Most of such problems occur because people transfer their understanding of numbers based on the natural numbers to the implementation of real numbers on a PC.
Your problem is furthermore not urgent (it will probably not change), as there are methods to intercept the problems of the number conversion - one must understand just the respective number basis.

 
Carl Schreiber #:

I don't think you are right. Most of such problems occur because people transfer their understanding of numbers based on the natural numbers to the implementation of real numbers on a PC.
Your problem is furthermore not urgent (it will probably not change), as there are methods to intercept the problems of the number conversion - one must understand just the respective number basis.

FYI, String() function implementation was changed according to my suggestions.

Thanks