video
We now have here a simple Expert Advisor, a basic framework and I would like to briefly go into the individual components that are used here. It starts with these slashes here. These are so-called comments. Comments are ignored by the system itself, but are very good for us humans to find out what certain parts of the code do. It makes sense to use many comments. Whenever I put these two slashes in front of a function, it is also shown here in gray. This means: Everything behind these two slashes would be ignored by the compiler from now on. The second thing that is used here is the property. If I highlight it and press the F1 key, I get a message that it is a program property. There is also a list of such properties below. For example I can specify the copyright or a link. In this case we use copyright, link and version here. With version numbers it makes sense to use ascending numbers if you change something in a program version. OnInit, OnDeinit and OnTick are each a function. You can recognize a function by the round brackets. In object-oriented programming, a function would also be called a method. You can pass a value in these round brackets. Here, for example, a value is returned. You can recognize this by the function return. Let’s select the function and press F1 again. Then you see: Aha, return stops the running function and returns the control to the calling program. And the result of the calculation is returned. We will come to this later. To simplify the whole thing, we will first delete everything above the OnTick function. And also these two comment lines here will be removed. If we click on Compile once, we will see that we have already created a fully compilable, executable program here. And in the next video we will add a function.

Hide picture