MtApi provides a .NET API for working with famous trading platfrom [MetaTrader(MetaQuotes)](https://www.metatrader5.com/).
It is not API for connection to MT servers directly. MtApi is just a bridge between MT terminal and .NET applications designed by developers.
MtApi executes MQL commands and functions by MtApi's expert linked to chart of MetaTrader.
Most of the API's functions duplicates MQL interface.
The project was designed using [WCF](https://docs.microsoft.com/en-us/dotnet/framework/wcf/whats-wcf) framework with the intention of using flexibility to setup connections.
3. Install the WiX Toolset Visual Studio Extension depending on your VS version.
For example, if you use VS 2017, go [here](https://marketplace.visualstudio.com/items?itemName=WixToolset.WixToolsetVisualStudio2017Extension) or download from their GitHub, releases.
Use [MetaEditor](https://www.metatrader5.com/en/automated-trading/metaeditor) to working with MQL files.
MtApiBootstrapper, MtApi5Bootstrapper (WIX, .exe) - installation package bundles. There are wrappers for installers that contains the vc_redist libraries (Visual C++ runtime) placed in [root]\vcredist\.
# Installation
Use installers to setup all libraries automatically.
MtApiInstaller setup the API's files for MetaTrader 4.
MtApi5Installer setup the API's files for MetaTrader 5.
MtApiBootstrapper or MtApi5Bootstrapper are installation package bundles contains installers and vc_redist libraries.
The installers places MTApiService.dll into Windows GAC (Global Assembly Cache) and copies MTConnector.dll and MT5Connector.dll into Windows's system folder.
After instalation MtApi expert (MtApi.ex4 or MtApi5.ex5) must be copied into folder for Expert Advisors (/MQL5/Experts).
To quickly navigate to the trading platform data folder, click "Open data folder" in the File menu.
# Using
MtApi provides two types of connection to MetaTrader terminal: local (using Pipe or TCP) and remote (via TCP).
The port of connection is defined by MtApi expert.
Console sample for MT5:
```C#
using System;
using System.Threading;
using System.Threading.Tasks;
using MtApi5;
namespace MtApi5Console
{
class Program
{
static readonly EventWaitHandle _connnectionWaiter = new AutoResetEvent(false);
static readonly MtApi5Client _mtapi = new MtApi5Client();