Self-learning the MQL5 language from scratch - page 59

 
MrBrooklin:

Hello Alexey, sorry for not reacting to your post straight away. The link is very interesting. I have looked through the codes of all 11 types of trailing stops and function libraries. It is all very interesting, even though it is written in MQL4. To be honest, I have never imagined that there are so many types of trailing stops. Thank you very much for your support!

Sincerely, Vladimir.


Everything is OK! :-)
To be honest I expected your reaction :-) :-)
I want to let you know that thanks to you and Vasily Sokolov I myself started to revise my codes and libraries here...
Thank you for the motivation!
He explained everything very well in terms of starting the trail template. All the more the names of functions are intuitively understandable. You've already approached it yourself in your code. Here everything is clear. The exp exp trawl body and functions come next. You've already got to this point on your own, so it's OK. The main thing now is to pay attention to their semantic load such as Breakeven and the trawl itself for buy and sell positions.
 
MrBrooklin:

Vasiliy, of course thank you very much for doing so much work for me, but it didn't bring me any closer to understanding where these functions plus operators came from and, most importantly, why they appeared. It would have been more correct to get to the point of writing that code, which you've suggested to me. I really wanted to get to this point myself and now I want to.

I understand that you, like many others, are tired of my constantly spelling out all the lines of code and trampling on the spot, but the problem is that I still don't understand how everything is built, from the algorithm to code writing. I must add lack of knowledge of English to the problem, because I have to copy and paste almost all compiler error and warning messages, and other English words into Google Translator. By the way, if anyone tried to run those micro, even nano-codes I posted in this thread, they all passed compilation with "0 error, 0 warnings".

Now I need some time to realize, or rather to understand why these functions and operators appeared. So, in short, it's a silent horror. And I am a bad student when I don't understand elementary things.

Thank you and all other programmers for tolerating my slow-wittedness. Although I realize that your patience is not boundless.

Sincerely, Vladimir.


If you do not understand something in the MetaEditor, press F11 on highlighted operators in the code of Vasiliy's template and read the help on them.
 
Aleksey Masterov:

If you don't understand something in the meta-editor, press F11 on the highlighted operators in Vasiliy's template code and study the help on them.

Hello Alexey, thanks for the tip. I learnt about F1 key (maybe it is what you mean) when I have just started studying MQL5. I always use HELP, i.e. MQL5 Reference, and look through available examples that explain how to use one or another property (variable, operator, loop, function, class, etc.).

Regards, Vladimir.

 
MrBrooklin:

Hello! Maxim above correctly said a brief description of what this or that function does helps in understanding and remembering,

I would add that headers help to find the right block in a pile of code, e.g. a block of input parameters starts with a header

//+------------------------------------------------------------------+
//| Expert input parameters                                          |
//+------------------------------------------------------------------+
 
A simple task for Vladimir:
Write a script to calculate the factorial of a given number. The number is given by parameters and can be in the range from 1 to 15 inclusive, if it exceeds the specified range, output a message. The answer should also be printed.
 
Aliaksandr Hryshyn:
A simple task for Vladimir:
Write a script to calculate the factorial of a given number. The number is given by parameters and can be in the range from 1 to 15 inclusive, if it is out of the specified range, print a message. The answer should also be printed.

Hello, Alexander!

Hello, dear participants of this thread!

I decided to take a break until the next weekend, i.e. October 17, for several reasons:

  1. Because of the excess of information obtained in such a short time for me, came a complete stupor!
  2. I need to take a little rest and completely switch to other topics, without visiting the MQL5 Forum.
  3. I plan to sit at computer again this weekend and read all messages from 1st to 59th page of this thread.
  4. Analyze all constructive material provided by the participants in this thread and draw conclusions.

In the future I will try to post code less frequently, but to make it richer and more well-rounded and not as I did before, when I posted a few lines at a time, distracting forum participants from more important things.

This message doesn't mean that I've decided to give up and capitulate to MQL5. In fact, I've got a strong desire to study it, but I will try to do it on a different level of perception of information.

See you this weekend!

With great respect to all, Vladimir.

 

While TC is on time out...

Parallel to this topic I teach my children programming (they are supposed to be at school, but they are taught "would kill you"). Therefore, there are some conclusions and notes.

1. The visual, tangible, visible and significant result is extremely important. The minimal amount of code you put in, printed out, should produce the maximum effect.

2. We, as self-respecting gurus, are drowning the TC in details. It should have a mess of MQL and API platform.

3. MQL is totally unsuitable for learning from 0 ...:-( having the background, it's pretty simple, but the foundation you need to get

to support TS in learning from zeros,

the first one is to provide the tester with an Expert Advisor with minimal code, which it will already be able to modify and add.

the last (it's the first one about the trailing stop) task - to write an owl and run it in the tester, then TS will see how exactly a stop is trailed.

 

I see the man has been bombarded with advice. I also decided to sign up, maybe I'll get rid of the desire))). Just kidding.

Okay. So: I want a classic trawl.

We divide the task into two parts:

  1. The trawl itself.
  2. Something on the screen.
Let's write the code:
enum EMessType{Init,Deinit,Set};

int OnInit(void){
   Messenger(Init);
   return INIT_SUCCEEDED;
}

void OnDeinit(const int reason){
   Messenger(Deinit);
}

void OnTick(){
   Messenger(Set,Tral());
}
  
string Tral() {return "0";}

void Messenger(EMessType fType,string fInfo=""){
   switch(fType){
      case Init:
      case Deinit:
         Comment("");
         break;
      case Set:
         Comment(fInfo);
   }
}

What's going on here?

  1. We have a Messenger function that will display messages.
  2. We have a Tral function that will trawl orders while it is a so called "stub" that returns some valid value for code execution.
  3. There is EMessType enumeration that defines what we want from it in the Messenger function; it has Init, DeIni and Set blocks

This is an example of a simple decomposition.

That's it, my wife is here, I'm evaporating))))

Tomorrow we will continue)))

PS If you got bored, don't hesitate to tell me)))

 
one week course on enum)
 
And why are you sticking with this trawl? The trawl is a minor piece of advice, nothing more. It would be better to take the indicator apart, like the dashboard.