Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 839

 
CHART_SCALE Scale int from 0 to 5 what it means.
 
koctja:
CHART_SCALE Scale int from 0 to 5 what it means.
Six gradations of chart scale
 

Good afternoon!

Question: is it possible with MT4 Advisor to open a csv file of 1-5GB in size, and overwrite into a new csv/txt file of the same size.

The essence is to find empty bars, mega-bars and gaps in the file with tick quotes. To correct them, and rewrite in a new file (1 year is 500-1000mb )

P.S. scripts and other stuff to work with minute quotes not to offer.

Thank you!

 
MqlDateTime time1;
datetime date=TimeCurrent();

 int h=FileOpen("test1111111.txt",FILE_WRITE|FILE_ANSI|FILE_TXT);
   if(h==INVALID_HANDLE){
      Alert("Ошибка открытия файла");
      return(-1);
   }
   TimeToStruct(date,time1);
   FileWrite(h,time1.year,time1.mon,time1.day);


The file contains 2019510

How do I add a zero to a month in a simple way without using if?

 
psyman:


The file contains 2019510

How do I add a zero to a month in a simple way without using if?

Which zero? Where to add? Can I give you an example?

 
Artyom Trishkin:

What zero? Where to add? Can you give me an example?

Writing the current date into the file, I get 2019510 instead of20190510

Perhaps there is a formatting setting, but the help does not say so.

 
psyman:

Writing the current date into the file, I get 2019510 instead of20190510

Perhaps there is a formatting option, but the help does not say so.

FileWrite(h,(string)time1.year,IntegerToString(time1.mon,2,'0'),IntegerToString(time1.day,2,'0'));
It does:
Документация по MQL5: Преобразование данных / IntegerToString
Документация по MQL5: Преобразование данных / IntegerToString
  • www.mql5.com
[in]  Длина строки. Если длина полученной строки окажется больше указанной, то строка не усекается. Если длина полученной строки окажется меньше, то полученная строка будет дополнена слева символом-заполнителем.
 
Artyom Trishkin:
It says:


Strange that filling is not done in TimeToStruct. Looking inIntegerToString I didn't think, as it's all the same what data to write to the file, thanks.

 
psyman:


The file contains 2019510

How to add zero to a month in a simple way without using if?

datetime date=TimeCurrent();
int h=FileOpen("test1111111.txt",FILE_WRITE|FILE_ANSI|FILE_TXT);
if(h==INVALID_HANDLE){
      Alert("Ошибка открытия файла");
      return(-1);
}
FileWrite(h,TimeToStr(date,TIME_DATE));

Roni Iron:

Good afternoon!

Question: is it possible with MT4 EA to open a csv file of 1-5GB in size and overwrite it into a new csv/txt file of the same size.

The idea is to find empty bars, megapips and gaps in the file with tick quotes. To correct them, and rewrite in a new file (1 year it is 500-1000mb )

P.S. scripts and other stuff to work with minute quotes not to offer.

Thank you!

Checked, you can:

1. open 2 files, one to read, the second to write and read and write at the same time

2. You can read one file into an array, process the data, then write the array into a file, but note that MT4 is 32-bit and memory for such programs is limited to 2GB, i.e. the ArrayResize() function will not allocate memory to resize the array,https://docs.mql4.com/ru/array/arrayresize

SZY: I don't offer scripts or anything like that.

 
psyman:


Strange that filling is not done in TimeToStruct. I didn't think to look for it in IntegerToString, since it doesn't matter what data is written to the file, thanks.

It's much stranger to think that 05 will be written to an int-variable instead of 5.

05 is already a display int-number - there you have to specify the format you want.

And here is an example of why you should do it yourself, as cited by Igor:

Forum on Trading, Automated Trading Systems and Testing Strategies

Any questions newbies have on MQL4, help and discussion on algorithms and codes

Igor Makanu, 2019.05.11 06:16

datetime date=TimeCurrent();
int h=FileOpen("test1111111.txt",FILE_WRITE|FILE_ANSI|FILE_TXT);
if(h==INVALID_HANDLE){
      Alert("Ошибка открытия файла");
      return(-1);
}
FileWrite(h,TimeToStr(date,TIME_DATE));

This variant will output the date already formatted. But not the way you need it(as you indicated):

Forum on trading, automated trading systems and trading strategy testing

Any questions from newbies on MQL4, help and discussion on algorithms and codes

psyman, 2019.05.10 22:14

Writing current date into file, i get 2019510 instead of20190510

Perhaps there is a formatting setting, but the help doesn't say so.

Read the format of MqlDateTime structure to understand:

Документация по MQL5: Константы, перечисления и структуры / Структуры данных / Структура даты
Документация по MQL5: Константы, перечисления и структуры / Структуры данных / Структура даты
  • www.mql5.com
Порядковый номер в году day_of_year в високосном году, начиная с марта, будет отличаться от порядкового номера соответствующего дня в невисокосном году.