Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 1118
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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
Please advise on possible developments.
I have array[100], also saved binary file with size [1000], how to return array of binary file last 100 values. Is there anything universal? I've been working on this for 12 hours and nothing.
If I remember correctly, it was written in mql4, that if count = WHOLE_ARRAY or value exceeds the number of array elements, then the entire array is written to the end. And it didn't say anything about any margin. I.e. it's out of the question not to mention 1,000.
To check it, count how many values are written and the size of the file.
If I remember correctly, it was written in mql4, that if count = WHOLE_ARRAY or value exceeds the number of array elements, the whole array is written to the end. And it didn't say anything about any margin. So it may be absolutely out of question if there is not a 1000-thousand-point margin.
To check this, calculate how many values are written and the resulting file size.
I do not mean that after writing the array to the binary, new data appear, and I keep writing them to the binary via a new dimensioned array (= the dimension of the primary array column), each time to the end of the file, for a new j column
then we need to remove the data from the binary equal in number to the index of the original array, which was transferred to the binary in the first integration. However, the last data will be included in this limited array, because the binary is larger than the primary array, as secondary rows have been added. Secondary rows must go into read array, and first rows in binary must be out of area.
I do not mean that after writing the array to the binary, new data appears after a moment of time, which I continue to write to the binary via a new dimensioned array (= dimension of the primary array column), each time at the end of the file, for a new j-column
then we need to remove the data from the binary equal in number to the index of the original array, which was transferred to the binary in the first integration. However, the last data should be removed in such a way that the last data are included in this limited array, because the binary is larger than the primary array due to the addition of secondary rows.
Then you don't need to assign a size to the array before reading. If it is not the first data that is needed, then calculate the size in bytes and shift the start position for reading by the right amount.
That is the question how to calculate bytes
s1=FileReadInteger(h,INT_VALUE); //ножно ли перед восстановлением считываем размер массива?
может как то через это sizeof
This is the question how to calculate bytes
s1=FileReadInteger(h,INT_VALUE); //ножно ли перед восстановлением считываем размер массива?
может как то через это sizeof
If data is of double type then divide file size by the number of bytes occupied by the number of double type, i.e. by 8.
If the data is double, then divide the file size by the number of bytes occupied by the double number, i.e. by 8.
Is it byFileFindFirst?
or just scan each new line in bytes
file_size=+FileSize(handle); // чтобы выяснить индекс от которого открывать
FileReadArray(file_handle,arr,file_size,WHOLE_ARRAY);
WithFileFindFirst?
ThroughFileFindFirst?
Or just bysummarize each new line in bytes
file_size=+FileSize(handle); // чтобы выяснить индекс от которого открывать
FileReadArray(file_handle,arr,file_size,WHOLE_ARRAY);
You should not have corrected your post after answering it...
Wrong. Before reading an array, define its size file_size = FileSize(handle); and divide by memory occupied by data type, i.e. for double by 8. You get the number of numbers in the file. If array is two-dimensional, then the number of records in the file will be twice less. And you get how many bytes should be shifted to read from the desired line.
You should have corrected your post after replying to it...
Wrong. Before reading an array, define its size file_size = FileSize(handle); and divide by memory occupied by data type, i.e. for double by 8. You get the number of numbers in the file. If array is two-dimensional, then the number of records in the file will be twice less. And you get how many bytes should be shifted to read from the desired line.
as a result, I divided by 8000, so that the array values fit into their indexes
You tell me...
FileSize
Returns file size in bytes.
Type
Size in bytes
Positive minimum value
Maximum value
Analog in C++
float
4
1.175494351e-38
3.402823466e+38
float
double
8
2.2250738585072014e-308
1.7976931348623158e+308
double
file size in bytes, the size occupied by type double in bytes, and it is necessary to divide it by zhzhezhezhezhezhezhezhez