Download MetaTrader 5

Detect MetaTrader 4 Brokers located on system (C#)

To add comments, please log in or register
xeechaun
15
xeechaun  
Hi,

Background
I'm a C# developer, working for my employer to build an Excel Add-in having MT4 functionalities.
As a first step I've implemented most of the trading functions and some other important ones, as Excel UDFs and now I can do the trading stuff by using these functions from Excel.

Now as a next step, I'm building an Excel Ribbon utilizing those UDFs, for providing ease-of-use.

What I need to figure out:
>I want to provide a Wizard in the ribbon which can detect all the MetaTrader 4 Brokers installed on the system and get their credentials e.g. Broker name, User, Password etc into the excel cells so that user don't have to enter them manually for all the brokers present on the computer. How can I detect all the MetaTrader 4 Brokers installed on the system and get their credentials?


there's an Excel Add-in available, named MexcelTrader, which does this. here's the video


please guide how can I do this.

thanks


Regards,

Zeeshan

Ian Flanagan
549
Ian Flanagan  

My guess is, MT4 doesn't know the broker name (as defined by AccountCompany() and/or TerminalCompany() ) unless it is connected to the server.

In the video, the "broker" actually looks like a server domain, so maybe you can find that in a file somewhere.

But how did they get account number and balance to Excel?

I'm pretty sure the only way to do it is to have each instance of MT4 open, and running an indicator that passes the broker name (actually server), account number, balance etc. Most of the commands you would need are here

EDIT: If MT4 has connected at least once to the server, the server name can be found in the history folder, but beware that different brokers sometimes use that same servers.

xeechaun
15
xeechaun  

Hi,

I've inspected how it detects the brokers installed on the system.

it goes through all the folders in Program Files (Program Files (x86) in case of x64 OS), tries to find the terminal.exe in all folders, and where it finds terminal.exe, it verifies that it's a MT4 broker by validating that folders like config, experts, profiles exist. and also verifies the .srv file exists in config folder.

now, to fetch the information, what it does is, it copies a .ex4 file into the experts folder, runs the terminal.exe (MetaTrader 4 terminal) and attaches the .ex4 as an expert adviser. following image shows this:Navigator

now what I need to know is how can I write such a script/monitor/advisor which can pass me back the info like Server Name, Account ID, Account Name, balance etc. in my C# program. I want to run and attach this monitor from C# code. please guide.

thanks

Regards,

Zeeshan

whroeder1
14781
whroeder1  
xeechaun: which can detect all the MetaTrader 4 Brokers installed on the system and get their credentials e.g. Broker name, User, Password etc
  1. Since terminals can be installed anywhere the only way is to scan all the hard drives, all directories for the terminal directory.
  2. You might be able to figure out the broker name from the history directory but not the others (config\\server.ini and the like are binary files)
  3. You might be able to have an EA write a file with TerminalCompany( ) but there is no access to passwords.
xeechaun
15
xeechaun  
WHRoeder:
  1. Since terminals can be installed anywhere the only way is to scan all the hard drives, all directories for the terminal directory.
  2. You might be able to figure out the broker name from the history directory but not the others (config\\server.ini and the like are binary files)
  3. You might be able to have an EA write a file with TerminalCompany( ) but there is no access to passwords.

please see my reply above and suggest.
Thanks

Ian Flanagan
549
Ian Flanagan  

If it's one time info, use a script. If it's continuous (like balance), use an indicator. Remember, this only runs once, every time there is a tick on the chart it's attached to. Maybe you're prefer to run an internal endless loop to continuously send data.

Easiest way to send data is to write to CSV, then C# reads

Harder but better is to include a C# dll in the mt4 indicator.

Any more and I may as well do your whole project for you.

xeechaun
15
xeechaun  
alladir:

If it's one time info, use a script. If it's continuous (like balance), use an indicator. Remember, this only runs once, every time there is a tick on the chart it's attached to. Maybe you're prefer to run an internal endless loop to continuously send data.

Easiest way to send data is to write to CSV, then C# reads

Harder but better is to include a C# dll in the mt4 indicator.

Any more and I may as well do your whole project for you.


thanks a lot, I think I can do it, just needed a few hints.


I need continuous data. and this is how the existing tool does it: attach to a chart (EURUSD), update the info on each tick.

suggest me a tutorial for writing a custom indicator to pass the info to a C# program and to include a C# dll in the mt4 indicator.

thanks

To add comments, please log in or register