Expert Advisors • Indicators • Scripts • Libraries

MQL.RobotFX.org is the biggest collection of MetaTrader expert advisors (MT5 & MT4), indicators, scripts and libraries that can be used to improve trading results, minimize risks or simply automate trading tasks

MetaTrader 5 Script | Instance ID script for MT4/MT5

MetaTrader Experts, Indicators, Scripts and Libraries

This script calculates and prints out the instance_id for MT4/MT5 installations.

The instance_id is used in the roaming folder names such as

C:/Users/{username}/AppData/Roaming/MetaQuotes/Terminal/{instance_id}/

Please, find more details here:

The original idea comes from the user JC, posted on the forum. Main changes are:

  • Built-in Unicode conversion using StringToShortArray (wide chars, 2 bytes); this should presumably support folder names with non-ASCII characters;
  • Built-in MD5 hashing using CryptEncode (CRYPT_HASH_MD5); this removes dependency from custom MD5 implementation;
The script prints current MetaTrader instance installation folder and corresponding instance_id in the experts log.
26945