This guide describes how to create an expert advisor with a custom name, and how to prepare the setup package. This can be helpful if you create a lot of expert advisors for youself or develop for your clients - forex traders.
There's a template file "MyExpertTemplate.mq4" in "%TERMINAL_DATA_PATH%\MQL4\Projects\nquotes" folder which you can use. Copy it to "%TERMINAL_DATA_PATH%\MQL4\Experts" folder, rename to a custom name like "MyExpert.mq4" and open for modification. You need to modify the following:
After that you can compile this expert with MetaEditor, and run it as usually from the MT4 terminal. On startup it will pick up the right .NET DLL with your expert advisor code.
You can build the setup package using any tool you like. The simplest is to use a usual ZIP file. You will need the following minimum number of files to run your NQuotes-based code on the client PC:
%TERMINAL_DATA_PATH%\MQL4\Experts\MyExpert.ex4 (the compiled "MyExpert.mq4" MQL file) %TERMINAL_DATA_PATH%\MQL4\Experts\MyExpert.dll (the compiled .NET expert advisor) %TERMINAL_DATA_PATH%\MQL4\nquotes.config %TERMINAL_DATA_PATH%\MQL4\Libraries\nquotes\nquoteslib.ex4 %TERMINAL_DATA_PATH%\MQL4\Libraries\nquotes\nquotes.dll %TERMINAL_DATA_PATH%\MQL4\Libraries\nquotes\nquotes.connector.dll %TERMINAL_PATH%\msvcp100.dll %TERMINAL_PATH%\msvcr100.dll
In addition you need to have the base dependencies on the client PC: the MetaTrader 4 terminal and the .NET framework. To simplify development of an installer package you can embed the NQuotes setup file inside your custom installer. The NQuotes setup file is checking if .NET framework is present, and installs it if it's not. To run nquotes-setup-X.exe from your custom installer silently, use the following command line options:
nquotes-setup-X.exe /S /D=%TERMINAL_PATH%
nquotes-setup-X.exe /S /D=c:\Program Files\MetaTrader 4
Note the absense of quotes. See NSIS Installer Command Line Usage for some more examples.
A custom installer must be able to find a TERMINAL_DATA_PATH by a given TERMINAL_PATH. This is possible using the following process: scan "%APPDATA%\MetaQuotes\Terminal" folder, and for each folder X inside check if "%APPDATA%\MetaQuotes\Terminal\X\origin.txt" file is there. If origin.txt contains TERMINAL_PATH string, then TERMINAL_DATA_PATH = "%APPDATA%\MetaQuotes\Terminal\X" (we have a UAC mode terminal). If no such origin.txt was found, TERMINAL_DATA_PATH = TERMINAL_PATH (we have a portable/administrator mode terminal). Consider installing your package into both TERMINAL_DATA_PATH and TERMINAL_PATH.