Hi,
WHat is the replaced function of WindowExpertName() in MQL5 ? How can i get expert name in MQL5?
Thanks
This s corrrect sintaxe:
string pgm_name = MQLInfoString(MQL_PROGRAM_NAME)
https://www.mql5.com/en/docs/check/mqlinfostring

- www.mql5.com
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.
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!
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, ...).
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():
- then I tried to change Indicator shortname so I can remove it:
MQLInfoString(MQL_PROGRAM_NAME) -> return "to_be_deleted"
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"
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():
- then I tried to change Indicator shortname so I can remove it:
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"
MQL5_PROGRAM_PATH is the only way to get correct filename

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
WHat is the replaced function of WindowExpertName() in MQL5 ? How can i get expert name in MQL5?
Thanks