Is there a way to get a unique and constant identifier for someone's mql5 account inside of a mq5 indicator script?
Currently, there is no documented way of obtaining the MQL5.Community user name. There may be an undocumented way, but I am not aware of it.
The username is however stored in the "Config/common.ini" file as follows:
[Common] MQL5Login=username
It also appears in the Journal log file.
Currently, there is no documented way of obtaining the MQL5.Community user name. There may be an undocumented way, but I am not aware of it.
The username is however stored in the "Config/common.ini" file as follows:
It also appears in the Journal log file.
Hi, thanks for taking the time to read through my post and reply, I really appreciate it!
This username in the ini file is exactly what I'm looking for. I tried doing this snippet below but I can't seem to get the code to detect that the ini file exists. The following snippet was returning false for FileIsExist. What am I missing here?
string InpFileName = "C:/Users/Drew/AppData/Roaming/MetaQuotes/Terminal/D0E8209F77C8CF37AD8BF550E51FF075/config/common.ini"; if(!FileIsExist(InpFileName)) { printf("File does not exist"); }
As a sanity check I used python and did the following snippet and got back "True" so the path definitely exists.
os.path.exists("C:/Users/Drew/AppData/Roaming/MetaQuotes/Terminal/D0E8209F77C8CF37AD8BF550E51FF075/config/common.ini")
Do I need to copy the file to a txt file and/or write it to a new location or something? Maybe the mq5 code doesn't have access to the /config directory?
The documentation for FileIsExist https://www.mql5.com/en/docs/files/fileisexist states "For security reasons, work with files is strictly controlled in the MQL5 language. Files with which file operations are conducted using MQL5 means, cannot be outside the file sandbox." which I understand this but wouldn't a config ini file be within the sandbox of mql5?
Also might be a dumb question but where would one find the "Journal log file". I found there is a log file in MQL5\Logs but there was unfortunately no username within this file
Thanks for your help!
- www.mql5.com
MQL's file handling functions are sandboxed to the "Files" folder, under MQL folder, or under the Tester folder or in the common path folder. Those are the only areas where files can be accessed.
The journal log files would also be out of reach for the sandboxed functions.
Only DLL calls would be able to access these files (be it the config or logs).
MQL's file handling functions are sandboxed to the "Files" folder, under MQL folder, or under the Tester folder or in the common path folder. Those are the only areas where files can be accessed.
The journal log files would also be out of reach for the sandboxed functions.
Only DLL calls would be able to access these files (be it the config or logs).
"C:/Users/Drew/AppData/Roaming/MetaQuotes/Terminal/D0E8209F77C8CF37AD8BF550E51FF075
is unique to a persons metatrader account or metatrader installation?
It's for the installation only. So each installation on the PC has a different one, irrespective of the user ID or account number.
Hmm okay I think this might be my golden ticket then. I think I can use this unique computer instance ID to communicate with the licensing server. This would prevent someone from sending the .ex5 to someone else and using it on their computer. I went down the path of using serial number/mac address as a unique hardware identifier but this requires DLLs, is tough to handle across multiple operating systems, and its a bit more heavy lifting. I found a way to generate the instance id programmatically and natively within the .mq5 file.
dumb question but when you say "each installation on the PC has a different one". Am I understanding you correctly that this means someone could install multiple copies or versions of metatrader 5 and each installation has it's own unique instance id?
this is where I found the instance ID generation -> https://www.mql5.com/en/code/26945
- www.mql5.com
Hmm okay I think this might be my golden ticket then. I think I can use this unique computer instance ID to communicate with the licensing server. This would prevent someone from sending the .ex5 to someone else and using it on their computer. I went down the path of using serial number/mac address as a unique hardware identifier but this requires DLLs, is tough to handle across multiple operating systems, and its a bit more heavy lifting. I found a way to generate the instance id programmatically and natively within the .mq5 file.
dumb question but when you say "each installation on the PC has a different one". Am I understanding you correctly that this means someone could install multiple copies or versions of metatrader 5 and each installation has it's own unique instance id?
this is where I found the instance ID generation -> https://www.mql5.com/en/code/26945
No! That is not the same thing as I was talking about. That script generates a hash based on the terminal path and not the Installation Hash generated by MetaTrader.
I don't recommend using that method because should the user change the path (especially in portable mode), it would invalidade the license.
Plus, many of us use portable mode that does not have an installation hash ID in the path. Here is my example (using that script):
2022.09.07 01:01:41.231 instance (GBPUSD,D1) Install folder = C:\Trading\MetaQuotes\MetaTrader 5 2022.09.07 01:01:41.232 instance (GBPUSD,D1) Instance ID = 897252626A1CF54B5C61C568B559B237
Yes, you can have multiple installations of the terminal on a PC, and each will have a different hash in the data folder path. In portable mode however, we can choose own directory path and not have a hash id in it.
Yes, you can have multiple installations of the terminal on a PC, and each will have a different hash in the data folder path. In portable mode however, we can choose own directory path and not have a hash id in it.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello!
I'm brand new to metatrader but I work professionally as a programmer. I'm also brand new to these forums as well so I'm sorry if I'm overlooking some information out there. I'm working on a side project for a buddy of mine where I'm trying to create a remote licensing server for an indicator using this extremely helpful tutorial https://www.mql5.com/en/articles/359
What I would like to do is have the .mq5 indicator code send the python XML-RPC server a request that contains some sort of unique identifier that identifies the users mql5 account. What I wish that existed was a function called like ACCOUNT_USERNAME() that would give me the username that appears in the top right profile of metatrader. For example my mql5 community account username is "ginjahd". Is there some way I can get this username within the mq5 indicator code?
I found this documentation https://www.mql5.com/en/docs/constants/environment_state/accountinformation but it seems like all of the account info inside of it is related to broker accounts. From my limited understanding, it seems like a user could change their broker and thus these strings and account numbers returned by these functions could change and not be constant. I almost need something like the serial number of a users motherboard on their PC to be sent in the http request (I'm not going to do this but this is an idea I had, I needs some sort of unique identifier) Thank you for anyone who takes time to read this!
This is my code snippet in OnInit() but it seems like these values are not constant and will change depending on what the user chooses for their broker account