Skip to content

A .NET Farmework API for MetaTrader 4 and 5

License

Notifications You must be signed in to change notification settings

VeriEasi/MetaTraderAPI

 
 

Repository files navigation

MetaTrader API Net Core

MetaTraderAPINetCore C# solution Operating systems CPU Architect

Overview

MetaTraderAPINetCore provides a .NET Core API for working with famous trading platfrom MetaTrader 4 and 5. It is not API for connection to MT servers directly. It is just a bridge between MT terminal and .NET Core applications designed by developers.

MetaTraderAPINetCore executes MQL commands and functions by MtApi's expert linked to chart of MetaTrader. Most of the API's functions duplicates MQL interface.


Build environment

  • The project is supported by Visual Studio 2017, 2019 and 2022.
  • It requires WIX Tools for preparing project's installers. You can install WIX extension in the Visual Studio extensions marketplace (In the “Extension” tab select “Manage Extensions” and then search for “Wix v3” in the “Visual Studio Marketplace”) or you can download it from https://wixtoolset.org/docs/wix3/ and install it manualy.
  • Use “MetaEditor” to working with MQL files.

How to Build Solution

To build the solution for MT4, you need to choose the configuration to build for “Release”, “x86” and start with building the MtApiInstaller. This will build all projects related to MT4:

  • MtApi
  • MTApiService
  • MTConnector

For building the solution for MT5, you need to choose the configuration to build for “Release”, “x64” (or “x86” for the 32-bit MT5) and start build MtApi5Installer. This will build all projects related to MT5:

  • MtApi5
  • MTApiService
  • MT5Connector

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 can be found under:

../mq4/. 
../mq5/. 

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.mqh
./json.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.

  • MTApiServiceNetCore: (C#, .dll)

    Port main MtApi project to .Net Core

  • 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 ../vcredist/.


Installation

Use the installers to setup all libraries automatically.

  • For MT4, use:

    MtApiInstaller.msi
    
  • For x86 MT5, use:

    MtApi5Installer_x86.msi
    
  • For x64 MT5, use:

    MtApi5Installer_x64.msi
    

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.

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:

C:\Users\<username>\AppData\Roaming\MetaQuotes\Terminal\<terminal-hash>\MQL5\ Experts \.

To quickly navigate to the trading platform data folder, click: File >> "Open data folder" in your MetaTrader Terminal.


License


Distributed under the MIT License. See LICENSE.txt for more information.


Contact


VeriEasi - [email protected]

Project Link: https://github.com/VeriEasi/MetaTraderAPI.git

About

A .NET Farmework API for MetaTrader 4 and 5

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 42.7%
  • MQL5 37.3%
  • MQL4 16.2%
  • Smalltalk 1.9%
  • C++ 1.9%