WindowExpertName() in MQL5 ?

 

Hi,

WHat is the replaced function of WindowExpertName() in MQL5 ? How can i get expert name in MQL5?


Thanks

 
yster:

Hi,

WHat is the replaced function of WindowExpertName() in MQL5 ? How can i get expert name in MQL5?


Thanks

Try to use the MQL5InfoString(MQL5_PROGRAM_NAME)
 

This s corrrect sintaxe:


string pgm_name = MQLInfoString(MQL_PROGRAM_NAME)

https://www.mql5.com/en/docs/check/mqlinfostring

Documentation on MQL5: Checkup / MQLInfoString
Documentation on MQL5: Checkup / MQLInfoString
  • www.mql5.com
Checkup / MQLInfoString - Reference on algorithmic/automated trading language for MetaTrader 5
 
fksalviano:

This s corrrect sintaxe:


string pgm_name = MQLInfoString(MQL_PROGRAM_NAME)

https://www.mql5.com/en/docs/check/mqlinfostring

Did you realize that the previous answer had been made in 2010 ??  Regards.
 
Jose Francisco Casado Fernandez:
Did you realize that the previous answer had been made in 2010 ??  Regards.
Yes, but if tomorrow  another person find this topic like i've found today, so will found the correct sintaxe 
 

However the return values of MQLInfoString(MQL_PROGRAM_NAME) do not match in MQL4 and MQL5.

While MQL4 returns the name of the file (without the extension), MQL5 returns a name assigned in IndicatorSetString(INDICATOR_SHORTNAME, ...).

 
if(MQLInfoString(MQL_PROGRAM_NAME)!="your eaname") return(0);

no extension!

 
fksalviano #:

This s corrrect sintaxe:


string pgm_name = MQLInfoString(MQL_PROGRAM_NAME)

https://www.mql5.com/en/docs/check/mqlinfostring

This one helped me

 
Ex Ovo Omnia #:

However the return values of MQLInfoString(MQL_PROGRAM_NAME) do not match in MQL4 and MQL5.

While MQL4 returns the name of the file (without the extension), MQL5 returns a name assigned in IndicatorSetString(INDICATOR_SHORTNAME, ...).

Since Google results this thread when searching "MQL5 WindowExpertName", I'm here to ask is this issue solved?

MQL4 returns the name of the file, I want to also check the filename in MQL5, any idea? or we must use WinAPI now?

I have tried some results on indicators:

- OnInit():
MQLInfoString(MQL_PROGRAM_NAME) -> return "Data not ready, please refer to expert log for more information"
- then I tried to change Indicator shortname so I can remove it:
IndicatorSetString(INDICATOR_SHORTNAME, "to_be_deleted");
MQLInfoString(MQL_PROGRAM_NAME) -> return "to_be_deleted"

Ex Ovo Omnia #:

Well, regarding the proper import, the information is in the link you published.

GetModuleFileNameW (Unicode) and GetModuleFileNameA (ANSI)

 and

DWORD WINAPI GetModuleFileName( _In_opt_ HMODULE hModule, _Out_    LPTSTR  lpFilename, _In_     DWORD   nSize); 

The proper syntax for import would be

int GetModuleFileNameW(int zero,str& lpFilename,int nSize);

This command would very likely return "terminal.exe" module.

If you expect the current script name, you should use MQLInfoString(MQL_PROGRAM_NAME)

I have also saw your reply on another thread, pointing out that GetModuleFileNameW() will very likely return "terminal.exe" which is not desirable as we may want to get "MyIndicator" from "MyIndicator.ex4"

 
Yu Pang Chan #:
Since Google results this thread when searching "MQL5 WindowExpertName", I'm here to ask is this issue solved?

MQL4 returns the name of the file, I want to also check the filename in MQL5, any idea? or we must use WinAPI now?

I have tried some results on indicators:

- OnInit():
MQLInfoString(MQL_PROGRAM_NAME) -> return "Data not ready, please refer to expert log for more information"
- then I tried to change Indicator shortname so I can remove it:
IndicatorSetString(INDICATOR_SHORTNAME, "to_be_deleted");
MQLInfoString(MQL_PROGRAM_NAME) -> return "to_be_deleted"

I have also saw your reply on another thread, pointing out that GetModuleFileNameW() will very likely return "terminal.exe" which is not desirable as we may want to get "MyIndicator" from "MyIndicator.ex4"

edit:
MQL5_PROGRAM_PATH is the only way to get correct filename