Now as a next step, I'm building an Excel Ribbon utilizing those UDFs, for providing ease-of-use.
there's an Excel Add-in available, named MexcelTrader, which does this. here's the video
please guide how can I do this.
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.
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:
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.
please see my reply above and suggest.
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.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.