mtapi
mtapi copied to clipboard
Update "How to build" in README
Please update the building section of your README to include more details.
The following really can't get anyone started.
How to Build Solution
The project is supported by Visual Studio 2017 and requires WIX Tools (http://wixtoolset.org/).
To make an API for MetaTrader4 use MtApiInstaller and for MetaTrader5 use MtApi5Installer.
All installers will be placed in the folder "[root]\build\installers" and all *.dll files will be
placed in "[root]\build\products". MQL files have been build to ex4 and stored into
folders "mq4" for MetaTrader and "mq5" for MetaTrader5. They are ready to be used in
terminals. Changing the source code of MQL expert requires recompilation with MetaEditor.
Resulting in the need to copy files "hash.mqh" and "json.mqh" to the MetaEditor include folder.
(Yes, I installed VS and WIX, then what?)
Here's a start to a Wiki...
Installing WIX for mtapi
-
You need to have Visual Studio already installed.
-
Make sure you install one of the latest (3.14+) development releases of the wixtoolset. (If you use an older installer you will have to install the ancient .NET 3.5 framework, and that I am sure you will regret, if you do!)
-
Run the installer and wait for completion or for asking to also install the VS extensions.

-
Install the WiX Toolset Visual Studio Extension depending on your VS version. For example, if you use VS 2017, go here or download from their GitHub, releases.
-
Done.
From forum channel:
To build the solution for MT4 you need to choose configuration x86 and start build for MtApiInstaller. It will build all projects related to MT4:
MtApi, MTApiService, MTConnector. MtApiBootstrapper is anexewrapper for installer that also contains the vc_redist libraries.
I think I need some more help here.
After having already installed VS2017 + WIX dep's as shown above, and having done:
git clone https://github.com/vdemydiuk/mtapi/
What are the next steps to import and compile the project (when using VS Code)?
I made some updates in readme. I will fill more information about project time to time.
WIP :construction:
What's a better place to test README markup files, but in an issue post!?
How to Build Solution
To build the solution for MT4, you need to choose the configuration to build for x86
and start with building the MtApiInstaller. This will build all projects related to MT4:
MtApiMTApiServiceMTConnector
For building the solution for MT5, you need to choose the configuration to build for x64 (or x86 for the 32-bit MT5)) and start build MtApi5Installer. This will build all projects related to MT5:
MtApi5MTApiServiceMT5Connector
All binaries are placed in the project root folder, in the build directory: ../build/.
The installers (*.msi, *.exe) will be found under: ../build/installers/.
All the DLL library binaries (*.dll) in: ../bin/.
MQL files have been pre-compiled to *.ex4 and can be found in the repository here:
..\mql4\..\mql5\
Changing the source code of the MQL Expert Advisor (EA), requires recompilation with MetaEditor.
Before you can recompile the EA, you need to add/place the following MQL library files, in the MetaEditor ../Include/ folder.
hash.mqhjson.mqh
The MetaEditor include folder is usually located here:
C:\Users\<username>\AppData\Roaming\MetaQuotes\Terminal\<terminal-hash>\MQL5\Include\.
Project Structure
-
MTApiService:(C#, .dll)
The common engine communication project of the API. It contains the implementations of client and server sides. -
MTConnector, MT5Connector:(C++/CLI, .dll)
The libraries that are working as proxy between MQL and C# layers. They provides the interfaces. -
MtApi, MtApi5:(C#, .dll)
The client side libraries that are using in user's projects. -
(MQL4/MQL5, .ex4)
MT4 and MT5 Expert Advisors linked to terminal's charts. They executes API's functions and provides trading events. -
MtApiInstaller, MtApi5Installer(WIX, .msi)
The project's installers. -
MtApiBootstrapper, MtApi5Bootstrapper(WIX, .exe)
The installation package bundles. There are wrappers for installers that contains the vc_redist libraries (Visual C++ runtime) placed in [root]\vcredist.
Installation
Use the installers to setup all libraries automatically.
- For MT4, use:
MtApiInstaller_setup.exe - For MT5, use:
MtApi5Installer setup.exe
MtApiBootstrapper and MtApi5Bootstrapper are installation package bundles that contain the installers and vc_redist Windows libraries. The installers place the MTApiService.dll into the Windows GAC (Global Assembly Cache) and copies MTConnector.dll and MT5Connector.dll into the Windows's system folder, whose location depend on your Windows OS. After installation, the MtApi.ex4 (or MtApi5.ex5) EA, must be copied into your Terminal data folder for Expert Advisors, which is normally located in: ../MQL5/Experts/.
To quickly navigate to the trading platform data folder, click: File >> "Open data folder" in your MetaTrader Terminal.
@vdemydiuk just sent you PR for updating the README. Forgot to do it to the dev branch, but maybe you can handle it anyway?
PS. I am still not able to compile, using these instructions. Can you provide some detail pelase?
- Also, is .NET SDKs for Visual Studio 2017 needed?
- Can VS 2019 be used?
:hot_face: --- :arrow_right: --- :1st_place_medal:
Thanks to some amazing help by @vdemydiuk I have now been able to compile this whole project for MT4 on a Win8.1 & VS 2017. I will try to summarize the steps and procedures in this thread, and then we can clean it up and add it to a COMPILE.md or the Wiki.
First things first. make sure you have cloned the latest version of this repo.
Note: :exclamation:
Here I use a shallow clone, because I am not yet interested in making dev changes, just build the project.
If you need to do dev and make PR's, you have to use a normal/full clone.
# cd D:\myDev\_gh_cloned\
#git clone --depth=1 --no-tags [email protected]:vdemydiuk/mtapi.git # ssh -- better
git clone --depth=1 --no-tags https://github.com/vdemydiuk/mtapi.git # http --faster
cd mtapi
Installation Instructions
Next Prepare yourself for Visual Studio 2019 (from now on just "VS"). (But here I use 2017.) You need to install a bunch, and I mean a lot of, yes too many, dependencies. Otherwise you will run into all sorts of weird stuff. So if you're new to VS, just make sure you have the latest updated version.
Click for a Surprise!

- [ ] Install
Visual Studio 2019from here. - [x] Install the WIX stuff from above ...
- [ ] Install the 2 .NET Framework's:
.NET 4.8,.NET 4.7.2and.NET Core(5.0) from here:
Click Me!


- [ ] Fire up the
Visual Studio Installerand install the following items:
Click Me!


- [ ] Also make sure you install the
C++/CLIpackage.
More interestingly you may also try to just import all the requirements I had, by clicking "Import Configuration" in the drop-down (as shown in the screenshot below). Save the following text/code into a file called .vsconf and import it.
Click Me!

:arrow_right: Import This:
{
"version": "1.0",
"components": [
"Microsoft.VisualStudio.Workload.ManagedDesktop",
"Microsoft.VisualStudio.Workload.NativeDesktop",
"microsoft.net.componentgroup.targetingpacks.common",
"microsoft.componentgroup.blend",
"microsoft.visualstudio.component.entityframework",
"microsoft.visualstudio.component.diagnostictools",
"microsoft.visualstudio.component.debugger.justintime",
"microsoft.net.componentgroup.4.7.2.developertools",
"microsoft.visualstudio.component.vc.diagnostictools",
"microsoft.visualstudio.component.vc.cmake.project",
"microsoft.visualstudio.component.vc.atl",
"microsoft.visualstudio.component.vc.testadapterforboosttest",
"microsoft.visualstudio.component.vc.testadapterforgoogletest",
"microsoft.visualstudio.componentgroup.nativedesktop.win81",
"microsoft.visualstudio.component.vc.cli.support",
"microsoft.component.netfx.native",
"microsoft.visualstudio.component.windows10sdk",
"component.wixtoolset.visualstudioextension.dev15",
"component.wixtoolset.visualstudioextension.schemas3",
"component.wixtoolset.visualstudioextension.schemas4"
]
}
- [ ] Fire up
Visual Studioand open the cloned project repo (mtapi), by clicking:
[File] > Open > Project/Solution(or just typeCTRL-SHIFT-o)- Navigate to the path of your repo. For example:
D:\myDev\_gh_cloned\mtapi\ - Select the solution file, named:
MetaTraderApi_2017.sln.
(Note that VS projects are also called solutions and have the file extension*.sln.)
Click Me!

- [ ] Now the project is imported, you need to adjust a few things:
- Retarget the project to use
Win8.1instead ofWin10, if needed. - Change to use
32-bitbuilds (for MT4) by default, as shown on top bar of VS. - Select a Startup Project. Set to use:
TestApiClientUI, also shown on top bar of VS. - Select what to build in the
Configuration Manager....
Click Me!




- [ ] You are now ready to Build the project!
Select:Solution 'MetaTraderApi_2017' (13 projects)and hitF6or click the Build Solution button.
Click Me!

:1st_place_medal: DONE! :sparkling_heart:
The tree structure of all available DLL's, after a successful release build:
Click Me!
# tree --dirsfirst --prune -P *.dll ./
./
├── build
│ └── products
│ ├── Debug
│ │ ├── MT5Connector.dll
│ │ ├── MtApi.dll
│ │ ├── MTApiService.dll
│ │ ├── MTConnector.dll
│ │ └── Newtonsoft.Json.dll
│ └── Release
│ ├── MT5Connector.dll
│ ├── MtApi.dll
│ ├── MtApi5.dll
│ ├── MTApiService.dll
│ ├── MTConnector.dll
│ └── Newtonsoft.Json.dll
├── Examples
│ └── MatLab
│ └── AdvancedExample
│ └── DLL
│ └── MtApi5.dll
├── MtApi
│ └── obj
│ ├── Debug
│ │ └── MtApi.dll
│ └── Release
│ └── MtApi.dll
├── MtApi5
│ └── obj
│ └── Release
│ └── MtApi5.dll
├── MTApiService
│ └── obj
│ ├── Debug
│ │ └── MTApiService.dll
│ └── Release
│ └── MTApiService.dll
├── MtApiSetupActions
│ ├── bin
│ │ ├── Debug
│ │ │ ├── Microsoft.Deployment.WindowsInstaller.dll
│ │ │ ├── MtApiSetupActions.CA.dll
│ │ │ └── MtApiSetupActions.dll
│ │ └── Release
│ │ ├── Microsoft.Deployment.WindowsInstaller.dll
│ │ ├── MtApiSetupActions.CA.dll
│ │ └── MtApiSetupActions.dll
│ └── obj
│ └── x86
│ ├── Debug
│ │ ├── MtApiSetupActions.CA.dll
│ │ └── MtApiSetupActions.dll
│ └── Release
│ ├── MtApiSetupActions.CA.dll
│ └── MtApiSetupActions.dll
├── packages
│ ├── log4net.2.0.5
│ │ └── lib
│ │ ├── net10-full
│ │ │ └── log4net.dll
│ │ ├── net11-full
│ │ │ └── log4net.dll
│ │ ├── net20-full
│ │ │ └── log4net.dll
│ │ ├── net35-client
│ │ │ └── log4net.dll
│ │ ├── net35-full
│ │ │ └── log4net.dll
│ │ ├── net40-client
│ │ │ └── log4net.dll
│ │ ├── net40-full
│ │ │ └── log4net.dll
│ │ └── net45-full
│ │ └── log4net.dll
│ ├── MSBuild.ILMerge.Task.1.0.5
│ │ └── tools
│ │ └── MSBuild.ILMerge.Task.dll
│ ├── Newtonsoft.Json.12.0.2
│ │ └── lib
│ │ ├── net20
│ │ │ └── Newtonsoft.Json.dll
│ │ ├── net35
│ │ │ └── Newtonsoft.Json.dll
│ │ ├── net40
│ │ │ └── Newtonsoft.Json.dll
│ │ ├── net45
│ │ │ └── Newtonsoft.Json.dll
│ │ ├── netstandard1.0
│ │ │ └── Newtonsoft.Json.dll
│ │ ├── netstandard1.3
│ │ │ └── Newtonsoft.Json.dll
│ │ ├── netstandard2.0
│ │ │ └── Newtonsoft.Json.dll
│ │ ├── portable-net40+sl5+win8+wp8+wpa81
│ │ │ └── Newtonsoft.Json.dll
│ │ └── portable-net45+win8+wp8+wpa81
│ │ └── Newtonsoft.Json.dll
│ └── Newtonsoft.Json.8.0.3
│ └── lib
│ ├── net20
│ │ └── Newtonsoft.Json.dll
│ ├── net35
│ │ └── Newtonsoft.Json.dll
│ ├── net40
│ │ └── Newtonsoft.Json.dll
│ ├── net45
│ │ └── Newtonsoft.Json.dll
│ ├── portable-net40+sl5+wp80+win8+wpa81
│ │ └── Newtonsoft.Json.dll
│ └── portable-net45+wp80+win8+wpa81+dnxcore50
│ └── Newtonsoft.Json.dll
└── TestClients
├── MtApi5TestClient
│ ├── bin
│ │ └── Release
│ │ ├── MtApi5.dll
│ │ ├── MTApiService.dll
│ │ └── Newtonsoft.Json.dll
│ └── obj
│ └── x86
│ └── Release
│ └── TempPE
│ └── Properties.Resources.Designer.cs.dll
├── TestApiClientUI
│ ├── bin
│ │ ├── Debug
│ │ │ ├── MtApi.dll
│ │ │ ├── MTApiService.dll
│ │ │ └── Newtonsoft.Json.dll
│ │ └── Release
│ │ ├── MtApi.dll
│ │ ├── MTApiService.dll
│ │ └── Newtonsoft.Json.dll
│ └── obj
│ └── x86
│ └── Release
│ └── TempPE
│ └── Properties.Resources.Designer.cs.dll
└── TestMtApi
└── TestMtApi
├── bin
│ ├── Debug
│ │ ├── MtApi.dll
│ │ ├── MTApiService.dll
│ │ └── Newtonsoft.Json.dll
│ └── Release
│ ├── MtApi.dll
│ ├── MTApiService.dll
│ └── Newtonsoft.Json.dll
└── obj
└── x86
└── Release
└── TempPE
└── My Project.Resources.Designer.vb.dll
84 directories, 69 files
The tree structure of all available *.exe' applications...
Click Me!
# tree --dirsfirst --prune -P *.exe ./
./
├── build
│ └── installers
│ ├── Debug
│ │ └── MtApi_Setup.exe
│ └── Release
│ ├── MtApi_Setup.exe
│ └── MtApi5_Setup_x86.exe
├── packages
│ └── ILMerge.2.13.0307
│ └── ILMerge.exe
├── TestClients
│ ├── MtApi5TestClient
│ │ ├── bin
│ │ │ └── Release
│ │ │ └── MtApi5TestClient.exe
│ │ └── obj
│ │ └── x86
│ │ └── Release
│ │ └── MtApi5TestClient.exe
│ ├── TestApiClientUI
│ │ ├── bin
│ │ │ ├── Debug
│ │ │ │ └── TestApiClientUI.exe
│ │ │ └── Release
│ │ │ └── TestApiClientUI.exe
│ │ └── obj
│ │ └── x86
│ │ ├── Debug
│ │ │ └── TestApiClientUI.exe
│ │ └── Release
│ │ └── TestApiClientUI.exe
│ └── TestMtApi
│ └── TestMtApi
│ ├── bin
│ │ ├── Debug
│ │ │ └── TestMtApi.exe
│ │ └── Release
│ │ └── TestMtApi.exe
│ └── obj
│ └── x86
│ ├── Debug
│ │ └── TestMtApi.exe
│ └── Release
│ └── TestMtApi.exe
└── vcredist
├── vc_redist.x64.exe
└── vc_redist.x86.exe
31 directories, 16 files
MtApi5_Setup_x86.exe are obsolete. Actually releases of MT5 runs only on 64Bit Windows https://www.mql5.com/en/forum/325529
MtApi5_Setup_x86.exe are obsolete.
That's great new. Finally get rid of that extra "crust". Now it will be clear what's 32 vs 64 bit without confusing installations. Which mean that perhaps the next installer would do both MT4 and MT5.
Maybe there will be big changes soon anyway. I recently had contact with the developers. The tester will be completely rewritten. This has surely to do with the fact that the MQ MT5-Python-API has no functionality for the strategy tester yet. This will be in the new tester. But this is only my guess.
Maybe it makes sense to wait until then and then reorient the project.
FAQ item:
Taken from Telegram:
-
Q: What is the difference between the
installerand thebootstrap?A: The
installersetup all libraries of the MtApi project into the defined folders:Window system, Window GACand inProgram Files).Boostrapis a bundle that contains the installer and vc_redist package. vc_redist is theMicrosoft Visual C++ redistributablepackages, which are runtime components in support of Windows applications compiled with Microsoft Visual Studio.
The reason why I made bootstrap for MtApi, is that many users sent feedbacks that MtApi is not working after install. I investigated dependences of the dll's on their PC and found that many versions of Windows does not contains some libraries needed for working MtApi (specifically
MTConnector.dll, MT5Connector.dllwere not loaded to MT). Users have to install vc_redist package separately. So I decided to facilitate installation process for users and made setup file that install both components (MtApi and vc_redist) automatically.