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

 

Hello, I want to write a trading panel for my EA in two versions mql4 and mql5. I'm not familiar with graphical objects yet. I've used an example from CLabel class of the standard library to create a moving menu. In mql5, the menu works fine, but not in mql4. When a chart period is changed, the menu objects are duplicated and their location relative to each other changes. Maybe, mql4 lacks some methods in CLabel class, that mql5 has? Could you suggest what to add in this class to avoid such problems?

Also in the example code of CLabel class it's not clear to me what these lines do:

EVENT_MAP_BEGIN(CControlsDialog) 
  
EVENT_MAP_END(CAppDialog)
 
Aleksandr Teleguz:

Hello, I want to write a trading panel for my EA in two versions mql4 and mql5. I'm not familiar with graphical objects yet. I've used an example from CLabel class of the standard library to create a moving menu. In mql5, the menu works fine, but not in mql4. When a chart period is changed, the menu objects are duplicated and their location relative to each other changes. Maybe, mql4 lacks some methods in CLabel class, that mql5 has? Could you suggest what to add in this class to avoid such problems?

Also, I'm not clear what these strings do in the code of CLabel class example:


The specified lines are macros which are written in file Defines.mqh. Literally, the first line of macro passes control to event handling function ofCControlsDialog class, then functions are executed between these macros and the last macro passes control toCAppDialogclass

 
Алексей Барбашин:

The specified lines are macros, which are written in Defines.mqh file. Literally, the first macro line passes control to event-handling function ofCControlsDialog class, then the functions between these macros are executed, and the last macro passes control toCAppDialogclass


Thank you, something is starting to become clear) And can you give me a link to documentation on the topic of macros?

 
Aleksandr Teleguz:

Thank you, it's starting to make sense) Can you give me a link to documentation on the topic of macros?


https://www.mql5.com/ru/docs/basis/preprosessor/constant

Документация по MQL5: Основы языка / Препроцессор / Макроподстановка (#define)
Документация по MQL5: Основы языка / Препроцессор / Макроподстановка (#define)
  • www.mql5.com
Основы языка / Препроцессор / Макроподстановка (#define) - справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 

int OnDeinit()

{

Alert("beg OnDeinit()");

// err=StringToInteger(err);

//------------------------

return(0);

Alert("end OnDeinit()");

}

//OnDeinit();-----------

The captive err is described as an integer


I don't see what the problem is.

Got the message

 
buyanov:

int OnDeinit()

{

Alert("beg OnDeinit()");

// err=StringToInteger(err);

//------------------------

return(0);

Alert("end OnDeinit()");

}

//OnDeinit();-----------

The captive err is described as an integer


I don't see what the problem is.

I got a message


I am not quite clear what the issue is and where the error is generated. If you have an err variable of the int type, why in the commented out line are you trying to convert it from string to int? Where exactly the error occurs?

 
Алексей Барбашин:

It is not clear what the issue is and where the error is coming from. If you have a variable err of int type, why are you trying to convert it from string to int type in the commented string? In what place an error occurs?

The thing is, I don't see any error, but I get a warning message implicut conversion integer to string. In any case, we need to figure it out.
 
buyanov The err string is described as an integer It is unclear what the problem is

The compiler message indicates the line and position of the error. You can click on the description line (bottom line in the picture) and the cursor will indicate the error in the program text. The DeInit function is executed right before the indicator or Expert Advisor is removed from the chart. Here, for example, created graphic elements can be deleted. If there are no actions to be performed (the function is empty) - the function can be deleted... If you have something like string x=125, correct to string x = (string)125

Instead of err=StringToInteger(err); err=StringToInteger((string)err); although some might find it funny

 
STARIJ:

The compiler message indicates the line and position of the error. You can click on the description line (bottom line in the picture) and the cursor will indicate the error in the program text. The DeInit function is executed right before the indicator or Expert Advisor is removed from the chart. Here, for example, created graphic elements can be deleted. If there are no actions to be performed (the function is empty) - the function can be deleted... If you have something like string x=125 correct to string x = (string)125

Instead of err=StringToInteger(err); err=StringToInteger((string)err); although some might find it funny


ms...

I did as you recommend

put lineerr=StringToInteger((string)err) in theOption function; no error.

But the warning implicit convthtion from string to number still remains, I guess the terminal will have to be reinstalled after all.

 
buyanov: I did, as you recommended, put lineerr=StringToInteger((string)err) in the OnDeinit function; no error.

but the implicit convthtion from string to number warning still remains, I guess I'll have to reinstall the terminal after all.

Please post your function OnDeinit - I will look at it. And tell me what you want from it. MetaEditor gives this error. Have a copy of terminal folder. Here Alexey Viktorov told how to quickly reinstall

Reason: