Good afternoon. Question about a file pointer... In the MQL4 book, found at MQL4.community, in the "Standard Functions" section, there is an example of the script "File Operations", which is intended for reading data from a file and displaying graphical objects in a symbol window:
//--------------------------------------------------------------------// timetablenews.mq4// Предназначен для использования в качестве примера в учебнике MQL4.//--------------------------------------------------------------- 1 --int start() // Спец. функция start
{
//--------------------------------------------------------------- 2 --int Handle, // Файловый описатель
Stl; // Стиль вертикальной линииstring File_Name="News.csv", // Имя файла
Obj_Name, // Bмя объекта
Instr, // Название валюты
One,Two, // 1я и 2я чать названия инстр.
Text, // Текст описания события
Str_DtTm; // Дата и время события(строка)datetime Dat_DtTm; // Дата и время события(дата)color Col; // Цвет вертикальной линии//--------------------------------------------------------------- 3 --
Handle=FileOpen(File_Name,FILE_CSV|FILE_READ,";");// Открытие файлаif(Handle<0) // Неудача при открытии файла
{
if(GetLastError()==4103) // Если файла не существует,..Alert("Нет файла с именем ",File_Name);//.. извещаем трейдера else// При любой другой ошибке..Alert("Ошибка при открытии файла ",File_Name);//..такое сообщPlaySound("Bzrrr.wav"); // Звуковое сопровождениеreturn; // Выход из start()
}
//--------------------------------------------------------------- 4 --while(FileIsEnding(Handle)==false)// До тех пор, пока файловый ..
{ // ..указатель не в конце файла//--------------------------------------------------------- 5 --
Str_DtTm =FileReadString(Handle);// Дата и время события(дата)
Text =FileReadString(Handle);// Текст описания событияif(FileIsEnding(Handle)==true) // Файловый указатель в концеbreak; // Выход из чтения и рисования//--------------------------------------------------------- 6 --
Dat_DtTm =StrToTime(Str_DtTm); // Преобразование типа данных
Instr =StringSubstr(Text,0,3);// Извлекаем первые 3 символа
One=StringSubstr(Symbol(),0,3);// Извлекаем первые 3 символа
Two=StringSubstr(Symbol(),3,3);// Извлекаем вторые 3 символа
Stl=STYLE_DOT; // Для всех - стиль пунктир
Col=DarkOrange; // Для всех - цвет такойif(Instr==One || Instr==Two) // А для событий по нашему ..
{ // .. финансовому инструменту..
Stl=STYLE_SOLID; // .. такой стиль..
Col=Red; // .. и такой цвет верт. линии
}
//--------------------------------------------------------- 7 --
Obj_Name="News_Line "+Str_DtTm; // Имя объектаObjectCreate(Obj_Name,OBJ_VLINE,0,Dat_DtTm,0);//Создаем объект..ObjectSet(Obj_Name,OBJPROP_COLOR, Col); // ..и его цвет,..ObjectSet(Obj_Name,OBJPROP_STYLE, Stl); // ..стиль..ObjectSetText(Obj_Name,Text,10); // ..и описание
}
//--------------------------------------------------------------- 8 --FileClose( Handle ); // Закрываем файлPlaySound("bulk.wav"); // Звуковое сопровождениеWindowRedraw(); // Перерисовываем объектыreturn; // Выход из start()
}
//--------------------------------------------------------------- 9 --
Below, when analyzing this script in the Book on MQL4, the following phrase is given: "if the specified check (the last 2 lines in block 5-6) is removed, an extra object will be created at runtime. And only after that, the while loop's termination condition will trigger and control will be passed to block 8-9".
Do I understand it correctly? A file pointer is NOT INFLOWED BY TEXT SIGNS (for example: text| where | is a file pointer), but is a pointer WITH EXPRESSION, for example: text where k is the "to" character, k-th is highlighted by a file pointer. This explains the need for strings (see p.164):
if(FileIsEnding(Handle)==true) // Файловый указатель в концеbreak; // Выход из чтения и рисования//--------------------------------------------------------- 6 --
Indeed. On penultimate iteration, after creating LAST object
2007.05.11 18:30;JPY
the file pointer is at the position of the last object, i.e:
2007.05.11 18:30;JPY IndustrialManufacture
(where o is the "o" character, k is the file index). Then when passing control to while statement header, FileIsEnding(handle) function will obviously return true, because file pointer is NOT at end of file, but at LAST character of that file. Then when the first two lines are executed, the file pointer will move to empty space and if there are no lines
if(FileIsEnding(Handle)==true) // Файловый указатель в концеbreak; // Выход из чтения и рисования//--------------------------------------------------------- 6 --
the script will create a graphic (i.e. a line) with an empty description and a time coordinate that corresponds to 0. This is what is meant in the phrase: "if the specified check (the last 2 lines in block 5-6) is removed, then an extra object will be created at runtime. "
Question: do I understand correctly:
a) the definition of a file pointer;
b) the meaning of the phrase "If the specified check (the last 2 lines in block 5-6) is deleted, then an extra object will be created at program execution.And only after that the while loop's end condition will be triggered and control will be passed to block 8-9".
P.S. In order not to litter the forum, thank you in advance for your answer
People!!! Please give me the function to open the hour bar (I need to determine the Open of the previous candle) and if (TimeMinute(TimeCurrent())==m && TimeSeconds(TimeCurrent())==n) for some reason it does not work putting m=1 n=1 but I beg you, who cares...
stater: People!!! Please give me the function to open the hour bar (I need to determine the Open of the previous candle) and if (TimeMinute(TimeCurrent())==m && TimeSeconds(TimeCurrent())==n) for some reason it does not work putting m=1 n=1 but I beg you, who cares...
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Good afternoon, gentlemen.
I am a beginner and I have a question: how do I optimise my robot correctly?
I know which buttons and checkboxes need to be pressed in order to run the strategy tester.
I am wondering, how to figure out what period to optimize it for? How to figure out how long the EA will work "well"?
How can we calculate it? It's not just the method of insight that can work...
Hello.
Can you tell me what changes need to be made to the code. I want the histogram to display only the values for bearish bars.
The indicator itself https://www.mql5.com/ru/code/8920
Good afternoon. Question about a file pointer... In the MQL4 book, found at MQL4.community, in the "Standard Functions" section, there is an example of the script "File Operations", which is intended for reading data from a file and displaying graphical objects in a symbol window:
Below, when analyzing this script in the Book on MQL4, the following phrase is given: "if the specified check (the last 2 lines in block 5-6) is removed, an extra object will be created at runtime. And only after that, the while loop's termination condition will trigger and control will be passed to block 8-9".
Do I understand it correctly? A file pointer is NOT INFLOWED BY TEXT SIGNS (for example: text| where | is a file pointer), but is a pointer WITH EXPRESSION, for example: text where k is the "to" character, k-th is highlighted by a file pointer. This explains the need for strings (see p.164):
Indeed. On penultimate iteration, after creating LAST object
2007.05.11 18:30;JPY
the file pointer is at the position of the last object, i.e:
2007.05.11 18:30;JPY IndustrialManufacture
(where o is the "o" character, k is the file index). Then when passing control to while statement header, FileIsEnding(handle) function will obviously return true, because file pointer is NOT at end of file, but at LAST character of that file. Then when the first two lines are executed, the file pointer will move to empty space and if there are no lines
the script will create a graphic (i.e. a line) with an empty description and a time coordinate that corresponds to 0. This is what is meant in the phrase: "if the specified check (the last 2 lines in block 5-6) is removed, then an extra object will be created at runtime. "
Question: do I understand correctly:
a) the definition of a file pointer;
b) the meaning of the phrase "If the specified check (the last 2 lines in block 5-6) is deleted, then an extra object will be created at program execution.And only after that the while loop's end condition will be triggered and control will be passed to block 8-9".
P.S. In order not to litter the forum, thank you in advance for your answer
People!!! Please give me the function to open the hour bar (I need to determine the Open of the previous candle) and if (TimeMinute(TimeCurrent())==m && TimeSeconds(TimeCurrent())==n) for some reason it does not work putting m=1 n=1 but I beg you, who cares...
https://docs.mql4.com/ru/series
thanks for your feedback, but I don't understand which function is used to know if an hour candle has opened....
iTime
iTime
EA keeps giving out error 0, advise - how to check what is causing it, how to find this place?
Error 0 is that there are no errors.
Stop doing Print (alert) =)