Ali Morakabi

Algorithmic Trading, Blockchain, Data science, Forex

Prepare Microsoft Visual Studio for MetaTrader Development

This article help you to avoid many common error and issues while you developing new Meta Trader Server plugins . A number of setting in Microsoft visual studio should be changed as follows :

32-bit time_t

MetaTrader 4 API uses 32-bit time_t type, but in recent versions of Microsoft Visual Studio the default value of this type is 64 bits. Macro _USE_32BIT_TIME_T should be set in the compilation directives when working with projects.

Visual Studio Project Properties
Project Properties

Specification of Order Volume

In all functions and structures, volume in lots is specified as a value multiplied by 100: 100 means 1 lot, 1 means 0.01 lots.

Links to Detailed Descriptions in other References

Many sections of MetaTrader 4 API Reference contain links to documentation on other platform components , including MetaTrader 4 Administrator User Guide. The links provide the detailed descriptions of the platform functions. The API documentation only contains a brief description of their nature and focuses mainly on programming features.

Reserved Fields in Structures

Many structures used in MetaTrader 4 API contain reserved fields. It is not recommended to use these fields for your own needs. The trading platform developer may at any time remove or replace these fields.

Resetting Structures

Before using structures, it is recommended to initialize them to zero. Example:

UserInfo uinfo={0};

Adding Descriptions of Exported Functions to a Project

When developing plug-ins (Server API) and data feeds (DataFeed API), a DEF file with descriptions of all exported functions must be included into the project. Example:

LIBRARY AdvancedDealerHelper
EXPORTS
MtSrvAbout
MtSrvStartup
MtSrvPluginCfgAdd
MtSrvPluginCfgSet
MtSrvPluginCfgGet
MtSrvPluginCfgNext
MtSrvPluginCfgDelete
MtSrvPluginCfgTotal
MtSrvTradeRequestApply
MtSrvHistoryTickApply

Leave a Response