Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 1116
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Remove FILE_CSV, use FILE_ANSI instead if youuse"\n\t" etc.
Hello, the task is to overwrite a two-dimensional array, in BIN format, will the function recognize a two-dimensional array as input?
FileWriteArray
Of course it'll read two-dimensional. Sorry, no offense... Wouldn't it be easier to just write a 2x2 element test array, read it and see?
NULL empty values are written to the file.arrayZ is two-dimensional
//| Запись n элементов массива в файл |
//+------------------------------------------------------------------+
void WriteData(const int n)
{
//--- откроем файл
ResetLastError();
int handle=FileOpen(path,FILE_READ|FILE_WRITE|FILE_BIN);
if(handle!=INVALID_HANDLE)
{
//--- запишем данные массива в конец файла
FileSeek(handle,0,SEEK_END);
FileWriteArray(handle,arrayZ,0,n);
//--- закрываем файл
FileClose(handle);
}
else
Print("Failed to open the file, error ",GetLastError());
}
NULL empty values are written to the file.arrayZ is two-dimensional
//| Запись n элементов массива в файл |
//+------------------------------------------------------------------+
void WriteData(const int n)
{
//--- откроем файл
ResetLastError();
int handle=FileOpen(path,FILE_READ|FILE_WRITE|FILE_BIN);
if(handle!=INVALID_HANDLE)
{
//--- запишем данные массива в конец файла
FileSeek(handle,0,SEEK_END);
FileWriteArray(handle,arrayZ,0,n);
//--- закрываем файл
FileClose(handle);
}
else
Print("Failed to open the file, error ",GetLastError());
}
I'm too lazy today and have no time... In documentation, where you've copied this function, they even write array of structures. Does the entire example given in the documentation work, if you don't change it? Check it yourself, if it doesn't work, you have to write to the CD.
These are serialisation functions. If you want to open file in text-readable format - write string to file.
string s = StringFormat("first line: %s\n", first);
s += StringFormat("second line: %s\n", second);
s += StringFormat("third line: %s\n", third);
FileWrite(s);
and so on and so forth.
To read FileRead and parse each line (you have to play around, but you'll have to if you want readability).
Like children, by golly. They expect from a Funky Christmas miracle, like it will do everything nicely, fill it all up and format it )))).
In general, Merry Christmas to all, good luck ))))
Do not use FileWriteArray and FileReadArray sharpeners for purposes for which they are not intended.
These are serialisation functions. If you want to open file in text-readable format - write string to file.
string s = StringFormat("first line: %s\n", first);
s += StringFormat("second line: %s\n", second);
s += StringFormat("third line: %s\n", third);
FileWrite(s);
and so on and so forth.
To read FileRead and parse each line (you have to play around, but you'll have to if you want readability).
Like children, by golly. They expect from a Funky Christmas miracle, like it will do everything nicely, fill it all up and format it )))).
In general, Merry Christmas and merry Christmas to all )))).
Can you tell me if it's possible to bypass importing a two-dimensional array from csv. by extracting a three (or two) dimensional array from the indicator to the EA?
C DoesFileReadDouble consider a two-dimensional array, if so how?
In general, what operation should be used to convert a csv matrix to an array?
In general, I do not understand how, for example, take an example
//--- прочитаем данные из файла
for(int i=0;i<size;i++)
{
time_buff[i]=(datetime)FileReadDouble(file_handle);
ma_buff[i]=FileReadDouble(file_handle);
}
how this, write the same data in the arraytime_buff[i]andma_buff[i]
example from https://www.mql5.com/ru/docs/files/filereaddouble
And if I have a two-dimensional array, how can I arrange enumeration.
If I useFileReadString, I need to specify length of the string, I need to know number of digits in the string, not cells?
Apparently, I should useFileReadNumber but it's too weird
Can you tell me if it's possible to bypass importing a two-dimensional array from csv. by extracting a three (or two) dimensional array from the indicator to the EA?
C DoesFileReadDouble consider a two-dimensional array, if so how?
In general, what operation should be used to convert a csv matrix to an array?
In general, I do not understand how, for example, take an example
//--- прочитаем данные из файла
for(int i=0;i<size;i++)
{
time_buff[i]=(datetime)FileReadDouble(file_handle);
ma_buff[i]=FileReadDouble(file_handle);
}
how this, write the same data in the arraytime_buff[i]andma_buff[i]
example from https://www.mql5.com/ru/docs/files/filereaddouble
And if I have a two-dimensional array, how can I arrange enumeration.
If I useFileReadString, I need to specify length of the string, I need to know number of digits in the string, not cells?
Apparently, I should useFileReadNumber but it's too weird
And please tell me, when we talked about writing an array FileWriteArray(), how did you try to read what was written?
string path=InpDirectoryName+"//"+InpFileName;
//--- откроем файл
ResetLastError();
int file_handle=FileOpen(path,FILE_READ|FILE_BIN);
if(file_handle!=INVALID_HANDLE)
{
//--- прочитаем все данные из файла в массив
FileReadArray(file_handle,arr);
//--- получим размер массива
int size=ArraySize(arr);
//--- распечатаем данные из массива
Print(" = ",arr[0][0]," = ",arr[1][1]," = ",arr[2][2]);
Print("Total data = ",size);
//--- закрываем файл
FileClose(file_handle);
}
else
Print("File open failed, error ",GetLastError());
2017.01.09 17:20:40.609 TorFid_v02 (EURUSD,H1) Total data = 1020100
I understand what's missing, the reverse conversion to a 2D array, but I don't understand how
Unless of course I saved it correctly.
{
for(int q=1; q<ARRAY_SIZE_X-1; q++) // Перебор по периоду, колонка X
{
arr[q][z]=NormalizeDouble(sm.d[q+1].m[nBar-z],5); // M(I) SMA
}
}
WriteData(1000);
//| Запись n элементов массива в файл |
//+------------------------------------------------------------------+
void WriteData(const int n)
{
//--- откроем файл
ResetLastError();
int handle=FileOpen(path,FILE_READ|FILE_WRITE|FILE_BIN);
if(handle!=INVALID_HANDLE)
{
//--- запишем данные массива в конец файла
FileSeek(handle,0,SEEK_END);
FileWriteArray(handle,arr,0,n);
//--- закрываем файл
FileClose(handle);
}
else
Print("Failed to open the file, error ",GetLastError());
}
Once upon a time it was mentioned on the forum that MT5 would add the ability to import custom historical data, has this been implemented?