[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 471

 
Axmed писал(а) >>


CSV - Comma Separated Values. The "," is the default delimiter. Separation with ";" is used less often, and I'm not sure it's even supported in MQL4.


int FileOpen( string filename, int mode, int delimiter=';')
Opens File for input and/or output. Returns the file descriptor of the opened file or -1 in case of failure. Call GetLastError() to get more information about the error.
Note: files can only be opened in the terminal_directory\experts\files(terminal_directory\tester\files in case of expert testing) folder or its subfolders.
The FILE_BIN and FILE_CSV modes cannot be used simultaneously.
If FILE_WRITE is not combined with FILE_READ, a file with zero length will be opened. Even if there was data in the file before it was opened, it will be destroyed. If data needs to be appended to an existing file, it must be opened using the combination FILE_READ | FILE_WRITE.
If FILE_READ is not combined with FILE_WRITE, the file will only be opened if it already exists. If the file does not exist, it can be created using FILE_WRITE.
No more than 32 files can be opened at the same time within the same executable. Descriptors of files opened in one module cannot be transferred to other modules (libraries).
Parameters:
filename - Filename - file name.
mode - Method of opening. This can be a single value or a combination of values: FILE_BIN, FILE_CSV, FILE_READ, FILE_WRITE.
delimiter - A delimiter character for csv files. By default the ';' character is applied.
Example:
 int handle; handle=FileOpen("my_data.csv",FILE_CSV|FILE_READ,';'); if(handle<1) { Print("File my_data.dat not detected, last error ", GetLastError()); return(false); }

You should read the help too.
 
Axmed >>:


Что конкретно Вам не понравилось в том что я пишу?..

It's all wrong.
The ";" is the default delimiter.
FileReadString - does not read the whole string, but from the current pointer position in the file to the next separator.

 

Hello, could you please tell me how to call the required variable from a custom indicator, I tried GlobalVariableSet() / GlobalVariableGet() - it works from another EA, but not from an indicator. Thank you in advance.

 
kara100 писал(а) >>

Hello, could you please tell me how to call the required variable from a custom indicator? I tried GlobalVariableSet() / GlobalVariableGet() - it works from another EA, but not from an indicator. Thank you in advance...


Which variable do you want to get and from which indicator?
 

Price from +MP (line 228) - I need (price) level values

Files:
ymp_1.mq4  6 kb
 
kara100 писал(а) >>

Price from +MP (line 228) - I need values (price) levels


try to move variable prise to global level, and place string GlobalVariableSet("55", prise); at the beginning of the function start() and from the other program get double x=GlobalVariableGet("55");

 
Techno писал(а) >>


try to move variable prise to global level, and place string GlobalVariableSet("55", prise); at the beginning of function start() and from the other program get double x=GlobalVariableGet("55");


I've tried it... It writes, that global variable is not described, i.e. global variables don't come out of the indicator... >> I'll try again.

 
kara100 писал(а) >>


I think I tried it... it says that no global variable is described, i.e. no global variables come out of the indicator... >> I'll try again.


Once you fix the code, post it here.
 
Friends, thank you very much for responding. clarification, how to convert string to double?
StrToDouble() does not work :(

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()
}
k=0;
while(FileIsEnding(Handle)==false) // До тех пор, пока файловый ..
{ // ..указатель не в конце файла
//--------------------------------------------------------- 5 --
ss1[k] = (FileReadString(Handle));
x1[k]=StrToDouble(ss1[k]);//
ss2[k] = (FileReadString(Handle));
rr1[k] = (FileReadString(Handle));
rr2[k] = (FileReadString(Handle));
k=k+1;
if(FileIsEnding(Handle)==true) // Файловый указатель в конце
break; // Выход из чтения и рисования
}
FileClose( Handle ); // Закрываем файл
PlaySound("bulk.wav"); // Звуковое сопровождение
//-----------------------------------------------
Alert(" ", ss1[0], " ", ss2[0], " ", rr1[0], " ", rr2[0], " x1== ", x1[0] );

String arrays are filled from file normally. But, I need to convert these strings to double.
I do it:
x1[k]=StrToDouble(ss1[k]);
but, when output to Alert, x1[0] = 0, which is wrong. i.e. there is a mistake in type conversion somewhere...

How to fix this situation?
 
Morzh09 >>:

Друзья, спасибо большое, что откликнулись. уточнение, как преобразовать string в double?
StrToDouble() - не прокатывает :(
Строковые массивы заполняются из файла нормально. Но, необходимо преобразовать эти строки в double.
делаю это:
x1[k]=StrToDouble(ss1[k]);
но, при выводе в Алерте, x1[0] = 0, что неправильно. то есть, где-то тут ошибка в преобразовании типов...

Как такую ситуацию исправить?

Could you please post the whole script? I mean with the variable array declarations etc.