Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1923

 
Valeriy Yastremskiy #:

Thanks, I see.)

Actually, the filling could be written explicitly)))), but not like this

MqlTick

Variable of MqlTick type allows you to get values Ask, Bid, Last and Volume in one call to SymbolInfoTick() function.

There is an example in the help.

Документация по MQL5: Константы, перечисления и структуры / Структуры данных / Структура для получения текущих цен
Документация по MQL5: Константы, перечисления и структуры / Структуры данных / Структура для получения текущих цен
  • www.mql5.com
Структура для получения текущих цен - Структуры данных - Константы, перечисления и структуры - Справочник MQL5 - Справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
That's the one I didn't fully understand. You can get it and it fills the structure))) Didn't expect equality)
 
Valeriy Yastremskiy #:
That's the one I don't fully understand. You can get and it fills the structure))) Didn't expect equality)

What's unclear in this help text?

"A variable of MqlTick type allows you to get the values of Ask, Bid, Last and Volume in one call to SymbolInfoTick(). "

A structure is just a data object into which you can write several values of different types.

If you don't write anything to the structure, what do you think will be in its fields?

In Help, it says "in one call to SymbolInfoTick() function", which means, that calling this function will fill the MqlTick structure passed to it.

In itself, the variable with structure type MqlTick will not magically fill in anything.

You write something in your variable, don't you? For example, Ask=SymbolInfoDouble(Symbol(),SYMBOL_ASK);.

What's the difference between these variables, then, that you want to see it filled with data immediately after declaring a variable with MqlTick type?

 
Artyom Trishkin #:

What's unclear in this help text?

"A variable of MqlTick type allows you to get the values of Ask, Bid, Last and Volume in one call to SymbolInfoTick(). "

A structure is just a data object into which you can write several values of different types.

If you don't write anything to the structure, what do you think will be in its fields?

In Help, it says "in one call to SymbolInfoTick() function", which means, that calling this function will fill the MqlTick structure passed to it.

In itself, the variable with structure type MqlTick will not magically fill in anything.

You write something in your variable, don't you? For example, Ask=SymbolInfoDouble(Symbol(),SYMBOL_ASK);.

What's the difference between these variables, if you want to see it filled with data right after declaring a variable of MqlTick type?

It's about the difference in perception))). This is the second time with me. OrderSelect also fills the structure, and I learned about it in the forum, and I did not understand it from the help. Maybe it's just me of course))))

Solutions may be different)))) )))

 
Valeriy Yastremskiy #:

It's about differences in perception.)) This is the second time it has happened to me. OrderSelect also fills in the structure, and I found out about it in the forum, but I didn't understand it from the help. Maybe it's just me of course))))

Solutions may be different)))) )))

If something (array, structure, variable) is passed to a function by reference, then it is logical to assume that it is filled in the function and the result is immediately displayed in the array, structure, variable

 
Artyom Trishkin #:

If something (array, structure, variable) is passed to a function by reference, it is logical to assume that it is filled in the function, and the result is immediately displayed in the array, structure, variable

An array and a structure are ALWAYS passed to a function by reference.

 
PapaYozh #:

Array and structure are ALWAYS passed to a function by reference.

We're talking about documentation, its usability when you get to know it), about references to an array / structure when passing them to a function, no argument)))

In general, of course you can guess, assume... but the soldier is not always clear, even a direct order))) Therefore, he is asked to repeat it)))

 
Valeriy Yastremskiy #:

A question has arisen.


#define Symbol  _Symbol

int OnInit()
  {
 
Ask=SymbolInfoDouble(Symbol,SYMBOL_ASK);        // Так работает
Ask=SymbolInfoDouble(Symbol(),SYMBOL_ASK);      // Почему ошибку скобок пишет? 

Funny mistake of copypaste)))

 
Valeriy Yastremskiy #:

Funny mistake in copypaste)))

The macro matched the function name

 
PapaYozh #:

The macro matched the function name

#define Symbol()  _Symbol       // скобки были пропущены

int OnInit()
  {
 
Ask=SymbolInfoDouble(Symbol,SYMBOL_ASK);        // Так перестанет работать
Ask=SymbolInfoDouble(Symbol(),SYMBOL_ASK);      // Так начнет

No, the substitution gave the wrong result.

_Symbol()              // скобки лишние
Reason: