Self-learning the MQL5 language from scratch - page 27

 
Vasiliy Sokolov:

This is a spherical horse in a vacuum, not a flowchart of a working EA. Some blocks may not exist at all. Blocks may be rearranged. Any MCL program is an event handler. This is the main postulate that is not in the scheme, which means that it misleads the readers. My advice to you: do not read this old stuff. Kovalev's textbook is outdated. Many of the information in it is not correct, especially with respect to the order system of MT5. Kovalev essentially offers to memorize this ridiculous scheme, then memorize sets of events, and then pulls the owl on the globe: where supposedly this scheme is implemented in the Expert Advisor program. There are no schemes in MKL. There are typical patterns of using the trading environment. But there is no universal scheme, which has to be understood and remembered. All "schemes" are composed using functions and reactions of these functions to events. Plus, there are data that are requested... again by functions.

With all due respect. There's no such thing there. It's just that the students understand that this is an educational Expert Advisor and it's not allowed to trade using it. And in order to trade, you have to learn trading strategies... But this is after learning the language. By the way, the explanation is good and clear. What we often miss here, especially in comments in the kodobase. Sometimes it's hard to understand what's written)))) I agree, there is no such thing in good code)

 
MrBrooklin:

In Sergei Kovalev's MQL4 textbook I found what I was looking for. Here is an extract from the book:"Structure of a Simple Expert Advisor . Below is a basic structure of a simple Expert Advisor based on several functional blocks, each of which involves a certain independent part of calculations".


In this regard, I need some expert advice, is this structured scheme applicable to writing an Expert Advisor in MQL5, or should I add some other blocks?

Best regards, Vladimir.

Yes, this scheme will suit you. It is simple and orderly. Once you have mastered the language, you can complicate/change/add blocks as you see fit, but you can start with this one. The right scheme.
 
Vasiliy Sokolov:

This is a spherical horse in a vacuum, not a flowchart of a working EA. Some blocks may not exist at all. Blocks may be rearranged. Any MCL program is an event handler. This is the main postulate that is not in the scheme, which means that it misleads the readers. My advice to you: do not read this old stuff. Kovalev's textbook is outdated. Many of the information in it is not correct, especially with respect to the order system of MT5. Kovalev essentially offers to memorize this ridiculous scheme, then memorize sets of events, and then pulls the owl on the globe: where supposedly this scheme is implemented in the Expert Advisor program. There are no schemes in MKL. There are typical patterns of using the trading environment. But there is no universal scheme, which has to be understood and remembered. All "schemes" are composed using functions and reactions of these functions to events. Plus, there are data that are requested... again by functions.

I don't understand your criticism. The scheme is logical, all the actions are sequentially ordered. Gives an idea of the correct structure of the EA. Of course, you can mix things up, cut out some things and add others, but the stability of such a program would be dramatically affected. In general, I do not see what there is to complain about in the scheme.
 
Реter Konow:
I do not understand your criticism. The scheme is logical, all the actions are sequentially ordered. Gives an idea of the correct structure of an EA. Of course, we can mix things up and throw some things out, but the stability of this program will dramatically change. In general, I do not see what there is to complain about in the scheme.

OK, all right. Let me try to explain.

1) Here is a scheme. Some blocks are given (what is a block, as applied to mql program, is not explained. Perhaps it is a function, perhaps a set of procedures, maybe something else, but okay, let us intuitively understand what a block is at the same level with the author).

2) The blocks form a chain from the beginning of the program to its end. In some blocks, the program execution chain is divided into two (but why, by the way, only two? Can't the three be divided into four? And if four is required, how to show it in a diagram? Shall we switch to A1 format?). Apparently, it is a way to show branching.

3) There are some very strange blocks, like "messages". What kind of block is this? Probably some kind of notification from the program that there are no suitable conditions: every tick will come a message: "Too expensive to buy, too expensive to buy, too...". - cool of course, but it's all guesswork.

4) The strangest block, is the "error handling" block. You can get into it, but you can't get out of it. The program caught an error and sits in this block (hangs probably until a complete reboot, even better make it so that the terminal hangs permanently, what would not do more errors - this is the idea!)

5) If we start the program for the first time, or there are no open positions in the account, then the order closing block does what? Nothing. But this logical scheme should still get us to the order closing block. We get there because the scheme is strictly and hierarchically structured. All the blocks must be processed one by one, even if this is pointless and ruthless processing of an empty list of positions.

6) The block of order value calculation is placed below the block of order closing. How can it be? Maybe we close an order based on its "value". It's not clear what is going on here.

And I look at this scheme and do not really understand how we can recommend this "thing" to be studied? How can it be considered good, great and educational?

 
Vasiliy Sokolov:

OK, all right. Let me try to explain.

1) Here is a scheme. Some blocks are given (what is a block, as applied to mql program, is not explained. Perhaps it is a function, perhaps a set of procedures, maybe something else, but okay, let us intuitively understand what a block is at the same level with the author).

2) The blocks form a chain from the beginning of the program to its end. In some blocks, the program execution chain is divided into two (but why, by the way, only two? Can't the three be divided into four? And if four is required, how to show it in a diagram? Shall we switch to A1 format?). Apparently, it is a way to show branching.

3) There are some very strange blocks, like "messages". What kind of block is this? Probably some kind of notification from the program that there are no suitable conditions: every tick will come a message: "Too expensive to buy, too expensive to buy, too...". - cool of course, but it's all guesswork.

4) The strangest block, is the "error handling" block. You can get into it, but you can't get out of it. The program caught an error and sits in this block (hangs probably until a complete reboot, even better make it so that the terminal hangs permanently, what would not do more errors - this is the idea!)

5) If we start the program for the first time, or there are no open positions in the account, then the order closing block does what? Nothing. But this logical scheme should still get us to the order closing block. We get there because the scheme is strictly and hierarchically structured. All the blocks must be processed one by one, even if this is pointless and ruthless processing of an empty list of positions.

6) The block of order value calculation is placed below the block of order closing. How can it be? Maybe we close an order based on its "value". It's not clear what is going on here.

And I look at this scheme and do not really understand how we can recommend this "thing" to be studied? How can it be considered good, wonderful and educational?

OK. Now the criticism is clearer. Well, in many ways you can agree if you view it "under the magnifying glass", but there is no point in doing so. A beginner should get a quick, generalised and simplified idea of the most common and correct (in the global sense) EA composition.

A block is a logically isolated set of conditions, checks, functions and programs.

The design of the program blocks implements the correct execution of the program.

The branching and deep hierarchy of block links is not shown in the diagram so as not to confuse the student. Everything is simplified deliberately and this is correct from the pedagogical point of view. If Kovalev had described a "gallery" of possible structure hierarchies for 20 pages, would it have been better? Probably not after all...) But, yes, everything is in fact more complicated and varied in life than on the diagram. But you have to start with a simple one.
 
Реter Konow:
A beginner must get a basic, generalized and simplified idea of the most common and correct (in the global sense) composition of the EA.

Aha, well, i.e. globally Kovalev is right, so what about mistakes in the scheme - a beginner will understand where these mistakes are and where it is drawn correctly. He is a beginner for that to get the essence of the generalized representation of the advisor's device. And what is a block, what are arrows, and why do I have to freeze after handling errors- a beginner will think it over with his high-powered wit.

 
Реter Konow:
Ok. Now the criticism is clearer. Well, in many ways you can agree if you look at it "under the magnifying glass", but there is no point in doing so. A beginner should get a quick, generalised and simplified idea of the most widespread and correct (in the global sense) EA composition.

A block is a logically isolated set of conditions, checks, functions and programs.

The block structure implements the correct execution of the programme.

The branching and hierarchical links of the blocks are not shown in the diagram so as not to confuse the student. Everything is simplified deliberately and this is correct from the pedagogical point of view. If Kovalev had described a "gallery" of possible hierarchical structures for 20 pages, would it have been better? Probably not after all...) But, yes, everything is in fact more complicated and varied in life than on the diagram. But you have to start with a simple one.

Hello Peter! I'm summarizing the information from all messages. In the MQL5 programming language there is no clearly defined BASE algorithm for the creation and execution of a program (script, Expert Advisor). All algorithms are unique in their own way and cannot have a so-called "kernel", which can then be expanded. Then it turns out that my self-learning program is at a dead end? If anyone has noticed, all of my previously written scripts follow a complication scheme, i.e. from simple to complex. In essence, I need to break the very notion of organizing thoughts in my head. Does it work like that?

Respectfully, Vladimir.

 
MrBrooklin:

Hello Peter! I will summarize the information from all messages. In the MQL5 programming language there is no clearly defined BASE algorithm for creating and executing a program (script, Expert Advisor). All algorithms are unique in their own way and cannot have a so-called "kernel", which then can be expanded. Then it turns out that my self-learning program is at a dead end? If anyone has noticed, all of my previously written scripts follow a complication scheme, i.e. from simple to complex. In essence, I need to break the very notion of organizing thoughts in my head. Does it work like that?

Respectfully, Vladimir.

No. By no means. Vassily's criticism has in no way diminished the logical correctness of the EA scheme. Yes, you can find some flaws and "get" them, but in general, it's correct, and that's the most important thing. This scheme will help you start writing your own EAs when you get there. By and large, there is no difference between mql4 and mql5. The details are different, but they are easy to understand. Keep learning as before.
 
Vasiliy Sokolov:

Aha, well, i.e. globally Kovalev is right, so what about mistakes in the scheme - a beginner will understand where these mistakes are and where it is drawn correctly. He is a beginner for that to get the essence of the generalized representation of the advisor's device. What is a block, what are arrows, and why does one have to freeze after handling errors - a beginner will think it through with his or her powerful mind.

We don't have a better textbook anyway, so....

Small errors are not an excuse to stop and "glue" together parts of other people's code, as many do. In addition, you ignore the basic correctness of the presentation of the material, of which there is a great deal.
 
MrBrooklin:

Hello Peter! I will summarize the information from all messages. In the MQL5 programming language there is no clearly defined BASE algorithm for creating and executing a program (script, Expert Advisor). All algorithms are unique in their own way and cannot have a so-called "kernel", which then can be expanded. Then it turns out that my self-learning program is at a dead end? If anyone has noticed, all of my previously written scripts follow a complication scheme, i.e. from simple to complex. In essence, I need to break the very notion of organizing thoughts in my head. Does it work like that?

Respectfully, Vladimir.

Right! Everyone is trying to learn programming, using incorrect conceptions of the program, based on life experience. For example, that a program is like a text in a book with a table of contents, introduction, table of contents and conclusion. That is, that the program is a kind of sequential scheme from the beginning to the end. At first stages, this idea works, but then, as the program becomes more complex, difficulties arise, and it is not possible to write a reliable working program in any way. Kovalev is a very good at rendering bearish services: he tries to explain to the reader, using his accessible conceptual apparatus, that the program is the same book with such-and-such a scheme. But there are no schemes! The script has a fundamentally different "scheme" than the Expert Advisor, and the Expert Advisor has a different scheme than the indicator.

Reason: