How to work with cluster addresses in MT5 API

easy direct connection to any MT4 and MT5 server

How to work with cluster addresses in MT5 API

To connect MT5 account for the first time you need server ip address. You can get it with Broker.Search or MT5API.LoadServersDat methods.

Each MT5 server its cluster with several IP addresses, if you cannot connect to one IP address, need to try others.

After each successful connection we recommend to save field api.ClusterMembers that contains fresh cluster IP addresses or DNS names.

Code Snippet
  1. var api = new MT5API(1000686, "PaSs2572", "", 443);
  2. api.Connect();
  3. foreach (var item in api.ClusterMembers)
  4. {
  5.     Console.WriteLine(item.Key.ServerName);
  6.     foreach (var addr in item.Value)
  7.         Console.WriteLine(addr.Address);
  8. }

Later you can you can use that addresses to connect to MT5 account again. Keep in mind that some addresses from this list could be non responsive, in this case just need to try next member from the list.

If all members in that saved list failed to connect you can try to call Broker.Search method again. If you cannot find required server with Broker.Search but can connect with MT5 Terminal please use MT5API.LoadServersDat to extract data from servers.dat file (

Leave a Reply