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

 
ANDREY:

Thanks for the valuable advice. Now I only read the documentation while writing code, when I come across a question I don't know the answer to. I've never encountered a need to write data to files while writing code in the past, so it's a totally new topic for me.
Tell me, can't my idea be realized in a simpler way, without writing it to a file? As in my code. This is not a working code but to illustrate my idea of how to find the minimum between two adjacent orders opened on one minute candlestick
Thanks for the help.

That is, I wrote the price of each tick directly into the array, not into a file.

Well, I don't know how you can read like that. When I started programming, when I got into the documentation for any trivial thing, the programming just stopped. I got more and more out of it... You read about one function writing to a file and didn't see anything next to it. You've been told about another one and you're euphoric at what you've heard. What else is there? Have you read anything at all? What other functions are there for writing to a file? And how do you have to read to ask such questions? I told you to write an array and read an array. And you want to write .csv and read to an array. That's not how it works. And if you only need it all... at the moment, why write it to a file?
 
Valeriy Yastremskiy:

You get their price, you can fix the time but you wait for a new order. and then you ask for the maximum or minimum tick time. a tick is a tick after all.

The price of a tick is always a tick. This is not the x low variable , but the expression X =LoY[1]. LoY[1] is price..... with no options.
"..... and then you ask the maximum or minimum tick time...."

That's the thing about this idea, time is not involved at all ..... only the minimum price of the candle, which I only find out two times. The first time when the first order is opened and the second time when the second order is opened. Then I compare those prices and make a conclusion: whether the first order was opened before LoY[] was formed or after it was formed. At first, I thought that I needed information about time to solve my problem. But then it dawned upon me.... and it appeared that we can do without time and only the minimum price of a candle is enough.

 
Alexey Viktorov:
Well, I don't know how you can read like that. When I started programming, getting into the documentation for anything trivial would just stop the programming. I got more and more out of it... You read about one function writing to a file and didn't see anything next to it . You've been told about another one and you're euphoric at what you've heard. What else is there? Have you read anything at all? What other functions are there for writing to a file? And how do you have to read to ask such questions? I told you to write an array and read an array. And you want to write .csv and read to an array. That's not how it works. And if you only need it all... at the moment, why write it to a file?

I think it is useful to look at what is next to each other when the material is logically connected in meaning and presented in a comprehensible sequence. As is usually the case in textbooks. I do not feel this connection and consistency in the Handbook. I admit that I may have them, but the issue is related to my cognitive peculiarities.

I don't understand the main thing yet. Why should I write data from my code into the file if I don't need to. Under what circumstances does it make sense to write data of a program into a file .... in general and in my case. As it seems to me from your words, the reasonability of writing data into a file is somehow conditioned by how often I will use my code. But I still don't understand the sense of this conditionality. Maybe the point is that the same data from the file can also be used from my other program? But then another program would need exactly this data written into the file. And this is far from a certainty...
Thanks for the help.

 
Colleagues, hello! I'm looking for an equity indicator to show the percentage of current drawdown on equity, as well as the real-time curves of balance and equity. I don't do monitoring on the fly for the sake of it.
 
Alexey Viktorov:
I told you to write an array and read an array. And you want to write .csv and read the array. It doesn't work that way. And if you only need it all... at the moment, why write to a file?

I was also intrigued by the red phrase. Because I didn't want to write a .csv and read into an array. Because I don't know how to do it yet. I know that there are text files with .csv extension. But have I touched a file with this extension in my code in any way? From the array .... read.... I'm sorry :=)... butI also don't know howto readintoarray and I don't understand what it means yet.
I would appreciate it, if you could rewrite my code (it's rather short) so that it would have function
of writing into file and function of reading from file.
Since this code is mine, I will quickly learn new information for me.
Thank you once again, and excuse me for not being as advanced as you and asking probably stupid (in your professional opinion) questions.

I want to learn mql4 and then mql5 in a stable way. This is not a momentary fad. Moreover, now I have more time for it.
Another thing is that I am getting new information not as fast as I would like.... but I am. Thanks to you and the other participants of this forum. For what I am grateful to all.

 
ANDREY:

I was also intrigued by the red phrase. Because I didn't want to write a .csv and read into an array. Because I don't know how to do it yet. I know that there are text files with .csv extension. But have I touched a file with this extension in my code in any way? From the array .... read.... I'm sorry :=)... butI also don't know howto readintoarray and I don't understand what it means yet.
I would appreciate it, if you could rewrite my code (it's rather short) so that it would have function
of writing into file and function of reading from file.
Since this code is mine, I will quickly learn new information for me.
Thank you once again and excuse me for not being as advanced as you and asking probably silly questions, in your professional opinion.

Andriy, I don't dig in other people's codes. I prefer to explain, if I can't understand what's written in the documentation. If you haven't read the documentation or haven't go deep into it, you obviously haven't understood anything. And the way you suggest will not be a training, but a "fishbowl" for which you want to do something similar in the future. But this approach does not always work.

 
ANDREY:

Thanks for the advice. But...... Here is a screenshot of the Documentation on file operations

Seems to me the guide is designed for already advanced users. Kovalev in his tutorial explained in detail what is needed and for what purpose before going into details.

But his tutorial, as they say here, is hopelessly outdated, and even dangerous for beginners.

No, it's not. You just need to read it understanding that there have been language improvements and changes. You'd better insert the code first by creating a template in the meta-editor. There will be fewer errors. In the logic of algorithms the textbook is relevant. And writing to the file there is correct. Take a look at Dmitry Fedoseyev's book on µl5. I think he put his on Googleplay.

 
Valeriy Yastremskiy:

No, it's not outdated. You just need to read understanding that there have been language improvements and there are changes. It is better to insert the code by first creating a program template in the meta-editor. There will be fewer errors. In the logic of algorithms the textbook is relevant. And writing to the file there is correct. Take a look at Dmitry Fedoseyev's book on µl5. I think he put his on Googleplay.

Thanks for the tip. I've already started reading FILE OPERATIONS from Kovalev's tutorial. Indeed... something is starting to become clear. I understood that all EAs I was testing read text files with bar prices (though not created by my program) with .cvv extension located in the folder of the Tester terminal.
In other words, information (data) from any program is written to the file and read this data from the file, also by any program. It seems to me that the files store large amount of data which is not reasonable to store in the program. Something like mqh file.
If you want to explain me what Alexey Victorov's phrase means : ".... Do you want to write .csv and read array....." from post with reference to my code from post
. I thought he meant the text file .cvv, with bar prices from the tester directory. But what exactly he means, I still do not understand. I'm not writing these .cvv files, but the Alpari dealer's program... How the program reads from an array - in general I understand a little ... It accesses a cell of an array by its address, gets inside the cell and accesses the value of the cell (i.e. reads it). How can a program read into an array instead of out of it? This is an unsolvable contradiction, ...., as it seems to me, in my layman's opinion. I think, for some reason, that in an array you can only write some values. And you can only read from an array

 
ANDREY:

...
If you don't mind explaining to me what Alexey Victorov's phrase "....And you want to write .csv and read into array....." from post is meant in relation to my code from post
As it seemed to me he means text file .cvv, with bar prices from Tester catalogue. But what exactly he means, I still do not understand. I'm not writing these .cvv files, but the Alpari dealer's program... How the program reads from an array - in general I understand a little ... It accesses a cell of an array by its address, gets inside the cell and accesses the value of the cell (i.e. reads it). How can a program read into an array instead of out of it? This is an unsolvable contradiction, ...., as it seems to me, in my layman's opinion. I think, for some reason, that in an array you can only write some values. And you can read only from the array.

Yes, and I do not mind. It's not digging in the code.

FileWrite

Writes data to a CSV or TXT file

FileWriteArray

Writes arrays of any types, except string arrays, to a BIN type file .


Read into an array, i.e. from a file. Look at the function

uint  FileReadArray( 
   int    file_handle,               // handle файла 
   void&  array[],                   // массив для записи 
   int    start=0,                   // стартовая позиция для записи в массив 
   int    count=WHOLE_ARRAY          // сколько читать 
   );

Passes a prepared array and writes to it.

You can only use the read array function from a file written with the array write function.

In principle, you can read any file that doesn't contain strings into an array. But it will be only element-by-element filling of the array.

ps;

Thanks to chance, at least I've read documentation myself and found new functions of array writing and array reading in mql5.

Документация по MQL5: Файловые операции / FileSave
Документация по MQL5: Файловые операции / FileSave
  • www.mql5.com
FileSave - Файловые операции - Справочник MQL5 - Справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
Alexey Viktorov:

It's not difficult for me either. It's not about digging into code.

FileWrite

Writes data to a CSV or TXT file

FileWriteArray

Writes any types of arrays, except string arrays, to a BIN type file .



Thanks to chance, at least I've read the documentation myself and found new functions in mql5 for array writing and array reading.

Glad I could help you :=) :=) :=)

Now about my code, which is probably so bad that it is unpleasant to poke around in it. But tell me at least what would be the advantage of my code, if I wrote a single array (with price values) of this code into a file, and then the program would read it from this file and use its values in further calculations? And the array of only 60 elements. What exactly in my code would be optimal?
Thanks for your help.
Reason: