How to develop MT5 Gateway API Quote and Trade

The main task for a developer is to transfer all the data, obtained in the MetaTrader 5 Gateway API. For application programmers we can compose the following algorithm to work with this API:

  1. Initialization. At this stage, developer has to load the library.

  2. Obtaining and running server port interface. All interaction with API is done via server port interface. This interface contains methods of data management and sending. When you create a user interface API, developer must specify his own notification handler. Using this handler API will notify the developer about new connections of History Servers and their parameters (quotes symbols, operation mode, additional parameters). This information only notifies a user and its use is optional.

  3. Sending data. Server port interface contains all the necessary methods for sending data to connected History Servers.

  4. Exiting. At this stage, a developer has to release server port interface and unload the library.

MetaTrader 5 Gateway API is described in a single 'MT5APIGateway.h' file and implemented in the 'MT5APIGateway.dll' and 'MT5APIGateway64.dll' files for win32 and x64 platforms, respectively. For an application that uses API, it is necessary that these files must be available. Simply copy them into the application folder.

The library exports a few simple functions:

  • MTAPIRES MTGatewayVersion(UINT &version) - returns the version of the Gateway API.

  • MTAPIRES MTGatewayCreateLocal(MTGatewayInfo& info,IMTGatewayAPI **gateway,int argc,wchar_t** argv) - creates and returns an instance of the gateway interface taking into account its description and parameters passed in the command line. In the command line from History Server passed are the time zone and the server port number, on which interface must be started as a server accepting incoming connections. Command line is also used to obtain Data Feed description. By passing command line parameters to the library, we've freed developers from parsing line parameters, time zone initialization and Data Feed description formatting. This method is used only by Data Feeds, controlled by History Server.

  • MTAPIRES MTGatewayCreate(MTGatewayInfo& info,IMTGatewayAPI **gateway) - creates and returns an instance of gateway interface.


When creating a gateway interface, we need to pass to it a correctly filled out MTGatewayInfo structure. This structure contains the description of a data feed and its default settings.

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值