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

 
Roman Sharanov:
The question is this. Can I open 2 (or more) graphs at the touch of a button so that they are positioned vertically, equally occupying the entire monitor?

Should I try to open one chart and apply to it the customized template? I haven't tried it - I don't know. Just thinking out loud...

 

In mql, is there a way to set an abstract type for variables in a method?

For example, here we have:

void append(int &array[], int value){

}

I want the types to be not only int, but any type at all. Or is it necessary to overload a method as many times as I want it to accept types?

 
Dmitri Custurov:

In mql, is there a way to set an abstract type for variables in a method?

For example, here we have:

I want the types to be not only int, but any types at all. Or is it necessary to overload a method as many times as I want it to accept types?

  template<typename T>
  void append(int &array[], T value){ }

Or, if both types are the same:

  template<typename T>
  void append(T &array[], T value){ }

Or, if both are different types:

  template<typename T 1, typename T 2>
  void append(T1 &array[], T2 value){ }
Документация по MQL5: Основы языка / Объектно-ориентированное программирование / Шаблоны функций
Документация по MQL5: Основы языка / Объектно-ориентированное программирование / Шаблоны функций
  • www.mql5.com
Перегруженные функции обычно используются для выполнения похожих операций над различными типами данных. Простой пример такой функции в MQL5 - ArraySize(), которая возвращает размер массива любого типа. На самом деле эта системная функция является перегруженной, и вся реализация такой перегрузки спрятана от разработчика программ на MQL5: То есть...
 
Artyom Trishkin:

Great, thank you.

 
Dmitri Custurov:

Great, thank you.

Completed above.

 
Artyom Trishkin:

Maybe you should try to open one chart and apply to it a customized template? Haven't tried it - don't know. Just thinking out loud...

No, it still opens one graph in full screen

 
Roman Sharanov:

no, it still opens a single graph in full screen

I don't remember and can't look now, is there no way to apply a profile? Only a profile can help in this matter.

 

Help with the syntax, it's hard to find the difference

from the help and from the examples

int  ArraySize(
   int array[]      // массив с элементами типа int
   );
int  ArraySize(
   int &array[] 
   );
 
Alexey Viktorov:

I don't remember and can't look it up now, is there no way to apply a profile? Only a profile can help in this matter.

They write that if possible, only through WinAPI DLL, there is no such thing in MT as standard

 
Valeriy Yastremskiy:

Help with the syntax, it's hard to find the difference

from the help and from the examples

In MQL5, arrays are passed into the function by reference only - an appersand is required. It doesn't matter where it is located.

Reason: