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

 
Seric29:

For example, I declare input parameters and from these parameters I need to take global variables and view them, but there is a problem Input parameters cannot be an array

if we're talking aboutInput variables, you can simplify it - they have a global visibility and you can use them in any code section

or write them once to an array in the OnInit() section, and later you can copy an array to an array, but here you need arrays to be the same - take an array with spare, but then you need to control array index numbers to avoid a bug - you might use an empty array value - the compiler will not generate an error, but the calculation will be erroneous

input int a1=1;
input int a2=2;
input int a3=3;

int ArrayOfInput[3];
int OnInit()
  {
   ArrayOfInput[0] =a1;
   ArrayOfInput[1] =a2;
   ArrayOfInput[2] =a3;
  return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
 // delete cx;
  }
//+------------------------------------------------------------------+
void OnTick()
  {
      int arr[3];
      ArrayCopy(arr,ArrayOfInput);
  }
//+------------------------------------------------------------------+
HH: for some reason I was sure that the assignment operator works for identical arrays, maybe mixed up with class - it definitely works there if the objects are of the same class
 
Igor Makanu:

if we are talking aboutInput variables, you can simplify it - they have global visibility and you can use them in any code section

or write them once to an array in the OnInit() section, and later you can copy an array to an array, but here you need arrays to be the same - take an array with spare, but then you need to control array index numbers, to avoid a bug - you may use an empty array value - the error will not appear, but calculations will be erroneous

SZZ: for some reason, I was sure that the assignment operator works for the same arrays, maybe mixed up with the class - it certainly works if the objects are the same class

No there also such I tried (maybe tried a little and badly because I'm not very good at them but as far as I tried it does not work plus to all classes need to handle through a colon is better to do so here as you showed) thought maybe through the classes is not necessary so that's how you did one line to assign.

 

Hello.

Can you please tell me if you can change the time zone in the standard alerts popup?

I need to synchronize the time of the alert with the terminal time (when it's different in the terminal and the alert window). Is it possible?
 
Why in mql4 you can call int(and any other returnable value) and void(procedural function) in the same way, how come?
 

Question. How can I loop through all enumeration values with a non-equal step?


enum Types {

One=11,

Two=12,

Three=15,

Four=22,

Five=27

};

 
The_Sheikh:

Question. How can I loop through all enumeration values with a non-equal step?


enum Types {

One=11,

Two=12,

Three=15,

Four=22,

Five=27

};

no, sizeof() does not work for enumhttps://docs.mql4.com/ru/basis/types/integer/enumeration

and when converting types, the constant name is lost

enum Types { One=11, Two=12, Three=15, Four=22, Five=27,Six = 111,Seven = 222};
enum Types_abc { a, b, c, d, e,f,g};
void OnStart()
  {
   int sz = sizeof(Types);
   Print("sz = ",sz);
   Types z = Two;
   Types_abc x = b;
   Print("z = ",EnumToString(z)," , x = ",EnumToString(x));
   x = (Types_abc)z;
   Print("z = ",EnumToString(z)," , x = ",EnumToString(x));
  }

2019.08.03 10:52:13.288 tst EURUSD,H1: sz = 4

2019.08.03 10:52:13.288 tst EURUSD,H1: z = Two , x = b

2019.08.03 10:52:13.288 tst EURUSD,H1: z = Two , x = Types_abc::12


 
Elena Baranova:

Hello.

Can you please tell me if it is possible to change the time zone in the standard pop-up with an alert?

I need to synchronize the time of the alert with the terminal time (when it's different in the terminal and the alert window). Is it possible?
The Alert shows the local time on the PC. To make it match the terminal time, you can simply change the computer time.
 
Seric29:
Why in mql4 you can call int(and any other returnable value) and void(procedural function) functions in the same way?

it's called "overloading".

Документация по MQL5: Основы языка / Функции / Перегрузка функций
Документация по MQL5: Основы языка / Функции / Перегрузка функций
  • www.mql5.com
Обычно в названии функции стремятся отобразить ее основное назначение. Читабельные программы, как правило, содержат разнообразные и грамотно подобранные идентификаторы. Иногда различные функции используются для одних и тех же целей. Например, рассмотрим функцию, которая вычисляет среднее значение массива чисел двойной точности, и такую же...
 

Hello. How do I catch the input signal from the illuminator indicator in the code? The indicator paints a candle on the chart and outputs an alert for entry.

Simply put I want to write a robot for this indicator.

 
Alexey Viktorov:
Alert displays the local time on the PC. To set it to the same time as the terminal time you can simply change the computer time.

Thanks ) Is this the only way, there is no other way to set the time in Alert? And is there an alternative to the standard Alert() function in MQL4, in which the alert time can be set to the terminal time?

Reason: