Questions from Beginners MQL5 MT5 MetaTrader 5 - page 25

 
fyords:

Yes, it is set, but when it is triggered...

Or another example: we have a pending order, its price differs from the current one by 1 point, at the next tick the price jumps not by 1 point, but, let us say, by 3-5 points, which results in opening at a wrong price. An obvious example is a gap.

Or maybe I do not understand the question and am dumb.

Here I rather misunderstand how OrderGetTicket works. The function returns alternately false and true. Even if we consider that the order is placed at a wrong price, it should simply return false. But it alternately ...


UPD: In general, the matter was in a forgotten NormalizeDouble in price passing. As usual:) The function itself works fine.


 
Please tell me if it is possible to write
 if (OrderTicket=OrderGetTicket(i)) {//Возвращает тикет соответствующего ордера и автоматически выбирает ордер

The function, if no order is selected, gives zero?

That is, if the equal is not double, simple, it will be an assignment here, not a comparison? Isn't zero the same as no?

I didn't get an error right away, but I realized later that I hadn't understood what I'd written!

 
Dimka-novitsek:
Can you please tell us if it is possible to write

The function, if no order is selected, gives zero?

That is, if the equal is not double, simple, it will be an assignment here, not a comparison? Isn't zero the same as no?

I didn't get an error right away, but I realized later that I hadn't understood what I'd written!

The expression is correct; the function description says that it will return zero if it fails. Zero for if is false. So the construct will work all right.

Another thing is that the trading functionality is so fast that we have sent an order on one tick and it is already in the history on the next one, so this construct will very often (but not always) return false.

This code shows that you are checking the orders you have placed, but not yet filled. The OnTradeTransaction() function is better suited for monitoring them.

Документация по MQL5: Стандартные константы, перечисления и структуры / Торговые константы / Свойства ордеров
Документация по MQL5: Стандартные константы, перечисления и структуры / Торговые константы / Свойства ордеров
  • www.mql5.com
Стандартные константы, перечисления и структуры / Торговые константы / Свойства ордеров - Документация по MQL5
 
THANK YOU!!!
 
I have no idea how to deal with classes, virtual functions. I've been reading, reading, reading... For an hour now, and not for the first time. It is written somehow heavily, incomprehensibly, and most importantly, sprinkled with new and novel terms - you just have to follow the links. Here, it says ( Classes and structures can have an explicit constructor and destructor) go look Constructors and Destructors It says (Constructor is a special function that is called automatically when you create a structure object or class and is usually used to initialize class members) In short, I do not understand.
Документация по MQL5: Основы языка / Типы данных / Структуры и классы
Документация по MQL5: Основы языка / Типы данных / Структуры и классы
  • www.mql5.com
Основы языка / Типы данных / Структуры и классы - Документация по MQL5
 
Dimka-novitsek:
I have no idea how to deal with classes, virtual functions. Reading, reading, reading, reading. For an hour, and not for the first time. It is written somehow heavily, incomprehensibly, and the main thing is covered with new and novel terms - you just have to follow the links. It says ( Classes and structures can have an explicit constructor and destructor) I'm going to look at Constructors and Destructors It says (Constructor is a special function that is called automatically when creating a structure object or class and is usually used to initialize class members) In short, I do not understand.

A constructor is a function called automatically when a class object is created and is used to initialise the object.

Is it clearer? If not, I'm powerless.

 
Thank you! All right. I'm gonna go play soccer now. I'll come back and pack up and ask. I'll ask. What's a virtual function? Does it run whenever it wants? What's the word dynamic?
Документация по MQL5: Основы языка / Объектно-ориентированное программирование / Виртуальные функции
Документация по MQL5: Основы языка / Объектно-ориентированное программирование / Виртуальные функции
  • www.mql5.com
Основы языка / Объектно-ориентированное программирование / Виртуальные функции - Документация по MQL5
 

So. It says that the choice of which function definition to call for the virtual function is dynamic (at runtime).

The function definition, which is in brackets, that is, it orders the machine to do something specific, right? But here it turns out that the machine itself does whatever it wants and when it wants, just like my friend Vasya? Really, I've read the phrase 100 times already, but I can't understand it. I can't understand it! I'll try to read the examples carefully and attentively...

And I started reading about the class - that's where I started, to understand, I was writing about the function!

 
Dimka-novitsek:

So. It says that the choice of which function definition to call for the virtual function is dynamic (at runtime).

The function definition, which is in brackets, that is, it orders the machine to do something specific, right? But here it turns out that the machine itself does whatever it wants and when it wants, just like my friend Vasya? Really, I've read the phrase 100 times already, but I can't understand it. I could bang my head! I'll try to read the examples carefully and attentively...

And I started reading about the class - that's where I started, to understand, I was writing about a function!

Are you kidding me?

Learn to ask the right questions and you won't have to ask most of them.

Virtual functions only make sense in the context of inheritance.

The trick with inheritance is not only that code can be spread out over many classes (as inheritance increases),

but in that you can first declare a dynamic ancestor object and then undefine it as a descendant.

For example, an object needs to be declared globally, but at the declaration point there is no knowledge about what class the object should be. Then classes are inherited from common ancestor, a dynamic object of the ancestor is declared in global scope and then, when the class the object should be of, it is redefined by new operator.

The word dynamic is underlined because it cannot be done with static class, static one is defined immediately and completely.

 
OK, it doesn't really sink in right away, but something is coming through. Thank you. If I may, I will ask as I go along.