Self-learning the MQL5 language from scratch - page 38

 
MrBrooklin:

I have read Modification of pending orders subsection and realized that I am as far away from trailing stop as Peking. I will return to studying the material on writing functions for "Enough_time" and "Enough_patience" for now.

Regards, Vladimir.

Right solution. Here's the learning curve to writing a VERY simple trailing function in an EA.

1. Master the if operator, switch operator.

2. You will practically master the principles of loops for, while - where, why and how they are used.

You may write your own usable functions for different tasks.

You get acquainted with standard functions (what they are used for, what they return, where they are used...).

6. Become familiar with working with your Expert Advisor.

5. You will try to write your own function of trailing one pending order.

Further you will see....)

 
Valeriy Yastremskiy:

Then just play with what you've learned. For example, rewrite examples from the tutorial in MKL5) Yes, and I hope you use the Create button in MetaEditor when creating an EA or script from the tutorial, rather than just copying examples from the tutorial. New templates with the right features, not outdated ones. The old ones work in 4ka too, but that's not the right style)

Yes, Valery, in MetaEditor I write all scripts only through the "Create" button. Thanks for the tip, I will try to rewrite it from 4 to 5!

Regards, Vladimir.

 
Реter Konow:
Good decision. Here is the learning path to writing a VERY simple trailing function in Expert Advisor.

1. Master the if, switch operator.

2. In practice, you will understand the principles of for and while loops - where, why and how they are used.

3. Write your own useful functions for different tasks.

4. Get acquainted with standard functions (what they are used for, what they return, where they are used...).

6. Become familiar with working with your Expert Advisor.

5. You will try to write your own function of trailing one pending order.

Further you will see....)

Hello Peter! Thank you for your detailed plan for continuing my self-study. Now I am mastering if, for and while. With the if-else operator is more or less clear, but the loops are still not quite figured out. I'd like to write something of my own, and see how the code works.

Regards, Vladimir.

 
MrBrooklin:

Hello Peter! Thank you for the detailed plan. I'm mastering if, for and while. I understand more or less the if-else statement, but I haven't quite mastered the loops yet. I'd like to write something of my own and see how the code works.

Regards, Vladimir.

Hello, and you make sure you apply the knowledge you get from the tutorial, documentation and forum users to your own practice. Build your own conditions, loops, functions, and devise and solve your own problems. Don't limit yourselves to tutorial examples, try to write your own. This is the only way the material will be perceived and assimilated.
 
Реter Konow:
Hello, Be sure to strengthen the knowledge you have received from the textbook, documentation and forum users with practice. Build your own conditions, loops, functions, and devise and solve your own problems. Don't limit yourselves to tutorial examples, try to write your own. This is the only way the material will be perceived and assimilated.

The results of self-study will be periodically posted in this thread, so that you and other professionals in the field of programming could get feedback.

Regards, Vladimir

 

Good evening all!

Dear programming experts, could you please tell me what does the error the compiler generates mean:" function declarations are only allowed in global, namespace or class area", or to be more specific, what is a namespace and where should it be located in the script?

The question is related to writing function code for "Enough_time" and "Enough_patience".

Regards, Vladimir.

 
MrBrooklin:

Good evening all!

Dear programming experts, please tell me what it means in the error, which the compiler generates:"declaration of functions is only allowed in the global, namespace or class area", and more precisely, I am interested in what is namespace and where it should be located in the script?

Regards, Vladimir.

The creation of a function should be behind regular functions like OnInit, OnStart, etc..

not inside them.

 
Fast235:

Creating a function behind the regular functions, like OnInit, OnStart, etc.

Thanks! Just don't understand what the compiler doesn't like, when I do so, namely after OnStart of the script.

Regards, Vladimir.

 
MrBrooklin:

Thanks! Just don't understand what the compiler doesn't like when I do that, namely after the OnStart script.

Regards, Vladimir.

brackets, opening/closing functions, converge back and vertically after "Styling"? I do not remember your level of skill) sorry

 
Fast235:

brackets, opening/closing brackets are backlit and vertical after "Styling"?

Yes, the opening and closing brackets are vertical after "Styling", but the backlight either I don't understand what it is, or I don't see it. Level of programming skill, at the moment, is near zero.

Regards, Vladimir.