Self-learning the MQL5 language from scratch - page 67

 
Valeriy Yastremskiy:

The wording is not quite right, depending on the iterator, actions must be performed in the body of the loop. Depending on the iterator. And return the result of performing these actions in the loop body. If the loop was passed and there were no break or contingency statements, then to Expression 3 and then to Expression 2 and if it is True, then with a new iterator to the body of the loop.

That's it! Going to hang myself... Didn't understand anything at all. I needed a pause for comprehending what I had written.

Regards, Vladimir.

 
MrBrooklin:

By the way, there's nothing in the MQL5 Reference about the fact that the loop should return something upon completion. Maybe I misunderstood something again? Or maybe it refers to the if statement?

Sincerely, Vladimir.

I didn't say it right, the loop returns nothing, but you have to know the result of calculation somehow.)

Hang yourself early, it's more complicated.)

 
MrBrooklin:

That's it! I'm going to hang myself... I don't understand anything at all. You need a pause to comprehend what you've written.

Respectfully, Vladimir.

Norm, if you don't understand it the first time, you have to read it a second time... But not immediately, walking helps. The cycle is well explained in Kovalev. Or in C textbooks. It just needs to be understood. And then you will understand where you need it and where you don't.

When initiating the loop, the first iteration of Expression 1 and into the loop body, at the end of the loop body Expression 2, then Expression 3 and if it is False the loop ends, and if it is true the next iteration into the loop body.

 
VVT:

I said it wrong, the loop does not return anything, but you need to know the result of the calculation somehow, I showed an example of this solution)

Yes, I'm already sitting here figuring it out and want to understand it thoroughly, what and for what. Thanks for the tip!

Regards, Vladimir.

 
Valeriy Yastremskiy:

Norm, if you don't understand it the first time, you have to read it a second time... BUT not immediately, walking helps. The cycle is well explained in Kovalev. Or in C textbooks. It just needs to be understood. And then an understanding will come where it's needed and where it's not.

Right, we should go and have lunch at the same time.

Sincerely, Vladimir.

 
Valeriy Yastremskiy:

Norm, if you don't understand it the first time, you have to read it a second time... BUT not immediately, walking helps. The cycle is well explained in Kovalev. Or in C textbooks. It just needs to be understood. And then you will understand where you need it and where you don't.

At loop initiation, the first iteration of expression 1 and into the loop body, at the end of the loop body, expression 2, then expression 3, and if it is False, the loop is terminated; if it is true, the next iteration into the loop body.

Valery, please clarify what you call the loop body? Expressions 1, 2 and 3 or the if statement which should be executed when looping through positions? In short, you need to reread the subject of loops in Sergiy Kovalev's textbook.

Regards, Vladimir.

 

This is what I found in Sergei Kovalev's tutorial for MQL4 programming language:

Формат оператора for

Полноформатный оператор цикла for состоит из заголовка, содержащего Выражение_1, Условие и Выражение_2,
и исполняемого тела цикла, обрамлённого фигурными скобками.

  for (Выражение_1; Условие; Выражение_2)          // Заголовок оператора цикла
      {                                            // Открывающая фигурная скобка
      Блок операторов,                             // Тело цикла может состоять ..
      составляющих тело цикла                      //.. из нескольких операторов
      }                                            // Закрывающая фигурная скобка

Если в операторе for тело цикла составляет один оператор, то фигурные скобки можно опустить.

Regards, Vladimir.

 
MrBrooklin:

Valery, please clarify what you call the body of the loop? Expressions 1, 2 and 3 or the if statement, which should be executed when looping through positions? In short, you need to reread the subject of loops in Sergei Kovalev's textbook.

Sincerely, Vladimir.

The body is the contents of the operator/function, i.e. what exactly it does.

Expressions 1,2,3 are mandatory parameters, they usually pop up in the hint window when writing code

 
VVT:

Body, this is the content of the statement/function, i.e. what it does

Expressions 1,2,3 are mandatory parameters, they usually pop up in the hint window when writing code

Thanks for the tip. I also found the information on the body in Sergei Kovalev's tutorial.

Regards, Vladimir.

 

If the MQL5 programming language handbook had written it like this straight away:

Формат оператора for

Полноформатный оператор цикла for состоит из заголовка, содержащего Выражение_1, Выражение_2 и Выражение_3,
и исполняемого тела цикла, обрамлённого фигурными скобками.

  for (Выражение_1; Выражение_2; Выражение_3)      // Заголовок оператора цикла
      {                                            // Открывающая фигурная скобка
      Блок операторов,                             // Тело цикла может состоять ..
      составляющих тело цикла                      //.. из нескольких операторов
      }                                            // Закрывающая фигурная скобка

Если в операторе for тело цикла составляет один оператор, то фигурные скобки можно опустить.

Правило исполнения оператора for такое: "Начиная с ..., до тех пор пока..., с шагом... выполнять следующее: ...".

then there wouldn't be so many unnecessary questions. At least, beginners would have fewer questions.

Regards, Vladimir.