KarsusNeko 6 lat temu
commit
b6a4663c68
74 zmienionych plików z 17653 dodań i 0 usunięć
  1. 3 0
      .gitmodules
  2. 1 0
      CommonLib
  3. 31 0
      MT5MonkPAMM.sln
  4. 54 0
      MT5MonkPAMM/MT5MonkMAM.cpp
  5. 172 0
      MT5MonkPAMM/MT5MonkPAMM.vcxproj
  6. 36 0
      MT5MonkPAMM/MT5MonkPAMM.vcxproj.filters
  7. 4 0
      MT5MonkPAMM/MT5MonkPAMM.vcxproj.user
  8. 129 0
      MT5MonkPAMM/PluginInstance.cpp
  9. 50 0
      MT5MonkPAMM/PluginInstance.h
  10. 5 0
      MT5MonkPAMM/pch.cpp
  11. 16 0
      MT5MonkPAMM/pch.h
  12. 136 0
      MT5SDK/Bases/MT5APIAccount.h
  13. 61 0
      MT5SDK/Bases/MT5APIAttachment.h
  14. 65 0
      MT5SDK/Bases/MT5APIBook.h
  15. 79 0
      MT5SDK/Bases/MT5APIByteStream.h
  16. 54 0
      MT5SDK/Bases/MT5APICertificate.h
  17. 39 0
      MT5SDK/Bases/MT5APIChart.h
  18. 388 0
      MT5SDK/Bases/MT5APIClient.h
  19. 125 0
      MT5SDK/Bases/MT5APIComment.h
  20. 72 0
      MT5SDK/Bases/MT5APIConfirm.h
  21. 210 0
      MT5SDK/Bases/MT5APIDaily.h
  22. 787 0
      MT5SDK/Bases/MT5APIDataset.h
  23. 282 0
      MT5SDK/Bases/MT5APIDeal.h
  24. 129 0
      MT5SDK/Bases/MT5APIDocument.h
  25. 240 0
      MT5SDK/Bases/MT5APIExecution.h
  26. 73 0
      MT5SDK/Bases/MT5APIExposure.h
  27. 76 0
      MT5SDK/Bases/MT5APIMail.h
  28. 63 0
      MT5SDK/Bases/MT5APINews.h
  29. 67 0
      MT5SDK/Bases/MT5APIOnline.h
  30. 328 0
      MT5SDK/Bases/MT5APIOrder.h
  31. 256 0
      MT5SDK/Bases/MT5APIPosition.h
  32. 260 0
      MT5SDK/Bases/MT5APIRequest.h
  33. 91 0
      MT5SDK/Bases/MT5APISummary.h
  34. 175 0
      MT5SDK/Bases/MT5APITick.h
  35. 257 0
      MT5SDK/Bases/MT5APIUser.h
  36. 371 0
      MT5SDK/Classes/MT5APIFile.h
  37. 902 0
      MT5SDK/Classes/MT5APIFormat.h
  38. 276 0
      MT5SDK/Classes/MT5APIMath.h
  39. 132 0
      MT5SDK/Classes/MT5APIMemPack.h
  40. 149 0
      MT5SDK/Classes/MT5APIProcess.h
  41. 403 0
      MT5SDK/Classes/MT5APISearch.h
  42. 689 0
      MT5SDK/Classes/MT5APIStorage.h
  43. 1049 0
      MT5SDK/Classes/MT5APIStr.h
  44. 23 0
      MT5SDK/Classes/MT5APISync.h
  45. 122 0
      MT5SDK/Classes/MT5APIThread.h
  46. 220 0
      MT5SDK/Classes/MT5APITime.h
  47. 92 0
      MT5SDK/Config/MT5APIConfigCommon.h
  48. 60 0
      MT5SDK/Config/MT5APIConfigEmail.h
  49. 202 0
      MT5SDK/Config/MT5APIConfigFeeder.h
  50. 52 0
      MT5SDK/Config/MT5APIConfigFirewall.h
  51. 251 0
      MT5SDK/Config/MT5APIConfigFund.h
  52. 218 0
      MT5SDK/Config/MT5APIConfigGateway.h
  53. 698 0
      MT5SDK/Config/MT5APIConfigGroup.h
  54. 109 0
      MT5SDK/Config/MT5APIConfigHistory.h
  55. 72 0
      MT5SDK/Config/MT5APIConfigHoliday.h
  56. 167 0
      MT5SDK/Config/MT5APIConfigManager.h
  57. 96 0
      MT5SDK/Config/MT5APIConfigMessenger.h
  58. 606 0
      MT5SDK/Config/MT5APIConfigNetwork.h
  59. 98 0
      MT5SDK/Config/MT5APIConfigParam.h
  60. 101 0
      MT5SDK/Config/MT5APIConfigPlugin.h
  61. 128 0
      MT5SDK/Config/MT5APIConfigReport.h
  62. 367 0
      MT5SDK/Config/MT5APIConfigRoute.h
  63. 105 0
      MT5SDK/Config/MT5APIConfigSpread.h
  64. 602 0
      MT5SDK/Config/MT5APIConfigSymbol.h
  65. 50 0
      MT5SDK/Config/MT5APIConfigTime.h
  66. 173 0
      MT5SDK/MT5APIConstants.h
  67. 687 0
      MT5SDK/MT5APIGateway.h
  68. 83 0
      MT5SDK/MT5APILogger.h
  69. 1412 0
      MT5SDK/MT5APIManager.h
  70. 31 0
      MT5SDK/MT5APIPublicKey.h
  71. 1002 0
      MT5SDK/MT5APIReport.h
  72. 980 0
      MT5SDK/MT5APIServer.h
  73. 17 0
      MT5SDK/MT5APITools.h
  74. 44 0
      MT5SDK/MT5APITypes.h

+ 3 - 0
.gitmodules

@@ -0,0 +1,3 @@
+[submodule "CommonLib"]
+	path = CommonLib
+	url = http://alisz.titanera.com:3000/titan/CommonLib.git

+ 1 - 0
CommonLib

@@ -0,0 +1 @@
+Subproject commit 0612f28f412968fbbd2479a385e9be9a8ba3d299

+ 31 - 0
MT5MonkPAMM.sln

@@ -0,0 +1,31 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 15
+VisualStudioVersion = 15.0.28307.705
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MT5MonkPAMM", "MT5MonkPAMM\MT5MonkPAMM.vcxproj", "{6380375F-A6B3-496A-84F4-C89BF6315C75}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|x64 = Debug|x64
+		Debug|x86 = Debug|x86
+		Release|x64 = Release|x64
+		Release|x86 = Release|x86
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{6380375F-A6B3-496A-84F4-C89BF6315C75}.Debug|x64.ActiveCfg = Debug|x64
+		{6380375F-A6B3-496A-84F4-C89BF6315C75}.Debug|x64.Build.0 = Debug|x64
+		{6380375F-A6B3-496A-84F4-C89BF6315C75}.Debug|x86.ActiveCfg = Debug|Win32
+		{6380375F-A6B3-496A-84F4-C89BF6315C75}.Debug|x86.Build.0 = Debug|Win32
+		{6380375F-A6B3-496A-84F4-C89BF6315C75}.Release|x64.ActiveCfg = Release|x64
+		{6380375F-A6B3-496A-84F4-C89BF6315C75}.Release|x64.Build.0 = Release|x64
+		{6380375F-A6B3-496A-84F4-C89BF6315C75}.Release|x86.ActiveCfg = Release|Win32
+		{6380375F-A6B3-496A-84F4-C89BF6315C75}.Release|x86.Build.0 = Release|Win32
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+	GlobalSection(ExtensibilityGlobals) = postSolution
+		SolutionGuid = {A1CED112-F668-421D-AEDE-98DAAF3E7EC7}
+	EndGlobalSection
+EndGlobal

+ 54 - 0
MT5MonkPAMM/MT5MonkMAM.cpp

@@ -0,0 +1,54 @@
+// MT5MonkPAMM.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
+//
+
+#include "pch.h"
+#include "PluginInstance.h"
+
+MTPluginInfo ExtPluginInfo =
+{
+	1,
+	MTServerAPIVersion,
+	L"Monk MT5 MAM",
+	L"",
+	L"order append plugin"
+};
+
+MTPluginParam ExtPluginDefaults[] =
+{
+	{ MTPluginParam::TYPE_INT, L"Trader Login", L"-" },
+	{ MTPluginParam::TYPE_INT, L"Step", L"-" },
+	{ MTPluginParam::TYPE_INT, L"Tolerance", L"-" },
+	{ MTPluginParam::TYPE_STRING, L"Groups", L"-" },
+	{ MTPluginParam::TYPE_STRING, L"Logins", L"-" }
+};
+
+BOOL APIENTRY DllMain(HMODULE hModule, DWORD reason, LPVOID lpReserved)
+{
+	//---
+	switch (reason)
+	{
+	case DLL_PROCESS_ATTACH:
+	case DLL_THREAD_ATTACH:
+	case DLL_THREAD_DETACH:
+	case DLL_PROCESS_DETACH:
+		break;
+	}
+	return(TRUE);
+}
+
+MTAPIENTRY MTAPIRES MTServerAbout(MTPluginInfo& info)
+{
+	info = ExtPluginInfo;
+	memcpy(info.defaults, ExtPluginDefaults, sizeof(ExtPluginDefaults));
+	info.defaults_total = _countof(ExtPluginDefaults);
+	return MT_RET_OK;
+}
+
+MTAPIENTRY MTAPIRES MTServerCreate(UINT apiversion, IMTServerPlugin **plugin)
+{
+	if (!plugin)	return MT_RET_ERR_PARAMS;
+	if (((*plugin) = new(std::nothrow) CPluginInstance()) == NULL)
+		return MT_RET_ERR_MEM;
+	return MT_RET_OK;
+}
+

+ 172 - 0
MT5MonkPAMM/MT5MonkPAMM.vcxproj

@@ -0,0 +1,172 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup Label="ProjectConfigurations">
+    <ProjectConfiguration Include="Debug|Win32">
+      <Configuration>Debug</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|Win32">
+      <Configuration>Release</Configuration>
+      <Platform>Win32</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Debug|x64">
+      <Configuration>Debug</Configuration>
+      <Platform>x64</Platform>
+    </ProjectConfiguration>
+    <ProjectConfiguration Include="Release|x64">
+      <Configuration>Release</Configuration>
+      <Platform>x64</Platform>
+    </ProjectConfiguration>
+  </ItemGroup>
+  <PropertyGroup Label="Globals">
+    <VCProjectVersion>15.0</VCProjectVersion>
+    <ProjectGuid>{6380375F-A6B3-496A-84F4-C89BF6315C75}</ProjectGuid>
+    <Keyword>Win32Proj</Keyword>
+    <RootNamespace>MT5MonkPAMM</RootNamespace>
+    <WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
+    <ProjectName>MT5MonkMAM</ProjectName>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <UseDebugLibraries>true</UseDebugLibraries>
+    <PlatformToolset>v140</PlatformToolset>
+    <CharacterSet>Unicode</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <UseDebugLibraries>false</UseDebugLibraries>
+    <PlatformToolset>v141</PlatformToolset>
+    <WholeProgramOptimization>true</WholeProgramOptimization>
+    <CharacterSet>Unicode</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <UseDebugLibraries>true</UseDebugLibraries>
+    <PlatformToolset>v141</PlatformToolset>
+    <CharacterSet>Unicode</CharacterSet>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+    <ConfigurationType>Application</ConfigurationType>
+    <UseDebugLibraries>false</UseDebugLibraries>
+    <PlatformToolset>v141</PlatformToolset>
+    <WholeProgramOptimization>true</WholeProgramOptimization>
+    <CharacterSet>Unicode</CharacterSet>
+  </PropertyGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+  <ImportGroup Label="ExtensionSettings">
+  </ImportGroup>
+  <ImportGroup Label="Shared">
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+  </ImportGroup>
+  <PropertyGroup Label="UserMacros" />
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <LinkIncremental>true</LinkIncremental>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+    <LinkIncremental>true</LinkIncremental>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <LinkIncremental>false</LinkIncremental>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+    <LinkIncremental>false</LinkIncremental>
+  </PropertyGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+    <ClCompile>
+      <PrecompiledHeader>Use</PrecompiledHeader>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>Disabled</Optimization>
+      <SDLCheck>true</SDLCheck>
+      <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <ConformanceMode>true</ConformanceMode>
+      <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
+      <AdditionalIncludeDirectories>..\MT5SDK</AdditionalIncludeDirectories>
+    </ClCompile>
+    <Link>
+      <SubSystem>Console</SubSystem>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+    <ClCompile>
+      <PrecompiledHeader>Use</PrecompiledHeader>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>Disabled</Optimization>
+      <SDLCheck>true</SDLCheck>
+      <PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <ConformanceMode>true</ConformanceMode>
+      <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
+    </ClCompile>
+    <Link>
+      <SubSystem>Console</SubSystem>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+    <ClCompile>
+      <PrecompiledHeader>Use</PrecompiledHeader>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>MaxSpeed</Optimization>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
+      <SDLCheck>true</SDLCheck>
+      <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <ConformanceMode>true</ConformanceMode>
+      <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
+    </ClCompile>
+    <Link>
+      <SubSystem>Console</SubSystem>
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
+      <OptimizeReferences>true</OptimizeReferences>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+    <ClCompile>
+      <PrecompiledHeader>Use</PrecompiledHeader>
+      <WarningLevel>Level3</WarningLevel>
+      <Optimization>MaxSpeed</Optimization>
+      <FunctionLevelLinking>true</FunctionLevelLinking>
+      <IntrinsicFunctions>true</IntrinsicFunctions>
+      <SDLCheck>true</SDLCheck>
+      <PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+      <ConformanceMode>true</ConformanceMode>
+      <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
+    </ClCompile>
+    <Link>
+      <SubSystem>Console</SubSystem>
+      <EnableCOMDATFolding>true</EnableCOMDATFolding>
+      <OptimizeReferences>true</OptimizeReferences>
+      <GenerateDebugInformation>true</GenerateDebugInformation>
+    </Link>
+  </ItemDefinitionGroup>
+  <ItemGroup>
+    <ClInclude Include="pch.h" />
+    <ClInclude Include="PluginInstance.h" />
+  </ItemGroup>
+  <ItemGroup>
+    <ClCompile Include="MT5MonkMAM.cpp" />
+    <ClCompile Include="pch.cpp">
+      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
+      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
+      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
+      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
+    </ClCompile>
+    <ClCompile Include="PluginInstance.cpp" />
+  </ItemGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+  <ImportGroup Label="ExtensionTargets">
+  </ImportGroup>
+</Project>

+ 36 - 0
MT5MonkPAMM/MT5MonkPAMM.vcxproj.filters

@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <ItemGroup>
+    <Filter Include="源文件">
+      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
+      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
+    </Filter>
+    <Filter Include="头文件">
+      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
+      <Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>
+    </Filter>
+    <Filter Include="资源文件">
+      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
+      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
+    </Filter>
+  </ItemGroup>
+  <ItemGroup>
+    <ClInclude Include="pch.h">
+      <Filter>头文件</Filter>
+    </ClInclude>
+    <ClInclude Include="PluginInstance.h">
+      <Filter>头文件</Filter>
+    </ClInclude>
+  </ItemGroup>
+  <ItemGroup>
+    <ClCompile Include="pch.cpp">
+      <Filter>源文件</Filter>
+    </ClCompile>
+    <ClCompile Include="PluginInstance.cpp">
+      <Filter>源文件</Filter>
+    </ClCompile>
+    <ClCompile Include="MT5MonkMAM.cpp">
+      <Filter>源文件</Filter>
+    </ClCompile>
+  </ItemGroup>
+</Project>

+ 4 - 0
MT5MonkPAMM/MT5MonkPAMM.vcxproj.user

@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup />
+</Project>

+ 129 - 0
MT5MonkPAMM/PluginInstance.cpp

@@ -0,0 +1,129 @@
+#include "pch.h"
+#include "PluginInstance.h"
+
+CPluginInstance::CPluginInstance()
+{
+}
+
+CPluginInstance::~CPluginInstance()
+{
+}
+
+void CPluginInstance::Release()
+{
+	delete this;
+}
+
+MTAPIRES CPluginInstance::Start(IMTServerAPI * server)
+{
+	MTAPIRES ret = MT_RET_OK;
+	if (!server)	return MT_RET_ERR_PARAMS;
+	m_api = server;
+
+	if ((m_config = m_api->PluginCreate()) == nullptr)
+		return MT_RET_ERR_MEM;
+
+	ret = m_api->About(m_info);
+	if (ret != MT_RET_OK)
+		m_api->LoggerOut(MTLogOK, L"Server info failed [%d]", ret);
+
+	if ((ret = m_api->PluginSubscribe(this)) != MT_RET_OK)
+	{
+		m_api->LoggerOut(MTLogAtt, L"Plugin subscribe failed [%d]", ret);
+		return ret;
+	}
+	if (ret = m_api->OrderSubscribe(this) != MT_RET_OK)
+	{
+		m_api->LoggerOut(MTLogAtt, L"Order subscribe failed [%d]", ret);
+		return ret;
+	}
+	if (ret = m_api->DealSubscribe(this) != MT_RET_OK)
+	{
+		m_api->LoggerOut(MTLogAtt, L"Deal subscribe failed [%d]", ret);
+		return ret;
+	}
+
+	if ((ret = LoadParam()) != MT_RET_OK)
+	{
+		m_api->LoggerOut(MTLogAtt, L"Load param failed [%d]", ret);
+		return ret;
+	}
+
+	return MT_RET_OK;
+}
+
+MTAPIRES CPluginInstance::Stop()
+{
+	MTAPIRES ret = MT_RET_OK;
+
+	if (m_api == nullptr)
+		return MT_RET_OK;
+
+	if (m_config != nullptr)
+	{
+		m_config->Release();
+		m_config = nullptr;
+	}
+
+	if ((ret = m_api->PluginUnsubscribe(this)) != MT_RET_OK && ret != MT_RET_ERR_NOTFOUND)
+		m_api->LoggerOut(MTLogErr, L"failed to unsubscribe from plugin config updates [%s (%u)]",
+			SMTFormat::FormatError(ret), ret);
+	if ((ret = m_api->OrderUnsubscribe(this)) != MT_RET_OK && ret != MT_RET_ERR_NOTFOUND)
+		m_api->LoggerOut(MTLogErr, L"failed to unsubscribe order [%s (%u)]",
+			SMTFormat::FormatError(ret), ret);
+	if ((ret = m_api->DealUnsubscribe(this)) != MT_RET_OK && ret != MT_RET_ERR_NOTFOUND)
+		m_api->LoggerOut(MTLogErr, L"failed to unsubscribe deal [%s (%u)]",
+			SMTFormat::FormatError(ret), ret);
+
+	m_api = nullptr;
+
+	return MT_RET_OK;
+}
+
+MTAPIRES CPluginInstance::LoadParam()
+{
+	MTAPIRES res = MT_RET_OK;
+	IMTConParam* param = NULL;
+	CMTStr128 tmp;
+
+	if (!m_api || !m_config)	return MT_RET_ERR_PARAMS;
+
+	if ((res = m_api->PluginCurrent(m_config)) != MT_RET_OK)
+	{
+		m_api->LoggerOut(MTLogErr, L"failed to get current plugin configuration [%s (%u)]",
+			SMTFormat::FormatError(res), res);
+		return res;
+	}
+
+	if ((param = m_api->PluginParamCreate()) == NULL)
+	{
+		m_api->LoggerOut(MTLogErr, L"failed to create plugin parameter object");
+		return MT_RET_ERR_MEM;
+	}
+
+	if ((res = m_config->ParameterGet(L"Trader", param)) != MT_RET_OK || param->Type() != IMTConParam::TYPE_INT)
+	{
+		return(MT_RET_ERR_PARAMS);
+	}
+	m_trader = param->ValueInt();
+	if ((res = m_config->ParameterGet(L"Step", param)) != MT_RET_OK || param->Type() != IMTConParam::TYPE_INT)
+	{
+		return(MT_RET_ERR_PARAMS);
+	}
+	m_step = param->ValueInt();
+	if ((res = m_config->ParameterGet(L"Tolerance", param)) != MT_RET_OK || param->Type() != IMTConParam::TYPE_INT)
+	{
+		return(MT_RET_ERR_PARAMS);
+	}
+	m_tolerance = param->ValueInt();
+	if ((res = m_config->ParameterGet(L"Groups", param)) != MT_RET_OK || param->Type() != IMTConParam::TYPE_STRING)
+	{
+		return(MT_RET_ERR_PARAMS);
+	}
+	m_groups = param->ValueString();
+	if ((res = m_config->ParameterGet(L"Logins", param)) != MT_RET_OK || param->Type() != IMTConParam::TYPE_STRING)
+	{
+		return(MT_RET_ERR_PARAMS);
+	}
+	m_logins = param->ValueString();
+}

+ 50 - 0
MT5MonkPAMM/PluginInstance.h

@@ -0,0 +1,50 @@
+#pragma once
+
+#include <string>
+#include <mutex>
+
+class CPluginInstance
+	: public IMTServerPlugin
+	, public IMTConPluginSink
+	, public IMTOrderSink
+	, public IMTDealSink
+{
+public:
+	CPluginInstance();
+	virtual ~CPluginInstance();
+
+	virtual void Release();
+	virtual MTAPIRES Start(IMTServerAPI* server);
+	virtual MTAPIRES Stop();
+
+	virtual void OnPluginUpdate(const IMTConPlugin* plugin);
+
+	virtual void OnOrderAdd(const IMTOrder* order);
+	virtual void OnOrderUpdate(const IMTOrder* order);
+	virtual void OnOrderDelete(const IMTOrder* order);
+	virtual void OnOrderClean(const UINT64 login);
+	virtual void OnOrderSync();
+
+	virtual void OnDealAdd(const IMTDeal* deal);
+	virtual void OnDealUpdate(const IMTDeal* deal);
+	virtual void OnDealDelete(const IMTDeal* deal);
+	virtual void OnDealClean(const UINT64 login);
+	virtual void OnDealSync(void);
+	virtual void OnDealPerform(const IMTDeal* deal, IMTAccount* account, IMTPosition* position);
+
+protected:
+	virtual MTAPIRES LoadParam();
+
+private:
+	IMTServerAPI*	m_api;
+	IMTConPlugin*	m_config;
+	MTServerInfo	m_info;
+
+	std::mutex		m_lock;
+	bool			m_enable;
+	std::wstring	m_groups;
+	std::wstring	m_logins;
+	UINT64			m_trader;
+	int				m_step;
+	int				m_tolerance;
+};

+ 5 - 0
MT5MonkPAMM/pch.cpp

@@ -0,0 +1,5 @@
+// pch.cpp: 与预编译标头对应的源文件;编译成功所必需的
+
+#include "pch.h"
+
+// 一般情况下,忽略此文件,但如果你使用的是预编译标头,请保留它。

+ 16 - 0
MT5MonkPAMM/pch.h

@@ -0,0 +1,16 @@
+// 入门提示: 
+//   1. 使用解决方案资源管理器窗口添加/管理文件
+//   2. 使用团队资源管理器窗口连接到源代码管理
+//   3. 使用输出窗口查看生成输出和其他消息
+//   4. 使用错误列表窗口查看错误
+//   5. 转到“项目”>“添加新项”以创建新的代码文件,或转到“项目”>“添加现有项”以将现有代码文件添加到项目
+//   6. 将来,若要再次打开此项目,请转到“文件”>“打开”>“项目”并选择 .sln 文件
+
+#ifndef PCH_H
+#define PCH_H
+
+// TODO: 添加要在此处预编译的标头
+#include "MT5APIServer.h"
+#include "MT5APITools.h"
+
+#endif //PCH_H

+ 136 - 0
MT5SDK/Bases/MT5APIAccount.h

@@ -0,0 +1,136 @@
+//+------------------------------------------------------------------+
+//|                                         MetaTrader 5 API Server  |
+//|                   Copyright 2000-2019, MetaQuotes Software Corp. |
+//|                                        http://www.metaquotes.net |
+//+------------------------------------------------------------------+
+#pragma once
+//+------------------------------------------------------------------+
+//| Trade account interface                                          |
+//+------------------------------------------------------------------+
+class IMTAccount
+  {
+public:
+   //--- activation mode
+   enum EnSoActivation
+     {
+      ACTIVATION_NONE       =0,
+      ACTIVATION_MARGIN_CALL=1,
+      ACTIVATION_STOP_OUT   =2,
+      //---
+      ACTIVATION_FIRST      =ACTIVATION_NONE,
+      ACTIVATION_LAST       =ACTIVATION_STOP_OUT,
+     };
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTAccount* user)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- login
+   virtual UINT64    Login(void) const=0;
+   virtual MTAPIRES  Login(const UINT64 login)=0;
+   //--- currency digits
+   virtual UINT      CurrencyDigits(void) const=0;
+   virtual MTAPIRES  CurrencyDigits(const UINT digits)=0;
+   //--- balance
+   virtual double    Balance(void) const=0;
+   virtual MTAPIRES  Balance(const double balance)=0;
+   //--- credit
+   virtual double    Credit(void) const=0;
+   virtual MTAPIRES  Credit(const double credit)=0;
+   //--- margin
+   virtual double    Margin(void) const=0;
+   virtual MTAPIRES  Margin(const double margin)=0;
+   //--- free margin
+   virtual double    MarginFree(void) const=0;
+   virtual MTAPIRES  MarginFree(const double margin_free)=0;
+   //--- margin level
+   virtual double    MarginLevel(void) const=0;
+   virtual MTAPIRES  MarginLevel(const double margin_level)=0;
+   //--- margin leverage
+   virtual UINT      MarginLeverage(void) const=0;
+   virtual MTAPIRES  MarginLeverage(const UINT leverage)=0;
+   //--- floating profit
+   virtual double    Profit(void) const=0;
+   virtual MTAPIRES  Profit(const double profit)=0;
+   //--- storage
+   virtual double    Storage(void) const=0;
+   virtual MTAPIRES  Storage(const double storage)=0;
+   //--- commission
+   virtual double    Commission(void) const=0;
+   virtual MTAPIRES  Commission(const double storage)=0;
+   //--- cumulative floating
+   virtual double    Floating(void) const=0;
+   virtual MTAPIRES  Floating(const double floating)=0;
+   //--- equity
+   virtual double    Equity(void) const=0;
+   virtual MTAPIRES  Equity(const double equity)=0;
+   //--- stop-out activation mode
+   virtual UINT      SOActivation(void) const=0;
+   virtual MTAPIRES  SOActivation(const UINT activation)=0;
+   //--- stop-out activation time
+   virtual INT64     SOTime(void) const=0;
+   virtual MTAPIRES  SOTime(const INT64 datetime)=0;
+   //--- margin level on stop-out 
+   virtual double    SOLevel(void) const=0;
+   virtual MTAPIRES  SOLevel(const double level)=0;
+   //--- equity on stop-out
+   virtual double    SOEquity(void) const=0;
+   virtual MTAPIRES  SOEquity(const double equity)=0;
+   //--- margin on stop-out
+   virtual double    SOMargin(void) const=0;
+   virtual MTAPIRES  SOMargin(const double margin)=0;
+   //--- blocked daily & monthly commission
+   virtual double    BlockedCommission(void) const=0;
+   virtual MTAPIRES  BlockedCommission(const double commission)=0;
+   //--- blocked fixed profit
+   virtual double    BlockedProfit(void) const=0;
+   virtual MTAPIRES  BlockedProfit(const double profit)=0;
+   //--- account initial margin
+   virtual double    MarginInitial(void) const=0;
+   virtual MTAPIRES  MarginInitial(const double margin)=0;
+   //--- account maintenance margin 
+   virtual double    MarginMaintenance(void) const=0;
+   virtual MTAPIRES  MarginMaintenance(const double margin)=0;
+   //--- account assets
+   virtual double    Assets(void) const=0;
+   virtual MTAPIRES  Assets(const double assets)=0;
+   //--- account liabilities
+   virtual double    Liabilities(void) const=0;
+   virtual MTAPIRES  Liabilities(const double liabilities)=0;
+  };
+//+------------------------------------------------------------------+
+//| Account array interface                                          |
+//+------------------------------------------------------------------+
+class IMTAccountArray
+  {
+public:
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTAccountArray* array)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- add
+   virtual MTAPIRES  Add(IMTAccount* account)=0;
+   virtual MTAPIRES  AddCopy(const IMTAccount* account)=0;
+   virtual MTAPIRES  Add(IMTAccountArray* array)=0;
+   virtual MTAPIRES  AddCopy(const IMTAccountArray* array)=0;
+   //--- delete & detach
+   virtual MTAPIRES  Delete(const UINT pos)=0;
+   virtual IMTAccount* Detach(const UINT pos)=0;
+   //--- update
+   virtual MTAPIRES  Update(const UINT pos,IMTAccount* account)=0;
+   virtual MTAPIRES  UpdateCopy(const UINT pos,const IMTAccount* account)=0;
+   virtual MTAPIRES  Shift(const UINT pos,const int shift)=0;
+   //--- data access
+   virtual UINT      Total(void) const=0;
+   virtual IMTAccount* Next(const UINT index) const=0;
+   //--- sorting and search
+   virtual MTAPIRES  Sort(MTSortFunctionPtr sort_function)=0;
+   virtual int       Search(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchGreatOrEq(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchGreater(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchLessOrEq(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchLess(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchLeft(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchRight(const void *key,MTSortFunctionPtr sort_function) const=0;
+  };
+//+------------------------------------------------------------------+
+  

+ 61 - 0
MT5SDK/Bases/MT5APIAttachment.h

@@ -0,0 +1,61 @@
+//+------------------------------------------------------------------+
+//|                                                 MetaTrader 5 API |
+//|                   Copyright 2000-2019, MetaQuotes Software Corp. |
+//|                                        http://www.metaquotes.net |
+//+------------------------------------------------------------------+
+#pragma once
+//+------------------------------------------------------------------+
+//| Attachment record interface                                      |
+//+------------------------------------------------------------------+
+class IMTAttachment
+  {
+public:
+   //--- file types
+   enum EnFileType
+     {
+      FILE_TYPE_OTHER                       =0,          // other
+      FILE_TYPE_TXT                         =1,          // txt
+      FILE_TYPE_DOC                         =2,          // doc
+      FILE_TYPE_PDF                         =3,          // pdf
+      FILE_TYPE_JPG                         =4,          // jpg
+      FILE_TYPE_PNG                         =5,          // png
+      FILE_TYPE_BMP                         =6,          // bmp
+      FILE_TYPE_ZIP                         =7,          // zip
+      //--- enumeration borders
+      FILE_TYPE_FIRST                       =FILE_TYPE_OTHER,
+      FILE_TYPE_LAST                        =FILE_TYPE_ZIP,
+     };
+   //--- file flags
+   enum EnFileFlags
+     {
+      FILE_FLAG_EMBEDDED                    =0x1,        // embedded for content (images in HTML)
+      //--- enumeration borders
+      FILE_FLAG_NONE                        =0,
+      FILE_FLAG_ALL                         =FILE_FLAG_EMBEDDED,
+     };
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTAttachment* file)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- record id
+   virtual UINT64    RecordID(void) const=0;
+   virtual MTAPIRES  RecordID(const UINT64 record_id)=0;
+   //--- related client
+   virtual UINT64    RelatedClient(void) const=0;
+   virtual MTAPIRES  RelatedClient(const UINT64 record_id)=0;
+   //--- file type
+   virtual UINT      FileType(void) const=0;
+   virtual MTAPIRES  FileType(const UINT type)=0;
+   //--- file name
+   virtual LPCWSTR   FileName(void) const=0;
+   virtual MTAPIRES  FileName(LPCWSTR name)=0;
+   //--- file content
+   virtual const void* FileContent(UINT& content_size) const=0;
+   virtual MTAPIRES  FileContent(const void* content,const UINT content_size)=0;
+   //--- file size
+   virtual UINT      FileSize(void)=0;
+   //--- file flags
+   virtual UINT      FileFlags(void) const=0;
+   virtual MTAPIRES  FileFlags(const UINT flags)=0;
+  };
+//+------------------------------------------------------------------+

+ 65 - 0
MT5SDK/Bases/MT5APIBook.h

@@ -0,0 +1,65 @@
+//+------------------------------------------------------------------+
+//|                                                 MetaTrader 5 API |
+//|                   Copyright 2000-2019, MetaQuotes Software Corp. |
+//|                                        http://www.metaquotes.net |
+//+------------------------------------------------------------------+
+#pragma once
+//+------------------------------------------------------------------+
+//| Book item transaction structure                                  |
+//+------------------------------------------------------------------+
+#pragma pack(push,1)
+struct MTBookItem
+  {
+   //--- book item type
+   enum EnBookItem
+     {
+      ItemReset      =0,                                    // reset book item
+      ItemSell       =1,                                    // sell item
+      ItemBuy        =2,                                    // buy item
+      ItemSellMarket =3,                                    // sell item by market
+      ItemBuyMarket  =4                                     // buy item by market
+     };
+   UINT              type;                                  // EnBookItem
+   double            price;                                 // deal price
+   INT64             volume;                                // deal volume - only integer values
+   INT64             volume_ext;                            // deal volume with extended accuracy - 8 digits
+   UINT              reserved[6];                           // reserved
+  };
+#pragma pack(pop)
+//+------------------------------------------------------------------+
+//| Book structure                                                   |
+//+------------------------------------------------------------------+
+#pragma pack(push,1)
+struct MTBook
+  {
+   //--- book flags
+   enum EnBookFlags
+     {
+      FLAG_PRE_AUCTION=1,                                   // pre-auction book state
+      FLAG_SNAPSHOT   =2,                                   // snapshot of book
+      //--- enumeration borders
+      FLAG_NONE       =0,                                   // none
+      FLAG_ALL        =FLAG_PRE_AUCTION|FLAG_SNAPSHOT       // all flags
+     };
+   wchar_t           symbol[32];                            // symbol
+   MTBookItem        items[32*4];                           // book transactions
+   UINT              items_total;                           // book transactions count
+   UINT64            flags;                                 // flags
+   INT64             datetime;                              // datetime
+   INT64             datetime_msc;                          // datetime
+   UINT              reserved[58];                          // reserved
+  };
+#pragma pack(pop)
+//+------------------------------------------------------------------+
+//| Book difference structure type                                   |
+//+------------------------------------------------------------------+
+typedef MTBook MTBookDiff;
+//+------------------------------------------------------------------+
+//| Book events notification interface                               |
+//+------------------------------------------------------------------+
+class IMTBookSink
+  {
+public:
+   virtual void      OnBook(const MTBook& /*book*/) {}
+  };
+//+------------------------------------------------------------------+

+ 79 - 0
MT5SDK/Bases/MT5APIByteStream.h

@@ -0,0 +1,79 @@
+//+------------------------------------------------------------------+
+//|                                                 MetaTrader 5 API |
+//|                   Copyright 2000-2019, MetaQuotes Software Corp. |
+//|                                        http://www.metaquotes.net |
+//+------------------------------------------------------------------+
+#pragma once
+//+------------------------------------------------------------------+
+//| Byte stream interface                                            |
+//+------------------------------------------------------------------+
+class IMTByteStream
+  {
+public:
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTByteStream* stream)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- common properties
+   virtual UINT      Len(void)=0;
+   virtual UINT      ReadLen(void)=0;
+   //--- data add
+   virtual MTAPIRES  Add(const void *buf,const UINT len)=0;
+   virtual MTAPIRES  AddChar(const char data)=0;
+   virtual MTAPIRES  AddUChar(const UCHAR data)=0;
+   virtual MTAPIRES  AddShort(const short data)=0;
+   virtual MTAPIRES  AddUShort(const USHORT data)=0;
+   virtual MTAPIRES  AddInt(const int data)=0;
+   virtual MTAPIRES  AddUInt(const UINT data)=0;
+   virtual MTAPIRES  AddInt64(const INT64 data)=0;
+   virtual MTAPIRES  AddUInt64(const UINT64 data)=0;
+   virtual MTAPIRES  AddFloat(const float data)=0;
+   virtual MTAPIRES  AddDouble(const double data)=0;
+   virtual MTAPIRES  AddResult(const MTAPIRES data)=0;
+   virtual MTAPIRES  AddStr(LPCWSTR buf)=0;
+   //--- data read
+   virtual void      ReadReset(void)=0;
+   virtual MTAPIRES  Read(void* buf,const UINT len)=0;
+   virtual MTAPIRES  ReadSkip(const UINT len)=0;
+   virtual MTAPIRES  ReadChar(char& data)=0;
+   virtual MTAPIRES  ReadUChar(UCHAR& data)=0;
+   virtual MTAPIRES  ReadShort(SHORT& data)=0;
+   virtual MTAPIRES  ReadUShort(USHORT& data)=0;
+   virtual MTAPIRES  ReadInt(int& data)=0;
+   virtual MTAPIRES  ReadUInt(UINT& data)=0;
+   virtual MTAPIRES  ReadInt64(INT64& data)=0;
+   virtual MTAPIRES  ReadUInt64(UINT64& data)=0;
+   virtual MTAPIRES  ReadFloat(float& data)=0;
+   virtual MTAPIRES  ReadDouble(double& data)=0;
+   virtual MTAPIRES  ReadResult(MTAPIRES& data)=0;
+   virtual MTAPIRES  ReadStr(MTAPISTR& buf)=0;
+   //--- web api data add
+   virtual MTAPIRES  WebAddParamStr(LPCWSTR name,LPCWSTR value)=0;
+   virtual MTAPIRES  WebAddParamChar(LPCWSTR name,const char value)=0;
+   virtual MTAPIRES  WebAddParamUChar(LPCWSTR name,const UCHAR value)=0;
+   virtual MTAPIRES  WebAddParamShort(LPCWSTR name,const short value)=0;
+   virtual MTAPIRES  WebAddParamUShort(LPCWSTR name,const USHORT value)=0;
+   virtual MTAPIRES  WebAddParamInt(LPCWSTR name,const int value)=0;
+   virtual MTAPIRES  WebAddParamUInt(LPCWSTR name,const UINT value)=0;
+   virtual MTAPIRES  WebAddParamInt64(LPCWSTR name,const INT64 value)=0;
+   virtual MTAPIRES  WebAddParamUInt64(LPCWSTR name,const UINT64 value)=0;
+   virtual MTAPIRES  WebAddParamDouble(LPCWSTR name,const double value,const UINT digits)=0;
+   virtual MTAPIRES  WebAddParamFinalize(void)=0;
+   //--- web api data read
+   virtual MTAPIRES  WebReadCommand(MTAPISTR& cmd)=0;
+   virtual MTAPIRES  WebReadParamName(MTAPISTR& name)=0;
+   virtual MTAPIRES  WebReadParamStr(MTAPISTR& str)=0;
+   virtual MTAPIRES  WebReadParamStr(LPWSTR value,const UINT size)=0;
+   virtual MTAPIRES  WebReadParamSkip(void)=0;
+   virtual MTAPIRES  WebReadParamChar(char& data)=0;
+   virtual MTAPIRES  WebReadParamUChar(UCHAR& data)=0;
+   virtual MTAPIRES  WebReadParamShort(SHORT& data)=0;
+   virtual MTAPIRES  WebReadParamUShort(USHORT& data)=0;
+   virtual MTAPIRES  WebReadParamInt(int& value)=0;
+   virtual MTAPIRES  WebReadParamUInt(UINT& value)=0;
+   virtual MTAPIRES  WebReadParamInt64(INT64& value)=0;
+   virtual MTAPIRES  WebReadParamUInt64(UINT64& value)=0;
+   virtual MTAPIRES  WebReadParamDouble(double& value)=0;
+  };
+//+------------------------------------------------------------------+
+  

+ 54 - 0
MT5SDK/Bases/MT5APICertificate.h

@@ -0,0 +1,54 @@
+//+------------------------------------------------------------------+
+//|                                                 MetaTrader 5 API |
+//|                   Copyright 2000-2019, MetaQuotes Software Corp. |
+//|                                        http://www.metaquotes.net |
+//+------------------------------------------------------------------+
+#pragma once
+//+------------------------------------------------------------------+
+//| SSL certificate interface                                        |
+//+------------------------------------------------------------------+
+class IMTCertificate
+  {
+public:
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTCertificate *certificate)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- certificate open/save/close/raw access
+   virtual MTAPIRES  Open(LPCWSTR filename)=0;
+   virtual MTAPIRES  OpenMemory(const void *data,const UINT size)=0;
+   virtual MTAPIRES  Save(LPCWSTR filename) const=0;
+   virtual MTAPIRES  Close(void)=0;
+   virtual LPCVOID   Raw(void) const=0;
+   virtual UINT      RawSize(void) const=0;
+   virtual MTAPIRES  CommonReserved1(void)=0;
+   virtual MTAPIRES  CommonReserved2(void)=0;
+   virtual MTAPIRES  CommonReserved3(void)=0;
+   virtual MTAPIRES  CommonReserved4(void)=0;
+   virtual MTAPIRES  CommonReserved5(void)=0;
+   //--- certificate properties
+   virtual bool      IsOpened(void) const=0;
+   virtual bool      IsRoot(void) const=0;
+   virtual bool      IsCA(void) const=0;
+   virtual bool      IsEqual(const IMTCertificate *certificate)=0;
+   virtual bool      IsReserved1(void)=0;
+   virtual bool      IsReserved2(void)=0;
+   virtual bool      IsReserved3(void)=0;
+   virtual bool      IsReserved4(void)=0;
+   virtual bool      IsReserved5(void)=0;
+   //--- certificate number and fields
+   virtual UINT64    SerialNumber(void) const=0;
+   virtual INT64     ValidFrom(void) const=0;
+   virtual INT64     ValidTo(void) const=0;
+   virtual MTAPIRES  NameCommon(MTAPISTR& name) const=0;
+   virtual MTAPIRES  NameIssuer(MTAPISTR& name) const=0;
+   virtual MTAPIRES  NameOrganization(MTAPISTR& name) const=0;
+   virtual MTAPIRES  NameOrganizationUnit(MTAPISTR& name) const=0;
+   virtual MTAPIRES  NameGiven(MTAPISTR& name) const=0;
+   virtual MTAPIRES  NameReserved1(void) const=0;
+   virtual MTAPIRES  NameReserved2(void) const=0;
+   virtual MTAPIRES  NameReserved3(void) const=0;
+   virtual MTAPIRES  NameReserved4(void) const=0;
+   virtual MTAPIRES  NameReserved5(void) const=0;
+  };
+//+------------------------------------------------------------------+

+ 39 - 0
MT5SDK/Bases/MT5APIChart.h

@@ -0,0 +1,39 @@
+//+------------------------------------------------------------------+
+//|                                                 MetaTrader 5 API |
+//|                   Copyright 2000-2019, MetaQuotes Software Corp. |
+//|                                        http://www.metaquotes.net |
+//+------------------------------------------------------------------+
+#pragma once
+
+//+------------------------------------------------------------------+
+//| History split rounding methods                                   |
+//+------------------------------------------------------------------+
+enum EnSplitRounding
+  {
+   SPLIT_ROUNDING_STANDARD=0,  // standard mathematical rounding
+   SPLIT_ROUNDING_DOWN    =1,  // round half up
+   SPLIT_ROUNDING_UP      =2,  // round half down
+//--- enumeration borders
+   SPLIT_ROUNDING_FIRST   =SPLIT_ROUNDING_STANDARD,
+   SPLIT_ROUNDING_LAST    =SPLIT_ROUNDING_UP
+  };
+//+------------------------------------------------------------------+
+//| History bar description                                          |
+//+------------------------------------------------------------------+
+#pragma pack(push,1)
+struct MTChartBar
+  {
+   INT64             datetime;          // datetime
+   //--- prices
+   double            open;              // open price
+   double            high;              // high price
+   double            low;               // low price
+   double            close;             // close price
+   //--- volumes
+   UINT64            tick_volume;       // tick volume
+   INT32             spread;            // spread
+   UINT64            volume;            // volume
+  };
+#pragma pack(pop)
+//+------------------------------------------------------------------+
+

+ 388 - 0
MT5SDK/Bases/MT5APIClient.h

@@ -0,0 +1,388 @@
+//+------------------------------------------------------------------+
+//|                                                 MetaTrader 5 API |
+//|                   Copyright 2000-2019, MetaQuotes Software Corp. |
+//|                                        http://www.metaquotes.net |
+//+------------------------------------------------------------------+
+#pragma once
+//+------------------------------------------------------------------+
+//| Client record interface                                          |
+//+------------------------------------------------------------------+
+class IMTClient
+  {
+public:
+   //--- genders
+   enum EnGender
+     {
+      GENDER_UNSPECIFIED                  =0,            // unspecified
+      GENDER_MALE                         =1,            // male
+      GENDER_FEMALE                       =2,            // female
+      //--- enumeration borders
+      GENDER_FIRST                        =GENDER_UNSPECIFIED,
+      GENDER_LAST                         =GENDER_FEMALE
+     };
+   //--- client types
+   enum EnClientType
+     {
+      CLIENT_TYPE_UNDEFINED               =0,            // undefined
+      CLIENT_TYPE_INDIVIDUAL              =1,            // individual person
+      CLIENT_TYPE_CORPORATE               =2,            // corporate
+      CLIENT_TYPE_FUND                    =3,            // fund
+      //--- enumeration borders
+      CLIENT_TYPE_FIRST                   =CLIENT_TYPE_UNDEFINED,
+      CLIENT_TYPE_LAST                    =CLIENT_TYPE_FUND
+     };
+   //--- client statuses
+   enum EnClientStatus
+     {
+      //--- demo account registered
+      CLIENT_STATUS_UNREGISTERED          =0,           // anonymous client (demo account without any data)
+      CLIENT_STATUS_REGISTERED            =100,         // client that opened demo account and filled contact data
+      CLIENT_STATUS_NOTINTERESTED         =200,         // client that opened demo account and filled contact data, but doesn't have interest to open real account
+      //--- preliminary account registered
+      CLIENT_STATUS_APPLICATION_INCOMPLETED=300,        // client that filled data for real account
+      CLIENT_STATUS_APPLICATION_COMPLETED =400,         // client that filled data for real account and attached all documents
+      CLIENT_STATUS_APPLICATION_INFORMATION=500,        // need more information for next processing to open real account
+      CLIENT_STATUS_APPLICATION_REJECTED  =600,         // client was rejected
+      //--- client
+      CLIENT_STATUS_APPROVED              =700,         // client with real account
+      CLIENT_STATUS_FUNDED                =800,         // client that was funded his real account
+      CLIENT_STATUS_ACTIVE                =900,         // client that have trading activity  for some period
+      CLIENT_STATUS_INACTIVE              =1000,        // client that haven't trading activity  for some period
+      CLIENT_STATUS_SUSPENDED             =1100,        // client that was suspended
+      //--- closed 
+      CLIENT_STATUS_CLOSED                =1200,        // closed by himself
+      CLIENT_STATUS_TERMINATED            =1300,        // closed by company
+      //--- enumeration borders
+      CLIENT_STATUS_FIRST                 =CLIENT_STATUS_UNREGISTERED,
+      CLIENT_STATUS_LAST                  =CLIENT_STATUS_TERMINATED
+     };
+   //--- preferred communications
+   enum EnPreferredCommunication
+     {
+      PREFERRED_COMMUNICATION_UNDEFINED   =0,            // undefined
+      PREFERRED_COMMUNICATION_EMAIL       =1,            // email
+      PREFERRED_COMMUNICATION_PHONE       =2,            // phone
+      PREFERRED_COMMUNICATION_PHONE_SMS   =3,            // SMS
+      PREFERRED_COMMUNICATION_MESSENGER   =4,            // messenger
+      //--- enumeration borders
+      PREFERRED_COMMUNICATION_FIRST       =PREFERRED_COMMUNICATION_UNDEFINED,
+      PREFERRED_COMMUNICATION_LAST        =PREFERRED_COMMUNICATION_MESSENGER,
+     };
+   //--- experiences
+   enum EnTradingExperience
+     {
+      EXPERIENCE_LESS_1_YEAR              =0,            // less than one year
+      EXPERIENCE_1_3_YEAR                 =1,            // from one to three years
+      EXPERIENCE_ABOVE_3_YEAR             =2,            // above three years
+      //--- enumeration borders
+      EXPERIENCE_FIRST                    =EXPERIENCE_LESS_1_YEAR,
+      EXPERIENCE_LAST                     =EXPERIENCE_ABOVE_3_YEAR,
+     };
+   //--- employments
+   enum EnEmployment
+     {
+      EMPLOYMENT_UNEMPLOYED               =0,            // unemployed
+      EMPLOYMENT_EMPLOYED                 =1,            // employed
+      EMPLOYMENT_SELF_EMPLOYED            =2,            // self employed
+      EMPLOYMENT_RETIRED                  =3,            // retired
+      EMPLOYMENT_STUDENT                  =4,            // student
+      EMPLOYMENT_OTHER                    =5,            // other
+      //--- enumeration borders           
+      EMPLOYMENT_FIRST                    =EMPLOYMENT_UNEMPLOYED,
+      EMPLOYMENT_LAST                     =EMPLOYMENT_OTHER
+     };
+   //--- employment industries
+   enum EnEmploymentIndustry
+     {
+      INDUSTRY_NONE                       =0,            // none
+      INDUSTRY_AGRICULTURE                =1,            // agriculture
+      INDUSTRY_CONSTRUCTION               =2,            // construction
+      INDUSTRY_MANAGEMENT                 =3,            // management
+      INDUSTRY_COMMUNICATION              =4,            // communication
+      INDUSTRY_EDUCATION                  =5,            // education
+      INDUSTRY_GOVERNMENT                 =6,            // government
+      INDUSTRY_HEALTHCARE                 =7,            // health care
+      INDUSTRY_TOURISM                    =8,            // tourism
+      INDUSTRY_IT                         =9,            // IT
+      INDUSTRY_SECURITY                   =10,           // security
+      INDUSTRY_MANUFACTURING              =11,           // manufacturing
+      INDUSTRY_MARKETING                  =12,           // marketing
+      INDUSTRY_SCIENCE                    =13,           // science
+      INDUSTRY_ENGINEERING                =14,           // engineering
+      INDUSTRY_TRANSPORT                  =15,           // transport
+      INDUSTRY_OTHER                      =16,           // other
+      //--- enumeration borders
+      INDUSTRY_FIRST                      =INDUSTRY_AGRICULTURE,
+      INDUSTRY_LAST                       =INDUSTRY_OTHER
+     };
+   //--- education levels
+   enum EnEducationLevel
+     {
+      EDUCATION_LEVEL_NONE                =0,            // none
+      EDUCATION_LEVEL_HIGH_SCHOOL         =1,            // high school
+      EDUCATION_LEVEL_BACHELOR            =2,            // bachelor
+      EDUCATION_LEVEL_MASTER              =3,            // master
+      EDUCATION_LEVEL_PHD                 =4,            // PHD
+      EDUCATION_LEVEL_OTHER               =5,            // other
+      //--- enumeration borders
+      EDUCATION_LEVEL_FIRST               =EDUCATION_LEVEL_NONE,
+      EDUCATION_LEVEL_LAST                =EDUCATION_LEVEL_OTHER
+     };
+   //--- wealth sources
+   enum EnWealthSource
+     {
+      WEALTH_SOURCE_EMPLOYMENT            =0,            // employment
+      WEALTH_SOURCE_SAVINGS               =1,            // savings
+      WEALTH_SOURCE_INHERITANCE           =2,            // inheritance
+      WEALTH_SOURCE_OTHER                 =3,            // other
+      //--- enumeration borders
+      WEALTH_SOURCE_FIRST                 =WEALTH_SOURCE_EMPLOYMENT,
+      WEALTH_SOURCE_LAST                  =WEALTH_SOURCE_OTHER
+     };
+   //--- client origins
+   enum EnClientOrigin
+     {
+      CLIENT_ORIGIN_MANUAL                =0,           // manual created
+      CLIENT_ORIGIN_DEMO                  =1,           // automatic was created from demo account
+      CLIENT_ORIGIN_CONTEST               =2,           // automatic was created from contest account
+      CLIENT_ORIGIN_PRELIMINARY           =3,           // automatic was created from preliminary account
+      CLIENT_ORIGIN_REAL                  =4,           // automatic was created from real account
+      //--- enumeration borders
+      CLIENT_ORIGIN_FIRST                 =CLIENT_ORIGIN_MANUAL,
+      CLIENT_ORIGIN_LAST                  =CLIENT_ORIGIN_REAL,
+     };
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTClient* client)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- record id
+   virtual UINT64    RecordID(void) const=0;
+   virtual MTAPIRES  RecordID(const UINT64 record_id)=0;
+   //--- client type
+   virtual UINT      ClientType(void) const=0;
+   virtual MTAPIRES  ClientType(const UINT type)=0;
+   //--- client status
+   virtual UINT      ClientStatus(void) const=0;
+   virtual MTAPIRES  ClientStatus(const UINT status)=0;
+   //--- assigned manager
+   virtual UINT64    AssignedManager(void) const=0;
+   virtual MTAPIRES  AssignedManager(const UINT64 manager)=0;
+   //--- compliance approved by
+   virtual UINT64    ComplianceApprovedBy(void) const=0;
+   virtual MTAPIRES  ComplianceApprovedBy(const UINT64 manager)=0;
+   //--- compliance client category
+   virtual LPCWSTR   ComplianceClientCategory(void) const=0;
+   virtual MTAPIRES  ComplianceClientCategory(LPCWSTR category)=0;
+   //--- compliance date approval
+   virtual INT64     ComplianceDateApproval(void) const=0;
+   virtual MTAPIRES  ComplianceDateApproval(const INT64 date)=0;
+   //--- compliance date termination
+   virtual INT64     ComplianceDateTermination(void) const=0;
+   virtual MTAPIRES  ComplianceDateTermination(const INT64 date)=0;
+   //--- lead campaign
+   virtual LPCWSTR   LeadCampaign(void) const=0;
+   virtual MTAPIRES  LeadCampaign(LPCWSTR campaign)=0;
+   //--- lead source
+   virtual LPCWSTR   LeadSource(void) const=0;
+   virtual MTAPIRES  LeadSource(LPCWSTR source)=0;
+   //--- introducer
+   virtual LPCWSTR   Introducer(void) const=0;
+   virtual MTAPIRES  Introducer(LPCWSTR introducer)=0;
+   //--- person title
+   virtual LPCWSTR   PersonTitle(void) const=0;
+   virtual MTAPIRES  PersonTitle(LPCWSTR title)=0;
+   //--- person name
+   virtual LPCWSTR   PersonName(void) const=0;
+   virtual MTAPIRES  PersonName(LPCWSTR name)=0;
+   //--- person middle name
+   virtual LPCWSTR   PersonMiddleName(void) const=0;
+   virtual MTAPIRES  PersonMiddleName(LPCWSTR middle_name)=0;
+   //--- person last name
+   virtual LPCWSTR   PersonLastName(void) const=0;
+   virtual MTAPIRES  PersonLastName(LPCWSTR last_name)=0;
+   //--- person birth date
+   virtual INT64     PersonBirthDate(void) const=0;
+   virtual MTAPIRES  PersonBirthDate(const INT64 date)=0;
+   //--- person citizenship
+   virtual LPCWSTR   PersonCitizenship(void) const=0;
+   virtual MTAPIRES  PersonCitizenship(LPCWSTR citizenship)=0;
+   //--- person gender
+   virtual UINT      PersonGender(void) const=0;
+   virtual MTAPIRES  PersonGender(const UINT gender)=0;
+   //--- person taxid
+   virtual LPCWSTR   PersonTaxID(void) const=0;
+   virtual MTAPIRES  PersonTaxID(LPCWSTR taxid)=0;
+   //--- person document type
+   virtual LPCWSTR   PersonDocumentType(void) const=0;
+   virtual MTAPIRES  PersonDocumentType(LPCWSTR type)=0;
+   //--- person document number
+   virtual LPCWSTR   PersonDocumentNumber(void) const=0;
+   virtual MTAPIRES  PersonDocumentNumber(LPCWSTR number)=0;
+   //--- person document date
+   virtual INT64     PersonDocumentDate(void) const=0;
+   virtual MTAPIRES  PersonDocumentDate(const INT64 date)=0;
+   //--- person document extra
+   virtual LPCWSTR   PersonDocumentExtra(void) const=0;
+   virtual MTAPIRES  PersonDocumentExtra(LPCWSTR extra)=0;
+   //--- person employment
+   virtual UINT      PersonEmployment(void) const=0;
+   virtual MTAPIRES  PersonEmployment(const UINT employment)=0;
+   //--- person industry
+   virtual UINT      PersonIndustry(void) const=0;
+   virtual MTAPIRES  PersonIndustry(const UINT industry)=0;
+   //--- person education
+   virtual UINT      PersonEducation(void) const=0;
+   virtual MTAPIRES  PersonEducation(const UINT education)=0;
+   //--- person wealth source
+   virtual UINT      PersonWealthSource(void) const=0;
+   virtual MTAPIRES  PersonWealthSource(const UINT source)=0;
+   //--- person annual income
+   virtual double    PersonAnnualIncome(void) const=0;
+   virtual MTAPIRES  PersonAnnualIncome(const double income)=0;
+   //--- person net worth
+   virtual double    PersonNetWorth(void) const=0;
+   virtual MTAPIRES  PersonNetWorth(const double worth)=0;
+   //--- person annual deposit
+   virtual double    PersonAnnualDeposit(void) const=0;
+   virtual MTAPIRES  PersonAnnualDeposit(const double deposit)=0;
+   //--- company name
+   virtual LPCWSTR   CompanyName(void) const=0;
+   virtual MTAPIRES  CompanyName(LPCWSTR name)=0;
+   //--- company registration number
+   virtual LPCWSTR   CompanyRegNumber(void) const=0;
+   virtual MTAPIRES  CompanyRegNumber(LPCWSTR number)=0;
+   //--- company registration date
+   virtual INT64     CompanyRegDate(void) const=0;
+   virtual MTAPIRES  CompanyRegDate(const INT64 date)=0;
+   //--- company registration authority
+   virtual LPCWSTR   CompanyRegAuthority(void) const=0;
+   virtual MTAPIRES  CompanyRegAuthority(LPCWSTR authority)=0;
+   //--- company VAT
+   virtual LPCWSTR   CompanyVat(void) const=0;
+   virtual MTAPIRES  CompanyVat(LPCWSTR vat)=0;
+   //--- company LEI
+   virtual LPCWSTR   CompanyLei(void) const=0;
+   virtual MTAPIRES  CompanyLei(LPCWSTR lei)=0;
+   //--- company license number
+   virtual LPCWSTR   CompanyLicenseNumber(void) const=0;
+   virtual MTAPIRES  CompanyLicenseNumber(LPCWSTR number)=0;
+   //--- company license authority
+   virtual LPCWSTR   CompanyLicenseAuthority(void) const=0;
+   virtual MTAPIRES  CompanyLicenseAuthority(LPCWSTR authority)=0;
+   //--- company country
+   virtual LPCWSTR   CompanyCountry(void) const=0;
+   virtual MTAPIRES  CompanyCountry(LPCWSTR country)=0;
+   //--- company address
+   virtual LPCWSTR   CompanyAddress(void) const=0;
+   virtual MTAPIRES  CompanyAddress(LPCWSTR address)=0;
+   //--- company website
+   virtual LPCWSTR   CompanyWebsite(void) const=0;
+   virtual MTAPIRES  CompanyWebsite(LPCWSTR website)=0;
+   //--- contact preferred
+   virtual UINT      ContactPreferred(void) const=0;
+   virtual MTAPIRES  ContactPreferred(const UINT preferred)=0;
+   //--- contact language
+   virtual LPCWSTR   ContactLanguage(void) const=0;
+   virtual MTAPIRES  ContactLanguage(LPCWSTR language)=0;
+   //--- contact email
+   virtual LPCWSTR   ContactEmail(void) const=0;
+   virtual MTAPIRES  ContactEmail(LPCWSTR email)=0;
+   //--- contact phone
+   virtual LPCWSTR   ContactPhone(void) const=0;
+   virtual MTAPIRES  ContactPhone(LPCWSTR phone)=0;
+   //--- contact messengers
+   virtual LPCWSTR   ContactMessengers(void) const=0;
+   virtual MTAPIRES  ContactMessengers(LPCWSTR messengers)=0;
+   //--- contact social networks
+   virtual LPCWSTR   ContactSocialNetworks(void) const=0;
+   virtual MTAPIRES  ContactSocialNetworks(LPCWSTR social_networks)=0;
+   //--- ñontact last date
+   virtual INT64     ContactLastDate(void) const=0;
+   virtual MTAPIRES  ContactLastDate(const INT64 date)=0;
+   //--- address country
+   virtual LPCWSTR   AddressCountry(void) const=0;
+   virtual MTAPIRES  AddressCountry(LPCWSTR country)=0;
+   //--- address postcode
+   virtual LPCWSTR   AddressPostcode(void) const=0;
+   virtual MTAPIRES  AddressPostcode(LPCWSTR postcode)=0;
+   //--- address street
+   virtual LPCWSTR   AddressStreet(void) const=0;
+   virtual MTAPIRES  AddressStreet(LPCWSTR street)=0;
+   //--- address state
+   virtual LPCWSTR   AddressState(void) const=0;
+   virtual MTAPIRES  AddressState(LPCWSTR state)=0;
+   //--- address city
+   virtual LPCWSTR   AddressCity(void) const=0;
+   virtual MTAPIRES  AddressCity(LPCWSTR city)=0;
+   //--- experience of FX
+   virtual UINT      ExperienceFX(void) const=0;
+   virtual MTAPIRES  ExperienceFX(const UINT experience)=0;
+   //--- experience of CFD
+   virtual UINT      ExperienceCFD(void) const=0;
+   virtual MTAPIRES  ExperienceCFD(const UINT experience)=0;
+   //--- experience of Futures
+   virtual UINT      ExperienceFutures(void) const=0;
+   virtual MTAPIRES  ExperienceFutures(const UINT experience)=0;
+   //--- experience of Stocks
+   virtual UINT      ExperienceStocks(void) const=0;
+   virtual MTAPIRES  ExperienceStocks(const UINT experience)=0;
+   //--- trading group
+   virtual LPCWSTR   TradingGroup(void) const=0;
+   virtual MTAPIRES  TradingGroup(LPCWSTR group)=0;
+   //--- client origin
+   virtual UINT      ClientOrigin(void) const=0;
+   virtual MTAPIRES  ClientOrigin(const UINT origin)=0;
+   //--- client origin login
+   virtual UINT64    ClientOriginLogin(void) const=0;
+   virtual MTAPIRES  ClientOriginLogin(const UINT64 login)=0;
+   //--- external ID
+   virtual LPCWSTR   ClientExternalID(void) const=0;
+   virtual MTAPIRES  ClientExternalID(LPCWSTR external_id)=0;
+  };
+//+------------------------------------------------------------------+
+//| Client array interface                                           |
+//+------------------------------------------------------------------+
+class IMTClientArray
+  {
+public:
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTClientArray* array)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- add
+   virtual MTAPIRES  Add(IMTClient* client)=0;
+   virtual MTAPIRES  AddCopy(const IMTClient* client)=0;
+   virtual MTAPIRES  Add(IMTClientArray* array)=0;
+   virtual MTAPIRES  AddCopy(const IMTClientArray* array)=0;
+   //--- delete & detach
+   virtual MTAPIRES  Delete(const UINT pos)=0;
+   virtual IMTClient *Detach(const UINT pos)=0;
+   //--- update
+   virtual MTAPIRES  Update(const UINT pos,IMTClient* client)=0;
+   virtual MTAPIRES  UpdateCopy(const UINT pos,const IMTClient* client)=0;
+   virtual MTAPIRES  Shift(const UINT pos,const int shift)=0;
+   //--- data access
+   virtual UINT      Total(void) const=0;
+   virtual IMTClient*Next(const UINT index) const=0;
+   //--- sorting and search
+   virtual MTAPIRES  Sort(MTSortFunctionPtr sort_function)=0;
+   virtual int       Search(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchGreatOrEq(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchGreater(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchLessOrEq(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchLess(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchLeft(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchRight(const void *key,MTSortFunctionPtr sort_function) const=0;
+  };
+//+------------------------------------------------------------------+
+//| Client records notification interface                            |
+//+------------------------------------------------------------------+
+class IMTClientSink
+  {
+public:
+   //--- events
+   virtual void      OnClientAdd(const IMTClient*    /*client*/)           {  }
+   virtual void      OnClientUpdate(const IMTClient* /*client*/)           {  }
+   virtual void      OnClientDelete(const IMTClient* /*client*/)           {  }
+  };
+//+------------------------------------------------------------------+

+ 125 - 0
MT5SDK/Bases/MT5APIComment.h

@@ -0,0 +1,125 @@
+//+------------------------------------------------------------------+
+//|                                                 MetaTrader 5 API |
+//|                   Copyright 2000-2019, MetaQuotes Software Corp. |
+//|                                        http://www.metaquotes.net |
+//+------------------------------------------------------------------+
+#pragma once
+//+------------------------------------------------------------------+
+//| Comment record interface                                         |
+//+------------------------------------------------------------------+
+class IMTComment
+  {
+public:
+   //--- comment flags
+   enum EnCommentFlags
+     {
+      COMMENT_FLAG_DELETED    =0x1,                   // deleted
+      COMMENT_FLAG_IMPORTANT  =0x2,                   // important
+      //--- enumeration borders
+      COMMENT_FLAG_NONE       =0,
+      COMMENT_FLAG_ALL        =COMMENT_FLAG_DELETED|COMMENT_FLAG_IMPORTANT,
+     };
+   //--- comment types
+   enum EnCommentType
+     {
+      COMMENT_TYPE_UNDEFINED                =0,       // undefined
+      COMMENT_TYPE_LOGRECORD                =1,       // log record
+      COMMENT_TYPE_CALLRECORD               =2,       // call record
+      COMMENT_TYPE_ROBOTRECORD              =3,       // robot record
+      //--- enumeration borders
+      COMMENT_TYPE_FIRST                    =COMMENT_TYPE_UNDEFINED,
+      COMMENT_TYPE_LAST                     =COMMENT_TYPE_ROBOTRECORD,
+     };
+   //--- comment results
+   enum EnCommentResult
+     {
+      COMMENT_RESULT_UNDEFINED              =0,       // undefined
+      COMMENT_RESULT_CALL_NO_ANSWER         =1,       // call no answer
+      COMMENT_RESULT_CALL_WRONG_NUMBER      =2,       // call wrong number
+      COMMENT_RESULT_CALL_NOT_INTERESTED    =3,       // call not interested
+      COMMENT_RESULT_CALL_SUCCESSFUL        =4,       // call successful
+      //--- enumeration borders
+      COMMENT_RESULT_FIRST                  =COMMENT_RESULT_UNDEFINED,
+      COMMENT_RESULT_LAST                   =COMMENT_RESULT_CALL_SUCCESSFUL,
+     };
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTComment* comment)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- record id
+   virtual UINT64    RecordID(void) const=0;
+   virtual MTAPIRES  RecordID(const UINT64 record_id)=0;
+   //--- related client
+   virtual UINT64    RelatedClient(void) const=0;
+   virtual MTAPIRES  RelatedClient(const UINT64 record_id)=0;
+   //--- related document
+   virtual UINT64    RelatedDocument(void) const=0;
+   virtual MTAPIRES  RelatedDocument(const UINT64 record_id)=0;
+   //--- flags
+   virtual UINT      Flags(void) const=0;
+   virtual MTAPIRES  Flags(const UINT flags)=0;
+   //--- extra
+   virtual LPCWSTR   Extra(void) const=0;
+   virtual MTAPIRES  Extra(LPCWSTR extra)=0;
+   //--- text
+   virtual LPCWSTR   Text(void) const=0;
+   virtual MTAPIRES  Text(LPCWSTR text)=0;
+   //--- comment type
+   virtual UINT      CommentType(void) const=0;
+   virtual MTAPIRES  CommentType(const UINT type)=0;
+   //--- comment result
+   virtual UINT      CommentResult(void) const=0;
+   virtual MTAPIRES  CommentResult(const UINT result)=0;
+   //--- attachments
+   virtual MTAPIRES  AttachmentsAdd(const IMTAttachment *attachment)=0;
+   virtual MTAPIRES  AttachmentsClear(void)=0;
+   virtual UINT      AttachmentsTotal(void) const=0;
+   virtual MTAPIRES  AttachmentsNext(const UINT pos,UINT64& attachment_id,MTAPISTR& attachment_name,UINT& attachment_size) const=0;
+  };
+//+------------------------------------------------------------------+
+//| Comment array interface                                          |
+//+------------------------------------------------------------------+
+class IMTCommentArray
+  {
+public:
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTCommentArray* array)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- add
+   virtual MTAPIRES  Add(IMTComment* comment)=0;
+   virtual MTAPIRES  AddCopy(const IMTComment* comment)=0;
+   virtual MTAPIRES  Add(IMTCommentArray* array)=0;
+   virtual MTAPIRES  AddCopy(const IMTCommentArray* array)=0;
+   //--- delete & detach
+   virtual MTAPIRES  Delete(const UINT pos)=0;
+   virtual IMTComment *Detach(const UINT pos)=0;
+   //--- update
+   virtual MTAPIRES  Update(const UINT pos,IMTComment* comment)=0;
+   virtual MTAPIRES  UpdateCopy(const UINT pos,const IMTComment* comment)=0;
+   virtual MTAPIRES  Shift(const UINT pos,const int shift)=0;
+   //--- data access
+   virtual UINT      Total(void) const=0;
+   virtual IMTComment*Next(const UINT index) const=0;
+   //--- sorting and search
+   virtual MTAPIRES  Sort(MTSortFunctionPtr sort_function)=0;
+   virtual int       Search(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchGreatOrEq(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchGreater(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchLessOrEq(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchLess(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchLeft(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchRight(const void *key,MTSortFunctionPtr sort_function) const=0;
+  };
+//+------------------------------------------------------------------+
+//| Comment records notification interface                           |
+//+------------------------------------------------------------------+
+class IMTCommentSink
+  {
+public:
+   //--- events
+   virtual void      OnCommentAdd(const IMTComment*    /*comment*/)           {  }
+   virtual void      OnCommentUpdate(const IMTComment* /*comment*/)           {  }
+   virtual void      OnCommentDelete(const IMTComment* /*comment*/)           {  }
+  };
+//+------------------------------------------------------------------+

+ 72 - 0
MT5SDK/Bases/MT5APIConfirm.h

@@ -0,0 +1,72 @@
+//+------------------------------------------------------------------+
+//|                                                 MetaTrader 5 API |
+//|                   Copyright 2000-2019, MetaQuotes Software Corp. |
+//|                                        http://www.metaquotes.net |
+//+------------------------------------------------------------------+
+#pragma once
+//+------------------------------------------------------------------+
+//| Trade request confim interface                                   |
+//+------------------------------------------------------------------+
+class IMTConfirm
+  {
+public:
+   //--- confirm flags
+   enum EnConfirmFlags
+     {
+      CONFIRM_FLAG_NONE=0,          // none
+      CONFIRM_FLAG_TICK=1,          // add quoted price into MT5 price stream
+      //--- enumeration borders
+      CONFIRM_FLAG_ALL =CONFIRM_FLAG_TICK
+     };
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTConfirm* confirm)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   virtual LPCWSTR   Print(MTAPISTR& string) const=0;
+   //--- request id
+   virtual UINT      ID(void) const=0;
+   virtual MTAPIRES  ID(const UINT id)=0;
+   //--- confirmation retcode
+   virtual MTAPIRES  Retcode(void) const=0;
+   virtual MTAPIRES  Retcode(const MTAPIRES retcode)=0;
+   //--- confirmed volume
+   virtual UINT64    Volume(void) const=0;
+   virtual MTAPIRES  Volume(const UINT64 volume)=0;
+   //--- confirmed price
+   virtual double    Price(void) const=0;
+   virtual MTAPIRES  Price(const double price)=0;
+   //--- confirmed tick bid
+   virtual double    TickBid(void) const=0;
+   virtual MTAPIRES  TickBid(const double tickbid)=0;
+   //--- confirmed tick ask
+   virtual double    TickAsk(void) const=0;
+   virtual MTAPIRES  TickAsk(const double tickask)=0;
+   //--- confirmed tick last
+   virtual double    TickLast(void) const=0;
+   virtual MTAPIRES  TickLast(const double ticklast)=0;
+   //--- confirmation comment
+   virtual LPCWSTR   Comment(void) const=0;
+   virtual MTAPIRES  Comment(LPCWSTR comment)=0;
+   //--- flags
+   virtual UINT      Flags(void) const=0;
+   virtual MTAPIRES  Flags(const UINT flags)=0;
+   //--- linked deal id in external system
+   virtual LPCWSTR   DealID(void) const=0;
+   virtual MTAPIRES  DealID(LPCWSTR deal_id)=0;
+   //--- linked order id in external system
+   virtual LPCWSTR   OrderID(void) const=0;
+   virtual MTAPIRES  OrderID(LPCWSTR order_id)=0;
+   //--- execution price on gateway
+   virtual double    PriceGateway(void) const=0;
+   virtual MTAPIRES  PriceGateway(const double price)=0;
+   //--- linked  position ticket in external system
+   virtual LPCWSTR   PositionExternalID(void) const=0;
+   virtual MTAPIRES  PositionExternalID(LPCWSTR id)=0;
+   //--- external trade system return code
+   virtual int       ExternalRetcode(void) const=0;
+   virtual MTAPIRES  ExternalRetcode(const int retcode)=0;
+   //--- confirmed volume with extended accuracy
+   virtual UINT64    VolumeExt(void) const=0;
+   virtual MTAPIRES  VolumeExt(const UINT64 volume)=0;
+  };
+//+------------------------------------------------------------------+

+ 210 - 0
MT5SDK/Bases/MT5APIDaily.h

@@ -0,0 +1,210 @@
+//+------------------------------------------------------------------+
+//|                                         MetaTrader 5 API Server  |
+//|                   Copyright 2000-2019, MetaQuotes Software Corp. |
+//|                                        http://www.metaquotes.net |
+//+------------------------------------------------------------------+
+#pragma once
+//+------------------------------------------------------------------+
+//| Trade account interface                                          |
+//+------------------------------------------------------------------+
+class IMTDaily
+  {
+public:
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTDaily* exec)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- date and time
+   virtual INT64     Datetime(void) const=0;
+   virtual MTAPIRES  Datetime(const INT64 datetime)=0;
+   //--- previous generation datetime
+   virtual INT64     DatetimePrev(void) const=0;
+   virtual MTAPIRES  DatetimePrev(const INT64 datetime)=0;
+   //--- login
+   virtual UINT64    Login(void) const=0;
+   virtual MTAPIRES  Login(const UINT64 login)=0;
+   //--- name
+   virtual LPCWSTR   Name(void) const=0;
+   virtual MTAPIRES  Name(LPCWSTR name)=0;
+   //--- group
+   virtual LPCWSTR   Group(void) const=0;
+   virtual MTAPIRES  Group(LPCWSTR group)=0;
+   //--- currency
+   virtual LPCWSTR   Currency(void) const=0;
+   virtual MTAPIRES  Currency(LPCWSTR curr)=0;
+   virtual UINT      CurrencyDigits(void) const=0;
+   //--- company
+   virtual LPCWSTR   Company(void) const=0;
+   virtual MTAPIRES  Company(LPCWSTR company)=0;
+   //--- e-mail
+   virtual LPCWSTR   EMail(void) const=0;
+   virtual MTAPIRES  EMail(LPCWSTR mail)=0;
+   //--- balance
+   virtual double    Balance(void) const=0;
+   virtual MTAPIRES  Balance(const double balance)=0;
+   //--- credit
+   virtual double    Credit(void) const=0;
+   virtual MTAPIRES  Credit(const double credit)=0;
+   //--- interest rate
+   virtual double    InterestRate(void) const=0;
+   virtual MTAPIRES  InterestRate(const double credit)=0;
+   //--- commission daily
+   virtual double    CommissionDaily(void) const=0;
+   virtual MTAPIRES  CommissionDaily(const double comm)=0;
+   //--- commission monthly
+   virtual double    CommissionMonthly(void) const=0;
+   virtual MTAPIRES  CommissionMonthly(const double comm)=0;
+   //--- commission daily
+   virtual double    AgentDaily(void) const=0;
+   virtual MTAPIRES  AgentDaily(const double agent)=0;
+   //--- commission monthly
+   virtual double    AgentMonthly(void) const=0;
+   virtual MTAPIRES  AgentMonthly(const double agent)=0;
+   //--- last day balance
+   virtual double    BalancePrevDay(void) const=0;
+   virtual MTAPIRES  BalancePrevDay(const double balance)=0;
+   //--- last month balance
+   virtual double    BalancePrevMonth(void) const=0;
+   virtual MTAPIRES  BalancePrevMonth(const double balance)=0;
+   //--- last day equity
+   virtual double    EquityPrevDay(void) const=0;
+   virtual MTAPIRES  EquityPrevDay(const double balance)=0;
+   //--- last month equity
+   virtual double    EquityPrevMonth(void) const=0;
+   virtual MTAPIRES  EquityPrevMonth(const double balance)=0;
+   //---
+   //--- margin
+   //---
+   virtual double    Margin(void) const=0;
+   virtual MTAPIRES  Margin(const double margin)=0;
+   //--- free margin 
+   virtual double    MarginFree(void) const=0;
+   virtual MTAPIRES  MarginFree(const double margin_free)=0;
+   //--- margin level
+   virtual double    MarginLevel(void) const=0;
+   virtual MTAPIRES  MarginLevel(const double margin_level)=0;
+   //--- margin leverage
+   virtual UINT      MarginLeverage(void) const=0;
+   virtual MTAPIRES  MarginLeverage(const UINT leverage)=0;
+   //---
+   //--- floating profit
+   //---
+   virtual double    Profit(void) const=0;
+   virtual MTAPIRES  Profit(const double profit)=0;
+   //--- storage
+   virtual double    ProfitStorage(void) const=0;
+   virtual MTAPIRES  ProfitStorage(const double storage)=0;
+   //--- commission
+   virtual double    ProfitCommission(void) const=0;
+   virtual MTAPIRES  ProfitCommission(const double commission)=0;
+   //--- equity
+   virtual double    ProfitEquity(void) const=0;
+   virtual MTAPIRES  ProfitEquity(const double equity)=0;
+   //---
+   //--- daily fixed profit details
+   //---
+   virtual double    DailyProfit(void) const=0;
+   virtual MTAPIRES  DailyProfit(const double profit)=0;
+   //---
+   virtual double    DailyBalance(void) const=0;
+   virtual MTAPIRES  DailyBalance(const double balance)=0;
+   //---
+   virtual double    DailyCredit(void) const=0;
+   virtual MTAPIRES  DailyCredit(const double comm)=0;
+   //---
+   virtual double    DailyCharge(void) const=0;
+   virtual MTAPIRES  DailyCharge(const double charge)=0;
+   //---
+   virtual double    DailyCorrection(void) const=0;
+   virtual MTAPIRES  DailyCorrection(const double correction)=0;
+   //---
+   virtual double    DailyBonus(void) const=0;
+   virtual MTAPIRES  DailyBonus(const double bonus)=0;
+   //---
+   virtual double    DailyStorage(void) const=0;
+   virtual MTAPIRES  DailyStorage(const double storage)=0;
+   //---
+   virtual double    DailyCommInstant(void) const=0;
+   virtual MTAPIRES  DailyCommInstant(const double comm)=0;
+   //---
+   virtual double    DailyCommRound(void) const=0;
+   virtual MTAPIRES  DailyCommRound(const double comm)=0;
+   //---
+   virtual double    DailyAgent(void) const=0;
+   virtual MTAPIRES  DailyAgent(const double comm)=0;
+   //---
+   virtual double    DailyInterest(void) const=0;
+   virtual MTAPIRES  DailyInterest(const double interest)=0;
+   //--- list of open positions
+   virtual MTAPIRES  PositionAdd(IMTPosition* position)=0;
+   virtual MTAPIRES  PositionUpdate(const UINT pos,const IMTPosition* position)=0;
+   virtual MTAPIRES  PositionDelete(const UINT pos)=0;
+   virtual MTAPIRES  PositionClear(void)=0;
+   virtual MTAPIRES  PositionShift(const UINT pos,const int shift)=0;
+   virtual UINT      PositionTotal(void) const=0;
+   virtual MTAPIRES  PositionNext(const UINT pos,IMTPosition* position) const=0;
+   virtual MTAPIRES  PositionGet(LPCWSTR symbol,IMTPosition* position) const=0;
+   //--- list of open orders
+   virtual MTAPIRES  OrderAdd(IMTOrder* order)=0;
+   virtual MTAPIRES  OrderUpdate(const UINT pos,const IMTOrder* order)=0;
+   virtual MTAPIRES  OrderDelete(const UINT pos)=0;
+   virtual MTAPIRES  OrderClear(void)=0;
+   virtual MTAPIRES  OrderShift(const UINT pos,const int shift)=0;
+   virtual UINT      OrderTotal(void) const=0;
+   virtual MTAPIRES  OrderNext(const UINT pos,IMTOrder* order) const=0;
+   virtual MTAPIRES  OrderGet(const UINT64 ticket,IMTOrder* order) const=0;
+   //--- assets
+   virtual double    ProfitAssets(void) const=0;
+   virtual MTAPIRES  ProfitAssets(const double assets)=0;
+   //--- liabilities
+   virtual double    ProfitLiabilities(void) const=0;
+   virtual MTAPIRES  ProfitLiabilities(const double liabilities)=0;
+  };
+//+------------------------------------------------------------------+
+//| Deal array interface                                             |
+//+------------------------------------------------------------------+
+class IMTDailyArray
+  {
+public:
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTDailyArray* array)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- add
+   virtual MTAPIRES  Add(IMTDaily* daily)=0;
+   virtual MTAPIRES  AddCopy(const IMTDaily* daily)=0;
+   virtual MTAPIRES  Add(IMTDailyArray* array)=0;
+   virtual MTAPIRES  AddCopy(const IMTDailyArray* array)=0;
+   //--- delete & detach
+   virtual MTAPIRES  Delete(const UINT pos)=0;
+   virtual IMTDaily* Detach(const UINT pos)=0;
+   //--- update
+   virtual MTAPIRES  Update(const UINT pos,IMTDaily* daily)=0;
+   virtual MTAPIRES  UpdateCopy(const UINT pos,const IMTDaily* daily)=0;
+   virtual MTAPIRES  Shift(const UINT pos,const int shift)=0;
+   //--- data access
+   virtual UINT      Total(void) const=0;
+   virtual IMTDaily* Next(const UINT index) const=0;
+   //--- sorting and search
+   virtual MTAPIRES  Sort(MTSortFunctionPtr sort_function)=0;
+   virtual int       Search(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchGreatOrEq(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchGreater(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchLessOrEq(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchLess(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchLeft(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchRight(const void *key,MTSortFunctionPtr sort_function) const=0;
+  };
+//+------------------------------------------------------------------+
+//| Deals events notification interface                              |
+//+------------------------------------------------------------------+
+class IMTDailySink
+  {
+public:
+   virtual void      OnDailyAdd(const IMTDaily*    /*daily*/)  {  }
+   virtual void      OnDailyUpdate(const IMTDaily* /*daily*/)  {  }
+   virtual void      OnDailyDelete(const IMTDaily* /*daily*/)  {  }
+   virtual void      OnDailyClean(const UINT64 /*login*/)      {  }
+   virtual void      OnDailySync(void)                         {  }
+  };
+//+------------------------------------------------------------------+

+ 787 - 0
MT5SDK/Bases/MT5APIDataset.h

@@ -0,0 +1,787 @@
+//+------------------------------------------------------------------+
+//|                                         MetaTrader 5 API Server  |
+//|                   Copyright 2000-2019, MetaQuotes Software Corp. |
+//|                                        http://www.metaquotes.net |
+//+------------------------------------------------------------------+
+#pragma once
+//+------------------------------------------------------------------+
+//| Dataset column interface                                         |
+//+------------------------------------------------------------------+
+class IMTDatasetColumn
+  {
+public:
+   //--- column data types
+   enum EnType
+     {
+      //--- base types
+      TYPE_INT8               =0,                     // Integer (8 bits)
+      TYPE_UINT8              =1,                     // Unsigned Integer (8 bits)
+      TYPE_INT16              =2,                     // Integer (16 bits)
+      TYPE_UINT16             =3,                     // Unsigned Integer (16 bits)
+      TYPE_INT32              =4,                     // Integer (32 bits)
+      TYPE_UINT32             =5,                     // Unsigned Integer (32 bits)
+      TYPE_INT64              =6,                     // Integer (64 bits)
+      TYPE_UINT64             =7,                     // Unsigned Integer (64 bits)
+      TYPE_DOUBLE             =8,                     // Double
+      TYPE_MONEY              =9,                     // Money (Double)
+      TYPE_STRING             =10,                    // Unicode String
+      TYPE_DATE               =11,                    // Date (Int64)
+      TYPE_TIME               =12,                    // Time (Int64)
+      TYPE_DATETIME           =13,                    // Datetime (Int64)
+      TYPE_TIME_MSC           =14,                    // Time in milliseconds (Int64)
+      TYPE_DATETIME_MSC       =15,                    // Datetime in milliseconds (Int64)
+      //--- prices
+      TYPE_PRICE              =100,                   // Price (Double)
+      TYPE_PRICES             =101,                   // Bid/Ask (Double[2])
+      TYPE_PRICE_POSITION     =102,                   // Price for positions (Double)
+      //--- volumes
+      TYPE_VOLUME             =200,                   // Volume (UInt64)
+      TYPE_VOLUME_ORDER       =201,                   // Initial Volume/Current Volume (UInt64[2])
+      TYPE_VOLUME_EXT         =202,                   // Volume with extended accuracy (UInt64)
+      TYPE_VOLUME_ORDER_EXT   =203,                   // Initial Volume/Current Volume with extended accuracy (UInt64[2])
+      //--- positions
+      TYPE_POSITION_TYPE      =300,                   // Position Type (UInt)
+      //--- orders
+      TYPE_ORDER_TYPE         =400,                   // Order Type (UInt)
+      TYPE_ORDER_TYPE_TIME    =401,                   // Order Type by Time (UInt)
+      TYPE_ORDER_TYPE_REASON  =402,                   // Order Type by Reason (UInt)
+      TYPE_ORDER_STATUS       =403,                   // Order Status (UInt)
+      TYPE_ORDER_FILLING      =404,                   // Order Filling (UInt)
+      //--- deals
+      TYPE_DEAL_ACTION        =500,                   // Deal Action (UInt)
+      TYPE_DEAL_ENTRY         =501,                   // Deal Entry (UInt)
+      //--- accounts
+      TYPE_USER_LOGIN         =600,                   // Account Login (UInt64)
+      TYPE_USER_LEVERAGE      =601,                   // Account Leverage (UInt)
+      //--- clients
+      TYPE_CLIENT_ID          =700,                   // Client Id (UInt64)
+      //--- enumeration borders
+      TYPE_FIRST              =TYPE_INT8,
+      TYPE_LAST               =TYPE_CLIENT_ID
+     };
+   //--- column flags
+   enum EnFlags
+     {
+      FLAG_NONE               =0x00000000,            // none flags
+      FLAG_PRIMARY            =0x00000001,            // primary integer column
+      FLAG_HIDDEN_VIEW        =0x00000002,            // hidden in grid view
+      FLAG_HIDDEN_SAVE        =0x00000004,            // hidden in saved file
+      FLAG_HIDDEN             =FLAG_HIDDEN_VIEW|FLAG_HIDDEN_SAVE, // hidden in grid and file
+      FLAG_LEFT               =0x00000008,            // force align left
+      FLAG_RIGHT              =0x00000010,            // force align right
+      FLAG_CENTER             =FLAG_LEFT|FLAG_RIGHT,  // force align center
+      //--- enumeration borders
+      FLAG_ALL                =FLAG_PRIMARY|FLAG_HIDDEN|FLAG_CENTER
+     };
+   //--- color
+   enum EnColumnColor
+     {
+      COLUMN_COLOR_AUTO       =0xFFFFFFFF,            // auto color
+     };
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTDatasetColumn *column)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- name
+   virtual LPCWSTR   Name(void) const=0;
+   virtual MTAPIRES  Name(LPCWSTR name)=0;
+   //--- column id
+   virtual UINT      ColumnID(void) const=0;
+   virtual MTAPIRES  ColumnID(const UINT column_id)=0;
+   //--- type IMTDatasetColumn::EnType
+   virtual UINT      Type(void) const=0;
+   virtual MTAPIRES  Type(const UINT type)=0;
+   //--- column relative width
+   virtual UINT      Width(void) const=0;
+   virtual MTAPIRES  Width(const UINT width)=0;
+   //--- column max width in pixels
+   virtual UINT      WidthMax(void) const=0;
+   virtual MTAPIRES  WidthMax(const UINT width_max)=0;
+   //--- default digits
+   virtual UINT      Digits(void) const=0;
+   virtual MTAPIRES  Digits(const UINT digits)=0;
+   //--- column digits reference
+   virtual UINT      DigitsColumn(void) const=0;
+   virtual MTAPIRES  DigitsColumn(const UINT column_id)=0;
+   //--- flags IMTDatasetColumn::EnFlags
+   virtual UINT64    Flags(void) const=0;
+   virtual MTAPIRES  Flags(const UINT64 flags)=0;
+   //--- offset
+   virtual UINT      Offset(void) const=0;
+   virtual MTAPIRES  Offset(const UINT offset)=0;
+   //--- size
+   virtual UINT      Size(void) const=0;
+   virtual MTAPIRES  Size(const UINT size)=0;
+   //--- chart color
+   virtual UINT      Color(void) const=0;
+   virtual MTAPIRES  Color(const UINT color)=0;
+  };
+//+------------------------------------------------------------------+
+//| Dataset summary interface                                        |
+//+------------------------------------------------------------------+
+class IMTDatasetSummary
+  {
+public:
+   //--- summary data types
+   enum EnType
+     {
+      //--- base types
+      TYPE_INT                =0,                     // Integer (64 bits)
+      TYPE_UINT               =1,                     // Unsigned Integer (64 bits)
+      TYPE_DOUBLE             =2,                     // Double
+      TYPE_MONEY              =3,                     // Money
+      TYPE_STRING             =4,                     // Unicode String
+      TYPE_DATE               =5,                     // Date
+      TYPE_TIME               =6,                     // Time
+      TYPE_DATETIME           =7,                     // Datetime
+      //--- prices
+      TYPE_PRICE              =100,                   // Price
+      TYPE_PRICES             =101,                   // Bid/Ask
+      //--- volumes
+      TYPE_VOLUME             =200,                   // Volume
+      TYPE_VOLUME_ORDER       =201,                   // Initial Volume/Current Volume (UInt64[2])
+      TYPE_VOLUME_EXT         =202,                   // Volume with extended accuracy (UInt64)
+      TYPE_VOLUME_ORDER_EXT   =203,                   // Initial Volume/Current Volume with extended accuracy (UInt64[2])
+      //--- enumeration borders
+      TYPE_FIRST              =TYPE_INT,
+      TYPE_LAST               =TYPE_VOLUME_ORDER_EXT
+     };
+   //--- summary flags
+   enum EnFlags
+     {
+      FLAG_NONE               =0x0,                   // none flag
+     };
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTDatasetSummary *summary)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- column id
+   virtual UINT      ColumnID(void) const=0;
+   virtual MTAPIRES  ColumnID(const UINT column_id)=0;
+   //--- line index
+   virtual UINT      Line(void) const=0;
+   virtual MTAPIRES  Line(const UINT line)=0;
+   //--- column for merging (merging from ColumnID to MergeColumn)
+   virtual UINT      MergeColumn(void) const=0;
+   virtual MTAPIRES  MergeColumn(const UINT column_id)=0;
+   //--- text color
+   virtual UINT      Color(void) const=0;
+   virtual MTAPIRES  Color(const UINT color)=0;
+   //--- flags IMTDatasetSummary::EnFlags
+   virtual UINT64    Flags(void) const=0;
+   virtual MTAPIRES  Flags(const UINT64 flags)=0;
+   //--- type IMTDatasetSummary::EnType
+   virtual UINT      Type(void) const=0;
+   //--- digits
+   virtual UINT      Digits(void) const=0;
+   virtual MTAPIRES  Digits(const UINT digits)=0;
+   //--- integer
+   virtual INT64     ValueInt(void) const=0;
+   virtual MTAPIRES  ValueInt(const INT64 value)=0;
+   //--- unsigned integer
+   virtual UINT64    ValueUInt(void) const=0;
+   virtual MTAPIRES  ValueUInt(const UINT64 value)=0;
+   //--- double
+   virtual double    ValueDouble(void) const=0;
+   virtual MTAPIRES  ValueDouble(const double value)=0;
+   //--- money
+   virtual double    ValueMoney(void) const=0;
+   virtual MTAPIRES  ValueMoney(const double value)=0;
+   //--- string
+   virtual LPCWSTR   ValueString(void) const=0;
+   virtual MTAPIRES  ValueString(LPCWSTR value)=0;
+   //--- date
+   virtual INT64     ValueDate(void) const=0;
+   virtual MTAPIRES  ValueDate(const INT64 value)=0;
+   //--- time
+   virtual INT64     ValueTime(void) const=0;
+   virtual MTAPIRES  ValueTime(const INT64 value)=0;
+   //--- datetime
+   virtual INT64     ValueDateTime(void) const=0;
+   virtual MTAPIRES  ValueDateTime(const INT64 value)=0;
+   //--- price
+   virtual double    ValuePrice(void) const=0;
+   virtual MTAPIRES  ValuePrice(const double value)=0;
+   //--- prices
+   virtual double    ValuePricesBid(void) const=0;
+   virtual double    ValuePricesAsk(void) const=0;
+   virtual MTAPIRES  ValuePrices(const double value_bid,const double value_ask)=0;
+   //--- volume
+   virtual UINT64    ValueVolume(void) const=0;
+   virtual MTAPIRES  ValueVolume(const UINT64 value)=0;
+   //--- order volume
+   virtual UINT64    ValueVolumeInitial(void) const=0;
+   virtual UINT64    ValueVolumeCurrent(void) const=0;
+   virtual MTAPIRES  ValueVolume(const UINT64 value_initial,const UINT64 value_current)=0;
+   //--- volume with extended accuracy
+   virtual UINT64    ValueVolumeExt(void) const=0;
+   virtual MTAPIRES  ValueVolumeExt(const UINT64 value)=0;
+   //--- order volume with extended accuracy
+   virtual UINT64    ValueVolumeExtInitial(void) const=0;
+   virtual UINT64    ValueVolumeExtCurrent(void) const=0;
+   virtual MTAPIRES  ValueVolumeExt(const UINT64 value_initial,const UINT64 value_current)=0;
+  };
+//+------------------------------------------------------------------+
+//| Dataset interface                                                |
+//+------------------------------------------------------------------+
+class IMTDataset
+  {
+public:
+   //--- flags
+   enum EnDataSetFlags
+     {
+      DATASET_FLAG_NONE     =0x0,    // no flags
+     };
+
+public:
+   //--- common methods
+   virtual MTAPIRES  Assign(const IMTDataset *data)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- flags
+   virtual UINT64    Flags(void) const=0;
+   virtual MTAPIRES  Flags(const UINT64 flags)=0;
+   //--- reserverd properites methods
+   virtual MTAPIRES  Reserved1(void)=0;
+   virtual MTAPIRES  Reserved2(void)=0;
+   virtual MTAPIRES  Reserved3(void)=0;
+   virtual MTAPIRES  Reserved4(void)=0;
+   //--- data set column management
+   virtual IMTDatasetColumn* ColumnCreate(void)=0;
+   virtual MTAPIRES  ColumnClear(void)=0;
+   virtual MTAPIRES  ColumnAdd(const IMTDatasetColumn *column)=0;
+   virtual MTAPIRES  ColumnDelete(const UINT pos)=0;
+   virtual UINT      ColumnTotal(void) const=0;
+   virtual UINT      ColumnSize(void) const=0;
+   virtual MTAPIRES  ColumnNext(const UINT pos,IMTDatasetColumn *column)=0;
+   virtual MTAPIRES  ColumnReserved1(void)=0;
+   virtual MTAPIRES  ColumnReserved2(void)=0;
+   //--- data set row management
+   virtual MTAPIRES  RowClear(void)=0;
+   virtual MTAPIRES  RowWrite(const void *data,const UINT size)=0;
+   virtual UINT      RowTotal(void) const=0;
+   virtual MTAPIRES  RowRead(const UINT pos,void *data,const UINT size) const=0;
+   virtual MTAPIRES  RowReserved2(void)=0;
+   //--- data set summary management
+   virtual IMTDatasetSummary* SummaryCreate(void)=0;
+   virtual MTAPIRES  SummaryClear(void)=0;
+   virtual MTAPIRES  SummaryAdd(const IMTDatasetSummary *summary)=0;
+   virtual MTAPIRES  SummaryDelete(const UINT pos)=0;
+   virtual MTAPIRES  SummaryNext(const UINT pos,IMTDatasetSummary *summary)=0;
+   virtual UINT      SummaryTotal(void) const=0;
+   virtual MTAPIRES  SummaryReserved1(void)=0;
+   virtual MTAPIRES  SummaryReserved2(void)=0;
+   //--- life control
+   virtual void      Release(void)=0;
+  };
+//+------------------------------------------------------------------+
+//| Datatset request field                                           |
+//+------------------------------------------------------------------+
+class IMTDatasetField
+  {
+public:
+   //--- filed type
+   enum EnFieldType
+     {
+      TYPE_NONE                              =0,            // none
+      TYPE_INT                               =1,            // integer
+      TYPE_UINT                              =2,            // unsigned integer
+      TYPE_DOUBLE                            =3,            // double
+      TYPE_STRING                            =4,            // string
+      //--- enumeration borders
+      TYPE_FIRST                             =TYPE_NONE,
+      TYPE_LAST                              =TYPE_STRING
+     };
+   //--- Request fields id enumeration
+   enum EnFieldId
+     {
+      //--- User fields enumeration
+      FIELD_USER_LOGIN                       =1,            // UINT64      , login
+      FIELD_USER_GROUP                       =2,            // wchar_t[64] , group
+      FIELD_USER_CERT_SERIAL_NUMBER          =3,            // UINT64      , certificate serial number
+      FIELD_USER_RIGHTS                      =4,            // UINT64      , EnUsersRights
+      FIELD_USER_REGISTRATION                =5,            // INT64       , registration datetime (filled by MT5)
+      FIELD_USER_LAST_ACCESS                 =6,            // INT64       , last access datetime (filled by MT5)
+      FIELD_USER_NAME                        =7,            // wchar_t[128], name
+      FIELD_USER_COMPANY                     =8,            // wchar_t[32] , company
+      FIELD_USER_ACCOUNT                     =9,            // wchar_t[64] , external system account (exchange, ECN, etc)
+      FIELD_USER_COUNTRY                     =10,           // wchar_t[32] , country
+      FIELD_USER_LANGUAGE                    =11,           // UINT        , client language (WinAPI LANGID)
+      FIELD_USER_CITY                        =12,           // wchar_t[32] , city
+      FIELD_USER_STATE                       =13,           // wchar_t[32] , state
+      FIELD_USER_ZIP_CODE                    =14,           // wchar_t[16] , ZIP code
+      FIELD_USER_ADDRESS                     =15,           // wchar_t[128], address
+      FIELD_USER_PHONE                       =16,           // wchar_t[32] , phone
+      FIELD_USER_EMAIL                       =17,           // wchar_t[64] , email
+      FIELD_USER_ID                          =18,           // wchar_t[32] , additional ID
+      FIELD_USER_STATUS                      =19,           // wchar_t[16] , additional status
+      FIELD_USER_COMMENT                     =20,           // wchar_t[64] , comment
+      FIELD_USER_COLOR                       =21,           // UINT        , color (WinAPI COLORREF)
+      FIELD_USER_PHONE_PASSWORD              =22,           // wchar_t[32] , phone password
+      FIELD_USER_LEVERAGE                    =23,           // UINT        , leverage
+      FIELD_USER_AGENT                       =24,           // UINT64      , agent account
+      FIELD_USER_BALANCE                     =25,           // double      , balance
+      FIELD_USER_CREDIT                      =26,           // double      , credit
+      FIELD_USER_INTEREST_RATE               =27,           // double      , accumulated interest rate
+      FIELD_USER_COMMISSION_DAILY            =28,           // double      , accumulated daily commissions
+      FIELD_USER_COMMISSION_MONTHLY          =29,           // double      , accumulated monthly commissions
+      FIELD_USER_COMMISSION_AGENT_DAILY      =30,           // double      , accumulated daily agent commissions
+      FIELD_USER_COMMISSION_AGENT_MONTHLY    =31,           // double      , accumulated monthly agent commissions
+      FIELD_USER_BALANCE_PREV_DAY            =32,           // double      , previous day balance state
+      FIELD_USER_BALANCE_PREV_MONTH          =33,           // double      , previous month balance state
+      FIELD_USER_EQUITY_PREV_DAY             =34,           // double      , previous day equity state
+      FIELD_USER_EQUITY_PREV_MONTH           =35,           // double      , previous month equity state
+      FIELD_USER_LAST_PASS_CHANGE            =36,           // INT64       , last password change datetime (filled by MT5)
+      FIELD_USER_MQID                        =37,           // UINT        , client's MetaQuotes ID
+      FIELD_USER_LEAD_CAMPAIGN               =38,           // wchar_t[32] , lead campaign
+      FIELD_USER_LEAD_SOURCE                 =39,           // wchar_t[32] , lead source
+      FIELD_USER_CLIENT_ID                   =40,           // UINT64      , client id
+      //--- User fields enumeration borders
+      FIELD_USER_FIRST                       =FIELD_USER_LOGIN,
+      FIELD_USER_LAST                        =FIELD_USER_CLIENT_ID,
+      //--- Client fields enumeration
+      FIELD_CLIENT_ID                        =1001,         // UINT64      , client id
+      FIELD_CLIENT_CREATED_TIME              =1002,         // INT64       , creation date and time
+      FIELD_CLIENT_CREATED_BY                =1003,         // UINT64      , login of manager who created the client
+      FIELD_CLIENT_MODIFIED_TIME             =1004,         // INT64       , modification date
+      FIELD_CLIENT_MODIFIED_BY               =1005,         // UINT64      , login of manager who modified the client
+      FIELD_CLIENT_TYPE                      =1006,         // UINT        , client type (EnClientType)
+      FIELD_CLIENT_STATUS                    =1007,         // UINT        , client status (EnClientStatus)
+      FIELD_CLIENT_ASSIGNED_MANAGER          =1008,         // UINT64      , assigned manager login
+      FIELD_CLIENT_COMMENT                   =1009,         // wchar_t[128], comment
+      FIELD_CLIENT_COMPLIANCE_APPROVED_BY    =1010,         // UINT64      , login of manager who approved the client
+      FIELD_CLIENT_COMPLIANCE_CLIENT_CATEGORY=1011,         // wchar_t[64] , customer classification according to the rules of the local regulator
+      FIELD_CLIENT_COMPLIANCE_TIME_APPROVAL  =1012,         // INT64       , approval date and time
+      FIELD_CLIENT_COMPLIANCE_TIME_TERMINATION=1013,        // INT64       , agreement termination date and time
+      FIELD_CLIENT_LEAD_CAMPAIGN             =1014,         // wchar_t[64] , lead campaign
+      FIELD_CLIENT_LEAD_SOURCE               =1015,         // wchar_t[64] , lead source
+      FIELD_CLIENT_INTRODUCER                =1016,         // wchar_t[32] , IB or Referal
+      FIELD_CLIENT_PERSON_TITLE              =1017,         // wchar_t[16] , title
+      FIELD_CLIENT_PERSON_NAME               =1018,         // wchar_t[32] , first name
+      FIELD_CLIENT_PERSON_MIDDLE_NAME        =1019,         // wchar_t[32] , middle name
+      FIELD_CLIENT_PERSON_LAST_NAME          =1020,         // wchar_t[32] , second name
+      FIELD_CLIENT_PERSON_BIRTH_DATE         =1021,         // INT64       , date of birth (file time, number of 100-nanosecond since 12:00 A.M. January 1, 1601 UTC)
+      FIELD_CLIENT_PERSON_CITIZENSHIP        =1022,         // wchar_t[64] , citizenship
+      FIELD_CLIENT_PERSON_GENDER             =1023,         // UINT        , gender (EnGender)
+      FIELD_CLIENT_PERSON_TAX_ID             =1024,         // wchar_t[64] , tax id
+      FIELD_CLIENT_PERSON_DOCUMENT_TYPE      =1025,         // wchar_t[16] , document type
+      FIELD_CLIENT_PERSON_DOCUMENT_NUMBER    =1026,         // wchar_t[32] , document number
+      FIELD_CLIENT_PERSON_DOCUMENT_DATE      =1027,         // INT64       , document issue or expiration date
+      FIELD_CLIENT_PERSON_DOCUMENT_EXTRA     =1028,         // wchar_t[64] , document extra data
+      FIELD_CLIENT_PERSON_EMPLOYMENT         =1029,         // UINT        , employment status (EnEmployment)
+      FIELD_CLIENT_PERSON_INDUSTRY           =1030,         // UINT        , employment industry (EnEmploymentIndustry)
+      FIELD_CLIENT_PERSON_EDUCATION          =1031,         // UINT        , education level (EnEducationLevel)
+      FIELD_CLIENT_PERSON_WEALTH_SOURCE      =1032,         // UINT        , wealth source (EnWealthSource)
+      FIELD_CLIENT_PERSON_ANNUAL_INCOME      =1033,         // double      , annual income, USD
+      FIELD_CLIENT_PERSON_NET_WORTH          =1034,         // double      , net worth, USD
+      FIELD_CLIENT_PERSON_ANNUAL_DEPOSIT     =1035,         // double      , annual deposit, USD
+      FIELD_CLIENT_COMPANY_NAME              =1036,         // wchar_t[64] , company name
+      FIELD_CLIENT_COMPANY_REG_NUMBER        =1037,         // wchar_t[64] , company registration number
+      FIELD_CLIENT_COMPANY_REG_DATE          =1038,         // INT64       , company registration date
+      FIELD_CLIENT_COMPANY_REG_AUTHORITY     =1039,         // wchar_t[64] , company registration authority
+      FIELD_CLIENT_COMPANY_VAT               =1040,         // wchar_t[64] , VAT registration number
+      FIELD_CLIENT_COMPANY_LEI               =1041,         // wchar_t[64] , EI number for EMIR reports
+      FIELD_CLIENT_COMPANY_LICENSE_NUMBER    =1042,         // wchar_t[64] , license number
+      FIELD_CLIENT_COMPANY_LICENSE_AUTHORITY =1043,         // wchar_t[64] , license issuer authority
+      FIELD_CLIENT_COMPANY_COUNTRY           =1044,         // wchar_t[64] , company registration country
+      FIELD_CLIENT_COMPANY_ADDRESS           =1045,         // wchar_t[64] , company registration address
+      FIELD_CLIENT_COMPANY_WEBSITE           =1046,         // wchar_t[64] , company website
+      FIELD_CLIENT_CONTACT_PREFERRED         =1047,         // UINT        , preferred communication type
+      FIELD_CLIENT_CONTACT_LANGUAGE          =1048,         // wchar_t[64] , communication language
+      FIELD_CLIENT_CONTACT_EMAIL             =1049,         // wchar_t[64] , email (or multiple comma-separated emails)
+      FIELD_CLIENT_CONTACT_PHONE             =1050,         // wchar_t[128], phone numbers (or multiple comma-separated phone numbers)
+      FIELD_CLIENT_CONTACT_MESSENGERS        =1051,         // wchar_t[128], messengers in format: "skype:username, qq:5454535454"
+      FIELD_CLIENT_CONTACT_SOCIALNETWORKS    =1052,         // wchar_t[128], social networks ids: "fb:user_id, vk:user_id"
+      FIELD_CLIENT_CONTACT_LAST_DATE         =1053,         // INT64       , date and time of the last contact
+      FIELD_CLIENT_ADDRESS_COUNTRY           =1054,         // wchar_t[64] , address - country
+      FIELD_CLIENT_ADDRESS_POSTCODE          =1055,         // wchar_t[16] , address - zip code
+      FIELD_CLIENT_ADDRESS_STREET            =1056,         // wchar_t[128], address - street address
+      FIELD_CLIENT_ADDRESS_STATE             =1057,         // wchar_t[64] , address - state, province or district
+      FIELD_CLIENT_ADDRESS_CITY              =1058,         // wchar_t[64] , address - city or town
+      FIELD_CLIENT_EXPERIENCE_FX             =1059,         // UINT        , Forex trading experience (EnTradingExperience)
+      FIELD_CLIENT_EXPERIENCE_CFD            =1060,         // UINT        , CFD trading experience (EnTradingExperience)
+      FIELD_CLIENT_EXPERIENCE_FUTURES        =1061,         // UINT        , futures trading experience (EnTradingExperience)
+      FIELD_CLIENT_EXPERIENCE_STOCKS         =1062,         // UINT        , stocks trading experience (EnTradingExperience)
+      //--- Client fields enumeration borders
+      FIELD_CLIENT_FIRST                     =FIELD_CLIENT_ID,
+      FIELD_CLIENT_LAST                      =FIELD_CLIENT_EXPERIENCE_STOCKS,
+      //--- Deal fields enumeration
+      FIELD_DEAL_DEAL                        =2001,         // UINT64      , deal ticket
+      FIELD_DEAL_EXTERNAL_ID                 =2002,         // wchar_t[32] , deal ticket in external system (exchange, ECN, etc)
+      FIELD_DEAL_LOGIN                       =2003,         // UINT64      , client login
+      FIELD_DEAL_DEALER                      =2004,         // UINT64      , processed dealer login (0-means auto)
+      FIELD_DEAL_ORDER                       =2005,         // UINT64      , deal order ticket
+      FIELD_DEAL_ACTION                      =2006,         // UINT        , EnDealAction
+      FIELD_DEAL_ENTRY                       =2007,         // UINT        , EnEntryFlags
+      FIELD_DEAL_DIGITS                      =2008,         // UINT        , price digits
+      FIELD_DEAL_DIGITS_CURRENCY             =2009,         // UINT        , currency digits
+      FIELD_DEAL_CONTRACT_SIZE               =2010,         // double      , symbol contract size
+      FIELD_DEAL_TIME                        =2011,         // INT64       , deal creation datetime in seconds
+      FIELD_DEAL_SYMBOL                      =2012,         // wchar_t[32] , deal symbol
+      FIELD_DEAL_PRICE                       =2013,         // double      , deal price
+      FIELD_DEAL_VOLUME_EXT                  =2014,         // UINT64      , deal volume with extended accuracy
+      FIELD_DEAL_PROFIT                      =2015,         // double      , deal profit
+      FIELD_DEAL_STORAGE                     =2016,         // double      , deal collected swaps
+      FIELD_DEAL_COMMISSION                  =2017,         // double      , deal commission
+      FIELD_DEAL_RATE_PROFIT                 =2018,         // double      , profit conversion rate (from symbol profit currency to deposit currency)
+      FIELD_DEAL_RATE_MARGIN                 =2019,         // double      , margin conversion rate (from symbol margin currency to deposit currency)
+      FIELD_DEAL_EXPERT_ID                   =2020,         // UINT64      , expert id (filled by expert advisor)
+      FIELD_DEAL_POSITION_ID                 =2021,         // UINT64      , position id
+      FIELD_DEAL_COMMENT                     =2022,         // wchar_t[32] , deal comment
+      FIELD_DEAL_PROFIT_RAW                  =2023,         // double      , deal profit in symbol's profit currency
+      FIELD_DEAL_PRICE_POSITION              =2024,         // double      , closed position  price
+      FIELD_DEAL_VOLUME_CLOSED_EXT           =2025,         // UINT64      , closed volume with extended accuracy
+      FIELD_DEAL_TICK_VALUE                  =2026,         // double      , tick value
+      FIELD_DEAL_TICK_SIZE                   =2027,         // double      , tick size
+      FIELD_DEAL_FLAGS                       =2028,         // UINT64      , flags
+      FIELD_DEAL_TIME_MSC                    =2029,         // INT64       , deal creation datetime in msc since 1970.01.01
+      FIELD_DEAL_REASON                      =2030,         // UINT        , EnDealReason
+      FIELD_DEAL_GATEWAY                     =2031,         // wchar_t[16] , source gateway name
+      FIELD_DEAL_PRICE_GATEWAY               =2032,         // double      , deal price on gateway
+      FIELD_DEAL_MODIFICATION_FLAGS          =2033,         // UINT        , modification flags
+      FIELD_DEAL_PRICE_SL                    =2034,         // double      , order SL
+      FIELD_DEAL_PRICE_TP                    =2035,         // double      , order TP
+      //--- Deal fields enumeration borders
+      FIELD_DEAL_FIRST                       =FIELD_DEAL_DEAL,
+      FIELD_DEAL_LAST                        =FIELD_DEAL_PRICE_TP,
+      //--- ïîëÿ çàïðîñà áàçû çàÿâîê
+      FIELD_ORDER_ORDER                      =3001,        // UINT64      , order ticket
+      FIELD_ORDER_EXTERNAL_ID                =3002,        // wchar_t[32] , order ticket in external system (exchange, ECN, etc)
+      FIELD_ORDER_LOGIN                      =3003,        // UINT64      , client login
+      FIELD_ORDER_DEALER                     =3004,        // UINT64      , processed dealer login (0-means auto)
+      FIELD_ORDER_SYMBOL                     =3005,        // wchar_t[32] , order symbol
+      FIELD_ORDER_TIME_SETUP                 =3006,        // INT64       , time of order reception from a client into the system
+      FIELD_ORDER_TIME_EXPIRATION            =3007,        // INT64       , order expiration time
+      FIELD_ORDER_TIME_DONE                  =3008,        // INT64       , order cancellation time
+      FIELD_ORDER_TYPE                       =3009,        // UINT        , order type
+      FIELD_ORDER_TYPE_FILL                  =3010,        // UINT        , order type by filling
+      FIELD_ORDER_TYPE_TIME                  =3011,        // UINT        , order type by time
+      FIELD_ORDER_TYPE_REASON                =3012,        // UINT        , order creation reason
+      FIELD_ORDER_PRICE_ORDER                =3013,        // double      , order price
+      FIELD_ORDER_PRICE_TRIGGER              =3014,        // double      , order execution price
+      FIELD_ORDER_PRICE_CURRENT              =3015,        // double      , current order prioce
+      FIELD_ORDER_PRICE_SL                   =3016,        // double      , stop-loss price
+      FIELD_ORDER_PRICE_TP                   =3017,        // double      , take-profit price
+      FIELD_ORDER_VOLUME_INITIAL             =3018,        // UINT64      , starting order volume
+      FIELD_ORDER_VOLUME_CURRENT             =3019,        // UINT64      , current order volume
+      FIELD_ORDER_STATE                      =3020,        // UINT        , actual order state
+      FIELD_ORDER_EXPERT_ID                  =3021,        // UINT64      , expert ID
+      FIELD_ORDER_POSITION_ID                =3022,        // UINT64      , position ID which the order opens or closes
+      FIELD_ORDER_COMMENT                    =3023,        // wchar_t[32] , order comment
+      FIELD_ORDER_CONTRACT_SIZE              =3024,        // double      , order contract size
+      FIELD_ORDER_DIGITS                     =3025,        // UINT        , number of digits of order symbol
+      FIELD_ORDER_DIGITS_CURRENCY            =3026,        // UINT        , number of digits of order currency
+      FIELD_ORDER_POSITION_BY_ID             =3027,        // UINT64      , counter Position ID for Close-By orders
+      FIELD_ORDER_MARGIN_RATE                =3028,        // double      , margin conversion rate at the creation time
+      FIELD_ORDER_TIME_SETUP_MSC             =3029,        // INT64       , order reception from a client into the system in milliseconds
+      FIELD_ORDER_TIME_DONE_MSC              =3030,        // INT64       , order cancellation time in milliseconds
+      FIELD_ORDER_MODIFICATION_FLAGS         =3031,        // UINT        , order modification flags
+      FIELD_ORDER_ACTIVATION_MODE            =3032,        // UINT        , order activation mode (for manager)
+      FIELD_ORDER_ACTIVATION_TIME            =3033,        // INT64       , order activation time (for manager)
+      FIELD_ORDER_ACTIVATION_PRICE           =3034,        // double      , order activation price (for manager)
+      FIELD_ORDER_ACTIVATION_FLAGS           =3035,        // UINT        , order activation flags
+      //--- ãðàíèöû id ïîëåé çàïðîñà áàçû èñòîðèè çàÿâîê
+      FIELD_ORDER_FIRST               =FIELD_ORDER_ORDER,
+      FIELD_ORDER_LAST                =FIELD_ORDER_ACTIVATION_FLAGS,
+      //--- ïîëÿ çàïðîñà áàçû äíåâíûõ îò÷¸òîâ
+      FIELD_DAILY_DATE_TIME                  =4001,        // INT64       , report generation date and time
+      FIELD_DAILY_DATE_TIME_PREV             =4002,        // INT64       , date and time of previous report generation
+      FIELD_DAILY_LOGIN                      =4003,        // UINT64      , login
+      FIELD_DAILY_NAME                       =4004,        // wchar_t[128], name
+      FIELD_DAILY_GROUP                      =4005,        // wchar_t[64] , group
+      FIELD_DAILY_CURRENCY                   =4006,        // wchar_t[32] , currency
+      FIELD_DAILY_DIGITS_CURRENCY            =4007,        // UINT        , number of digits of report currency
+      FIELD_DAILY_COMPANY                    =4008,        // wchar_t[64] , company
+      FIELD_DAILY_EMAIL                      =4009,        // wchar_t[64] , e-mail
+      FIELD_DAILY_BALANCE                    =4010,        // double      , balance
+      FIELD_DAILY_CREDIT                     =4011,        // double      , credit
+      FIELD_DAILY_INTEREST_RATE              =4012,        // double      , interest rate
+      FIELD_DAILY_COMMISSION_DAILY           =4013,        // double      , commission daily
+      FIELD_DAILY_COMMISSION_MONTHLY         =4014,        // double      , commission monthly
+      FIELD_DAILY_AGENT_DAILY                =4015,        // double      , commission daily
+      FIELD_DAILY_AGENT_MONTHLY              =4016,        // double      , commission monthly
+      FIELD_DAILY_BALANCE_PREV_DAY           =4017,        // double      , last day balance
+      FIELD_DAILY_BALANCE_PREV_MONTH         =4018,        // double      , last month balance
+      FIELD_DAILY_EQUITY_PREV_DAY            =4019,        // double      , last day equity
+      FIELD_DAILY_EQUITY_PREV_MONTH          =4020,        // double      , last month equity
+      FIELD_DAILY_MARGIN                     =4021,        // double      , margin
+      FIELD_DAILY_MARGIN_FREE                =4022,        // double      , free margin 
+      FIELD_DAILY_MARGIN_LEVEL               =4023,        // double      , margin level
+      FIELD_DAILY_MARGIN_LEVERAGE            =4024,        // UINT        , margin leverage
+      FIELD_DAILY_PROFIT                     =4025,        // double      , floating profit
+      FIELD_DAILY_PROFIT_STORAGE             =4026,        // double      , storage
+      FIELD_DAILY_PROFIT_COMMISSION          =4027,        // double      , commission
+      FIELD_DAILY_PROFIT_EQUITY              =4028,        // double      , equity
+      FIELD_DAILY_DAILY_PROFIT               =4029,        // double      , daily fixed profit details
+      FIELD_DAILY_DAILY_BALANCE              =4030,        // double      , daily balance operations
+      FIELD_DAILY_DAILY_CREDIT               =4031,        // double      , daily credit operations
+      FIELD_DAILY_DAILY_CHARGE               =4032,        // double      , fees per day
+      FIELD_DAILY_DAILY_CORRECTION           =4033,        // double      , correction for the day
+      FIELD_DAILY_DAILY_BONUS                =4034,        // double      , bonuses per day
+      FIELD_DAILY_DAILY_STORAGE              =4035,        // double      , closed positions swap
+      FIELD_DAILY_DAILY_COMM_INSTANT         =4036,        // double      , commission charged immediately
+      FIELD_DAILY_DAILY_COMM_ROUND           =4037,        // double      , deferred commission
+      FIELD_DAILY_DAILY_AGENT                =4038,        // double      , agency commissions per day
+      FIELD_DAILY_DAILY_INTEREST             =4039,        // double      , interest per day
+      FIELD_DAILY_PROFIT_ASSETS              =4040,        // double      , assets
+      FIELD_DAILY_PROFIT_LIABILITIES         =4041,        // double      , liabilities
+      //--- ãðàíèöû id ïîëåé çàïðîñà áàçû äíåâíûõ îò÷¸òîâ
+      FIELD_DAILY_FIRST                      =FIELD_DAILY_DATE_TIME,
+      FIELD_DAILY_LAST                       =FIELD_DAILY_PROFIT_LIABILITIES,
+      //--- ïîëÿ çàïðîñà áàçû ïîçèöèé
+      FIELD_POSITION_LOGIN                   =5001,        // UINT64      , owner client login
+      FIELD_POSITION_SYMBOL                  =5002,        // wchar_t[32] , position symbol
+      FIELD_POSITION_ACTION                  =5003,        // UINT        , EnPositionAction
+      FIELD_POSITION_DIGITS                  =5004,        // UINT        , number of digits of order symbol
+      FIELD_POSITION_DIGITS_CURRENCY         =5005,        // UINT        , number of digits of order currency
+      FIELD_POSITION_CONTRACT_SIZE           =5006,        // double      , symbol contract size
+      FIELD_POSITION_TIME_CREATE             =5007,        // INT64       , position create time
+      FIELD_POSITION_TIME_UPDATE             =5008,        // INT64       , position last update time
+      FIELD_POSITION_PRICE_OPEN              =5009,        // double      , position weighted average open price
+      FIELD_POSITION_PRICE_CURRENT           =5010,        // double      , position current price
+      FIELD_POSITION_PRICE_SL                =5011,        // double      , position SL price
+      FIELD_POSITION_PRICE_TP                =5012,        // double      , position TP price
+      FIELD_POSITION_VOLUME                  =5013,        // UINT64      , position volume
+      FIELD_POSITION_PROFIT                  =5014,        // double      , position floating profit
+      FIELD_POSITION_STORAGE                 =5015,        // double      , position accumulated swaps
+      FIELD_POSITION_RATE_PROFIT             =5016,        // double      , profit conversion rate (from symbol profit currency to deposit currency)
+      FIELD_POSITION_RATE_MARGIN             =5017,        // double      , margin conversion rate (from symbol margin currency to deposit currency)
+      FIELD_POSITION_EXPERT_ID               =5018,        // UINT64      , expert id (filled by expert advisor)
+      FIELD_POSITION_EXPERT_POSITION_ID      =5019,        // UINT64      , expert position id
+      FIELD_POSITION_COMMENT                 =5020,        // wchar_t[32] , comment
+      FIELD_POSITION_ACTIVATION_MODE         =5021,        // UINT        , order activation state, time and price
+      FIELD_POSITION_ACTIVATION_TIME         =5022,        // INT64       , activation mode
+      FIELD_POSITION_ACTIVATION_PRICE        =5023,        // double      , actionvation time
+      FIELD_POSITION_ACTIVATION_FLAGS        =5024,        // UINT        , actiovation flags
+      FIELD_POSITION_TIME_CREATE_MSC         =5025,        // INT64       , position create time in msc since 1970.01.01
+      FIELD_POSITION_TIME_UPDATE_MSC         =5026,        // INT64       , position last update time in msc since 1970.01.01
+      FIELD_POSITION_DEALER                  =5027,        // UINT64      , processed dealer login (0-means auto) (first position deal dealer)
+      FIELD_POSITION_POSITION                =5028,        // UINT64      , position ticket
+      FIELD_POSITION_EXTERNAL_ID             =5029,        // wchar_t[32] , position ticket in external system (exchange, ECN, etc)
+      FIELD_POSITION_MODIFICATION_FLAGS      =5030,        // UINT        , modification flags
+      FIELD_POSITION_REASON                  =5031,        // UINT        , position reason - EnPositionReason
+      FIELD_POSITION_VOLUME_EXT              =5032,        // UINT64      , position volume
+      //--- ãðàíèöû id ïîëåé çàïðîñà áàçû ïîçèöèé
+      FIELD_POSITION_FIRST                   =FIELD_POSITION_LOGIN,
+      FIELD_POSITION_LAST                    =FIELD_POSITION_VOLUME_EXT,
+      //--- enumeration borders
+      FIELD_FIRST                            =FIELD_USER_FIRST,
+      FIELD_LAST                             =FIELD_POSITION_LAST
+     };
+   //--- flags
+   enum EnFieldFlags
+     {
+      FLAG_NONE                              =0x0000000,    // none
+      FLAG_SELECT                            =0x0000001,    // select field
+      //--- enumeration borders
+      FLAG_DEFAULT                           =FLAG_SELECT,
+      FLAG_ALL                               =FLAG_SELECT
+     };
+   //--- gender enumeration
+   enum EnGender
+     {
+      GENDER_UNSPECIFIED                     =0,            // unspecified
+      GENDER_MALE                            =1,            // male
+      GENDER_FEMALE                          =2,            // female
+      //--- enumeration borders
+      GENDER_FIRST                           =GENDER_UNSPECIFIED,
+      GENDER_LAST                            =GENDER_FEMALE
+     };
+   //--- client type enumeration
+   enum EnClientType
+     {
+      CLIENT_TYPE_UNDEFINED                  =0,            // undefined
+      CLIENT_TYPE_INDIVIDUAL                 =1,            // individual
+      CLIENT_TYPE_CORPORATE                  =2,            // corporate
+      CLIENT_TYPE_FUND                       =3,            // fund
+      //--- enumeration borders
+      CLIENT_TYPE_FIRST                      =CLIENT_TYPE_UNDEFINED,
+      CLIENT_TYPE_LAST                       =CLIENT_TYPE_FUND
+     };
+   //--- client status enumeration
+   enum EnClientStatus
+     {
+      //--- Not a client yet - Demo accounts
+      CLIENT_STATUS_UNREGISTERED             =0,            // Anonymous user (demo account without data)
+      CLIENT_STATUS_REGISTERED               =100,          // The user who opened a demo account and left contact information (lead)
+      CLIENT_STATUS_NOTINTERESTED            =200,          // The user who left the contact information, but does not want to open an account
+      //--- Not a client yet - Preliminary
+      CLIENT_STATUS_APPLICATION_INCOMPLETED  =300,          // The user who filled out the form to open a real account
+      CLIENT_STATUS_APPLICATION_COMPLETED    =400,          // The user who filled out the questionnaire to open a real account and provided all the documents
+      CLIENT_STATUS_APPLICATION_INFORMATION  =500,          // User to open an account that requires additional information
+      CLIENT_STATUS_APPLICATION_REJECTED     =600,          // The user who filled out the questionnaire to open a real account but to whom the account was not opened according to the results of the verification of documents
+      //--- Client
+      CLIENT_STATUS_APPROVED                 =700,          // The client who opened a real account
+      CLIENT_STATUS_FUNDED                   =800,          // Customer with a real account refilled
+      CLIENT_STATUS_ACTIVE                   =900,          // A client with a real account with money that made at least one transaction in the last 90 days
+      CLIENT_STATUS_INACTIVE                 =1000,         // A client with a real money account that has not been traded in the past 90 days
+      CLIENT_STATUS_SUSPENDED                =1100,         // Client with a real account, trading on which is suspended at the initiative of the company
+      //--- No longer client
+      CLIENT_STATUS_CLOSED                   =1200,         // Client who had a real account (s) and who closed them on his own initiative
+      CLIENT_STATUS_TERMINATED               =1300,         // The client who had a real account (s), with which the contract was terminated at the initiative of the company
+      //--- enumeration borders
+      CLIENT_STATUS_FIRST                    =CLIENT_STATUS_UNREGISTERED,
+      CLIENT_STATUS_LAST                     =CLIENT_STATUS_TERMINATED
+     };
+   //--- employment status enumeration
+   enum EnEmployment
+     {
+      EMPLOY_UNEMPLOYED                      =0,            // unemployed
+      EMPLOY_EMPLOYED                        =1,            // employed
+      EMPLOY_SELF_EMPLOYED                   =2,            // self employed
+      EMPLOY_RETIRED                         =3,            // retired
+      EMPLOY_STUDENT                         =4,            // student
+      EMPLOY_OTHER                           =5,            // other
+      //--- enumeration borders
+      EMPLOY_FIRST                           =EMPLOY_UNEMPLOYED,
+      EMPLOY_LAST                            =EMPLOY_OTHER
+     };
+   //--- employment industry enumeration
+   enum EnEmploymentIndustry
+     {
+      INDUSTRY_NONE                          =0,            // none
+      INDUSTRY_AGRICULTURE                   =1,            // agriculture
+      INDUSTRY_CONSTRUCTION                  =2,            // construction
+      INDUSTRY_MANAGEMENT                    =3,            // management
+      INDUSTRY_COMMUNICATION                 =4,            // communication
+      INDUSTRY_EDUCATION                     =5,            // education
+      INDUSTRY_GOVERNMENT                    =6,            // government
+      INDUSTRY_HEALTHCARE                    =7,            // healthcare
+      INDUSTRY_TOURISM                       =8,            // tourism
+      INDUSTRY_IT                            =9,            // IT
+      INDUSTRY_SECURITY                      =10,           // security
+      INDUSTRY_MANUFACTURING                 =11,           // manufacturing
+      INDUSTRY_MARKETING                     =12,           // marketing
+      INDUSTRY_SCIENCE                       =13,           // science
+      INDUSTRY_ENGINEERING                   =14,           // engineering
+      INDUSTRY_TRANSPORT                     =15,           // transport
+      INDUSTRY_OTHER                         =16,           // other
+      //--- enumeration borders
+      INDUSTRY_FIRST                         =INDUSTRY_AGRICULTURE,
+      INDUSTRY_LAST                          =INDUSTRY_OTHER
+     };
+   //--- education level enumeration
+   enum EnEducationLevel
+     {
+      EDUCATION_LEVEL_NONE                   =0,            // none
+      EDUCATION_LEVEL_HIGH_SCHOOL            =1,            // high school
+      EDUCATION_LEVEL_BACHELOR               =2,            // bachelor
+      EDUCATION_LEVEL_MASTER                 =3,            // master
+      EDUCATION_LEVEL_PHD                    =4,            // PhD
+      EDUCATION_LEVEL_OTHER                  =5,            // other
+      //--- enumeration borders
+      EDUCATION_LEVEL_FIRST                  =EDUCATION_LEVEL_NONE,
+      EDUCATION_LEVEL_LAST                   =EDUCATION_LEVEL_OTHER
+     };
+   //--- wealth source enumeration
+   enum EnWealthSource
+     {
+      WEALTH_SOURCE_EMPLOYMENT               =0,            // employment
+      WEALTH_SOURCE_SAVINGS                  =1,            // savings
+      WEALTH_SOURCE_INHERITANCE              =2,            // inheritance
+      WEALTH_SOURCE_OTHER                    =3,            // other
+      //--- enumeration borders
+      WEALTH_SOURCE_FIRST                    =WEALTH_SOURCE_EMPLOYMENT,
+      WEALTH_SOURCE_LAST                     =WEALTH_SOURCE_OTHER
+     };
+   //--- preferred communication enumeration
+   enum EnPreferredCommunication
+     {
+      PREFERRED_COMMUNICATION_UNDEFINED      =0,            // undefined
+      PREFERRED_COMMUNICATION_EMAIL          =1,            // email
+      PREFERRED_COMMUNICATION_PHONE          =2,            // phone
+      PREFERRED_COMMUNICATION_PHONE_SMS      =3,            // phone SMS
+      PREFERRED_COMMUNICATION_MESSENGER      =4,            // messenger
+      //--- enumeration borders
+      PREFERRED_COMMUNICATION_FIRST          =PREFERRED_COMMUNICATION_UNDEFINED,
+      PREFERRED_COMMUNICATION_LAST           =PREFERRED_COMMUNICATION_MESSENGER
+     };
+   //--- trading experience enumeration
+   enum EnTradingExperience
+     {
+      EXPERIENCE_LESS_1_YEAR                 =0,            // less than 1 year
+      EXPERIENCE_1_3_YEAR                    =1,            // 1 to 3 years
+      EXPERIENCE_ABOVE_3_YEAR                =2,            // above 3 years
+      //--- enumeration borders
+      EXPERIENCE_FIRST                       =EXPERIENCE_LESS_1_YEAR,
+      EXPERIENCE_LAST                        =EXPERIENCE_ABOVE_3_YEAR
+     };
+
+public:
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTDatasetField *field)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- field id, EnFieldId
+   virtual UINT      Id(void) const=0;
+   virtual MTAPIRES  Id(const UINT id)=0;
+   //--- type, EnFieldType
+   virtual UINT      Type(void) const=0;
+   //--- offset in bytes
+   virtual UINT      Offset(void) const=0;
+   virtual MTAPIRES  Offset(const UINT offset)=0;
+   //--- size in bytes
+   virtual UINT      Size(void) const=0;
+   virtual MTAPIRES  Size(const UINT size)=0;
+   //--- flags, EnFieldFlags
+   virtual UINT64    Flags(void) const=0;
+   virtual MTAPIRES  Flags(const UINT64 flags)=0;
+   //--- reserverd properites methods
+   virtual MTAPIRES  Reserved1(void)=0;
+   virtual MTAPIRES  Reserved2(void)=0;
+   virtual MTAPIRES  Reserved3(void)=0;
+   virtual MTAPIRES  Reserved4(void)=0;
+   //--- add where value(s)
+   virtual MTAPIRES  WhereAddInt(const INT64 value)=0;
+   virtual MTAPIRES  WhereAddIntArray(const INT64 *values,const UINT values_total)=0;
+   virtual MTAPIRES  WhereAddUInt(const UINT64 value)=0;
+   virtual MTAPIRES  WhereAddUIntArray(const UINT64 *values,const UINT values_total)=0;
+   virtual MTAPIRES  WhereAddDouble(const double value)=0;
+   virtual MTAPIRES  WhereAddDoubleArray(const double *values,const UINT values_total)=0;
+   virtual MTAPIRES  WhereAddString(LPCWSTR value)=0;
+   virtual MTAPIRES  WhereAddStringArray(LPCWSTR *values,const UINT values_total)=0;
+   //--- reserverd where methods
+   virtual MTAPIRES  WhereReserved1(void)=0;
+   virtual MTAPIRES  WhereReserved2(void)=0;
+   virtual MTAPIRES  WhereReserved3(void)=0;
+   virtual MTAPIRES  WhereReserved4(void)=0;
+   //--- between values int
+   virtual MTAPIRES  BetweenInt(const INT64 from,const INT64 to)=0;
+   virtual MTAPIRES  BetweenUInt(const UINT64 from,const UINT64 to)=0;
+   virtual MTAPIRES  BetweenDouble(const double from,const double to)=0;
+   //--- reserverd between methods
+   virtual MTAPIRES  BetweenReserved1(void)=0;
+   virtual MTAPIRES  BetweenReserved2(void)=0;
+   virtual MTAPIRES  BetweenReserved3(void)=0;
+   virtual MTAPIRES  BetweenReserved4(void)=0;
+  };
+//+------------------------------------------------------------------+
+//| Report request interface                                         |
+//+------------------------------------------------------------------+
+class IMTDatasetRequest
+  {
+public:
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTDatasetRequest *request)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- reserverd properites methods
+   virtual MTAPIRES  Reserved1(void)=0;
+   virtual MTAPIRES  Reserved2(void)=0;
+   virtual MTAPIRES  Reserved3(void)=0;
+   virtual MTAPIRES  Reserved4(void)=0;
+   //--- fields
+   virtual IMTDatasetField* FieldCreate(void)=0;
+   virtual MTAPIRES  FieldAdd(const IMTDatasetField *field)=0;
+   virtual MTAPIRES  FieldUpdate(const UINT pos,const IMTDatasetField *field)=0;
+   virtual MTAPIRES  FieldDelete(const UINT pos)=0;
+   virtual MTAPIRES  FieldClear(void)=0;
+   virtual MTAPIRES  FieldShift(const UINT pos,const int shift)=0;
+   virtual UINT      FieldTotal(void) const=0;
+   virtual MTAPIRES  FieldNext(const UINT pos,IMTDatasetField *field) const=0;
+   //--- reserverd fields methods
+   virtual MTAPIRES  FieldReserved1(void)=0;
+   virtual MTAPIRES  FieldReserved2(void)=0;
+   virtual MTAPIRES  FieldReserved3(void)=0;
+   virtual MTAPIRES  FieldReserved4(void)=0;
+  };
+//+------------------------------------------------------------------+

+ 282 - 0
MT5SDK/Bases/MT5APIDeal.h

@@ -0,0 +1,282 @@
+//+------------------------------------------------------------------+
+//|                                                 MetaTrader 5 API |
+//|                   Copyright 2000-2019, MetaQuotes Software Corp. |
+//|                                        http://www.metaquotes.net |
+//+------------------------------------------------------------------+
+#pragma once
+#include "MT5APIAccount.h"
+#include "MT5APIPosition.h"
+//+------------------------------------------------------------------+
+//| Trade deal interface                                             |
+//+------------------------------------------------------------------+
+class IMTDeal
+  {
+public:
+   //--- deal types
+   enum EnDealAction
+     {
+      DEAL_BUY                 =0,     // buy
+      DEAL_SELL                =1,     // sell
+      DEAL_BALANCE             =2,     // deposit operation
+      DEAL_CREDIT              =3,     // credit operation
+      DEAL_CHARGE              =4,     // additional charges
+      DEAL_CORRECTION          =5,     // correction deals
+      DEAL_BONUS               =6,     // bonus
+      DEAL_COMMISSION          =7,     // commission
+      DEAL_COMMISSION_DAILY    =8,     // daily commission
+      DEAL_COMMISSION_MONTHLY  =9,     // monthly commission
+      DEAL_AGENT_DAILY         =10,    // daily agent commission
+      DEAL_AGENT_MONTHLY       =11,    // monthly agent commission
+      DEAL_INTERESTRATE        =12,    // interest rate charges
+      DEAL_BUY_CANCELED        =13,    // canceled buy deal
+      DEAL_SELL_CANCELED       =14,    // canceled sell deal
+      DEAL_DIVIDEND            =15,    // dividend
+      DEAL_DIVIDEND_FRANKED    =16,    // franked dividend
+      DEAL_TAX                 =17,    // taxes
+      DEAL_AGENT               =18,    // instant agent commission
+      DEAL_SO_COMPENSATION     =19,    // negative balance compensation after stop-out
+      //--- enumeration borders
+      DEAL_FIRST               =DEAL_BUY,
+      DEAL_LAST                =DEAL_SO_COMPENSATION
+     };
+   //--- deal entry direction
+   enum EnDealEntry
+     {
+      ENTRY_IN                 =0,     // in market
+      ENTRY_OUT                =1,     // out of market
+      ENTRY_INOUT              =2,     // reverse
+      ENTRY_OUT_BY             =3,     // closed by  hedged position
+      //--- enumeration borders
+      ENTRY_FIRST              =ENTRY_IN,
+      ENTRY_LAST               =ENTRY_OUT_BY
+     };
+   //--- deal creation reasons
+   enum EnDealReason
+     {
+      DEAL_REASON_CLIENT       =0,     // deal placed manually
+      DEAL_REASON_EXPERT       =1,     // deal placed by expert
+      DEAL_REASON_DEALER       =2,     // deal placed by dealer
+      DEAL_REASON_SL           =3,     // deal placed due SL
+      DEAL_REASON_TP           =4,     // deal placed due TP
+      DEAL_REASON_SO           =5,     // deal placed due Stop-Out
+      DEAL_REASON_ROLLOVER     =6,     // deal placed due rollover
+      DEAL_REASON_EXTERNAL_CLIENT=7,   // deal placed from the external system by client
+      DEAL_REASON_VMARGIN      =8,     // deal placed due variation margin
+      DEAL_REASON_GATEWAY      =9,     // deal placed by gateway
+      DEAL_REASON_SIGNAL       =10,    // deal placed by signal service
+      DEAL_REASON_SETTLEMENT   =11,    // deal placed due settlement
+      DEAL_REASON_TRANSFER     =12,    // deal placed due position transfer
+      DEAL_REASON_SYNC         =13,    // deal placed due position synchronization
+      DEAL_REASON_EXTERNAL_SERVICE=14, // deal placed from the external system due service issues
+      DEAL_REASON_MIGRATION    =15,    // deal placed due migration
+      DEAL_REASON_MOBILE       =16,    // deal placed manually by mobile terminal
+      DEAL_REASON_WEB          =17,    // deal placed manually by web terminal
+      DEAL_REASON_SPLIT        =18,    // deal placed due split
+      //--- enumeration borders
+      DEAL_REASON_FIRST        =DEAL_REASON_CLIENT,
+      DEAL_REASON_LAST         =DEAL_REASON_SPLIT
+     };
+   //--- modification flags
+   enum EnTradeModifyFlags
+     {
+      MODIFY_FLAGS_ADMIN       =0x00000001,
+      MODIFY_FLAGS_MANAGER     =0x00000002,
+      MODIFY_FLAGS_POSITION    =0x00000004,
+      MODIFY_FLAGS_RESTORE     =0x00000008,
+      MODIFY_FLAGS_API_ADMIN   =0x00000010,
+      MODIFY_FLAGS_API_MANAGER =0x00000020,
+      MODIFY_FLAGS_API_SERVER  =0x00000040,
+      MODIFY_FLAGS_API_GATEWAY =0x00000080,
+      //--- enumeration borders
+      MODIFY_FLAGS_NONE         =0x00000000,
+      MODIFY_FLAGS_ALL          =MODIFY_FLAGS_ADMIN|MODIFY_FLAGS_MANAGER|MODIFY_FLAGS_POSITION|MODIFY_FLAGS_RESTORE|
+      MODIFY_FLAGS_API_ADMIN|MODIFY_FLAGS_API_MANAGER|MODIFY_FLAGS_API_SERVER|MODIFY_FLAGS_API_GATEWAY
+     };
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTDeal* deal)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   virtual LPCWSTR   Print(MTAPISTR& string) const=0;
+   //--- deal ticket
+   virtual UINT64    Deal(void) const=0;
+   //--- deal ticket in external system (exchange, ECN, etc)
+   virtual LPCWSTR   ExternalID(void) const=0;
+   virtual MTAPIRES  ExternalID(LPCWSTR id)=0;
+   //--- client login
+   virtual UINT64    Login(void) const=0;
+   virtual MTAPIRES  Login(const UINT64 login)=0;
+   //--- processed dealer login (0-means auto)
+   virtual UINT64    Dealer(void) const=0;
+   virtual MTAPIRES  Dealer(const UINT64 dealer)=0;
+   //--- deal order ticket
+   virtual UINT64    Order(void) const=0;
+   virtual MTAPIRES  Order(const UINT64 order)=0;
+   //--- EnDealAction
+   virtual UINT      Action(void) const=0;
+   virtual MTAPIRES  Action(const UINT action)=0;
+   //--- EnEntryFlags
+   virtual UINT      Entry(void) const=0;
+   virtual MTAPIRES  Entry(const UINT entry)=0;
+   //--- price digits
+   virtual UINT      Digits(void) const=0;
+   virtual MTAPIRES  Digits(const UINT digits)=0;
+   //--- currency digits
+   virtual UINT      DigitsCurrency(void) const=0;
+   virtual MTAPIRES  DigitsCurrency(const UINT digits)=0;
+   //--- symbol contract size
+   virtual double    ContractSize(void) const=0;
+   virtual MTAPIRES  ContractSize(const double contract_size)=0;
+   //--- deal creation datetime in seconds
+   virtual INT64     Time(void) const=0;
+   virtual MTAPIRES  Time(const INT64 time)=0;
+   //--- deal symbol
+   virtual LPCWSTR   Symbol(void) const=0;
+   virtual MTAPIRES  Symbol(LPCWSTR symbol)=0;
+   //--- deal price
+   virtual double    Price(void) const=0;
+   virtual MTAPIRES  Price(const double price)=0;
+   //--- deal volume
+   virtual UINT64    Volume(void) const=0;
+   virtual MTAPIRES  Volume(const UINT64 volume)=0;
+   //--- deal profit
+   virtual double    Profit(void) const=0;
+   virtual MTAPIRES  Profit(const double profit)=0;
+   //--- deal collected swaps
+   virtual double    Storage(void) const=0;
+   virtual MTAPIRES  Storage(const double storage)=0;
+   //--- deal commission
+   virtual double    Commission(void) const=0;
+   virtual MTAPIRES  Commission(const double comm)=0;
+   //--- obsolete value
+   virtual double    ObsoleteValue(void) const=0;
+   virtual MTAPIRES  ObsoleteValue(const double agent)=0;
+   //--- profit conversion rate (from symbol profit currency to deposit currency)
+   virtual double    RateProfit(void) const=0;
+   virtual MTAPIRES  RateProfit(const double rate)=0;
+   //--- margin conversion rate (from symbol margin currency to deposit currency)
+   virtual double    RateMargin(void) const=0;
+   virtual MTAPIRES  RateMargin(const double rate)=0;
+   //--- expert id (filled by expert advisor)
+   virtual UINT64    ExpertID(void) const=0;
+   virtual MTAPIRES  ExpertID(const UINT64 id)=0;
+   //--- position id
+   virtual UINT64    PositionID(void) const=0;
+   virtual MTAPIRES  PositionID(const UINT64 id)=0;
+   //--- deal comment
+   virtual LPCWSTR   Comment(void) const=0;
+   virtual MTAPIRES  Comment(LPCWSTR comment)=0;
+   //--- deal internal data for API usage
+   virtual MTAPIRES  ApiDataSet(const USHORT app_id,const UCHAR id,const INT64 value)=0;
+   virtual MTAPIRES  ApiDataSet(const USHORT app_id,const UCHAR id,const UINT64 value)=0;
+   virtual MTAPIRES  ApiDataSet(const USHORT app_id,const UCHAR id,const double value)=0;
+   virtual MTAPIRES  ApiDataGet(const USHORT app_id,const UCHAR id,INT64& value) const=0;
+   virtual MTAPIRES  ApiDataGet(const USHORT app_id,const UCHAR id,UINT64& value) const=0;
+   virtual MTAPIRES  ApiDataGet(const USHORT app_id,const UCHAR id,double& value) const=0;
+   virtual MTAPIRES  ApiDataClear(const USHORT app_id)=0;
+   virtual MTAPIRES  ApiDataClearAll(void)=0;
+   //--- deal profit in symbol's profit currency
+   virtual double    ProfitRaw(void) const=0;
+   virtual MTAPIRES  ProfitRaw(const double profit)=0;
+   //--- closed position  price
+   virtual double    PricePosition(void) const=0;
+   virtual MTAPIRES  PricePosition(const double price)=0;
+   //--- closed volume
+   virtual UINT64    VolumeClosed(void) const=0;
+   virtual MTAPIRES  VolumeClosed(const UINT64 volume)=0;
+   //--- tick value
+   virtual double    TickValue(void) const=0;
+   virtual MTAPIRES  TickValue(const double value)=0;
+   //--- tick size
+   virtual double    TickSize(void) const=0;
+   virtual MTAPIRES  TickSize(const double size)=0;
+   //--- flags
+   virtual UINT64    Flags(void) const=0;
+   virtual MTAPIRES  Flags(const UINT64 flags)=0;
+   //--- deal creation datetime in msc since 1970.01.01
+   virtual INT64     TimeMsc(void) const=0;
+   virtual MTAPIRES  TimeMsc(const INT64 time)=0;
+   //--- EnDealReason
+   virtual UINT      Reason(void) const=0;
+   //--- source gateway name
+   virtual LPCWSTR   Gateway(void) const=0;
+   //--- deal price on gateway
+   virtual double    PriceGateway(void) const=0;
+   //--- user record internal data for API usage
+   virtual MTAPIRES  ApiDataUpdate(const UINT pos,const USHORT app_id,const UCHAR id,const INT64 value)=0;
+   virtual MTAPIRES  ApiDataUpdate(const UINT pos,const USHORT app_id,const UCHAR id,const UINT64 value)=0;
+   virtual MTAPIRES  ApiDataUpdate(const UINT pos,const USHORT app_id,const UCHAR id,const double value)=0;
+   virtual MTAPIRES  ApiDataNext(const UINT pos,USHORT& app_id,UCHAR& id,INT64& value) const=0;
+   virtual MTAPIRES  ApiDataNext(const UINT pos,USHORT& app_id,UCHAR& id,UINT64& value) const=0;
+   virtual MTAPIRES  ApiDataNext(const UINT pos,USHORT& app_id,UCHAR& id,double& value) const=0;
+   //--- deal ticket
+   virtual MTAPIRES  DealSet(const UINT64 deal)=0;
+   //--- modification flags
+   virtual UINT      ModificationFlags(void) const=0;
+   //--- EnOrderReason
+   virtual MTAPIRES  ReasonSet(const UINT reason)=0;
+   //--- source gateway name
+   virtual MTAPIRES  GatewaySet(LPCWSTR gateway)=0;
+   //--- deal price on gateway
+   virtual MTAPIRES  PriceGatewaySet(double price_gateway)=0;
+   //--- order SL
+   virtual double    PriceSL(void) const=0;
+   virtual MTAPIRES  PriceSL(const double price)=0;
+   //--- order TP
+   virtual double    PriceTP(void) const=0;
+   virtual MTAPIRES  PriceTP(const double price)=0;
+   //--- deal volume with extended accuracy
+   virtual UINT64    VolumeExt(void) const=0;
+   virtual MTAPIRES  VolumeExt(const UINT64 volume)=0;
+   //--- closed volume with extended accuracy
+   virtual UINT64    VolumeClosedExt(void) const=0;
+   virtual MTAPIRES  VolumeClosedExt(const UINT64 volume)=0;
+  };
+//+------------------------------------------------------------------+
+//| Deal array interface                                             |
+//+------------------------------------------------------------------+
+class IMTDealArray
+  {
+public:
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTDealArray* array)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- add
+   virtual MTAPIRES  Add(IMTDeal* deal)=0;
+   virtual MTAPIRES  AddCopy(const IMTDeal* deal)=0;
+   virtual MTAPIRES  Add(IMTDealArray* array)=0;
+   virtual MTAPIRES  AddCopy(const IMTDealArray* array)=0;
+   //--- delete & detach
+   virtual MTAPIRES  Delete(const UINT pos)=0;
+   virtual IMTDeal*  Detach(const UINT pos)=0;
+   //--- update
+   virtual MTAPIRES  Update(const UINT pos,IMTDeal* deal)=0;
+   virtual MTAPIRES  UpdateCopy(const UINT pos,const IMTDeal* deal)=0;
+   virtual MTAPIRES  Shift(const UINT pos,const int shift)=0;
+   //--- data access
+   virtual UINT      Total(void) const=0;
+   virtual IMTDeal*  Next(const UINT index) const=0;
+   //--- sorting and search
+   virtual MTAPIRES  Sort(MTSortFunctionPtr sort_function)=0;
+   virtual int       Search(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchGreatOrEq(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchGreater(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchLessOrEq(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchLess(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchLeft(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchRight(const void *key,MTSortFunctionPtr sort_function) const=0;
+  };
+//+------------------------------------------------------------------+
+//| Deals events notification interface                              |
+//+------------------------------------------------------------------+
+class IMTDealSink
+  {
+public:
+   virtual void      OnDealAdd(const IMTDeal*    /*deal*/) {  }
+   virtual void      OnDealUpdate(const IMTDeal* /*deal*/) {  }
+   virtual void      OnDealDelete(const IMTDeal* /*deal*/) {  }
+   virtual void      OnDealClean(const UINT64 /*login*/)   {  }
+   virtual void      OnDealSync(void)                      {  }
+   virtual void      OnDealPerform(const IMTDeal* /*deal*/,IMTAccount* /*account*/,IMTPosition* /*position*/) {  }
+  };
+//+------------------------------------------------------------------+

+ 129 - 0
MT5SDK/Bases/MT5APIDocument.h

@@ -0,0 +1,129 @@
+//+------------------------------------------------------------------+
+//|                                                 MetaTrader 5 API |
+//|                   Copyright 2000-2019, MetaQuotes Software Corp. |
+//|                                        http://www.metaquotes.net |
+//+------------------------------------------------------------------+
+#pragma once
+#include "MT5APIAttachment.h"
+//+------------------------------------------------------------------+
+//| Document record interface                                        |
+//+------------------------------------------------------------------+
+class IMTDocument
+  {
+public:
+   //--- document types
+   enum EnDocumentTypes
+     {
+      DOCUMENT_TYPE_OTHER                       =0,      // other
+      //--- ïðîñòûå êëèåíòû
+      DOCUMENT_TYPE_PERSONAL_IDENTITY           =1,      // proof of identity
+      DOCUMENT_TYPE_PERSONAL_ADDRESS            =2,      // proof of address
+      //--- êîìïàíèè
+      DOCUMENT_TYPE_REGISTERED_ADDRESS          =1000,   // registered address
+      DOCUMENT_TYPE_DIRECTORS_PASSPORT          =1001,   // directors passport
+      DOCUMENT_TYPE_CERTIFICATE_OF_INCORPORATION=1002,   // certificate of incorporation
+      DOCUMENT_TYPE_CERTIFICATE_OF_DIRECTORS    =1003,   // certificate of directors
+      DOCUMENT_TYPE_CERTIFICATE_OF_GOOD_STANDING=1004,   // certificate of good standing
+      //--- enumeration borders
+      DOCUMENT_TYPE_FIRST                       =DOCUMENT_TYPE_OTHER,
+      DOCUMENT_TYPE_LAST                        =DOCUMENT_TYPE_CERTIFICATE_OF_GOOD_STANDING
+     };
+   //--- document statuses
+   enum EnDocumentStatus
+     {
+      DOCUMENT_STATUS_NEW                     =0,        // new
+      DOCUMENT_STATUS_APPROVED                =100,      // approved
+      DOCUMENT_STATUS_REJECTED                =200,      // rejected
+      DOCUMENT_STATUS_ARCHIVED                =300,      // archived
+      DOCUMENT_STATUS_DELETED                 =400,      // deleted
+      //--- enumeration borders
+      DOCUMENT_STATUS_FIRST                    =DOCUMENT_STATUS_NEW,
+      DOCUMENT_STATUS_LAST                     =DOCUMENT_STATUS_DELETED,
+     };
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTDocument* document)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- record id
+   virtual UINT64    RecordID(void) const=0;
+   virtual MTAPIRES  RecordID(const UINT64 record_id)=0;
+   //--- related client
+   virtual UINT64    RelatedClient(void) const=0;
+   virtual MTAPIRES  RelatedClient(const UINT64 record_id)=0;
+   //--- approved date
+   virtual INT64     ApprovedDate(void) const=0;
+   virtual MTAPIRES  ApprovedDate(const INT64 date)=0;
+   //--- approved by
+   virtual UINT64    ApprovedBy(void) const=0;
+   virtual MTAPIRES  ApprovedBy(const UINT64 manager)=0;
+   //--- date issue
+   virtual INT64     DateIssue(void) const=0;
+   virtual MTAPIRES  DateIssue(const INT64 date)=0;
+   //--- date expiration
+   virtual INT64     DateExpiration(void) const=0;
+   virtual MTAPIRES  DateExpiration(const INT64 date)=0;
+   //--- document type
+   virtual UINT      DocumentType(void) const=0;
+   virtual MTAPIRES  DocumentType(const UINT type)=0;
+   //--- document name
+   virtual LPCWSTR   DocumentName(void) const=0;
+   virtual MTAPIRES  DocumentName(LPCWSTR name)=0;
+   //--- document comment
+   virtual LPCWSTR   DocumentComment(void) const=0;
+   virtual MTAPIRES  DocumentComment(LPCWSTR comment)=0;
+   //--- document status
+   virtual UINT      DocumentStatus(void) const=0;
+   virtual MTAPIRES  DocumentStatus(const UINT status)=0;
+   //--- attachments
+   virtual MTAPIRES  AttachmentsAdd(const IMTAttachment *attachment)=0;
+   virtual MTAPIRES  AttachmentsClear(void)=0;
+   virtual UINT      AttachmentsTotal(void) const=0;
+   virtual MTAPIRES  AttachmentsNext(const UINT pos,UINT64& attachment_id,MTAPISTR& attachment_name,UINT& attachment_size) const=0;
+  };
+//+------------------------------------------------------------------+
+//| Document array interface                                         |
+//+------------------------------------------------------------------+
+class IMTDocumentArray
+  {
+public:
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTDocumentArray* array)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- add
+   virtual MTAPIRES  Add(IMTDocument* document)=0;
+   virtual MTAPIRES  AddCopy(const IMTDocument* document)=0;
+   virtual MTAPIRES  Add(IMTDocumentArray* array)=0;
+   virtual MTAPIRES  AddCopy(const IMTDocumentArray* array)=0;
+   //--- delete & detach
+   virtual MTAPIRES  Delete(const UINT pos)=0;
+   virtual IMTDocument *Detach(const UINT pos)=0;
+   //--- update
+   virtual MTAPIRES  Update(const UINT pos,IMTDocument* document)=0;
+   virtual MTAPIRES  UpdateCopy(const UINT pos,const IMTDocument* document)=0;
+   virtual MTAPIRES  Shift(const UINT pos,const int shift)=0;
+   //--- data access
+   virtual UINT      Total(void) const=0;
+   virtual IMTDocument*Next(const UINT index) const=0;
+   //--- sorting and search
+   virtual MTAPIRES  Sort(MTSortFunctionPtr sort_function)=0;
+   virtual int       Search(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchGreatOrEq(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchGreater(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchLessOrEq(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchLess(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchLeft(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchRight(const void *key,MTSortFunctionPtr sort_function) const=0;
+  };
+//+------------------------------------------------------------------+
+//| Document records notification interface                          |
+//+------------------------------------------------------------------+
+class IMTDocumentSink
+  {
+public:
+   //--- events
+   virtual void      OnDocumentAdd(const IMTDocument*    /*document*/)           {  }
+   virtual void      OnDocumentUpdate(const IMTDocument* /*document*/)           {  }
+   virtual void      OnDocumentDelete(const IMTDocument* /*document*/)           {  }
+  };
+//+------------------------------------------------------------------+

+ 240 - 0
MT5SDK/Bases/MT5APIExecution.h

@@ -0,0 +1,240 @@
+//+------------------------------------------------------------------+
+//|                                         MetaTrader 5 API Server  |
+//|                   Copyright 2000-2019, MetaQuotes Software Corp. |
+//|                                        http://www.metaquotes.net |
+//+------------------------------------------------------------------+
+#pragma once
+//+------------------------------------------------------------------+
+//| Trade account interface                                          |
+//+------------------------------------------------------------------+
+class IMTExecution
+  {
+public:
+   //--- execution state
+   enum EnTradeExecutions
+     {
+      TE_ORDER_FIRST               =0,
+      //--- order filling
+      TE_ORDER_NEW_REQUEST         =0,
+      TE_ORDER_NEW                 =1,
+      TE_ORDER_FILL                =2,
+      TE_ORDER_REJECT              =3,
+      //--- order modify
+      TE_ORDER_MODIFY_REQUEST      =4,
+      TE_ORDER_MODIFY              =5,
+      TE_ORDER_MODIFY_REJECT       =6,
+      //--- order cancel
+      TE_ORDER_CANCEL_REQUEST      =7,
+      TE_ORDER_CANCEL              =8,
+      TE_ORDER_CANCEL_REJECT       =9,
+      //--- order others
+      TE_ORDER_CHANGE_ID           =10,
+      TE_ORDER_CLOSE_BY            =11,
+      TE_ORDER_LAST                =TE_ORDER_CLOSE_BY,
+      //--- deal modifications
+      TE_DEAL_FIRST                =50,
+      TE_DEAL_CANCEL               =50,
+      TE_DEAL_CORRECT              =51,
+      TE_DEAL_EXTERNAL             =52,
+      TE_DEAL_REPO                 =53,
+      TE_DEAL_COMMISSION           =54,
+      TE_DEAL_LAST                 =TE_DEAL_COMMISSION,
+      //--- end of session executions
+      TE_EOS_FIRST                 =100,
+      TE_EOS_CANCEL_DAILY_ORDERS   =100,
+      TE_EOS_VARIATION_MARGIN      =101,
+      TE_EOS_RECALC_DEALS          =102,
+      TE_EOS_SETTLEMENT            =103,
+      TE_EOS_TRANSFER              =104,
+      TE_EOS_CANCEL_ALL_ORDERS     =105,
+      TE_EOS_ROLLOVER              =106,
+      TE_EOS_LAST                  =TE_EOS_ROLLOVER,
+      //--- balance operations
+      TE_BALANCE_FIRST             =150,
+      TE_BALANCE_CHANGE            =150,
+      TE_BALANCE_CORRECT           =151,
+      TE_BALANCE_UNBLOCK_PROFIT    =152,
+      TE_BALANCE_LAST              =TE_BALANCE_UNBLOCK_PROFIT,
+      //--- position modifications
+      TE_POSITION_FIRST            =200,
+      TE_POSITION_CHANGE_ID        =201,
+      TE_POSITION_LAST             =TE_POSITION_CHANGE_ID,
+      //--- enumeration borders
+      TE_FIRST                     =TE_ORDER_FIRST,
+      TE_LAST                      =TE_POSITION_LAST
+     };
+   //--- execution flags
+   enum EnFlags
+     {
+      TE_FLAG_NONE                 =0x00000000,  // none
+      TE_FLAG_BROADCAST            =0x00000001,  // broadcast execution will be send to all trade servers
+      //--- enumeration borders
+      TE_FLAG_ALL                  =TE_FLAG_BROADCAST
+     };
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTExecution* exec)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   virtual LPCWSTR   Print(MTAPISTR& string) const=0;
+   //--- id
+   virtual UINT64    ID(void) const=0;
+   virtual MTAPIRES  ID(const UINT64 id)=0;
+   //--- execution id in external system (exchange, ECN, etc)
+   virtual LPCWSTR   ExternalID(void) const=0;
+   virtual MTAPIRES  ExternalID(LPCWSTR id)=0;
+   //--- execution action
+   virtual UINT      Action(void) const=0;
+   virtual MTAPIRES  Action(const UINT action)=0;
+   //--- datetime
+   virtual INT64     Datetime(void) const=0;
+   virtual MTAPIRES  Datetime(const INT64 datetime)=0;
+   //--- login
+   virtual UINT64    Login(void) const=0;
+   virtual MTAPIRES  Login(const UINT64 login)=0;
+   //--- group
+   virtual LPCWSTR   Group(void) const=0;
+   virtual MTAPIRES  Group(LPCWSTR group)=0;
+   //--- flags
+   virtual UINT64    Flags(void) const=0;
+   virtual MTAPIRES  Flags(const UINT64 flags)=0;
+   //--- symbol
+   virtual LPCWSTR   Symbol(void) const=0;
+   virtual MTAPIRES  Symbol(LPCWSTR symbol)=0;
+   //--- digits
+   virtual UINT      Digits(void) const=0;
+   //--- comment
+   virtual LPCWSTR   Comment(void) const=0;
+   virtual MTAPIRES  Comment(LPCWSTR comment)=0;
+   //--- MT5 order ticket
+   virtual UINT64    Order(void) const=0;
+   virtual MTAPIRES  Order(const UINT64 order)=0;
+   //--- order ticket in external system (exchange, ECN, etc)
+   virtual LPCWSTR   OrderExternalID(void) const=0;
+   virtual MTAPIRES  OrderExternalID(LPCWSTR id)=0;
+   //--- order type IMTOrder::EnOrderType
+   virtual UINT      OrderType(void) const=0;
+   virtual MTAPIRES  OrderType(const UINT type)=0;
+   //--- order volume
+   virtual UINT64    OrderVolume(void) const=0;
+   virtual MTAPIRES  OrderVolume(const UINT64 volume)=0;
+   //--- order price
+   virtual double    OrderPrice(void) const=0;
+   virtual MTAPIRES  OrderPrice(const double price)=0;
+   //--- order activation flags
+   virtual UINT      OrderActivationFlags(void) const=0;
+   virtual MTAPIRES  OrderActivationFlags(const UINT activation)=0;
+   //--- deal ticket in external system (exchange, ECN, etc)
+   virtual LPCWSTR   DealExternalID(void) const=0;
+   virtual MTAPIRES  DealExternalID(LPCWSTR id)=0;
+   //--- deal action IMTDeal::EnDealAction
+   virtual UINT      DealAction(void) const=0;
+   virtual MTAPIRES  DealAction(const UINT action)=0;
+   //--- deal volume
+   virtual UINT64    DealVolume(void) const=0;
+   virtual MTAPIRES  DealVolume(const UINT64 volume)=0;
+   //--- unfilled order volume
+   virtual UINT64    DealVolumeRemaind(void) const=0;
+   virtual MTAPIRES  DealVolumeRemaind(const UINT64 volume)=0;
+   //--- deal price
+   virtual double    DealPrice(void) const=0;
+   virtual MTAPIRES  DealPrice(const double price)=0;
+   //--- digits set
+   virtual MTAPIRES  Digits(const UINT digits)=0;
+   //--- external system trade account (exchange, ECN, etc)
+   virtual LPCWSTR   ExternalAccount(void) const=0;
+   virtual MTAPIRES  ExternalAccount(LPCWSTR account)=0;
+   //--- order trigger price
+   virtual double    OrderPriceTrigger(void) const=0;
+   virtual MTAPIRES  OrderPriceTrigger(const double price)=0;
+   //--- EnOrderTime
+   virtual UINT      OrderTypeTime(void) const=0;
+   virtual MTAPIRES  OrderTypeTime(const UINT type)=0;
+   //--- order expiration
+   virtual INT64     OrderTimeExpiration(void) const=0;
+   virtual MTAPIRES  OrderTimeExpiration(const INT64 time)=0;
+   //--- EnOrderFilling
+   virtual UINT      OrderTypeFill(void) const=0;
+   virtual MTAPIRES  OrderTypeFill(const UINT type)=0;
+   //--- session start datetime
+   virtual INT64     EOSSessionStart(void) const=0;
+   virtual MTAPIRES  EOSSessionStart(const INT64 start)=0;
+   //--- session end datetime
+   virtual INT64     EOSSessionEnd(void) const=0;
+   virtual MTAPIRES  EOSSessionEnd(const INT64 end)=0;
+   //--- session settlement price
+   virtual double    EOSPriceSettlement(void) const=0;
+   virtual MTAPIRES  EOSPriceSettlement(const double price)=0;
+   //--- profit conversion price
+   virtual double    EOSProfitRateBuy(void) const=0;
+   virtual double    EOSProfitRateSell(void) const=0;
+   virtual MTAPIRES  EOSProfitRate(const double rate_buy,const double rate_sell)=0;
+   //--- tick value
+   virtual double    EOSTickValue(void) const=0;
+   virtual MTAPIRES  EOSTickValue(const double value)=0;
+   //--- order price SL
+   virtual double    OrderPriceSL(void) const=0;
+   virtual MTAPIRES  OrderPriceSL(const double price)=0;
+   //--- order price TP
+   virtual double    OrderPriceTP(void) const=0;
+   virtual MTAPIRES  OrderPriceTP(const double price)=0;
+   //--- execution price on gateway
+   virtual double    PriceGateway(void) const=0;
+   virtual MTAPIRES  PriceGateway(const double price)=0;
+   //--- order activation flags
+   virtual UINT      OrderActivationMode(void) const=0;
+   virtual MTAPIRES  OrderActivationMode(const UINT activation)=0;
+   //--- deal commission
+   virtual double    DealCommission(void) const=0;
+   virtual MTAPIRES  DealCommission(const double comm)=0;
+   //--- datetime in msc since 1970.01.01
+   virtual INT64     DatetimeMsc(void) const=0;
+   virtual MTAPIRES  DatetimeMsc(const INT64 datetime)=0;
+   //--- symbol field new value
+   virtual LPCWSTR   SymbolNew(void) const=0;
+   virtual MTAPIRES  SymbolNew(LPCWSTR symbol)=0;
+   //--- internal data for API usage
+   virtual MTAPIRES  ApiDataUpdate(const UINT pos,const USHORT app_id,const UCHAR id,const INT64 value)=0;
+   virtual MTAPIRES  ApiDataUpdate(const UINT pos,const USHORT app_id,const UCHAR id,const UINT64 value)=0;
+   virtual MTAPIRES  ApiDataUpdate(const UINT pos,const USHORT app_id,const UCHAR id,const double value)=0;
+   virtual MTAPIRES  ApiDataNext(const UINT pos,USHORT& app_id,UCHAR& id,INT64& value) const=0;
+   virtual MTAPIRES  ApiDataNext(const UINT pos,USHORT& app_id,UCHAR& id,UINT64& value) const=0;
+   virtual MTAPIRES  ApiDataNext(const UINT pos,USHORT& app_id,UCHAR& id,double& value) const=0;
+   //--- deal storage
+   virtual double    DealStorage(void) const=0;
+   virtual MTAPIRES  DealStorage(const double storage)=0;
+   //--- rollover values
+   virtual double    EOSRolloverValueLong(void) const=0;
+   virtual double    EOSRolloverValueShort(void) const=0;
+   virtual MTAPIRES  EOSRolloverValue(const double value_long,const double value_short)=0;
+   //--- deal reason
+   virtual UINT      DealReason(void) const=0;
+   virtual MTAPIRES  DealReason(const UINT reason)=0;
+   //--- gateway id
+   virtual UINT64    GatewayID(void) const=0;
+   virtual MTAPIRES  GatewayID(const UINT64 gateway_id)=0;
+   //--- MT5 position ticket
+   virtual UINT64    Position(void) const=0;
+   virtual MTAPIRES  Position(const UINT64 position)=0;
+   //--- MT5 position ticket
+   virtual UINT64    PositionBy(void) const=0;
+   virtual MTAPIRES  PositionBy(const UINT64 position)=0;
+   //--- position ticket in external system (exchange, ECN, etc)
+   virtual LPCWSTR   PositionExternalID(void) const=0;
+   virtual MTAPIRES  PositionExternalID(LPCWSTR id)=0;
+   //--- position ticket in external system (exchange, ECN, etc)
+   virtual LPCWSTR   PositionByExternalID(void) const=0;
+   virtual MTAPIRES  PositionByExternalID(LPCWSTR id)=0;
+   //--- external trade system return code
+   virtual int       ExternalRetcode(void) const=0;
+   virtual MTAPIRES  ExternalRetcode(const int retcode)=0;
+   //--- order volume with extendede accuracy
+   virtual UINT64    OrderVolumeExt(void) const=0;
+   virtual MTAPIRES  OrderVolumeExt(const UINT64 volume)=0;
+   //--- deal volume with extendede accuracy
+   virtual UINT64    DealVolumeExt(void) const=0;
+   virtual MTAPIRES  DealVolumeExt(const UINT64 volume)=0;
+   //--- unfilled order volume with extendede accuracy
+   virtual UINT64    DealVolumeRemaindExt(void) const=0;
+   virtual MTAPIRES  DealVolumeRemaindExt(const UINT64 volume)=0;
+  };
+//+------------------------------------------------------------------+

+ 73 - 0
MT5SDK/Bases/MT5APIExposure.h

@@ -0,0 +1,73 @@
+//+------------------------------------------------------------------+
+//|                                                 MetaTrader 5 API |
+//|                   Copyright 2000-2019, MetaQuotes Software Corp. |
+//|                                        http://www.metaquotes.net |
+//+------------------------------------------------------------------+
+#pragma once
+//+------------------------------------------------------------------+
+//| Exposure interface                                               |
+//+------------------------------------------------------------------+
+class IMTExposure
+  {
+public:
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTExposure* exposure)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- exposure currency or symbol
+   virtual LPCWSTR   Symbol(void) const=0;
+   virtual UINT      Digits(void) const=0;
+   //--- volumes
+   virtual double    VolumeClients(void) const=0;
+   virtual double    VolumeCoverage(void) const=0;
+   //--- conversation rate from symbol volume 
+   //--- to net volume in exposure currency
+   virtual double    PriceRate(void) const=0;
+   //--- net volume in exposure currency
+   virtual double    VolumeNet(void) const=0;
+  };
+//+------------------------------------------------------------------+
+//| Exposure array interface                                         |
+//+------------------------------------------------------------------+
+class IMTExposureArray
+  {
+public:
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTExposureArray* array)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- add
+   virtual MTAPIRES  Add(IMTExposure* exposure)=0;
+   virtual MTAPIRES  AddCopy(const IMTExposure* exposure)=0;
+   virtual MTAPIRES  Add(IMTExposureArray* array)=0;
+   virtual MTAPIRES  AddCopy(const IMTExposureArray* array)=0;
+   //--- delete & detach
+   virtual MTAPIRES  Delete(const UINT pos)=0;
+   virtual IMTExposure* Detach(const UINT pos)=0;
+   //--- update
+   virtual MTAPIRES  Update(const UINT pos,IMTExposure* exposure)=0;
+   virtual MTAPIRES  UpdateCopy(const UINT pos,const IMTExposure* exposure)=0;
+   virtual MTAPIRES  Shift(const UINT pos,const int shift)=0;
+   //--- data access
+   virtual UINT      Total(void) const=0;
+   virtual IMTExposure* Next(const UINT index) const=0;
+   //--- sorting and search
+   virtual MTAPIRES  Sort(MTSortFunctionPtr sort_function)=0;
+   virtual int       Search(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchGreatOrEq(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchGreater(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchLessOrEq(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchLess(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchLeft(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchRight(const void *key,MTSortFunctionPtr sort_function) const=0;
+  };
+//+------------------------------------------------------------------+
+//| Exposure events notification interface                           |
+//+------------------------------------------------------------------+
+class IMTExposureSink
+  {
+public:
+   virtual void      OnExposureUpdate(const IMTExposure* /*exposure*/) { }
+  };
+//+------------------------------------------------------------------+
+  

+ 76 - 0
MT5SDK/Bases/MT5APIMail.h

@@ -0,0 +1,76 @@
+//+------------------------------------------------------------------+
+//|                                         MetaTrader 5 API Server  |
+//|                   Copyright 2000-2019, MetaQuotes Software Corp. |
+//|                                        http://www.metaquotes.net |
+//+------------------------------------------------------------------+
+#pragma once
+//+------------------------------------------------------------------+
+//| Mail recipients range                                            |
+//+------------------------------------------------------------------+
+#pragma pack(push,1)
+struct MTMailRange
+  {
+   UINT64            first_login;
+   UINT64            last_login;
+   UINT              reserved[4];
+  };
+#pragma pack(pop)
+//+------------------------------------------------------------------+
+//| Mail Message interface                                           |
+//+------------------------------------------------------------------+
+class IMTMail
+  {
+public:
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTMail* mail)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- mail ID and parent mail ID
+   virtual UINT64    ID(void) const=0;
+   virtual UINT64    Parent(void) const=0;
+   //--- subject
+   virtual LPCWSTR   Subject(void) const=0;
+   virtual MTAPIRES  Subject(LPCWSTR subject)=0;
+   //--- from ID
+   virtual UINT64    From(void) const=0;
+   virtual MTAPIRES  From(const UINT64 id)=0;
+   //--- from name
+   virtual LPCWSTR   FromName(void) const=0;
+   virtual MTAPIRES  FromName(LPCWSTR name)=0;
+   //--- to ID
+   virtual UINT64    To(void) const=0;
+   virtual MTAPIRES  To(const UINT64 id)=0;
+   //--- to name
+   virtual LPCWSTR   ToName(void) const=0;
+   virtual MTAPIRES  ToName(LPCWSTR name)=0;
+   //--- to ID ranges
+   virtual MTAPIRES  ToRangesAdd(MTMailRange& range)=0;
+   virtual MTAPIRES  ToRangesDelete(const UINT pos)=0;
+   virtual MTAPIRES  ToRangesClear(void)=0;
+   virtual UINT      ToRangesTotal(void) const=0;
+   virtual MTAPIRES  ToRangesNext(const UINT pos,MTMailRange& range) const=0;
+   //--- time
+   virtual INT64     Time(void) const=0;
+   //--- body
+   virtual LPCVOID   Body(void) const=0;
+   virtual UINT      BodySize(void) const=0;
+   virtual MTAPIRES  Body(LPCVOID body,const UINT body_size)=0;
+   //--- attachments
+   virtual MTAPIRES  AttachmentsAdd(LPCWSTR filename,LPCVOID attachment,const UINT attachment_size)=0;
+   virtual MTAPIRES  AttachmentsClear(void)=0;
+   virtual UINT      AttachmentsTotal(void) const=0;
+   virtual LPVOID    AttachmentsBody(const UINT pos) const=0;
+   virtual UINT      AttachmentsSize(const UINT pos) const=0;
+   virtual LPCWSTR   AttachmentsName(const UINT pos) const=0;
+  };
+//+------------------------------------------------------------------+
+//| Mail events notification interface                               |
+//+------------------------------------------------------------------+
+class IMTMailSink
+  {
+public:
+   virtual void      OnMail(const IMTMail* /*mail*/) {                    };
+   virtual MTAPIRES  HookMail(IMTMail* /*mail*/)     { return(MT_RET_OK); }
+  };
+//+------------------------------------------------------------------+
+

+ 63 - 0
MT5SDK/Bases/MT5APINews.h

@@ -0,0 +1,63 @@
+//+------------------------------------------------------------------+
+//|                                         MetaTrader 5 API Server  |
+//|                   Copyright 2000-2019, MetaQuotes Software Corp. |
+//|                                        http://www.metaquotes.net |
+//+------------------------------------------------------------------+
+#pragma once
+//+------------------------------------------------------------------+
+//| News Message interface                                           |
+//+------------------------------------------------------------------+
+class IMTNews
+  {
+public:
+   //--- news flags
+   enum EnNewsFlags
+     {
+      NEWS_FLAGS_NONE      =0x0000,
+      NEWS_FLAGS_PRIORITY  =0x0001,
+      NEWS_FLAGS_READ      =0x0002,
+      NEWS_FLAGS_NOBODY    =0x0004,
+      NEWS_FLAGS_CALENDAR  =0x0008,
+      //--- enumeration borders
+      NEWS_FLAGS_FIRST        =NEWS_FLAGS_PRIORITY,
+      NEWS_FLAGS_ALL          =NEWS_FLAGS_PRIORITY|NEWS_FLAGS_READ|NEWS_FLAGS_NOBODY|NEWS_FLAGS_CALENDAR
+     };
+
+public:
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTNews* news)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- news ID
+   virtual UINT64    ID(void) const=0;
+   //--- subject
+   virtual LPCWSTR   Subject(void) const=0;
+   virtual MTAPIRES  Subject(LPCWSTR subject)=0;
+   //--- category
+   virtual LPCWSTR   Category(void) const=0;
+   virtual MTAPIRES  Category(LPCWSTR category)=0;
+   //--- time
+   virtual INT64     Time(void) const=0;
+   virtual MTAPIRES  Time(const INT64 datetime)=0;
+   //--- language
+   virtual UINT      Language(void) const=0;
+   virtual MTAPIRES  Language(const UINT language)=0;
+   //--- language
+   virtual UINT      Flags(void) const=0;
+   virtual MTAPIRES  Flags(const UINT flags)=0;
+   //--- body
+   virtual LPCVOID   Body(void) const=0;
+   virtual UINT      BodySize(void) const=0;
+   virtual MTAPIRES  Body(LPCVOID body,const UINT body_size)=0;
+  };
+//+------------------------------------------------------------------+
+//| News events notification interface                               |
+//+------------------------------------------------------------------+
+class IMTNewsSink
+  {
+public:
+   virtual void      OnNews(const IMTNews* /*news*/)                  {                    };
+   virtual MTAPIRES  HookNews(const int /*feeder*/,IMTNews* /*news*/) { return(MT_RET_OK); }
+  };
+//+------------------------------------------------------------------+
+

+ 67 - 0
MT5SDK/Bases/MT5APIOnline.h

@@ -0,0 +1,67 @@
+//+------------------------------------------------------------------+
+//|                                         MetaTrader 5 API Server  |
+//|                   Copyright 2000-2019, MetaQuotes Software Corp. |
+//|                                        http://www.metaquotes.net |
+//+------------------------------------------------------------------+
+#pragma once
+//+------------------------------------------------------------------+
+//| Online connection interface                                      |
+//+------------------------------------------------------------------+
+class IMTOnline
+  {
+public:
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTOnline* online)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- unique session id
+   virtual UINT64    SessionID(void) const=0;
+   //--- client login
+   virtual UINT64    Login(void) const=0;
+   //--- client group
+   virtual LPCWSTR   Group(void) const=0;
+   //--- client ip
+   virtual LPCWSTR   Address(MTAPISTR& ip) const=0;
+   //--- client terminal type from IMTUser::EnUsersConnectionTypes
+   virtual UINT      Type(void) const=0;
+   //--- client terminal build
+   virtual UINT      Build(void) const=0;
+   //--- connection time
+   virtual INT64     Time(void) const=0;
+  };
+//+------------------------------------------------------------------+
+//| Account array interface                                          |
+//+------------------------------------------------------------------+
+class IMTOnlineArray
+  {
+public:
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTOnlineArray* array)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- add
+   virtual MTAPIRES  Add(IMTOnline* online)=0;
+   virtual MTAPIRES  AddCopy(const IMTOnline* online)=0;
+   virtual MTAPIRES  Add(IMTOnlineArray* array)=0;
+   virtual MTAPIRES  AddCopy(const IMTOnlineArray* array)=0;
+   //--- delete & detach
+   virtual MTAPIRES  Delete(const UINT pos)=0;
+   virtual IMTOnline* Detach(const UINT pos)=0;
+   //--- update
+   virtual MTAPIRES  Update(const UINT pos,IMTOnline* online)=0;
+   virtual MTAPIRES  UpdateCopy(const UINT pos,const IMTOnline* online)=0;
+   virtual MTAPIRES  Shift(const UINT pos,const int shift)=0;
+   //--- data access
+   virtual UINT      Total(void) const=0;
+   virtual IMTOnline* Next(const UINT index) const=0;
+   //--- sorting and search
+   virtual MTAPIRES  Sort(MTSortFunctionPtr sort_function)=0;
+   virtual int       Search(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchGreatOrEq(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchGreater(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchLessOrEq(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchLess(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchLeft(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchRight(const void *key,MTSortFunctionPtr sort_function) const=0;
+  };
+//+------------------------------------------------------------------+

+ 328 - 0
MT5SDK/Bases/MT5APIOrder.h

@@ -0,0 +1,328 @@
+//+------------------------------------------------------------------+
+//|                                                 MetaTrader 5 API |
+//|                   Copyright 2000-2019, MetaQuotes Software Corp. |
+//|                                        http://www.metaquotes.net |
+//+------------------------------------------------------------------+
+#pragma once
+//+------------------------------------------------------------------+
+//| Trade Order Interface                                            |
+//+------------------------------------------------------------------+
+class IMTOrder
+  {
+public:
+   //--- order types
+   enum EnOrderType
+     {
+      OP_BUY                   =0,     // buy order
+      OP_SELL                  =1,     // sell order
+      OP_BUY_LIMIT             =2,     // buy limit order
+      OP_SELL_LIMIT            =3,     // sell limit order
+      OP_BUY_STOP              =4,     // buy stop order
+      OP_SELL_STOP             =5,     // sell stop order
+      OP_BUY_STOP_LIMIT        =6,     // buy stop limit order
+      OP_SELL_STOP_LIMIT       =7,     // sell stop limit order
+      OP_CLOSE_BY              =8,     // close by
+      //--- enumeration borders
+      OP_FIRST                 =OP_BUY,
+      OP_LAST                  =OP_CLOSE_BY
+     };
+   //--- order filling types
+   enum EnOrderFilling
+     {
+      ORDER_FILL_FOK           =0,     // fill or kill
+      ORDER_FILL_IOC           =1,     // immediate or cancel
+      ORDER_FILL_RETURN        =2,     // return order in queue
+      //--- enumeration borders
+      ORDER_FILL_FIRST         =ORDER_FILL_FOK,
+      ORDER_FILL_LAST          =ORDER_FILL_RETURN
+     };
+   //--- order expiration types
+   enum EnOrderTime
+     {
+      ORDER_TIME_GTC           =0,     // good till cancel
+      ORDER_TIME_DAY           =1,     // good till day
+      ORDER_TIME_SPECIFIED     =2,     // good till specified
+      ORDER_TIME_SPECIFIED_DAY =3,     // good till specified day
+      //--- enumeration borders
+      ORDER_TIME_FIRST         =ORDER_TIME_GTC,
+      ORDER_TIME_LAST          =ORDER_TIME_SPECIFIED_DAY
+     };
+   //--- order state
+   enum EnOrderState
+     {
+      ORDER_STATE_STARTED      =0,     // order started
+      ORDER_STATE_PLACED       =1,     // order placed in system
+      ORDER_STATE_CANCELED     =2,     // order canceled by client
+      ORDER_STATE_PARTIAL      =3,     // order partially filled
+      ORDER_STATE_FILLED       =4,     // order filled
+      ORDER_STATE_REJECTED     =5,     // order rejected
+      ORDER_STATE_EXPIRED      =6,     // order expired
+      ORDER_STATE_REQUEST_ADD  =7,     // order requested to add
+      ORDER_STATE_REQUEST_MODIFY=8,    // order requested to modify
+      ORDER_STATE_REQUEST_CANCEL=9,    // order requested to cancel
+      //--- enumeration borders
+      ORDER_STATE_FIRST        =ORDER_STATE_STARTED,
+      ORDER_STATE_LAST         =ORDER_STATE_REQUEST_CANCEL
+     };
+   //--- order activation state
+   enum EnOrderActivation
+     {
+      ACTIVATION_NONE          =0,     // none
+      ACTIVATION_PENDING       =1,     // pending order activated
+      ACTIVATION_STOPLIMIT     =2,     // stop-limit order activated
+      ACTIVATION_EXPIRATION    =3,     // order expired
+      ACTIVATION_STOPOUT       =4,     // order activate for stop-out
+      //--- enumeration borders
+      ACTIVATION_FIRST         =ACTIVATION_NONE,
+      ACTIVATION_LAST          =ACTIVATION_STOPOUT
+     };
+   //--- order creation reasons
+   enum EnOrderReason
+     {
+      ORDER_REASON_CLIENT      =0,     // order placed manually
+      ORDER_REASON_EXPERT      =1,     // order placed by expert
+      ORDER_REASON_DEALER      =2,     // order placed by dealer
+      ORDER_REASON_SL          =3,     // order placed due SL
+      ORDER_REASON_TP          =4,     // order placed due TP
+      ORDER_REASON_SO          =5,     // order placed due Stop-Out
+      ORDER_REASON_ROLLOVER    =6,     // order placed due rollover
+      ORDER_REASON_EXTERNAL_CLIENT =7, // order placed from the external system by client
+      ORDER_REASON_VMARGIN     =8,     // order placed due variation margin
+      ORDER_REASON_GATEWAY     =9,     // order placed by gateway
+      ORDER_REASON_SIGNAL      =10,    // order placed by signal service
+      ORDER_REASON_SETTLEMENT  =11,    // order placed by settlement
+      ORDER_REASON_TRANSFER    =12,    // order placed due transfer
+      ORDER_REASON_SYNC        =13,    // order placed due synchronization
+      ORDER_REASON_EXTERNAL_SERVICE=14,// order placed from the external system due service issues
+      ORDER_REASON_MIGRATION   =15,    // order placed due account migration from MetaTrader 4 or MetaTrader 5
+      ORDER_REASON_MOBILE      =16,    // order placed manually by mobile terminal
+      ORDER_REASON_WEB         =17,    // order placed manually by web terminal
+      ORDER_REASON_SPLIT       =18,    // order placed due split
+      //--- enumeration borders
+      ORDER_REASON_FIRST        =ORDER_REASON_CLIENT,
+      ORDER_REASON_LAST         =ORDER_REASON_SPLIT
+     };
+   //--- order activation flags
+   enum EnTradeActivationFlags
+     {
+      ACTIV_FLAGS_NO_LIMIT     =0x00000001,
+      ACTIV_FLAGS_NO_STOP      =0x00000002,
+      ACTIV_FLAGS_NO_SLIMIT    =0x00000004,
+      ACTIV_FLAGS_NO_SL        =0x00000008,
+      ACTIV_FLAGS_NO_TP        =0x00000010,
+      ACTIV_FLAGS_NO_SO        =0x00000020,
+      ACTIV_FLAGS_NO_EXPIRATION=0x00000040,
+      //--- enumeration borders
+      ACTIV_FLAGS_NONE         =0x00000000,
+      ACTIV_FLAGS_ALL          =ACTIV_FLAGS_NO_LIMIT|ACTIV_FLAGS_NO_STOP|ACTIV_FLAGS_NO_SLIMIT|ACTIV_FLAGS_NO_SL|
+      ACTIV_FLAGS_NO_TP|ACTIV_FLAGS_NO_SO|ACTIV_FLAGS_NO_EXPIRATION
+     };
+   //--- modification flags
+   enum EnTradeModifyFlags
+     {
+      MODIFY_FLAGS_ADMIN       =0x00000001,
+      MODIFY_FLAGS_MANAGER     =0x00000002,
+      MODIFY_FLAGS_POSITION    =0x00000004,
+      MODIFY_FLAGS_RESTORE     =0x00000008,
+      MODIFY_FLAGS_API_ADMIN   =0x00000010,
+      MODIFY_FLAGS_API_MANAGER =0x00000020,
+      MODIFY_FLAGS_API_SERVER  =0x00000040,
+      MODIFY_FLAGS_API_GATEWAY =0x00000080,
+      //--- enumeration borders
+      MODIFY_FLAGS_NONE        =0x00000000,
+      MODIFY_FLAGS_ALL         =MODIFY_FLAGS_ADMIN|MODIFY_FLAGS_MANAGER|MODIFY_FLAGS_POSITION|MODIFY_FLAGS_RESTORE|
+      MODIFY_FLAGS_API_ADMIN|MODIFY_FLAGS_API_MANAGER|MODIFY_FLAGS_API_SERVER|MODIFY_FLAGS_API_GATEWAY
+     };
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTOrder* order)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   virtual LPCWSTR   Print(MTAPISTR& string) const=0;
+   //--- order ticket
+   virtual UINT64    Order(void) const=0;
+   //--- order ticket in external system (exchange, ECN, etc)
+   virtual LPCWSTR   ExternalID(void) const=0;
+   virtual MTAPIRES  ExternalID(LPCWSTR id)=0;
+   //--- client login
+   virtual UINT64    Login(void) const=0;
+   virtual MTAPIRES  Login(const UINT64 order)=0;
+   //--- processed dealer login (0-means auto)
+   virtual UINT64    Dealer(void) const=0;
+   virtual MTAPIRES  Dealer(const UINT64 dealer)=0;
+   //--- order symbol
+   virtual LPCWSTR   Symbol(void) const=0;
+   virtual MTAPIRES  Symbol(LPCWSTR symbol)=0;
+   //--- price digits
+   virtual UINT      Digits(void) const=0;
+   virtual MTAPIRES  Digits(const UINT digits)=0;
+   //--- currency digits
+   virtual UINT      DigitsCurrency(void) const=0;
+   virtual MTAPIRES  DigitsCurrency(const UINT digits)=0;
+   //--- contract size
+   virtual double    ContractSize(void) const=0;
+   virtual MTAPIRES  ContractSize(const double contract_size)=0;
+   //--- EnOrderState
+   virtual UINT      State(void) const=0;
+   //--- EnOrderReason
+   virtual UINT      Reason(void) const=0;
+   //--- order setup time
+   virtual INT64     TimeSetup(void) const=0;
+   virtual MTAPIRES  TimeSetup(const INT64 time)=0;
+   //--- order expiration
+   virtual INT64     TimeExpiration(void) const=0;
+   virtual MTAPIRES  TimeExpiration(const INT64 time)=0;
+   //--- order filling/cancel time
+   virtual INT64     TimeDone(void) const=0;
+   virtual MTAPIRES  TimeDone(const INT64 time)=0;
+   //--- EnOrderType
+   virtual UINT      Type(void) const=0;
+   virtual MTAPIRES  Type(const UINT type)=0;
+   //--- EnOrderFilling
+   virtual UINT      TypeFill(void) const=0;
+   virtual MTAPIRES  TypeFill(const UINT type)=0;
+   //--- EnOrderTime
+   virtual UINT      TypeTime(void) const=0;
+   virtual MTAPIRES  TypeTime(const UINT type)=0;
+   //--- order price
+   virtual double    PriceOrder(void) const=0;
+   virtual MTAPIRES  PriceOrder(const double price)=0;
+   //--- order trigger price (stop-limit price)
+   virtual double    PriceTrigger(void) const=0;
+   virtual MTAPIRES  PriceTrigger(const double price)=0;
+   //--- order current price
+   virtual double    PriceCurrent(void) const=0;
+   virtual MTAPIRES  PriceCurrent(const double price)=0;
+   //--- order SL
+   virtual double    PriceSL(void) const=0;
+   virtual MTAPIRES  PriceSL(const double price)=0;
+   //--- order TP
+   virtual double    PriceTP(void) const=0;
+   virtual MTAPIRES  PriceTP(const double price)=0;
+   //--- order initial volume
+   virtual UINT64    VolumeInitial(void) const=0;
+   virtual MTAPIRES  VolumeInitial(const UINT64 volume)=0;
+   //--- order current volume
+   virtual UINT64    VolumeCurrent(void) const=0;
+   virtual MTAPIRES  VolumeCurrent(const UINT64 volume)=0;
+   //--- expert id (filled by expert advisor)
+   virtual UINT64    ExpertID(void) const=0;
+   virtual MTAPIRES  ExpertID(const UINT64 id)=0;
+   //--- position id
+   virtual UINT64    PositionID(void) const=0;
+   virtual MTAPIRES  PositionID(const UINT64 id)=0;
+   //--- order comment
+   virtual LPCWSTR   Comment(void) const=0;
+   virtual MTAPIRES  Comment(LPCWSTR comment)=0;
+   //--- order activation state, time and price
+   virtual UINT      ActivationMode(void) const=0;
+   virtual INT64     ActivationTime(void) const=0;
+   virtual double    ActivationPrice(void) const=0;
+   virtual UINT      ActivationFlags(void) const=0;
+   //--- order internal data for API usage
+   virtual MTAPIRES  ApiDataSet(const USHORT app_id,const UCHAR id,const INT64 value)=0;
+   virtual MTAPIRES  ApiDataSet(const USHORT app_id,const UCHAR id,const UINT64 value)=0;
+   virtual MTAPIRES  ApiDataSet(const USHORT app_id,const UCHAR id,const double value)=0;
+   virtual MTAPIRES  ApiDataGet(const USHORT app_id,const UCHAR id,INT64& value) const=0;
+   virtual MTAPIRES  ApiDataGet(const USHORT app_id,const UCHAR id,UINT64& value) const=0;
+   virtual MTAPIRES  ApiDataGet(const USHORT app_id,const UCHAR id,double& value) const=0;
+   virtual MTAPIRES  ApiDataClear(const USHORT app_id)=0;
+   virtual MTAPIRES  ApiDataClearAll(void)=0;
+   //--- order setup time in msc since 1970.01.01
+   virtual INT64     TimeSetupMsc(void) const=0;
+   virtual MTAPIRES  TimeSetupMsc(const INT64 time)=0;
+   //--- order setup time in msc since 1970.01.01
+   virtual INT64     TimeDoneMsc(void) const=0;
+   virtual MTAPIRES  TimeDoneMsc(const INT64 time)=0;
+   //--- order activation state, time and price
+   virtual MTAPIRES  ActivationMode(const UINT mode)=0;
+   virtual MTAPIRES  ActivationTime(const INT64 atm)=0;
+   virtual MTAPIRES  ActivationPrice(const double price)=0;
+   virtual MTAPIRES  ActivationFlags(const UINT flags)=0;
+   //--- margin conversion rate (from symbol margin currency to deposit currency)
+   virtual double    RateMargin(void) const=0;
+   virtual MTAPIRES  RateMargin(const double rate)=0;
+   //--- user record internal data for API usage
+   virtual MTAPIRES  ApiDataUpdate(const UINT pos,const USHORT app_id,const UCHAR id,const INT64 value)=0;
+   virtual MTAPIRES  ApiDataUpdate(const UINT pos,const USHORT app_id,const UCHAR id,const UINT64 value)=0;
+   virtual MTAPIRES  ApiDataUpdate(const UINT pos,const USHORT app_id,const UCHAR id,const double value)=0;
+   virtual MTAPIRES  ApiDataNext(const UINT pos,USHORT& app_id,UCHAR& id,INT64& value) const=0;
+   virtual MTAPIRES  ApiDataNext(const UINT pos,USHORT& app_id,UCHAR& id,UINT64& value) const=0;
+   virtual MTAPIRES  ApiDataNext(const UINT pos,USHORT& app_id,UCHAR& id,double& value) const=0;
+   //--- order ticket
+   virtual MTAPIRES  OrderSet(const UINT64 order)=0;
+   //--- position by id
+   virtual UINT64    PositionByID(void) const=0;
+   virtual MTAPIRES  PositionByID(const UINT64 id)=0;
+   //--- modification flags
+   virtual UINT      ModificationFlags(void) const=0;
+   //--- EnOrderState
+   virtual MTAPIRES  StateSet(const UINT state)=0;
+   //--- EnOrderReason
+   virtual MTAPIRES  ReasonSet(const UINT reason)=0;
+   //--- order initial volume with extended accuracy
+   virtual UINT64    VolumeInitialExt(void) const=0;
+   virtual MTAPIRES  VolumeInitialExt(const UINT64 volume)=0;
+   //--- order current volume with extended accuracy
+   virtual UINT64    VolumeCurrentExt(void) const=0;
+   virtual MTAPIRES  VolumeCurrentExt(const UINT64 volume)=0;
+  };
+//+------------------------------------------------------------------+
+//| Order array interface                                            |
+//+------------------------------------------------------------------+
+class IMTOrderArray
+  {
+public:
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTOrderArray* array)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- add
+   virtual MTAPIRES  Add(IMTOrder* order)=0;
+   virtual MTAPIRES  AddCopy(const IMTOrder* order)=0;
+   virtual MTAPIRES  Add(IMTOrderArray* array)=0;
+   virtual MTAPIRES  AddCopy(const IMTOrderArray* array)=0;
+   //--- delete & detach
+   virtual MTAPIRES  Delete(const UINT pos)=0;
+   virtual IMTOrder* Detach(const UINT pos)=0;
+   //--- update
+   virtual MTAPIRES  Update(const UINT pos,IMTOrder* order)=0;
+   virtual MTAPIRES  UpdateCopy(const UINT pos,const IMTOrder* order)=0;
+   virtual MTAPIRES  Shift(const UINT pos,const int shift)=0;
+   //--- data access
+   virtual UINT      Total(void) const=0;
+   virtual IMTOrder* Next(const UINT index) const=0;
+   //--- sorting and search
+   virtual MTAPIRES  Sort(MTSortFunctionPtr sort_function)=0;
+   virtual int       Search(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchGreatOrEq(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchGreater(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchLessOrEq(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchLess(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchLeft(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchRight(const void *key,MTSortFunctionPtr sort_function) const=0;
+  };
+//+------------------------------------------------------------------+
+//| Open orders events notification interface                        |
+//+------------------------------------------------------------------+
+class IMTOrderSink
+  {
+public:
+   virtual void      OnOrderAdd(const IMTOrder*    /*order*/)       {  }
+   virtual void      OnOrderUpdate(const IMTOrder* /*order*/)       {  }
+   virtual void      OnOrderDelete(const IMTOrder* /*order*/)       {  }
+   virtual void      OnOrderClean(const UINT64 /*login*/)           {  }
+   virtual void      OnOrderSync(void)                              {  }
+  };
+//+------------------------------------------------------------------+
+//| History orders                                                   |
+//+------------------------------------------------------------------+
+class IMTHistorySink
+  {
+public:
+   virtual void      OnHistoryAdd(const IMTOrder*    /*order*/)     {  }
+   virtual void      OnHistoryUpdate(const IMTOrder* /*order*/)     {  }
+   virtual void      OnHistoryDelete(const IMTOrder* /*order*/)     {  }
+   virtual void      OnHistoryClean(const UINT64 /*login*/)         {  }
+   virtual void      OnHistorySync(void)                            {  }
+  };
+//+------------------------------------------------------------------+

+ 256 - 0
MT5SDK/Bases/MT5APIPosition.h

@@ -0,0 +1,256 @@
+//+------------------------------------------------------------------+
+//|                                                 MetaTrader 5 API |
+//|                   Copyright 2000-2019, MetaQuotes Software Corp. |
+//|                                        http://www.metaquotes.net |
+//+------------------------------------------------------------------+
+#pragma once
+//+------------------------------------------------------------------+
+//| Trade position interface                                         |
+//+------------------------------------------------------------------+
+class IMTPosition
+  {
+public:
+   //--- position types
+   enum EnPositionAction
+     {
+      POSITION_BUY             =0,     // buy
+      POSITION_SELL            =1,     // sell
+      //--- enumeration borders
+      POSITION_FIRST           =POSITION_BUY,
+      POSITION_LAST            =POSITION_SELL
+     };
+   //--- activation modes
+   enum EnActivation
+     {
+      ACTIVATION_NONE          =0,     // none
+      ACTIVATION_SL            =1,     // SL activated
+      ACTIVATION_TP            =2,     // TP activated
+      ACTIVATION_STOPOUT       =3,     // Stop-Out activated
+      //--- enumeration borders
+      ACTIVATION_FIRST  =ACTIVATION_NONE,
+      ACTIVATION_LAST   =ACTIVATION_STOPOUT,
+     };
+   //--- position activation flags
+   enum EnTradeActivationFlags
+     {
+      ACTIV_FLAGS_NO_LIMIT     =0x00000001,
+      ACTIV_FLAGS_NO_STOP      =0x00000002,
+      ACTIV_FLAGS_NO_SLIMIT    =0x00000004,
+      ACTIV_FLAGS_NO_SL        =0x00000008,
+      ACTIV_FLAGS_NO_TP        =0x00000010,
+      ACTIV_FLAGS_NO_SO        =0x00000020,
+      ACTIV_FLAGS_NO_EXPIRATION=0x00000040,
+      //--- 
+      ACTIV_FLAGS_NONE         =0x00000000,
+      ACTIV_FLAGS_ALL          =ACTIV_FLAGS_NO_LIMIT|ACTIV_FLAGS_NO_STOP|ACTIV_FLAGS_NO_SLIMIT|ACTIV_FLAGS_NO_SL|
+      ACTIV_FLAGS_NO_TP|ACTIV_FLAGS_NO_SO|ACTIV_FLAGS_NO_EXPIRATION
+     };
+   //--- position creation reasons
+   enum EnPositionReason
+     {
+      POSITION_REASON_CLIENT   =0,     // position placed manually
+      POSITION_REASON_EXPERT   =1,     // position placed by expert
+      POSITION_REASON_DEALER   =2,     // position placed by dealer
+      POSITION_REASON_SL       =3,     // position placed due SL
+      POSITION_REASON_TP       =4,     // position placed due TP
+      POSITION_REASON_SO       =5,     // position placed due Stop-Out
+      POSITION_REASON_ROLLOVER =6,     // position placed due rollover
+      POSITION_REASON_EXTERNAL_CLIENT=7,  // position placed from the external system by client
+      POSITION_REASON_VMARGIN  =8,     // position placed due variation margin
+      POSITION_REASON_GATEWAY  =9,     // position placed by gateway
+      POSITION_REASON_SIGNAL   =10,    // position placed by signal service
+      POSITION_REASON_SETTLEMENT=11,   // position placed due settlement
+      POSITION_REASON_TRANSFER =12,    // position placed due position transfer
+      POSITION_REASON_SYNC     =13,    // position placed due position synchronization
+      POSITION_REASON_EXTERNAL_SERVICE=14, // position placed from the external system due service issues
+      POSITION_REASON_MIGRATION=15,    // position placed due migration
+      POSITION_REASON_MOBILE   =16,    // position placed by mobile terminal
+      POSITION_REASON_WEB      =17,    // position placed by web terminal
+      POSITION_REASON_SPLIT    =18,    // position placed due split
+      //--- enumeration borders
+      POSITION_REASON_FIRST    =POSITION_REASON_CLIENT,
+      POSITION_REASON_LAST     =POSITION_REASON_SPLIT
+     };
+   //--- modification flags
+   enum EnTradeModifyFlags
+     {
+      MODIFY_FLAGS_ADMIN       =0x00000001,
+      MODIFY_FLAGS_MANAGER     =0x00000002,
+      MODIFY_FLAGS_POSITION    =0x00000004,
+      MODIFY_FLAGS_RESTORE     =0x00000008,
+      MODIFY_FLAGS_API_ADMIN   =0x00000010,
+      MODIFY_FLAGS_API_MANAGER =0x00000020,
+      MODIFY_FLAGS_API_SERVER  =0x00000040,
+      MODIFY_FLAGS_API_GATEWAY =0x00000080,
+      //--- enumeration borders
+      MODIFY_FLAGS_NONE         =0x00000000,
+      MODIFY_FLAGS_ALL          =MODIFY_FLAGS_ADMIN|MODIFY_FLAGS_MANAGER|MODIFY_FLAGS_POSITION|MODIFY_FLAGS_RESTORE|
+      MODIFY_FLAGS_API_ADMIN|MODIFY_FLAGS_API_MANAGER|MODIFY_FLAGS_API_SERVER|MODIFY_FLAGS_API_GATEWAY
+     };
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTPosition* position)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   virtual LPCWSTR   Print(MTAPISTR& string) const=0;
+   //--- owner client login
+   virtual UINT64    Login(void) const=0;
+   //--- position symbol
+   virtual LPCWSTR   Symbol(void) const=0;
+   virtual MTAPIRES  Symbol(LPCWSTR symbol)=0;
+   //--- EnPositionAction
+   virtual UINT      Action(void) const=0;
+   virtual MTAPIRES  Action(const UINT action)=0;
+   //--- price digits
+   virtual UINT      Digits(void) const=0;
+   virtual MTAPIRES  Digits(const UINT digits)=0;
+   //--- currency digits
+   virtual UINT      DigitsCurrency(void) const=0;
+   virtual MTAPIRES  DigitsCurrency(const UINT digits)=0;
+   //--- symbol contract size
+   virtual double    ContractSize(void) const=0;
+   virtual MTAPIRES  ContractSize(const double contract_size)=0;
+   //--- position create time
+   virtual INT64     TimeCreate(void) const=0;
+   virtual MTAPIRES  TimeCreate(const INT64 time)=0;
+   //--- position last update time
+   virtual INT64     TimeUpdate(void) const=0;
+   virtual MTAPIRES  TimeUpdate(const INT64 time)=0;
+   //--- position weighted average open price
+   virtual double    PriceOpen(void) const=0;
+   virtual MTAPIRES  PriceOpen(const double price)=0;
+   //--- position current price
+   virtual double    PriceCurrent(void) const=0;
+   virtual MTAPIRES  PriceCurrent(const double price)=0;
+   //--- position SL price
+   virtual double    PriceSL(void) const=0;
+   virtual MTAPIRES  PriceSL(const double price)=0;
+   //--- position TP price
+   virtual double    PriceTP(void) const=0;
+   virtual MTAPIRES  PriceTP(const double price)=0;
+   //--- position volume
+   virtual UINT64    Volume(void) const=0;
+   virtual MTAPIRES  Volume(const UINT64 volume)=0;
+   //--- position floating profit
+   virtual double    Profit(void) const=0;
+   virtual MTAPIRES  Profit(const double profit)=0;
+   //--- position accumulated swaps
+   virtual double    Storage(void) const=0;
+   virtual MTAPIRES  Storage(const double storage)=0;
+   //--- obsolete value
+   virtual double    ObsoleteValue(void) const=0;
+   virtual MTAPIRES  ObsoleteValue(const double value)=0;
+   //--- profit conversion rate (from symbol profit currency to deposit currency)
+   virtual double    RateProfit(void) const=0;
+   virtual MTAPIRES  RateProfit(const double rate)=0;
+   //--- margin conversion rate (from symbol margin currency to deposit currency)
+   virtual double    RateMargin(void) const=0;
+   virtual MTAPIRES  RateMargin(const double rate)=0;
+   //--- expert id (filled by expert advisor)
+   virtual UINT64    ExpertID(void) const=0;
+   virtual MTAPIRES  ExpertID(const UINT64 id)=0;
+   //--- expert position id
+   virtual UINT64    ExpertPositionID(void) const=0;
+   virtual MTAPIRES  ExpertPositionID(const UINT64 id)=0;
+   //--- comment
+   virtual LPCWSTR   Comment(void) const=0;
+   virtual MTAPIRES  Comment(LPCWSTR comment)=0;
+   //--- order activation state, time and price
+   virtual UINT      ActivationMode(void) const=0;
+   virtual INT64     ActivationTime(void) const=0;
+   virtual double    ActivationPrice(void) const=0;
+   virtual UINT      ActivationFlags(void) const=0;
+   //--- position internal data for API usage
+   virtual MTAPIRES  ApiDataSet(const USHORT app_id,const UCHAR id,const INT64 value)=0;
+   virtual MTAPIRES  ApiDataSet(const USHORT app_id,const UCHAR id,const UINT64 value)=0;
+   virtual MTAPIRES  ApiDataSet(const USHORT app_id,const UCHAR id,const double value)=0;
+   virtual MTAPIRES  ApiDataGet(const USHORT app_id,const UCHAR id,INT64& value) const=0;
+   virtual MTAPIRES  ApiDataGet(const USHORT app_id,const UCHAR id,UINT64& value) const=0;
+   virtual MTAPIRES  ApiDataGet(const USHORT app_id,const UCHAR id,double& value) const=0;
+   virtual MTAPIRES  ApiDataClear(const USHORT app_id)=0;
+   virtual MTAPIRES  ApiDataClearAll(void)=0;
+   //--- position create time in msc since 1970.01.01
+   virtual INT64     TimeCreateMsc(void) const=0;
+   virtual MTAPIRES  TimeCreateMsc(const INT64 time)=0;
+   //--- position last update time in msc since 1970.01.01
+   virtual INT64     TimeUpdateMsc(void) const=0;
+   virtual MTAPIRES  TimeUpdateMsc(const INT64 time)=0;
+   //--- order activation state, time and price
+   virtual MTAPIRES  ActivationMode(const UINT mode)=0;
+   virtual MTAPIRES  ActivationTime(const INT64 atm)=0;
+   virtual MTAPIRES  ActivationPrice(const double price)=0;
+   virtual MTAPIRES  ActivationFlags(const UINT flags)=0;
+   //--- processed dealer login (0-means auto) (first position deal dealer)
+   virtual UINT64    Dealer(void) const=0;
+   virtual MTAPIRES  Dealer(const UINT64 dealer)=0;
+   //--- user record internal data for API usage
+   virtual MTAPIRES  ApiDataUpdate(const UINT pos,const USHORT app_id,const UCHAR id,const INT64 value)=0;
+   virtual MTAPIRES  ApiDataUpdate(const UINT pos,const USHORT app_id,const UCHAR id,const UINT64 value)=0;
+   virtual MTAPIRES  ApiDataUpdate(const UINT pos,const USHORT app_id,const UCHAR id,const double value)=0;
+   virtual MTAPIRES  ApiDataNext(const UINT pos,USHORT& app_id,UCHAR& id,INT64& value) const=0;
+   virtual MTAPIRES  ApiDataNext(const UINT pos,USHORT& app_id,UCHAR& id,UINT64& value) const=0;
+   virtual MTAPIRES  ApiDataNext(const UINT pos,USHORT& app_id,UCHAR& id,double& value) const=0;
+   //--- owner client login
+   virtual MTAPIRES  LoginSet(const UINT64 login)=0;
+   //--- position ticket
+   virtual UINT64    Position(void) const=0;
+   //--- position ticket in external system (exchange, ECN, etc)
+   virtual LPCWSTR   ExternalID(void) const=0;
+   virtual MTAPIRES  ExternalID(LPCWSTR id)=0;
+   //--- modification flags
+   virtual UINT      ModificationFlags(void) const=0;
+   //--- position reason - EnPositionReason
+   virtual UINT      Reason(void) const=0;
+   //--- position volume
+   virtual UINT64    VolumeExt(void) const=0;
+   virtual MTAPIRES  VolumeExt(const UINT64 volume)=0;
+   //--- EnPositionReason
+   virtual MTAPIRES  ReasonSet(const UINT reason)=0;
+  };
+//+------------------------------------------------------------------+
+//| Position array interface                                         |
+//+------------------------------------------------------------------+
+class IMTPositionArray
+  {
+public:
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTPositionArray* array)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- add
+   virtual MTAPIRES  Add(IMTPosition* position)=0;
+   virtual MTAPIRES  AddCopy(const IMTPosition* position)=0;
+   virtual MTAPIRES  Add(IMTPositionArray* array)=0;
+   virtual MTAPIRES  AddCopy(const IMTPositionArray* array)=0;
+   //--- delete & detach
+   virtual MTAPIRES  Delete(const UINT pos)=0;
+   virtual IMTPosition* Detach(const UINT pos)=0;
+   //--- update
+   virtual MTAPIRES  Update(const UINT pos,IMTPosition* position)=0;
+   virtual MTAPIRES  UpdateCopy(const UINT pos,const IMTPosition* position)=0;
+   virtual MTAPIRES  Shift(const UINT pos,const int shift)=0;
+   //--- data access
+   virtual UINT      Total(void) const=0;
+   virtual IMTPosition* Next(const UINT index) const=0;
+   //--- sorting and search
+   virtual MTAPIRES  Sort(MTSortFunctionPtr sort_function)=0;
+   virtual int       Search(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchGreatOrEq(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchGreater(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchLessOrEq(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchLess(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchLeft(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchRight(const void *key,MTSortFunctionPtr sort_function) const=0;
+  };
+//+------------------------------------------------------------------+
+//| Position events notification interface                           |
+//+------------------------------------------------------------------+
+class IMTPositionSink
+  {
+public:
+   virtual void      OnPositionAdd(const IMTPosition* /*position*/)    {  }
+   virtual void      OnPositionUpdate(const IMTPosition* /*position*/) {  }
+   virtual void      OnPositionDelete(const IMTPosition* /*position*/) {  }
+   virtual void      OnPositionClean(const UINT64 /*login*/)           {  }
+   virtual void      OnPositionSync(void)                              {  }
+  };
+//+------------------------------------------------------------------+

+ 260 - 0
MT5SDK/Bases/MT5APIRequest.h

@@ -0,0 +1,260 @@
+//+------------------------------------------------------------------+
+//|                                                 MetaTrader 5 API |
+//|                   Copyright 2000-2019, MetaQuotes Software Corp. |
+//|                                        http://www.metaquotes.net |
+//+------------------------------------------------------------------+
+#pragma once
+//+------------------------------------------------------------------+
+//| Trade request interface                                          |
+//+------------------------------------------------------------------+
+class IMTRequest
+  {
+public:
+   //--- trade action types
+   enum EnTradeActions
+     {
+      //--- clients actions
+      TA_CLIENT_FIRST       =0,
+      TA_PRICE              =0,
+      TA_REQUEST            =1,
+      TA_INSTANT            =2,
+      TA_MARKET             =3,
+      TA_EXCHANGE           =4,
+      TA_PENDING            =5,
+      TA_SLTP               =6,
+      TA_MODIFY             =7,
+      TA_REMOVE             =8,
+      TA_TRANSFER           =9,
+      TA_CLOSE_BY           =10,
+      TA_CLIENT_LAST        =TA_CLOSE_BY,
+      //--- server actions
+      TA_SERVER_FIRST       =100,
+      TA_ACTIVATE           =100,
+      TA_ACTIVATE_SL        =101,
+      TA_ACTIVATE_TP        =102,
+      TA_ACTIVATE_STOPLIMIT =103,
+      TA_STOPOUT_ORDER      =104,
+      TA_STOPOUT_POSITION   =105,
+      TA_EXPIRATION         =106,
+      TA_SERVER_LAST        =TA_EXPIRATION,
+      //--- dealer actions
+      TA_DEALER_FIRST       =200,
+      TA_DEALER_POS_EXECUTE =200,
+      TA_DEALER_ORD_PENDING =201,
+      TA_DEALER_POS_MODIFY  =202,
+      TA_DEALER_ORD_MODIFY  =203,
+      TA_DEALER_ORD_REMOVE  =204,
+      TA_DEALER_ORD_ACTIVATE=205,
+      TA_DEALER_BALANCE     =206,
+      TA_DEALER_ORD_SLIMIT  =207,
+      TA_DEALER_CLOSE_BY    =208,
+      TA_DEALER_LAST        =TA_DEALER_CLOSE_BY,
+      //--- enumeration borders
+      TA_FIRST              =TA_PRICE,
+      TA_LAST               =TA_DEALER_CLOSE_BY,
+      TA_END                =255
+     };
+   //--- trade action flags
+   enum EnTradeActionFlags
+     {
+      TA_FLAG_CLOSE            =0x00000001, // position close request
+      TA_FLAG_MARKET           =0x00000002, // market prices request
+      TA_FLAG_CHANGED_PRICE    =0x00000004, // order price or position open price will be changed
+      TA_FLAG_CHANGED_TRIGGER  =0x00000008, // order trigger price will be changed
+      TA_FLAG_CHANGED_SL       =0x00000010, // order or position SL will be changed
+      TA_FLAG_CHANGED_TP       =0x00000020, // order or position TP will be changed
+      TA_FLAG_CHANGED_EXP_TYPE =0x00000040, // order expiration type will be changed
+      TA_FLAG_CHANGED_EXP_TIME =0x00000080, // order expiration datetime will be changed
+      TA_FLAG_EXPERT           =0x00000100, // request from expert
+      TA_FLAG_SIGNAL           =0x00000200, // request from signal
+      TA_FLAG_SKIP_MARGIN_CHECK=0x00000400, // skip margin check (only for dealers)
+      //--- enumeration borders
+      TA_FLAG_NONE            =0x00000000,
+      TA_FLAG_ALL             =TA_FLAG_CLOSE      | TA_FLAG_MARKET     | TA_FLAG_CHANGED_PRICE | TA_FLAG_CHANGED_TRIGGER |
+      TA_FLAG_CHANGED_SL | TA_FLAG_CHANGED_TP | TA_FLAG_CHANGED_EXP_TYPE | TA_FLAG_CHANGED_EXP_TIME | TA_FLAG_EXPERT | TA_FLAG_SIGNAL |
+      TA_FLAG_SKIP_MARGIN_CHECK
+     };
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTRequest* request)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   virtual LPCWSTR   Print(MTAPISTR& string) const=0;
+   //--- request id
+   virtual UINT      ID(void) const=0;
+   //--- client login
+   virtual UINT64    Login(void) const=0;
+   virtual MTAPIRES  Login(const UINT64 login)=0;
+   //--- client group
+   virtual LPCWSTR   Group(void) const=0;
+   //--- symbol
+   virtual LPCWSTR   Symbol(void) const=0;
+   virtual MTAPIRES  Symbol(LPCWSTR symbol)=0;
+   //--- price digits
+   virtual UINT      Digits(void) const=0;
+   //--- EnTradeActions
+   virtual UINT      Action(void) const=0;
+   virtual MTAPIRES  Action(const UINT action)=0;
+   //--- order expiration
+   virtual INT64     TimeExpiration(void) const=0;
+   virtual MTAPIRES  TimeExpiration(const INT64 time)=0;
+   //--- order type IMTOrder::EnOrderType
+   virtual UINT      Type(void) const=0;
+   virtual MTAPIRES  Type(const UINT type)=0;
+   //--- IMTOrder::EnOrderFilling
+   virtual UINT      TypeFill(void) const=0;
+   virtual MTAPIRES  TypeFill(const UINT type)=0;
+   //--- IMTOrder::EnOrderTime
+   virtual UINT      TypeTime(void) const=0;
+   virtual MTAPIRES  TypeTime(const UINT type)=0;
+   //--- additional flags EnTradeActionFlags
+   virtual UINT64    Flags(void) const=0;
+   virtual MTAPIRES  Flags(const UINT64 flags)=0;
+   //--- volume
+   virtual UINT64    Volume(void) const=0;
+   virtual MTAPIRES  Volume(const UINT64 volume)=0;
+   //--- order ticket
+   virtual UINT64    Order(void) const=0;
+   virtual MTAPIRES  Order(const UINT64 order)=0;
+   //--- order ticket in external system (exchange, ECN, etc)
+   virtual LPCWSTR   OrderExternalID(void) const=0;
+   virtual MTAPIRES  OrderExternalID(LPCWSTR id)=0;
+   //--- order price
+   virtual double    PriceOrder(void) const=0;
+   virtual MTAPIRES  PriceOrder(const double price)=0;
+   //--- order trigger price
+   virtual double    PriceTrigger(void) const=0;
+   virtual MTAPIRES  PriceTrigger(const double price)=0;
+   //--- order SL price
+   virtual double    PriceSL(void) const=0;
+   virtual MTAPIRES  PriceSL(const double price)=0;
+   //--- order TP price
+   virtual double    PriceTP(void) const=0;
+   virtual MTAPIRES  PriceTP(const double price)=0;
+   //--- price deviation details
+   virtual UINT64    PriceDeviation(void) const=0;
+   virtual MTAPIRES  PriceDeviation(const UINT64 deviation)=0;
+   virtual double    PriceDeviationTop(void) const=0;
+   virtual double    PriceDeviationBottom(void) const=0;
+   //--- comment
+   virtual LPCWSTR   Comment(void) const=0;
+   virtual MTAPIRES  Comment(LPCWSTR comment)=0;
+   //---
+   //--- request result information
+   //---
+   //--- request state retcode
+   virtual MTAPIRES  ResultRetcode(void) const=0;
+   //--- request dealer
+   virtual UINT64    ResultDealer(void) const=0;
+   //--- request result deal
+   virtual UINT64    ResultDeal(void) const=0;
+   //--- request result order
+   virtual UINT64    ResultOrder(void) const=0;
+   //--- request result confirmed volume
+   virtual UINT64    ResultVolume(void) const=0;
+   //--- request result confirmed price
+   virtual double    ResultPrice(void) const=0;
+   //--- request result dealer prices
+   virtual double    ResultDealerBid(void) const=0;
+   virtual double    ResultDealerAsk(void) const=0;
+   virtual double    ResultDealerLast(void) const=0;
+   //--- request result market prices
+   virtual double    ResultMarketBid(void) const=0;
+   virtual double    ResultMarketAsk(void) const=0;
+   virtual double    ResultMarketLast(void) const=0;
+   //--- request result comment
+   virtual LPCWSTR   ResultComment(void) const=0;
+   //--- external system trade account (exchange, ECN, etc)
+   virtual LPCWSTR   ExternalAccount(void) const=0;
+   virtual MTAPIRES  ExternalAccount(LPCWSTR account)=0;
+   //--- client side request id
+   virtual UINT      IDClient(void) const=0;
+   //--- source request ip
+   virtual LPCWSTR   IP(void) const=0;
+   virtual MTAPIRES  IP(LPCWSTR ip)=0;
+   //--- source dealer login (for dealer transaction)
+   virtual UINT64    SourceLogin(void) const=0;
+   virtual MTAPIRES  SourceLogin(const UINT64 login)=0;
+   //--- position ticket
+   virtual UINT64    Position(void) const=0;
+   virtual MTAPIRES  Position(const UINT64 position)=0;
+   //--- position ticket for close-by
+   virtual UINT64    PositionBy(void) const=0;
+   virtual MTAPIRES  PositionBy(const UINT64 position)=0;
+   //--- position ticket in external system (exchange, ECN, etc)
+   virtual LPCWSTR   PositionExternalID(void) const=0;
+   virtual MTAPIRES  PositionExternalID(LPCWSTR id)=0;
+   //--- position ticket in external system (exchange, ECN, etc)
+   virtual LPCWSTR   PositionByExternalID(void) const=0;
+   virtual MTAPIRES  PositionByExternalID(LPCWSTR id)=0;
+   //--- volume with extended accuracy
+   virtual UINT64    VolumeExt(void) const=0;
+   virtual MTAPIRES  VolumeExt(const UINT64 volume)=0;
+   //--- request result confirmed volume with extended accuracy
+   virtual UINT64    ResultVolumeExt(void) const=0;
+   //--- price digits
+   virtual MTAPIRES  DigitsSet(const UINT digits)=0;
+   //--- request internal data for API usage
+   virtual MTAPIRES  ApiDataSet(const USHORT app_id,const UCHAR id,const INT64 value)=0;
+   virtual MTAPIRES  ApiDataSet(const USHORT app_id,const UCHAR id,const UINT64 value)=0;
+   virtual MTAPIRES  ApiDataSet(const USHORT app_id,const UCHAR id,const double value)=0;
+   virtual MTAPIRES  ApiDataGet(const USHORT app_id,const UCHAR id,INT64& value) const=0;
+   virtual MTAPIRES  ApiDataGet(const USHORT app_id,const UCHAR id,UINT64& value) const=0;
+   virtual MTAPIRES  ApiDataGet(const USHORT app_id,const UCHAR id,double& value) const=0;
+   virtual MTAPIRES  ApiDataUpdate(const UINT pos,const USHORT app_id,const UCHAR id,const INT64 value)=0;
+   virtual MTAPIRES  ApiDataUpdate(const UINT pos,const USHORT app_id,const UCHAR id,const UINT64 value)=0;
+   virtual MTAPIRES  ApiDataUpdate(const UINT pos,const USHORT app_id,const UCHAR id,const double value)=0;
+   virtual MTAPIRES  ApiDataNext(const UINT pos,USHORT& app_id,UCHAR& id,INT64& value) const=0;
+   virtual MTAPIRES  ApiDataNext(const UINT pos,USHORT& app_id,UCHAR& id,UINT64& value) const=0;
+   virtual MTAPIRES  ApiDataNext(const UINT pos,USHORT& app_id,UCHAR& id,double& value) const=0;
+   virtual LPVOID    ApiDataRaw(void) const=0;
+   virtual UINT      ApiDataRawMax(void) const=0;
+   virtual MTAPIRES  ApiDataClear(const USHORT app_id)=0;
+   virtual MTAPIRES  ApiDataClearAll(void)=0;
+  };
+//+------------------------------------------------------------------+
+//| Order array interface                                            |
+//+------------------------------------------------------------------+
+class IMTRequestArray
+  {
+public:
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTRequestArray* array)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- add
+   virtual MTAPIRES  Add(IMTRequest* request)=0;
+   virtual MTAPIRES  AddCopy(const IMTRequest* request)=0;
+   virtual MTAPIRES  Add(IMTRequestArray* array)=0;
+   virtual MTAPIRES  AddCopy(const IMTRequestArray* array)=0;
+   //--- delete & detach
+   virtual MTAPIRES  Delete(const UINT pos)=0;
+   virtual IMTRequest* Detach(const UINT pos)=0;
+   //--- update
+   virtual MTAPIRES  Update(const UINT pos,IMTRequest* request)=0;
+   virtual MTAPIRES  UpdateCopy(const UINT pos,const IMTRequest* request)=0;
+   virtual MTAPIRES  Shift(const UINT pos,const int shift)=0;
+   //--- data access
+   virtual UINT        Total(void) const=0;
+   virtual IMTRequest* Next(const UINT index) const=0;
+   //--- sorting and search
+   virtual MTAPIRES  Sort(MTSortFunctionPtr sort_function)=0;
+   virtual int       Search(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchGreatOrEq(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchGreater(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchLessOrEq(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchLess(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchLeft(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchRight(const void *key,MTSortFunctionPtr sort_function) const=0;
+  };
+//+------------------------------------------------------------------+
+//| Request events notification interface                            |
+//+------------------------------------------------------------------+
+class IMTRequestSink
+  {
+public:
+   virtual void      OnRequestAdd(const IMTRequest*    /*request*/) {  }
+   virtual void      OnRequestUpdate(const IMTRequest* /*request*/) {  }
+   virtual void      OnRequestDelete(const IMTRequest* /*request*/) {  }
+   virtual void      OnRequestSync(void)                            {  }
+  };
+//+------------------------------------------------------------------+

+ 91 - 0
MT5SDK/Bases/MT5APISummary.h

@@ -0,0 +1,91 @@
+//+------------------------------------------------------------------+
+//|                                                 MetaTrader 5 API |
+//|                   Copyright 2000-2019, MetaQuotes Software Corp. |
+//|                                        http://www.metaquotes.net |
+//+------------------------------------------------------------------+
+#pragma once
+//+------------------------------------------------------------------+
+//| Trade summary interface                                          |
+//+------------------------------------------------------------------+
+class IMTSummary
+  {
+public:
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTSummary* summary)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- summary symbol
+   virtual LPCWSTR   Symbol(void) const=0;
+   virtual UINT      Digits(void) const=0;
+   //--- total positions
+   virtual UINT      PositionClients(void) const=0;
+   virtual UINT      PositionCoverage(void) const=0;
+   //--- volumes
+   virtual UINT64    VolumeBuyClients(void) const=0;
+   virtual UINT64    VolumeBuyCoverage(void) const=0;
+   virtual UINT64    VolumeSellClients(void) const=0;
+   virtual UINT64    VolumeSellCoverage(void) const=0;
+   virtual double    VolumeNet(void) const=0;
+   //--- average prices
+   virtual double    PriceBuyClients(void) const=0;
+   virtual double    PriceBuyCoverage(void) const=0;
+   virtual double    PriceSellClients(void) const=0;
+   virtual double    PriceSellCoverage(void) const=0;
+   //--- profit
+   virtual double    ProfitClients(void) const=0;
+   virtual double    ProfitCoverage(void) const=0;
+   virtual double    ProfitFullClients(void) const=0;
+   virtual double    ProfitFullCoverage(void) const=0;
+   virtual double    ProfitUncovered(void) const=0;
+   virtual double    ProfitUncoveredFull(void) const=0;
+   //--- volumes with extended accuracy
+   virtual UINT64    VolumeBuyClientsExt(void) const=0;
+   virtual UINT64    VolumeBuyCoverageExt(void) const=0;
+   virtual UINT64    VolumeSellClientsExt(void) const=0;
+   virtual UINT64    VolumeSellCoverageExt(void) const=0;
+  };
+//+------------------------------------------------------------------+
+//| Trade summary array interface                                    |
+//+------------------------------------------------------------------+
+class IMTSummaryArray
+  {
+public:
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTSummaryArray* array)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- add
+   virtual MTAPIRES  Add(IMTSummary* summary)=0;
+   virtual MTAPIRES  AddCopy(const IMTSummary* summary)=0;
+   virtual MTAPIRES  Add(IMTSummaryArray* array)=0;
+   virtual MTAPIRES  AddCopy(const IMTSummaryArray* array)=0;
+   //--- delete & detach
+   virtual MTAPIRES  Delete(const UINT pos)=0;
+   virtual IMTSummary* Detach(const UINT pos)=0;
+   //--- update
+   virtual MTAPIRES  Update(const UINT pos,IMTSummary* summary)=0;
+   virtual MTAPIRES  UpdateCopy(const UINT pos,const IMTSummary* summary)=0;
+   virtual MTAPIRES  Shift(const UINT pos,const int shift)=0;
+   //--- data access
+   virtual UINT      Total(void) const=0;
+   virtual IMTSummary* Next(const UINT index) const=0;
+   //--- sorting and search
+   virtual MTAPIRES  Sort(MTSortFunctionPtr sort_function)=0;
+   virtual int       Search(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchGreatOrEq(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchGreater(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchLessOrEq(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchLess(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchLeft(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchRight(const void *key,MTSortFunctionPtr sort_function) const=0;
+  };
+//+------------------------------------------------------------------+
+//| Trade summary events notification interface                      |
+//+------------------------------------------------------------------+
+class IMTSummarySink
+  {
+public:
+   virtual void      OnSummaryUpdate(const IMTSummary* /*summary*/) { }
+  };
+//+------------------------------------------------------------------+
+  

+ 175 - 0
MT5SDK/Bases/MT5APITick.h

@@ -0,0 +1,175 @@
+//+------------------------------------------------------------------+
+//|                                                 MetaTrader 5 API |
+//|                   Copyright 2000-2019, MetaQuotes Software Corp. |
+//|                                        http://www.metaquotes.net |
+//+------------------------------------------------------------------+
+#pragma once
+//+------------------------------------------------------------------+
+//| Feeder constants                                                 |
+//+------------------------------------------------------------------+
+enum EnMTFeederConstants
+  {
+   MT_FEEDER_DEALER =-1,                              // feeder index for dealer ticks 
+   MT_FEEDER_OFFSET =64                               // index offset for datafeed ticks
+  };
+//+------------------------------------------------------------------+
+//| Tick full description structure                                  |
+//+------------------------------------------------------------------+
+#pragma pack(push,1)
+struct MTTick
+  {
+   //--- tick flags
+   enum EnTickFlags
+     {
+      TICK_FLAG_BUY   =1,                             // tick created due buy operation
+      TICK_FLAG_SELL  =2,                             // tick created due sell operation
+      //--- enumeration borders
+      TICK_FLAG_NONE  =0,                             // none
+      TICK_FLAG_ALL   =TICK_FLAG_BUY|TICK_FLAG_SELL   // all flags
+     };
+   wchar_t           symbol[32];                      // symbol
+   wchar_t           bank[32];                        // tick source ticker
+   INT64             datetime;                        // datetime in seconds since 01/01/1970
+   //--- basic price data
+   double            bid;                             // bid price
+   double            ask;                             // ask price
+   double            last;                            // last price
+   UINT64            volume;                          // last trade volume
+   //--- additional data
+   INT64             datetime_msc;                    // datetime in milliseconds since 01/01/1970
+   UINT64            flags;                           // flags
+   UINT64            volume_ext;                      // last trade volume with extended accuracy
+   //--- reserved data
+   UINT              reserved[26];                    // reserved
+  };
+#pragma pack(pop)
+//+------------------------------------------------------------------+
+//| Tick short description structure                                 |
+//+------------------------------------------------------------------+
+#pragma pack(push,1)
+struct MTTickShort
+  {
+   //--- tick flags
+   enum EnTickShortFlags
+     {
+      TICK_SHORT_FLAG_RAW   =0x00000001,              // raw tick 
+      TICK_SHORT_FLAG_BID   =0x00000002,              // tick changes bid price value
+      TICK_SHORT_FLAG_ASK   =0x00000004,              // tick changes ask price value
+      TICK_SHORT_FLAG_LAST  =0x00000008,              // tick changes last price value
+      TICK_SHORT_FLAG_VOLUME=0x00000010,              // tick changes volume value
+      TICK_SHORT_FLAG_BUY   =0x00000020,              // tick created due buy operation
+      TICK_SHORT_FLAG_SELL  =0x00000040,              // tick created due sell operation
+      //--- enumeration borders
+      TICK_SHORT_FLAG_NONE  =0x00000000,              // none
+     };
+   INT64             datetime;                        // last update datetime in seconds since 01/01/1970
+   double            bid;                             // bid price
+   double            ask;                             // ask price
+   double            last;                            // last price
+   UINT64            volume;                          // last trade volume
+   INT64             datetime_msc;                    // datetime in milliseconds since 01/01/1970
+   UINT64            flags;                           // flags
+   UINT64            volume_ext;                      // last trade volume with extended volume
+   UINT              reserved[26];                    // reserved
+  };
+#pragma pack(pop)
+//+------------------------------------------------------------------+
+//| Tick short structure                                             |
+//+------------------------------------------------------------------+
+#pragma pack(push,1)
+struct MTTickRate
+  {
+   //--- tick flags
+   enum EnTickShortFlags
+     {
+      TICK_SHORT_FLAG_RAW   =0x00000001,              // raw tick 
+      TICK_SHORT_FLAG_BID   =0x00000002,              // tick changes bid price value
+      TICK_SHORT_FLAG_ASK   =0x00000004,              // tick changes ask price value
+      TICK_SHORT_FLAG_LAST  =0x00000008,              // tick changes last price value
+      TICK_SHORT_FLAG_VOLUME=0x00000010,              // tick changes volume value
+      TICK_SHORT_FLAG_BUY   =0x00000020,              // tick created due buy operation
+      TICK_SHORT_FLAG_SELL  =0x00000040,              // tick created due sell operation
+      //--- enumeration borders
+      TICK_SHORT_FLAG_NONE  =0x00000000,              // none
+     };
+   INT64             datetime_msc;                    // datetime in milliseconds since 01/01/1970
+   double            bid;                             // bid price
+   double            ask;                             // ask price
+   double            last;                            // last price
+   UINT64            flags;                           // flags
+   UINT64            volume_ext;                      // last trade volume with extended volume
+   INT64             reserved[2];
+  };
+#pragma pack(pop)
+//+------------------------------------------------------------------+
+//| Tick statistic description structure                             |
+//+------------------------------------------------------------------+
+#pragma pack(push,1)
+struct MTTickStat
+  {
+   wchar_t           symbol[32];                   // symbol
+   INT64             datetime;                     // last update datetime in seconds since 01/01/1970
+   //--- bid
+   double            bid_high;                     // bid high
+   double            bid_low;                      // bid low
+   //--- ask
+   double            ask_high;                     // ask high
+   double            ask_low;                      // ask low
+   //--- last
+   double            last_high;                    // last high
+   double            last_low;                     // last low
+   //--- trade volume
+   UINT64            vol_high;                     // last high
+   UINT64            vol_low;                      // last low
+   //--- trade session  statistics
+   UINT64            trade_deals;                  // total deals in current session
+   UINT64            trade_volume;                 // total deals volume in current session
+   UINT64            trade_turnover;               // total turnover in current session
+   UINT64            trade_interest;               // open interest in current session
+   UINT64            trade_buy_orders;             // total buy orders
+   UINT64            trade_buy_volume;             // total buy orders volume
+   UINT64            trade_sell_orders;            // total sell orders
+   UINT64            trade_sell_volume;            // total sell orders volume
+   UINT64            trade_volume_ext;             // total deals volume in current session with extended accuracy
+   UINT64            trade_buy_volume_ext;         // total buy orders volume with extended accuracy
+   UINT64            trade_sell_volume_ext;        // total sell orders volume with extended accuracy
+   UINT64            vol_high_ext;                 // last high with extended accuracy
+   UINT64            vol_low_ext;                  // last low with extended accuracy
+   int               trade_reserved[20];           // reserved
+   //--- datetime
+   INT64             datetime_msc;                 // last update datetime in milliseconds since 01/01/1970
+   //--- price session  statistics
+   double            price_open;                   // session open price
+   double            price_close;                  // session close price
+   double            price_aw;                     // average weighted price
+   double            price_change;                 // price change percentage
+   double            price_volatility;             // price volatility
+   double            price_theoretical;            // theoretical price
+   double            price_greeks_delta;           // option\warrant delta
+   double            price_greeks_theta;           // option\warrant theta
+   double            price_greeks_gamma;           // option\warrant gamma
+   double            price_greeks_vega;            // option\warrant vega
+   double            price_greeks_rho;             // option\warrant rho
+   double            price_greeks_omega;           // option\warrant omega
+   double            price_sensitivity;            // option\warrant sensitivity
+   int               price_reserved[14];           // reserved
+  };
+#pragma pack(pop)
+//+------------------------------------------------------------------+
+//| Tick events notification interface                               |
+//+------------------------------------------------------------------+
+class IMTTickSink
+  {
+public:
+   //--- tick events
+   virtual void      OnTick(LPCWSTR /*symbol*/,const MTTickShort& /*tick*/)       { }
+   virtual void      OnTickStat(const MTTickStat& /*tick*/)                       { }
+   //--- tick hooks
+   virtual MTAPIRES  HookTick(const int /*feeder*/,MTTick& /*tick*/)              { return(MT_RET_OK); }
+   virtual MTAPIRES  HookTickStat(const int /*feeder*/,MTTickStat& /*tstat*/)     { return(MT_RET_OK); }
+   //--- extended tick events
+   virtual void      OnTick(const int /*feeder*/,const MTTick& /*tick*/)          { }
+   virtual void      OnTickStat(const int /*feeder*/,const MTTickStat& /*tstat*/) { }
+  };
+//+------------------------------------------------------------------+
+

+ 257 - 0
MT5SDK/Bases/MT5APIUser.h

@@ -0,0 +1,257 @@
+//+------------------------------------------------------------------+
+//|                                                 MetaTrader 5 API |
+//|                   Copyright 2000-2019, MetaQuotes Software Corp. |
+//|                                        http://www.metaquotes.net |
+//+------------------------------------------------------------------+
+#pragma once
+//+------------------------------------------------------------------+
+//| User record interface                                            |
+//+------------------------------------------------------------------+
+class IMTUser
+  {
+public:
+   //--- client rights bit flags
+   enum EnUsersRights
+     {
+      USER_RIGHT_NONE             =0x0000000000000000,  // none
+      USER_RIGHT_ENABLED          =0x0000000000000001,  // client allowed to connect
+      USER_RIGHT_PASSWORD         =0x0000000000000002,  // client allowed to change password
+      USER_RIGHT_TRADE_DISABLED   =0x0000000000000004,  // client trading disabled
+      USER_RIGHT_INVESTOR         =0x0000000000000008,  // client is investor
+      USER_RIGHT_CONFIRMED        =0x0000000000000010,  // client certificate confirmed
+      USER_RIGHT_TRAILING         =0x0000000000000020,  // trailing stops are allowed
+      USER_RIGHT_EXPERT           =0x0000000000000040,  // expert advisors are allowed
+      USER_RIGHT_API              =0x0000000000000080,  // client API are allowed
+      USER_RIGHT_REPORTS          =0x0000000000000100,  // trade reports are allowed
+      USER_RIGHT_READONLY         =0x0000000000000200,  // client is readonly
+      USER_RIGHT_RESET_PASS       =0x0000000000000400,  // client must change password at next login
+      USER_RIGHT_OTP_ENABLED      =0x0000000000000800,  // client allowed to use one-time password
+      USER_RIGHT_SPONSORED_HOSTING=0x0000000000002000,  // client allowed to use sponsored by broker MetaTrader Virtual Hosting
+      //--- enumeration borders
+      USER_RIGHT_DEFAULT   =USER_RIGHT_ENABLED |USER_RIGHT_PASSWORD|USER_RIGHT_TRAILING|USER_RIGHT_EXPERT|USER_RIGHT_REPORTS,
+      USER_RIGHT_ALL       =USER_RIGHT_ENABLED |USER_RIGHT_PASSWORD |USER_RIGHT_TRADE_DISABLED|
+      USER_RIGHT_INVESTOR|USER_RIGHT_CONFIRMED|USER_RIGHT_TRAILING      |
+      USER_RIGHT_EXPERT  |USER_RIGHT_API      |USER_RIGHT_REPORTS       |
+      USER_RIGHT_READONLY|USER_RIGHT_RESET_PASS|USER_RIGHT_OTP_ENABLED  | USER_RIGHT_SPONSORED_HOSTING
+     };
+   //--- password types
+   enum EnUsersPasswords
+     {
+      USER_PASS_MAIN    =0,
+      USER_PASS_INVESTOR=1,
+      USER_PASS_API     =2,
+      //--- enumeration borders
+      USER_PASS_FIRST   =USER_PASS_MAIN,
+      USER_PASS_LAST    =USER_PASS_API,
+     };
+   //--- connection types
+   enum EnUsersConnectionTypes
+     {
+      //--- client types
+      USER_TYPE_CLIENT            =0,
+      USER_TYPE_CLIENT_WINMOBILE  =1,
+      USER_TYPE_CLIENT_WINPHONE   =2,
+      USER_TYPE_CLIENT_IPHONE     =4,
+      USER_TYPE_CLIENT_ANDROID    =5,
+      USER_TYPE_CLIENT_BLACKBERRY =6,
+      USER_TYPE_CLIENT_WEB        =11,
+      //--- manager types
+      USER_TYPE_ADMIN             =32,
+      USER_TYPE_MANAGER           =33,
+      USER_TYPE_MANAGER_API       =34,
+      USER_TYPE_ADMIN_API         =36,
+      //--- enumeration borders
+      USER_TYPE_FIRST             =USER_TYPE_CLIENT,
+      USER_TYPE_LAST              =USER_TYPE_ADMIN_API
+     };
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTUser* user)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- login
+   virtual UINT64    Login(void) const=0;
+   virtual MTAPIRES  Login(const UINT64 login)=0;
+   //--- group
+   virtual LPCWSTR   Group(void) const=0;
+   virtual MTAPIRES  Group(LPCWSTR group)=0;
+   //--- certificate serial number
+   virtual UINT64    CertSerialNumber(void) const=0;
+   //--- EnUsersRights
+   virtual UINT64    Rights(void) const=0;
+   virtual MTAPIRES  Rights(const UINT64 rights)=0;
+   //--- registration datetime (filled by MT5)
+   virtual INT64     Registration(void) const=0;
+   virtual INT64     LastAccess(void) const =0;
+   virtual LPCWSTR   LastIP(MTAPISTR& ip) const=0;
+   //--- name
+   virtual LPCWSTR   Name(void) const=0;
+   virtual MTAPIRES  Name(LPCWSTR name)=0;
+   //--- company
+   virtual LPCWSTR   Company(void) const=0;
+   virtual MTAPIRES  Company(LPCWSTR id)=0;
+   //--- external system account (exchange, ECN, etc)
+   virtual LPCWSTR   Account(void) const=0;
+   virtual MTAPIRES  Account(LPCWSTR account)=0;
+   //--- country
+   virtual LPCWSTR   Country(void) const=0;
+   virtual MTAPIRES  Country(LPCWSTR account)=0;
+   //--- client language (WinAPI LANGID)
+   virtual UINT      Language(void) const=0;
+   virtual MTAPIRES  Language(const UINT language)=0;
+   //--- city
+   virtual LPCWSTR   City(void) const=0;
+   virtual MTAPIRES  City(LPCWSTR city)=0;
+   //--- state
+   virtual LPCWSTR   State(void) const=0;
+   virtual MTAPIRES  State(LPCWSTR state)=0;
+   //--- ZIP code
+   virtual LPCWSTR   ZIPCode(void) const=0;
+   virtual MTAPIRES  ZIPCode(LPCWSTR code)=0;
+   //--- address
+   virtual LPCWSTR   Address(void) const=0;
+   virtual MTAPIRES  Address(LPCWSTR code)=0;
+   //--- phone
+   virtual LPCWSTR   Phone(void) const=0;
+   virtual MTAPIRES  Phone(LPCWSTR phone)=0;
+   //--- email
+   virtual LPCWSTR   EMail(void) const=0;
+   virtual MTAPIRES  EMail(LPCWSTR email)=0;
+   //--- additional ID
+   virtual LPCWSTR   ID(void) const=0;
+   virtual MTAPIRES  ID(LPCWSTR email)=0;
+   //--- additional status
+   virtual LPCWSTR   Status(void) const=0;
+   virtual MTAPIRES  Status(LPCWSTR id)=0;
+   //--- comment
+   virtual LPCWSTR   Comment(void) const=0;
+   virtual MTAPIRES  Comment(LPCWSTR comment)=0;
+   //--- color
+   virtual COLORREF  Color(void) const=0;
+   virtual MTAPIRES  Color(const COLORREF color)=0;
+   //--- phone password
+   virtual LPCWSTR   PhonePassword(void) const=0;
+   virtual MTAPIRES  PhonePassword(LPCWSTR password)=0;
+   //--- leverage
+   virtual UINT      Leverage(void) const=0;
+   virtual MTAPIRES  Leverage(const UINT leverage)=0;
+   //--- agent account
+   virtual UINT64    Agent(void) const=0;
+   virtual MTAPIRES  Agent(const UINT64 agent)=0;
+   //--- balance & credit
+   virtual double    Balance(void) const=0;
+   virtual double    Credit(void) const=0;
+   //--- accumulated interest rate
+   virtual double    InterestRate(void) const=0;
+   //--- accumulated daily and monthly commissions
+   virtual double    CommissionDaily(void) const=0;
+   virtual double    CommissionMonthly(void) const=0;
+   //--- accumulated daily and monthly agent commissions
+   virtual double    CommissionAgentDaily(void) const=0;
+   virtual double    CommissionAgentMonthly(void) const=0;
+   //--- previous balance state
+   virtual double    BalancePrevDay(void) const=0;
+   virtual double    BalancePrevMonth(void) const=0;
+   //--- previous equity state
+   virtual double    EquityPrevDay(void) const=0;
+   virtual double    EquityPrevMonth(void) const=0;
+   //--- user record internal data for API usage
+   virtual MTAPIRES  ApiDataSet(const USHORT app_id,const UCHAR id,const INT64 value)=0;
+   virtual MTAPIRES  ApiDataSet(const USHORT app_id,const UCHAR id,const UINT64 value)=0;
+   virtual MTAPIRES  ApiDataSet(const USHORT app_id,const UCHAR id,const double value)=0;
+   virtual MTAPIRES  ApiDataGet(const USHORT app_id,const UCHAR id,INT64& value) const=0;
+   virtual MTAPIRES  ApiDataGet(const USHORT app_id,const UCHAR id,UINT64& value) const=0;
+   virtual MTAPIRES  ApiDataGet(const USHORT app_id,const UCHAR id,double& value) const=0;
+   virtual MTAPIRES  ApiDataClear(const USHORT app_id)=0;
+   virtual MTAPIRES  ApiDataClearAll(void)=0;
+   //--- external accounts
+   virtual MTAPIRES  ExternalAccountAdd(const UINT64 gateway_id,LPCWSTR account)=0;
+   virtual MTAPIRES  ExternalAccountUpdate(const UINT pos,const UINT64 gateway_id,LPCWSTR account)=0;
+   virtual MTAPIRES  ExternalAccountDelete(const UINT pos)=0;
+   virtual MTAPIRES  ExternalAccountClear(void)=0;
+   virtual UINT      ExternalAccountTotal(void) const=0;
+   virtual MTAPIRES  ExternalAccountNext(const UINT pos,UINT64& gateway_id,MTAPISTR& account) const=0;
+   virtual MTAPIRES  ExternalAccountGet(const UINT64 gateway_id,MTAPISTR& account) const=0;
+   //--- last password change datetime (filled by MT5)
+   virtual INT64     LastPassChange(void) const =0;
+   //--- client's MetaQuotes ID
+   virtual LPCWSTR   MQID(MTAPISTR& mqid) const=0;
+   //--- user record internal data for API usage
+   virtual MTAPIRES  ApiDataUpdate(const UINT pos,const USHORT app_id,const UCHAR id,const INT64 value)=0;
+   virtual MTAPIRES  ApiDataUpdate(const UINT pos,const USHORT app_id,const UCHAR id,const UINT64 value)=0;
+   virtual MTAPIRES  ApiDataUpdate(const UINT pos,const USHORT app_id,const UCHAR id,const double value)=0;
+   virtual MTAPIRES  ApiDataNext(const UINT pos,USHORT& app_id,UCHAR& id,INT64& value) const=0;
+   virtual MTAPIRES  ApiDataNext(const UINT pos,USHORT& app_id,UCHAR& id,UINT64& value) const=0;
+   virtual MTAPIRES  ApiDataNext(const UINT pos,USHORT& app_id,UCHAR& id,double& value) const=0;
+   //--- clients passwords derivative hash for password comparisson
+   virtual MTAPIRES  PasswordHash(const UINT type,MTAPISTR& password_hash) const=0;
+   //--- lead campaign
+   virtual LPCWSTR   LeadCampaign(void) const=0;
+   virtual MTAPIRES  LeadCampaign(LPCWSTR lead_campaign)=0;
+   //--- lead source
+   virtual LPCWSTR   LeadSource(void) const=0;
+   virtual MTAPIRES  LeadSource(LPCWSTR lead_source)=0;
+   //--- client id
+   virtual UINT64    ClientID(void) const=0;
+   virtual UINT64    ClientID(const UINT64 id)=0;
+  };
+//+------------------------------------------------------------------+
+//| User array interface                                             |
+//+------------------------------------------------------------------+
+class IMTUserArray
+  {
+public:
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTUserArray* array)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- add
+   virtual MTAPIRES  Add(IMTUser* user)=0;
+   virtual MTAPIRES  AddCopy(const IMTUser* user)=0;
+   virtual MTAPIRES  Add(IMTUserArray* array)=0;
+   virtual MTAPIRES  AddCopy(const IMTUserArray* array)=0;
+   //--- delete & detach
+   virtual MTAPIRES  Delete(const UINT pos)=0;
+   virtual IMTUser*  Detach(const UINT pos)=0;
+   //--- update
+   virtual MTAPIRES  Update(const UINT pos,IMTUser* account)=0;
+   virtual MTAPIRES  UpdateCopy(const UINT pos,const IMTUser* account)=0;
+   virtual MTAPIRES  Shift(const UINT pos,const int shift)=0;
+   //--- data access
+   virtual UINT      Total(void) const=0;
+   virtual IMTUser*  Next(const UINT index) const=0;
+   //--- sorting and search
+   virtual MTAPIRES  Sort(MTSortFunctionPtr sort_function)=0;
+   virtual int       Search(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchGreatOrEq(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchGreater(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchLessOrEq(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchLess(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchLeft(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchRight(const void *key,MTSortFunctionPtr sort_function) const=0;
+  };
+//+------------------------------------------------------------------+
+//| User records notification interface                              |
+//+------------------------------------------------------------------+
+class IMTUserSink
+  {
+public:
+   //--- events
+   virtual void      OnUserAdd(const IMTUser*    /*user*/)           {  }
+   virtual void      OnUserUpdate(const IMTUser* /*user*/)           {  }
+   virtual void      OnUserDelete(const IMTUser* /*user*/)           {  }
+   virtual void      OnUserClean(const UINT64 /*login*/)             {  }
+   virtual void      OnUserLogin(LPCWSTR /*ip*/,const IMTUser* /*user*/,const UINT /*type*/) {  }
+   virtual void      OnUserSync(void)                                {  }
+   //--- hooks
+   virtual MTAPIRES  HookUserAdd(IMTUser* /*user*/)                                            { return(MT_RET_OK); }
+   virtual MTAPIRES  HookUserUpdate(const IMTUser* /*prev*/,IMTUser* /*user*/)                 { return(MT_RET_OK); }
+   virtual MTAPIRES  HookUserDelete(const IMTUser* /*user*/)                                   { return(MT_RET_OK); }
+   virtual MTAPIRES  HookUserLogin(LPCWSTR /*ip*/,const IMTUser* /*user*/,const UINT /*type*/) { return(MT_RET_OK); }
+   //--- events
+   virtual void      OnUserLogout(LPCWSTR /*ip*/,const IMTUser* /*user*/,const UINT /*type*/)  {                    }
+   virtual void      OnUserArchive(const IMTUser*  /*user*/)                                   {                    }
+   virtual void      OnUserRestore(const IMTUser*  /*user*/)                                   {                    }
+   //--- hooks
+   virtual MTAPIRES  HookUserArchive(const IMTUser*  /*user*/)                                 { return(MT_RET_OK); }
+  };
+//+------------------------------------------------------------------+

+ 371 - 0
MT5SDK/Classes/MT5APIFile.h

@@ -0,0 +1,371 @@
+//+------------------------------------------------------------------+
+//|                                                 MetaTrader 5 API |
+//|                   Copyright 2000-2019, MetaQuotes Software Corp. |
+//|                                        http://www.metaquotes.net |
+//+------------------------------------------------------------------+
+#pragma once
+#include "MT5APIStr.h"
+//+------------------------------------------------------------------+
+//| File operations wrapper class                                    |
+//+------------------------------------------------------------------+
+class CMTFile
+  {
+public:
+   static const UINT64 INVALID_POSITION;
+private:
+   HANDLE            m_file;
+
+public:
+                     CMTFile():m_file(INVALID_HANDLE_VALUE) {}
+   virtual          ~CMTFile()                              { Close(); }
+   //--- file open
+   bool              Open(LPCWSTR lpFileName,const DWORD dwAccess,const DWORD dwShare,const DWORD dwCreationFlags,const DWORD dwAttributes=FILE_ATTRIBUTE_NORMAL);
+   bool              OpenRead(LPCWSTR lpFileName);
+   bool              OpenWrite(LPCWSTR lpFileName);
+   //--- file close
+   void              Close(void);
+   //--- file properties
+   HANDLE            Handle(void);
+   bool              IsOpen() const;
+   UINT64            Size(void) const;
+   static UINT64     Size(LPCWSTR path);
+   FILETIME          TimeCreate(void) const;
+   FILETIME          TimeLastAccess(void) const;
+   FILETIME          TimeLastModify(void) const;
+   UINT64            CurrPos(void);
+   //--- file operations
+   DWORD             Read(void  *buffer,const DWORD length);
+   DWORD             Write(const void *buffer,const DWORD length);
+   UINT64            Seek(const INT64 distance,const DWORD method);
+   bool              ChangeSize(const UINT64 size);
+   bool              Flush();
+   //--- files group operations
+   static int        FilesCopy(const CMTStr& path,const CMTStr& newpath,const CMTStr& mask,const bool subdir);
+   //--- directory operations
+   static bool       DirectoryCreate(const CMTStr& path);
+   static bool       DirectoryRemove(const CMTStr& path);
+   static bool       DirectoryClean(const CMTStr& path,const CMTStr& mask);
+  };
+//+------------------------------------------------------------------+
+//| Constant declaration                                             |
+//+------------------------------------------------------------------+
+const __declspec(selectany) UINT64 CMTFile::INVALID_POSITION=_UI64_MAX;
+//+------------------------------------------------------------------+
+//| File open                                                        |
+//+------------------------------------------------------------------+
+inline bool CMTFile::Open(LPCWSTR lpFileName,const DWORD dwAccess,const DWORD dwShare,const DWORD dwCreationFlags,const DWORD dwAttributes)
+  {
+//--- close previous
+   Close();
+//--- check name and open
+   if(lpFileName)
+      m_file=CreateFileW(lpFileName,dwAccess,dwShare,NULL,dwCreationFlags,dwAttributes,NULL);
+//--- return
+   return(m_file!=INVALID_HANDLE_VALUE);
+  }
+//+------------------------------------------------------------------+
+//| File open for read                                               |
+//+------------------------------------------------------------------+
+inline bool CMTFile::OpenRead(LPCWSTR lpFileName)  
+  { 
+   return Open(lpFileName,GENERIC_READ,FILE_SHARE_READ|FILE_SHARE_WRITE,OPEN_EXISTING);
+  }
+//+------------------------------------------------------------------+
+//| File open for write                                              |
+//+------------------------------------------------------------------+
+inline bool CMTFile::OpenWrite(LPCWSTR lpFileName)
+ { 
+  return Open(lpFileName,GENERIC_WRITE,FILE_SHARE_READ|FILE_SHARE_WRITE,CREATE_ALWAYS); 
+ }
+//+------------------------------------------------------------------+
+//| File close                                                       |
+//+------------------------------------------------------------------+
+inline void CMTFile::Close(void)
+  {
+   if(m_file!=INVALID_HANDLE_VALUE)
+     {
+      CloseHandle(m_file);
+      m_file=INVALID_HANDLE_VALUE;
+     }
+  }
+//+------------------------------------------------------------------+
+//| File handle                                                      |
+//+------------------------------------------------------------------+
+inline HANDLE CMTFile::Handle(void)
+  {
+   return(m_file);
+  }
+//+------------------------------------------------------------------+
+//| Check file state                                                 |
+//+------------------------------------------------------------------+
+inline bool CMTFile::IsOpen(void) const
+  { 
+   return(m_file!=INVALID_HANDLE_VALUE); 
+  }
+//+------------------------------------------------------------------+
+//| File size                                                        |
+//+------------------------------------------------------------------+
+inline UINT64 CMTFile::Size() const
+  {
+   LARGE_INTEGER li={};
+//--- check and receive
+   if(m_file==INVALID_HANDLE_VALUE || !::GetFileSizeEx(m_file,&li)) 
+      return(0);
+//--- return result
+   return((UINT64)li.QuadPart);
+  }
+//+------------------------------------------------------------------+
+//| File size                                                        |
+//+------------------------------------------------------------------+
+inline UINT64 CMTFile::Size(LPCWSTR path)
+  {
+   LARGE_INTEGER             li={};
+   WIN32_FILE_ATTRIBUTE_DATA fad;
+//--- receive file 
+   if(GetFileAttributesExW(path,GetFileExInfoStandard,&fad))
+     {
+      li.LowPart =fad.nFileSizeLow;
+      li.HighPart=(LONG)fad.nFileSizeHigh;
+     }
+//--- return result
+   return((UINT64)li.QuadPart);
+  }
+//+------------------------------------------------------------------+
+//| File creation time                                               |
+//+------------------------------------------------------------------+
+inline FILETIME CMTFile::TimeCreate() const
+  {
+   FILETIME ft={};
+//--- check and receive
+   if(m_file!=INVALID_HANDLE_VALUE) 
+      GetFileTime(m_file,&ft,NULL,NULL);
+//--- return result
+   return(ft);
+  }
+//+------------------------------------------------------------------+
+//| File last access time                                            |
+//+------------------------------------------------------------------+
+inline FILETIME CMTFile::TimeLastAccess() const
+  {
+   FILETIME ft={};
+//--- check and receive
+   if(m_file!=INVALID_HANDLE_VALUE) 
+      GetFileTime(m_file,NULL,&ft,NULL);
+//--- return result
+   return(ft);
+  }
+//+------------------------------------------------------------------+
+//| File last modify time                                            |
+//+------------------------------------------------------------------+
+inline FILETIME CMTFile::TimeLastModify() const
+  {
+   FILETIME ft={};
+//--- check and receive
+   if(m_file!=INVALID_HANDLE_VALUE) 
+      GetFileTime(m_file,NULL,NULL,&ft);
+//--- return result
+   return(ft);
+  }
+//+------------------------------------------------------------------+
+//| File pointer position                                            |
+//+------------------------------------------------------------------+
+inline UINT64 CMTFile::CurrPos()
+  {
+   return(CMTFile::Seek(INT64(0),FILE_CURRENT));
+  }
+//+------------------------------------------------------------------+
+//| File read                                                        |
+//+------------------------------------------------------------------+
+inline DWORD CMTFile::Read(void *buffer,const DWORD length)
+  {
+//--- check
+   if(m_file==INVALID_HANDLE_VALUE || buffer==NULL || length<1)
+      return(0);
+//--- read
+   DWORD readed=0;
+
+   if(ReadFile(m_file,buffer,length,&readed,NULL)==0) 
+      readed=0;
+//--- return
+   return(readed);
+  }
+//+------------------------------------------------------------------+
+//| Write to file                                                    |
+//+------------------------------------------------------------------+
+inline DWORD CMTFile::Write(const void *buffer,const DWORD length)
+  {
+//--- check
+   if(m_file==INVALID_HANDLE_VALUE || buffer==NULL || length<1) 
+      return(0);
+//--- write
+   DWORD written=0;
+   
+   if(WriteFile(m_file,buffer,length,&written,NULL)==0) 
+      written=0;
+//--- return
+   return(written);
+  }
+//+------------------------------------------------------------------+
+//| Seek file pointer                                                |
+//+------------------------------------------------------------------+
+inline UINT64 CMTFile::Seek(const INT64 distance,const DWORD method)
+  {
+//--- check
+   if(m_file==INVALID_HANDLE_VALUE) 
+      return(INVALID_POSITION);
+//--- fill and seek
+   LARGE_INTEGER li={};
+
+   li.QuadPart=distance;
+   li.LowPart=SetFilePointer(m_file,(LONG)li.LowPart,&li.HighPart,method);
+//--- check result
+   if(li.LowPart==INVALID_SET_FILE_POINTER && GetLastError()!=NO_ERROR)
+      return(INVALID_POSITION);
+//--- return new file pointer position
+   return((UINT64)li.QuadPart);
+  }
+//+------------------------------------------------------------------+
+//| Change file size                                                 |
+//+------------------------------------------------------------------+
+inline bool CMTFile::ChangeSize(const UINT64 size)
+  {
+   return(CMTFile::Seek((INT64)size,FILE_BEGIN)==size && SetEndOfFile(m_file));
+  }
+//+------------------------------------------------------------------+
+//| Flush file buffer                                                |
+//+------------------------------------------------------------------+
+inline bool CMTFile::Flush()
+  {
+   if(m_file!=INVALID_HANDLE_VALUE) 
+      return(::FlushFileBuffers(m_file)!=0);
+   return(false);
+  }
+//+------------------------------------------------------------------+
+//| Copy files by mask                                               |
+//+------------------------------------------------------------------+
+inline int CMTFile::FilesCopy(const CMTStr& path,const CMTStr& newpath,const CMTStr& mask,const bool subdir)
+  {
+   CMTStr512        src,dst,name;
+   HANDLE           hSearch;
+   WIN32_FIND_DATAW fnd;
+   int              count=0;
+//--- find files
+   src.Format(L"%s\\%s",path.Str(),mask.Str());
+   if((hSearch=FindFirstFileW(src.Str(), &fnd))!=INVALID_HANDLE_VALUE)
+     {
+      do
+        {
+         //--- skip root directories
+         if(CMTStr::Compare(fnd.cFileName,L".")==0 || CMTStr::Compare(fnd.cFileName,L"..")==0)
+            continue;
+         //--- directory?
+         if(!(fnd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
+           {
+            //--- create source path
+            src.Format(L"%s\\%s",path.Str(),fnd.cFileName);
+            //--- create dst path
+            dst.Format(L"%s\\%s",newpath.Str(),fnd.cFileName);
+            //--- copy file
+            if(::CopyFileW(src.Str(),dst.Str(),FALSE)!=FALSE) count++;
+           }
+         else
+            if(subdir)
+              {
+               //--- create path
+               src.Format(L"%s\\%s",path.Str(),fnd.cFileName);
+               dst.Format(L"%s\\%s",newpath.Str(),fnd.cFileName);
+               //--- create dst path
+               DirectoryCreate(dst);
+               //--- copy files
+               count+=FilesCopy(src,dst,mask,subdir);
+              }
+        } while(FindNextFileW(hSearch,&fnd)!=0);
+      //--- close handle
+      FindClose(hSearch);
+     }
+//--- return copied count
+   return(count);
+  }
+//+------------------------------------------------------------------+
+//| Create directory with subdirectories                             |
+//+------------------------------------------------------------------+
+inline bool CMTFile::DirectoryCreate(const CMTStr& path)
+  {
+   wchar_t *cp,temp[MAX_PATH];
+//--- check directory
+   if(GetFileAttributesW(path.Str())!=INVALID_FILE_ATTRIBUTES) 
+      return(true);
+//--- copy
+   CMTStr::Copy(temp,path.Str());
+//--- parse path and create directories
+   for(cp=temp;*cp!=L'\0';cp++)
+      if(*cp==L'\\')
+        {
+         *cp=L'\0';
+         if(GetFileAttributesW(temp)==INVALID_FILE_ATTRIBUTES)
+            if(!::CreateDirectoryW(temp,NULL)) 
+               return(false);
+         *cp=L'\\';
+        }
+//--- copy remainder
+   if(GetFileAttributesW(temp)==INVALID_FILE_ATTRIBUTES)
+      if(!::CreateDirectoryW(temp,NULL))
+         return(false);
+//--- ok
+   return(true);
+  }
+//+------------------------------------------------------------------+
+//| Directory clean by mask                                          |
+//+------------------------------------------------------------------+
+inline bool CMTFile::DirectoryClean(const CMTStr& path,const CMTStr& mask)
+  {
+   HANDLE           hSearch;
+   WIN32_FIND_DATAW fnd;
+   CMTStrPath       tmp;
+   bool             res=true;
+//--- check
+   if(path.Empty() || path.Len()<=3) 
+      return(false);
+//--- create path
+   tmp.Format(L"%s\\%s",path.Str(),mask.Str());
+//--- search
+   if((hSearch=FindFirstFileW(tmp.Str(),&fnd))!=INVALID_HANDLE_VALUE)
+     {
+      do
+        {
+         //--- directory?
+         if(fnd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
+           {
+            //--- skip root directories
+            if(CMTStr::Compare(fnd.cFileName,L".")==0 || CMTStr::Compare(fnd.cFileName,L"..")==0)
+               continue;
+            //--- create directory path
+            tmp.Format(L"%s\\%s",path.Str(),fnd.cFileName);
+            //--- clean directory
+            DirectoryClean(tmp,mask);
+            //--- delete directory
+            res=::RemoveDirectoryW(tmp.Str()) && res;
+           }
+         else
+           {
+            //--- create file path
+            tmp.Format(L"%s\\%s",path.Str(),fnd.cFileName);
+            //--- delete file
+            res=::DeleteFileW(tmp.Str()) && res;
+           }
+        }
+      while(FindNextFileW(hSearch,&fnd));
+      //--- close handle
+      FindClose(hSearch);
+     }
+//--- result
+   return(res);
+  }
+//+------------------------------------------------------------------+
+//| Full directory remove                                            |
+//+------------------------------------------------------------------+
+inline bool CMTFile::DirectoryRemove(const CMTStr& path)
+  {
+   return(DirectoryClean(path,CMTStr16(L"*")) && ::RemoveDirectoryW(path.Str()));
+  }
+//+------------------------------------------------------------------+

+ 902 - 0
MT5SDK/Classes/MT5APIFormat.h

@@ -0,0 +1,902 @@
+//+------------------------------------------------------------------+
+//|                                                 MetaTrader 5 API |
+//|                   Copyright 2000-2019, MetaQuotes Software Corp. |
+//|                                        http://www.metaquotes.net |
+//+------------------------------------------------------------------+
+#pragma once
+#include <time.h>
+#include "MT5APIStr.h"
+#include "MT5APIMath.h"
+#include "MT5APITime.h"
+#include "..\Bases\MT5APITick.h"
+#include "..\Bases\MT5APIOrder.h"
+#include "..\Bases\MT5APIDeal.h"
+#include "..\Bases\MT5APIPosition.h"
+//+------------------------------------------------------------------+
+//| Format strings                                                   |
+//+------------------------------------------------------------------+
+class SMTFormat
+  {
+private:
+   //--- constants
+   enum constants
+     {
+      SIG_DECIMAL    =L'.',
+      SIG_NEGATIVE   =L'-',
+      SIG_THOUSAND   =L' ',
+      VOLUME_K       =L'K',
+      VOLUME_M       =L'M',
+     };
+
+public:
+   //--- error
+   static LPCWSTR    FormatError(const MTAPIRES retcode);
+   //--- double to string
+   static LPCWSTR    FormatDouble(CMTStr &str,double val,UINT digits);
+   static LPCWSTR    FormatMoney(CMTStr &str,double val,UINT digits);
+   //--- price to string
+   static LPCWSTR    FormatPrice(CMTStr &str,double val,UINT digits,UINT extra_digits=0);
+   static LPCWSTR    FormatPrices(CMTStr &str,MTTickShort& tick,const UINT digits);
+   //--- volume & size
+   static LPCWSTR    FormatVolumeDouble(CMTStr &str,const double volume,const bool compact);
+   static LPCWSTR    FormatVolume(CMTStr &str,const UINT64 volume,const bool compact=true);
+   static LPCWSTR    FormatVolumeExt(CMTStr &str,const UINT64 volume,const bool compact=true);
+   static LPCWSTR    FormatVolumeOrder(CMTStr &str,const UINT64 volume_initial,const UINT64 volume_current);
+   static LPCWSTR    FormatVolumeExtOrder(CMTStr &str,const UINT64 volume_initial,const UINT64 volume_current);
+   static LPCWSTR    FormatSize(CMTStr &str,const double size,const bool compact=true);
+   static LPCWSTR    FormatSizeOrder(CMTStr &str,const double size_initial,const double size_current);
+   //--- date & time
+   static LPCWSTR    FormatDateTime(CMTStr &str,const SYSTEMTIME &st,bool useTime=true,bool useSec=false);
+   static LPCWSTR    FormatDateTime(CMTStr &str,INT64 ctm,bool useTime=true,bool useSec=false);
+   static LPCWSTR    FormatDateTimeMsc(CMTStr &str,const SYSTEMTIME &st,bool useTime=true,bool useSec=false);
+   static LPCWSTR    FormatDateTimeMsc(CMTStr &str,INT64 ctm,bool useTime=true,bool useSec=false);
+   static LPCWSTR    FormatTime(CMTStr &str,INT64 ctm,bool useSec=false);
+   static LPCWSTR    FormatTimeMsc(CMTStr &str,INT64 ctm,bool useSec=false);
+   //--- IP & port
+   static LPCWSTR    FormatIP(CMTStr &str,const UINT ip,const UINT port=0);
+   static LPCWSTR    FormatIP(CMTStr &str,const USHORT* ip,const UINT port=0);
+   //--- positions
+   static LPCWSTR    FormatPositionType(CMTStr &str,const UINT type);
+   //--- orders
+   static LPCWSTR    FormatOrderType(CMTStr &str,const UINT type);
+   static LPCWSTR    FormatOrderStatus(CMTStr &str,const UINT status);
+   static LPCWSTR    FormatOrderTypeFilling(CMTStr &str,const UINT type);
+   static LPCWSTR    FormatOrderTypeTime(CMTStr &str,const UINT type);
+   static LPCWSTR    FormatOrderTypeReason(CMTStr &str,UINT reason);
+   static LPCWSTR    FormatOrderPrice(CMTStr &str,const double price_order,const double price_trigger,const UINT digits);
+   //--- deals
+   static LPCWSTR    FormatDealAction(CMTStr &str,const UINT action);
+   static LPCWSTR    FormatDealEntry(CMTStr &str,const UINT entry);
+   //--- 
+   static LPCWSTR    FormatModifyFlags(CMTStr &str,const UINT modify_flags);
+
+private:
+   //--- UINT64 to string
+   static LPCWSTR    FormatDouble(CMTStr &str,UINT64 val,UINT digits);
+   static LPCWSTR    FormatDoubleBrief(CMTStr &str,UINT64 val,UINT digits);
+   static LPCWSTR    FormatMoney(CMTStr &str,UINT64 val,UINT digits);
+   //--- trim zero
+   static void       TrimZeros(CMTStr &str,UINT extra_digits=UINT_MAX);
+  };
+//+------------------------------------------------------------------+
+//| Retcode description                                              |
+//+------------------------------------------------------------------+
+inline LPCWSTR SMTFormat::FormatError(const MTAPIRES retcode)
+  {
+//--- error description
+   struct ErrorDesc
+     {
+      MTAPIRES          code;
+      LPCWSTR           desc;
+     };
+//--- errors
+   static ErrorDesc errors[]=
+     {
+      { MT_RET_OK,                    L"Done"                             },
+      { MT_RET_OK_NONE,               L"OK/None"                          },
+      { MT_RET_ERROR,                 L"Common error"                     },
+      { MT_RET_ERR_PARAMS,            L"Invalid parameters"               },
+      { MT_RET_ERR_DATA,              L"Invalid data"                     },
+      { MT_RET_ERR_DISK,              L"Disk error"                       },
+      { MT_RET_ERR_MEM,               L"Memory error"                     },
+      { MT_RET_ERR_NETWORK,           L"Network error"                    },
+      { MT_RET_ERR_PERMISSIONS,       L"Not enough permissions"           },
+      { MT_RET_ERR_TIMEOUT,           L"Operation timeout"                },
+      { MT_RET_ERR_CONNECTION,        L"No connection"                    },
+      { MT_RET_ERR_NOSERVICE,         L"Service is not available"         },
+      { MT_RET_ERR_FREQUENT,          L"Too frequent requests"            },
+      { MT_RET_ERR_NOTFOUND,          L"Not found"                        },
+      { MT_RET_ERR_SHUTDOWN,          L"Server shutdown in progress"      },
+      { MT_RET_ERR_CANCEL,            L"Operation was canceled"           },
+      { MT_RET_ERR_DUPLICATE,         L"Duplicate attempt"                },
+      //--- auth errors
+      { MT_RET_AUTH_CLIENT_INVALID,   L"Invalid terminal type"            },
+      { MT_RET_AUTH_ACCOUNT_INVALID,  L"Invalid account"                  },
+      { MT_RET_AUTH_ACCOUNT_DISABLED, L"Account disabled"                 },
+      { MT_RET_AUTH_ADVANCED,         L"Advanced authorization"           },
+      { MT_RET_AUTH_CERTIFICATE,      L"Certificate required"             },
+      { MT_RET_AUTH_CERTIFICATE_BAD,  L"Invalid certificate"              },
+      { MT_RET_AUTH_NOTCONFIRMED,     L"Certificate is not confirmed"     },
+      { MT_RET_AUTH_SERVER_INTERNAL,  L"Attempt to connect to non-access server" },
+      { MT_RET_AUTH_SERVER_BAD,       L"Invalid or fake server"           },
+      { MT_RET_AUTH_UPDATE_ONLY,      L"Only updates available"           },
+      { MT_RET_AUTH_CLIENT_OLD,       L"Old version"                      },
+      { MT_RET_AUTH_MANAGER_NOCONFIG, L"Account doesn't have manager config" },
+      { MT_RET_AUTH_MANAGER_IPBLOCK,  L"IP address unallowed for manager" },
+      { MT_RET_AUTH_GROUP_INVALID,    L"Group is not initialized, server restart needed" },
+      { MT_RET_AUTH_CA_DISABLED,      L"Certificate generation disabled"  },
+      { MT_RET_AUTH_INVALID_ID,       L"Invalid or disabled server id [check server id]"},
+      { MT_RET_AUTH_INVALID_IP,       L"Unallowed address [check server ip address]"    },
+      { MT_RET_AUTH_INVALID_TYPE,     L"Invalid server type [check server id and type]" },
+      { MT_RET_AUTH_SERVER_BUSY,      L"Server is busy"                   },
+      { MT_RET_AUTH_SERVER_CERT,      L"Invalid server certificate or invalid local time" },
+      { MT_RET_AUTH_ACCOUNT_UNKNOWN,  L"Unknown account"                  },
+      { MT_RET_AUTH_SERVER_OLD,       L"Old server version"               },
+      { MT_RET_AUTH_SERVER_LIMIT,     L"Server cannot be connected due to license limitation" },
+      { MT_RET_AUTH_MOBILE_DISABLED,  L"Mobile terminal isn't allowed in license"             },
+      { MT_RET_AUTH_MANAGER_TYPE,     L"Connection type is not permitted for manager"         },
+      { MT_RET_AUTH_DEMO_DISABLED,    L"Demo allocation disabled"         },
+      { MT_RET_AUTH_RESET_PASSWORD,   L"Master password must be changed"  },
+      //--- config errors
+      { MT_RET_CFG_LAST_ADMIN,        L"Last admin config cannot be deleted" },
+      { MT_RET_CFG_LAST_ADMIN_GROUP,  L"Last admin group cannot be deleted"  },
+      { MT_RET_CFG_NOT_EMPTY,         L"Accounts or trades in group/symbol"  },
+      { MT_RET_CFG_INVALID_RANGE,     L"Invalid account or trade ranges"},
+      { MT_RET_CFG_NOT_MANAGER_LOGIN, L"Account doesn't belong to manager group"},
+      { MT_RET_CFG_BUILTIN,           L"Built-in protected config"        },
+      { MT_RET_CFG_DUPLICATE,         L"Configuration duplicate"          },
+      { MT_RET_CFG_LIMIT_REACHED,     L"Configuration limit reached"      },
+      { MT_RET_CFG_NO_ACCESS_TO_MAIN, L"Invalid network configuration"    },
+      { MT_RET_CFG_DEALER_ID_EXIST,   L"Dealer with same ID already exists"       },
+      { MT_RET_CFG_BIND_ADDR_EXIST,   L"Binding address already exists"              },
+      { MT_RET_CFG_WORKING_TRADE,     L"Attempt to delete working trade server" },
+      { MT_RET_CFG_GATEWAY_NAME_EXIST,L"Gateway with same name already exists"  },
+      { MT_RET_CFG_SWITCH_TO_BACKUP,  L"Server must be switched to backup mode" },
+      { MT_RET_CFG_NO_BACKUP_MODULE,  L"Backup server module is absent"         },
+      { MT_RET_CFG_NO_TRADE_MODULE,   L"Trade server module is absent"          },
+      { MT_RET_CFG_NO_HISTORY_MODULE, L"History server module is absent"        },
+      { MT_RET_CFG_ANOTHER_SWITCH,    L"Another switching process in progress"  },
+      { MT_RET_CFG_NO_LICENSE_FILE,   L"License file is absent"                 },
+      { MT_RET_CFG_GATEWAY_LOGIN_EXIST,L"Gateway with same login already exist" },
+      //--- client errors
+      { MT_RET_USR_LAST_ADMIN,        L"Last admin account cannot be deleted" },
+      { MT_RET_USR_LOGIN_EXHAUSTED,   L"Login range exhausted"             },
+      { MT_RET_USR_LOGIN_PROHIBITED,  L"Login reserved at another server"  },
+      { MT_RET_USR_LOGIN_EXIST,       L"Account already exists"            },
+      { MT_RET_USR_SUICIDE,           L"Attempt of self-deletion"          },
+      { MT_RET_USR_INVALID_PASSWORD,  L"Invalid account password"          },
+      { MT_RET_USR_LIMIT_REACHED,     L"User limit reached"                },
+      { MT_RET_USR_HAS_TRADES,        L"Account has open trades"           },
+      { MT_RET_USR_DIFFERENT_SERVERS, L"Attempt to move account to different server"              },
+      { MT_RET_USR_DIFFERENT_CURRENCY,L"Attempt to move account to group with different currency" },
+      { MT_RET_USR_IMPORT_BALANCE,    L"Account balance import error"      },
+      { MT_RET_USR_IMPORT_GROUP,      L"Imported account has invalid group"},
+      { MT_RET_USR_ACCOUNT_EXIST,     L"Account already exist"             },
+      //--- trade errors
+      { MT_RET_TRADE_LIMIT_REACHED,   L"Order or deal limit reached"      },
+      { MT_RET_TRADE_ORDER_EXIST,     L"Order already exists"             },
+      { MT_RET_TRADE_ORDER_EXHAUSTED, L"Order range exhausted"            },
+      { MT_RET_TRADE_DEAL_EXHAUSTED,  L"Deal range exhausted"             },
+      { MT_RET_TRADE_MAX_MONEY,       L"Money limit reached"              },
+      { MT_RET_TRADE_DEAL_EXIST,      L"Deal already exists"              },
+      { MT_RET_TRADE_ORDER_PROHIBITED,L"Order ticket reserved at another server" },
+      { MT_RET_TRADE_DEAL_PROHIBITED, L"Deal ticket reserved at another server"  },
+      //--- report errors
+      { MT_RET_REPORT_SNAPSHOT,       L"Base snapshot error"              },
+      { MT_RET_REPORT_NOTSUPPORTED,   L"Method is not supported by this report" },
+      { MT_RET_REPORT_NODATA,         L"No data for report"               },
+      { MT_RET_REPORT_TEMPLATE_BAD,   L"Bad template"                     },
+      { MT_RET_REPORT_TEMPLATE_END,   L"End of template"                  },
+      { MT_RET_REPORT_INVALID_ROW,    L"Invalid row size"                 },
+      { MT_RET_REPORT_LIMIT_REPEAT,   L"Tag repeat limit reached "        },
+      { MT_RET_REPORT_LIMIT_REPORT,   L"Report size limit reached"        },
+      //--- history errors
+      { MT_RET_HST_SYMBOL_NOTFOUND,   L"Symbol not found, try to restart history server" },
+      //--- request errors
+      { MT_RET_REQUEST_INWAY,         L"Request on the way"               },
+      { MT_RET_REQUEST_ACCEPTED,      L"Request accepted"                 },
+      { MT_RET_REQUEST_PROCESS,       L"Request processed"                },
+      { MT_RET_REQUEST_REQUOTE,       L"Requote"                          },
+      { MT_RET_REQUEST_PRICES,        L"Prices"                           },
+      { MT_RET_REQUEST_REJECT,        L"Request rejected"                 },
+      { MT_RET_REQUEST_CANCEL,        L"Request canceled"                 },
+      { MT_RET_REQUEST_PLACED,        L"Order placed"                     },
+      { MT_RET_REQUEST_DONE,          L"Request executed"                 },
+      { MT_RET_REQUEST_DONE_PARTIAL,  L"Request executed partially"       },
+      { MT_RET_REQUEST_ERROR,         L"Request error"                    },
+      { MT_RET_REQUEST_TIMEOUT,       L"Request timeout"                  },
+      { MT_RET_REQUEST_INVALID,       L"Invalid request"                  },
+      { MT_RET_REQUEST_INVALID_VOLUME,L"Invalid volume"                   },
+      { MT_RET_REQUEST_INVALID_PRICE, L"Invalid price"                    },
+      { MT_RET_REQUEST_INVALID_STOPS, L"Invalid stops"                    },
+      { MT_RET_REQUEST_TRADE_DISABLED,L"Trade disabled"                   },
+      { MT_RET_REQUEST_MARKET_CLOSED, L"Market closed"                    },
+      { MT_RET_REQUEST_NO_MONEY,      L"No money"                         },
+      { MT_RET_REQUEST_PRICE_CHANGED, L"Price changed"                    },
+      { MT_RET_REQUEST_PRICE_OFF,     L"No prices"                        },
+      { MT_RET_REQUEST_INVALID_EXP,   L"Invalid expiration"               },
+      { MT_RET_REQUEST_ORDER_CHANGED, L"Order has been changed already"   },
+      { MT_RET_REQUEST_TOO_MANY,      L"Too many trade requests"          },
+      { MT_RET_REQUEST_AT_DISABLED_SERVER, L"AutoTrading disabled by server" },
+      { MT_RET_REQUEST_AT_DISABLED_CLIENT, L"AutoTrading disabled by client" },
+      { MT_RET_REQUEST_LOCKED,             L"Order locked by dealer"         },
+      { MT_RET_REQUEST_FROZEN,             L"Modification failed due to order or position being close to market" },
+      { MT_RET_REQUEST_INVALID_FILL,       L"Unsupported filling mode"       },
+      { MT_RET_REQUEST_RETURN,             L"Request returned in queue"      },
+      { MT_RET_REQUEST_DONE_CANCEL,        L"Request executed partially"     },
+      { MT_RET_REQUEST_ONLY_REAL,          L"Allowed for real accounts only" },
+      { MT_RET_REQUEST_LIMIT_ORDERS,       L"Order limit reached"            },
+      { MT_RET_REQUEST_LIMIT_VOLUME,       L"Volume limit reached"           },
+      { MT_RET_REQUEST_POSITION_CLOSED,    L"Position already closed"        },
+      { MT_RET_REQUEST_EXECUTION_SKIPPED,    L"Execution doesn't belong to this server" },
+      { MT_RET_REQUEST_INVALID_CLOSE_VOLUME, L"Volume to be closed exceeds the position volume" },
+      { MT_RET_REQUEST_CLOSE_ORDER_EXIST,    L"Order to close this position already exists"  },
+      { MT_RET_REQUEST_REQUOTE_RETURN,     L"Requote"                        },
+      { MT_RET_REQUEST_LIMIT_POSITIONS,    L"Position limit reached"         },
+      { MT_RET_REQUEST_REJECT_CANCEL,      L"Request rejected, order will be canceled"},
+      { MT_RET_REQUEST_LONG_ONLY,          L"Only long positions are allowed"         },
+      { MT_RET_REQUEST_SHORT_ONLY,         L"Only short positions are allowed"        },
+      { MT_RET_REQUEST_CLOSE_ONLY,         L"Only position closing is allowed"       },
+      //--- API retcodes
+      { MT_RET_ERR_NOTIMPLEMENT,     	   L"Not implemented"                },
+      { MT_RET_ERR_NOTMAIN,                L"Operation must be performed on main server"},
+      { MT_RET_ERR_NOTSUPPORTED,           L"Command doesn't supported"                 },
+      { MT_RET_ERR_DEADLOCK,               L"Operation canceled due possible deadlock"  },
+      { MT_RET_ERR_LOCKED,                 L"Operation on locked entity"                },
+      //--- default
+      { INT_MAX,                        L"Network problem"                },
+     };  
+//--- search description
+   for(UINT i=0;i<_countof(errors);i++)
+      if(errors[i].code==retcode) return(errors[i].desc);
+//--- default value
+   return(L"Unknown error");
+  }
+//+------------------------------------------------------------------+
+//| Format double value                                              |
+//+------------------------------------------------------------------+
+inline LPCWSTR SMTFormat::FormatDouble(CMTStr &str,double val,UINT digits)
+  {
+   double valdec;
+   UINT   digits_int=(digits<10)?digits:10;
+//--- convert to integer
+   valdec=val*SMTMath::DecPow((int)digits_int);
+//--- check size
+   if(valdec>=double(_I64_MAX/100i64) || valdec<=double(_I64_MIN/100i64))
+     {
+      CMTStr32 fmt;
+      int    pos;
+      //--- format using CRT
+      fmt.Format(L"%%.0%ulf",digits_int);
+      str.Format(fmt.Str(),val);
+      //--- decimal point
+      pos=str.FindRChar(L'.');
+      if(pos>=0) str.Buffer()[pos]=SIG_DECIMAL;
+      //---
+      return(str.Str());
+     }
+//--- format fast
+   if(val>=0)
+      FormatDouble(str,UINT64(valdec+0.5),digits_int);
+   else
+     {
+      FormatDouble(str,UINT64(0.5-valdec),digits_int);
+      str.Insert(0,SIG_NEGATIVE);
+     }
+//---
+   return(str.Str());
+  }
+//+------------------------------------------------------------------+
+//| Format money                                                     |
+//+------------------------------------------------------------------+
+inline LPCWSTR SMTFormat::FormatMoney(CMTStr &str,double val,UINT digits)
+  {
+   double valdec;
+//--- convert to integer
+   valdec=val*SMTMath::DecPow((int)digits);
+//--- check size
+   if(valdec>=double(_I64_MAX/100i64) || valdec<=double(_I64_MIN/100i64))
+     {
+      CMTStr32 fmt;
+      int    pos;
+      //--- format using CRT
+      fmt.Format(L"%%.0%ulf",digits);
+      str.Format(fmt.Str(),val);
+      //--- decimal point
+      pos=str.FindRChar(L'.');
+      if(pos>=0) str.Buffer()[pos]=SIG_DECIMAL;
+      //--- insert thousands delimeters
+      for(pos=str.FindRChar(L'.')-3;pos>=3;pos-=3)
+         str.Insert((UINT)pos,SIG_THOUSAND);
+      //---
+      return(str.Str());
+     }
+//--- format fast
+   if(val>=0)
+      FormatMoney(str,UINT64(valdec+0.5),digits);
+   else
+     {
+      FormatMoney(str,UINT64(0.5-valdec),digits);
+      str.Insert(0,SIG_NEGATIVE);
+     }
+//---
+   return(str.Str());
+  }
+//+------------------------------------------------------------------+
+//| Format price                                                     |
+//+------------------------------------------------------------------+
+inline LPCWSTR SMTFormat::FormatPrice(CMTStr &str,double val,UINT digits,UINT extra_digits)
+  {
+//--- format with extra digits
+   FormatDouble(str,val,digits+extra_digits);
+//--- trim zero
+   TrimZeros(str,extra_digits);
+//--- return
+   return(str.Str());
+  }
+//+------------------------------------------------------------------+
+//| Current prices                                                   |
+//+------------------------------------------------------------------+
+inline LPCWSTR SMTFormat::FormatPrices(CMTStr &str,MTTickShort& tick,const UINT digits)
+  {
+   CMTStr32 sbid,sask,slast;
+//--- check last prices
+   if(!tick.last) str.Format(L"%s / %s"     ,FormatPrice(sbid,tick.bid,digits),FormatPrice(sask,tick.ask,digits));
+   else           str.Format(L"%s / %s / %s",FormatPrice(sbid,tick.bid,digits),FormatPrice(sask,tick.ask,digits),FormatPrice(slast,tick.last,digits));
+//--- return
+   return(str.Str());
+  }
+//+------------------------------------------------------------------+
+//| Format trade volume                                              |
+//+------------------------------------------------------------------+
+inline LPCWSTR SMTFormat::FormatVolumeDouble(CMTStr &str,const double volume,const bool compact/*=true*/)
+  {
+//--- check M
+   if(compact && volume>1000000.0)
+     {
+      //--- 
+      str.Format(L"%.8lf",volume/1000000.0);
+      TrimZeros(str,8);
+      str.Append(VOLUME_M);
+      //--- 
+      return(str.Str());
+     }
+//--- check K
+   if(compact && volume>1000.0)
+     {
+      //--- 
+      str.Format(L"%.5lf",volume/1000.0);
+      TrimZeros(str,5);
+      str.Append(VOLUME_K);
+      //--- 
+      return(str.Str());
+     }
+//--- normal method
+   FormatDouble(str,volume,MTAPI_VOLUME_EXT_DIGITS);
+   TrimZeros(str,6);
+   return(str.Str());
+  }
+//+------------------------------------------------------------------+
+//| Format trade volume                                              |
+//+------------------------------------------------------------------+
+inline LPCWSTR SMTFormat::FormatVolume(CMTStr &str,const UINT64 volume,const bool compact/*=true*/)
+  {
+   return(FormatVolumeDouble(str,SMTMath::VolumeToDouble(volume),compact));
+  }
+//+------------------------------------------------------------------+
+//| Format trade volume                                              |
+//+------------------------------------------------------------------+
+inline LPCWSTR SMTFormat::FormatVolumeExt(CMTStr &str,const UINT64 volume,const bool compact/*=true*/)
+  {
+   return(FormatVolumeDouble(str,SMTMath::VolumeExtToDouble(volume),compact));
+  }
+//+------------------------------------------------------------------+
+//| Format order volume                                              |
+//+------------------------------------------------------------------+
+inline LPCWSTR SMTFormat::FormatVolumeOrder(CMTStr &str,const UINT64 volume_initial,const UINT64 volume_current)
+  {
+   CMTStr64 vol_filled,vol_init;
+//--- 
+   str.Format(L"%s / %s",FormatVolume(vol_init,volume_initial),
+                         FormatVolume(vol_filled,volume_initial-volume_current));
+//--- summary
+   return(str.Str());
+  }
+//+------------------------------------------------------------------+
+//| Format order volume                                              |
+//+------------------------------------------------------------------+
+inline LPCWSTR SMTFormat::FormatVolumeExtOrder(CMTStr &str,const UINT64 volume_initial,const UINT64 volume_current)
+  {
+   CMTStr64 vol_filled,vol_init;
+//--- 
+   str.Format(L"%s / %s",FormatVolumeExt(vol_init,volume_initial),
+                         FormatVolumeExt(vol_filled,volume_initial-volume_current));
+//--- summary
+   return(str.Str());
+  }
+//+------------------------------------------------------------------+
+//| Format trade amount                                              |
+//+------------------------------------------------------------------+
+inline LPCWSTR SMTFormat::FormatSize(CMTStr &str,const double volume,const bool compact/*=true*/)
+  {
+   return(FormatVolumeDouble(str,volume,compact));
+  }
+//+------------------------------------------------------------------+
+//| Format order amount                                              |
+//+------------------------------------------------------------------+
+inline LPCWSTR SMTFormat::FormatSizeOrder(CMTStr &str,const double size_initial,const double size_current)
+  {
+   CMTStr64 sz_filled,sz_current;
+//---
+   str.Format(L"%s / %s",FormatSize(sz_filled,size_initial),
+                         FormatSize(sz_current,size_initial-size_current));
+//---
+   return(str.Str());
+  }
+//+------------------------------------------------------------------+
+//| Format date & time                                               |
+//+------------------------------------------------------------------+
+inline LPCWSTR SMTFormat::FormatDateTime(CMTStr &str,const SYSTEMTIME &st,bool useTime/*=true*/,bool useSec/*=false*/)
+  {
+//---
+   if(useTime)
+     {
+      if(useSec)
+         str.Format(L"%04d.%02d.%02d %02d:%02d:%02d",st.wYear,st.wMonth,st.wDay,st.wHour,st.wMinute,st.wSecond);
+      else
+         str.Format(L"%04d.%02d.%02d %02d:%02d",st.wYear,st.wMonth,st.wDay,st.wHour,st.wMinute);
+     }
+   else str.Format(L"%04d.%02d.%02d",st.wYear,st.wMonth,st.wDay);
+//---
+   return(str.Str());
+  }
+//+------------------------------------------------------------------+
+//| Format date & time                                               |
+//+------------------------------------------------------------------+
+inline LPCWSTR SMTFormat::FormatDateTime(CMTStr &str,INT64 ctm,bool useTime/*=true*/,bool useSec/*=false*/)
+  {
+   tm ttm={};
+//---
+   if(!SMTTime::ParseTime(ctm,&ttm)) return(str.Str());
+//---
+   if(useTime)
+     {
+      if(useSec)
+         str.Format(L"%04d.%02d.%02d %02d:%02d:%02d",ttm.tm_year+1900,ttm.tm_mon+1,ttm.tm_mday,ttm.tm_hour,ttm.tm_min,ttm.tm_sec);
+      else
+         str.Format(L"%04d.%02d.%02d %02d:%02d",ttm.tm_year+1900,ttm.tm_mon+1,ttm.tm_mday,ttm.tm_hour,ttm.tm_min);
+     }
+   else str.Format(L"%04d.%02d.%02d",ttm.tm_year+1900,ttm.tm_mon+1,ttm.tm_mday);
+//---
+   return(str.Str());
+  }
+//+------------------------------------------------------------------+
+//| Format date & time                                               |
+//+------------------------------------------------------------------+
+inline LPCWSTR SMTFormat::FormatDateTimeMsc(CMTStr &str,const SYSTEMTIME &st,bool useTime/*=true*/,bool useSec/*=false*/)
+  {
+//---
+   if(useTime)
+     {
+      if(useSec)
+         str.Format(L"%04d.%02d.%02d %02d:%02d:%02d.%03u",st.wYear,st.wMonth,st.wDay,st.wHour,st.wMinute,st.wSecond,st.wMilliseconds);
+      else
+         str.Format(L"%04d.%02d.%02d %02d:%02d",st.wYear,st.wMonth,st.wDay,st.wHour,st.wMinute);
+     }
+   else str.Format(L"%04d.%02d.%02d",st.wYear,st.wMonth,st.wDay);
+//---
+   return(str.Str());
+  }
+//+------------------------------------------------------------------+
+//| Format date & time                                               |
+//+------------------------------------------------------------------+
+inline LPCWSTR SMTFormat::FormatDateTimeMsc(CMTStr &str,INT64 ctm,bool useTime/*=true*/,bool useSec/*=false*/)
+  {
+   tm ttm={};
+//---
+   if(!SMTTime::ParseTime(ctm/1000,&ttm))
+      return(str.Str());
+//---
+   if(useTime)
+     {
+      if(useSec)
+         str.Format(L"%04d.%02d.%02d %02d:%02d:%02d.%03d",ttm.tm_year+1900,ttm.tm_mon+1,ttm.tm_mday,ttm.tm_hour,ttm.tm_min,ttm.tm_sec,(int)(ctm%1000));
+      else
+         str.Format(L"%04d.%02d.%02d %02d:%02d",ttm.tm_year+1900,ttm.tm_mon+1,ttm.tm_mday,ttm.tm_hour,ttm.tm_min);
+     }
+   else str.Format(L"%04d.%02d.%02d",ttm.tm_year+1900,ttm.tm_mon+1,ttm.tm_mday);
+//---
+   return(str.Str());
+  }
+//+------------------------------------------------------------------+
+//| Format time                                                      |
+//+------------------------------------------------------------------+
+inline LPCWSTR SMTFormat::FormatTime(CMTStr &str,INT64 ctm,bool useSec/*=false*/)
+  {
+   tm ttm={};
+//---
+   if(!SMTTime::ParseTime(ctm,&ttm))
+      return(str.Str());
+//---
+   if(useSec) str.Format(L"%02d:%02d:%02d",ttm.tm_hour,ttm.tm_min,ttm.tm_sec);
+   else       str.Format(L"%02d:%02d",ttm.tm_hour,ttm.tm_min);
+//---
+   return(str.Str());
+  }
+//+------------------------------------------------------------------+
+//| Format time                                                      |
+//+------------------------------------------------------------------+
+inline LPCWSTR SMTFormat::FormatTimeMsc(CMTStr &str,INT64 ctm,bool useSec/*=false*/)
+  {
+   tm ttm={};
+//---
+   if(!SMTTime::ParseTime(ctm/1000,&ttm))
+      return(str.Str());
+//---
+   if(useSec) str.Format(L"%02d:%02d:%02d.%03d",ttm.tm_hour,ttm.tm_min,ttm.tm_sec,(int)(ctm%1000));
+   else       str.Format(L"%02d:%02d",ttm.tm_hour,ttm.tm_min);
+//---
+   return(str.Str());
+  }
+//+------------------------------------------------------------------+
+//| Format IP[:port]                                                 |
+//+------------------------------------------------------------------+
+inline LPCWSTR SMTFormat::FormatIP(CMTStr &str,const UINT ip,const UINT port/*=0*/)
+  {
+   if(port>0) str.Format(L"%d.%d.%d.%d:%u",ip&255,(ip>>8)&255,(ip>>16)&255,(ip>>24)&255,port);
+   else       str.Format(L"%d.%d.%d.%d",   ip&255,(ip>>8)&255,(ip>>16)&255,(ip>>24)&255);
+//---
+   return(str.Str());
+  }
+//+------------------------------------------------------------------+
+//| Format IP[:port]                                                 |
+//+------------------------------------------------------------------+
+inline LPCWSTR SMTFormat::FormatIP(CMTStr &str,const USHORT *ip,const UINT port/*=0*/)
+  {
+   if(ip)
+     {
+      if(port>0)
+         str.Format(L"[%04x:04x:04x:04x:04x:04x:04x:04x]:%u",
+                    ip[0],ip[1],ip[2],ip[3],ip[4],ip[5],ip[6],ip[7],port);
+      else
+         str.Format(L"[%04x:04x:04x:04x:04x:04x:04x:04x]",
+                    ip[0],ip[1],ip[2],ip[3],ip[4],ip[5],ip[6],ip[7]);
+     }
+//---
+   return(str.Str());
+  }
+//+------------------------------------------------------------------+
+//| Position type                                                    |
+//+------------------------------------------------------------------+
+inline LPCWSTR SMTFormat::FormatPositionType(CMTStr &str,const UINT type)
+  {
+//--- clear
+   str.Clear();
+//--- check type
+   switch(type)
+     {
+      case IMTPosition::POSITION_BUY  : str.Assign(L"buy");  break;
+      case IMTPosition::POSITION_SELL : str.Assign(L"sell"); break;
+     }
+//--- return
+   return(str.Str());
+  }
+//+------------------------------------------------------------------+
+//| Order type                                                       |
+//+------------------------------------------------------------------+
+inline LPCWSTR SMTFormat::FormatOrderType(CMTStr &str,const UINT type)
+  {
+//--- clear
+   str.Clear();
+//--- check type
+   switch(type)
+     {
+      case IMTOrder::OP_BUY            : str.Assign(L"buy");             break;
+      case IMTOrder::OP_SELL           : str.Assign(L"sell");            break;
+      case IMTOrder::OP_BUY_LIMIT      : str.Assign(L"buy limit");       break;
+      case IMTOrder::OP_SELL_LIMIT     : str.Assign(L"sell limit");      break;
+      case IMTOrder::OP_BUY_STOP       : str.Assign(L"buy stop");        break;
+      case IMTOrder::OP_SELL_STOP      : str.Assign(L"sell stop");       break;
+      case IMTOrder::OP_BUY_STOP_LIMIT : str.Assign(L"buy stop limit");  break;
+      case IMTOrder::OP_SELL_STOP_LIMIT: str.Assign(L"sell stop limit"); break;
+     }
+//--- return
+   return(str.Str());
+  }
+//+------------------------------------------------------------------+
+//| Order status                                                     |
+//+------------------------------------------------------------------+
+inline LPCWSTR SMTFormat::FormatOrderStatus(CMTStr &str,const UINT status)
+  {
+//--- clear
+   str.Clear();
+//--- check type
+   switch(status)
+     {
+      case IMTOrder::ORDER_STATE_STARTED :  str.Assign(L"started");  break;
+      case IMTOrder::ORDER_STATE_PLACED  :  str.Assign(L"placed");   break;
+      case IMTOrder::ORDER_STATE_CANCELED:  str.Assign(L"canceled"); break;
+      case IMTOrder::ORDER_STATE_PARTIAL :  str.Assign(L"partial");  break;
+      case IMTOrder::ORDER_STATE_FILLED  :  str.Assign(L"filled");   break;
+      case IMTOrder::ORDER_STATE_REJECTED:  str.Assign(L"rejected"); break;
+      case IMTOrder::ORDER_STATE_EXPIRED :  str.Assign(L"expired");  break;
+      case IMTOrder::ORDER_STATE_REQUEST_ADD   : str.Assign(L"request adding");       break;
+      case IMTOrder::ORDER_STATE_REQUEST_MODIFY: str.Assign(L"request modification"); break;
+      case IMTOrder::ORDER_STATE_REQUEST_CANCEL: str.Assign(L"request cancelling");   break;
+     }
+//--- return
+   return(str.Str());
+  }
+//+------------------------------------------------------------------+
+//| Order filling type                                               |
+//+------------------------------------------------------------------+
+inline LPCWSTR SMTFormat::FormatOrderTypeFilling(CMTStr &str,const UINT type)
+  {
+//--- clear
+   str.Clear();
+//--- check type
+   switch(type)
+     {
+      case IMTOrder::ORDER_FILL_FOK   : str.Assign(L"fill or kill");        break;
+      case IMTOrder::ORDER_FILL_IOC   : str.Assign(L"immediate or cancel"); break;
+      case IMTOrder::ORDER_FILL_RETURN: str.Assign(L"return");              break;
+     }
+//--- return
+   return(str.Str());
+  }
+//+------------------------------------------------------------------+
+//| Order expiration type                                            |
+//+------------------------------------------------------------------+
+inline LPCWSTR SMTFormat::FormatOrderTypeTime(CMTStr &str,const UINT type)
+  {
+//--- clear
+   str.Clear();
+//--- check type
+   switch(type)
+     {
+      case IMTOrder::ORDER_TIME_GTC      : str.Assign(L"gtc");       break;
+      case IMTOrder::ORDER_TIME_DAY      : str.Assign(L"day");       break;
+      case IMTOrder::ORDER_TIME_SPECIFIED: str.Assign(L"specified"); break;
+     }
+//--- return
+   return(str.Str());
+  }
+//+------------------------------------------------------------------+
+//| Order reason                                                     |
+//+------------------------------------------------------------------+
+inline LPCWSTR SMTFormat::FormatOrderTypeReason(CMTStr &str,UINT reason)
+  {
+//--- clear
+   str.Clear();
+//--- check type
+   switch(reason)
+     {
+      case IMTOrder::ORDER_REASON_CLIENT            : str.Assign(L"Client");           break;
+      case IMTOrder::ORDER_REASON_EXPERT            : str.Assign(L"Expert");           break;
+      case IMTOrder::ORDER_REASON_DEALER            : str.Assign(L"Dealer");           break;
+      case IMTOrder::ORDER_REASON_SL                : str.Assign(L"Stop loss");        break;
+      case IMTOrder::ORDER_REASON_TP                : str.Assign(L"Take profit");      break;
+      case IMTOrder::ORDER_REASON_SO                : str.Assign(L"Stop out");         break;
+      case IMTOrder::ORDER_REASON_ROLLOVER          : str.Assign(L"Rollover");         break;
+      case IMTOrder::ORDER_REASON_EXTERNAL_CLIENT   : str.Assign(L"External Client");  break;
+      case IMTOrder::ORDER_REASON_VMARGIN           : str.Assign(L"Variation margin"); break;
+      case IMTOrder::ORDER_REASON_GATEWAY           : str.Assign(L"Gateway");          break;
+      case IMTOrder::ORDER_REASON_SIGNAL            : str.Assign(L"Signal");           break;
+      case IMTOrder::ORDER_REASON_SETTLEMENT        : str.Assign(L"Settlement");       break;
+      case IMTOrder::ORDER_REASON_TRANSFER          : str.Assign(L"Transfer");         break;
+      case IMTOrder::ORDER_REASON_SYNC              : str.Assign(L"Synchronization");  break;
+      case IMTOrder::ORDER_REASON_EXTERNAL_SERVICE  : str.Assign(L"External Service"); break;
+      case IMTOrder::ORDER_REASON_MIGRATION         : str.Assign(L"Migration");        break;
+      case IMTOrder::ORDER_REASON_MOBILE            : str.Assign(L"Mobile");           break;
+      case IMTOrder::ORDER_REASON_WEB               : str.Assign(L"Web");              break;
+      case IMTOrder::ORDER_REASON_SPLIT             : str.Assign(L"Split");            break;
+     }
+//--- return
+   return(str.Str());
+  }
+//+------------------------------------------------------------------+
+//| Order price                                                      |
+//+------------------------------------------------------------------+
+inline LPCWSTR SMTFormat::FormatOrderPrice(CMTStr &str,const double price_order,const double price_trigger,const UINT digits)
+  {
+   CMTStr64 price,trigger;
+//--- clear
+   str.Clear();
+//--- check trigger price
+   if(price_trigger)
+     {
+      FormatPrice(price,price_order,digits);
+      FormatPrice(trigger,price_trigger,digits);
+      str.Format(L"%s (%s)",price.Str(),trigger.Str());
+     }
+   else
+     {
+      if(price_order!=0) FormatPrice(str,price_order,digits);
+      else               str.Assign(L"market");
+     }
+//--- return
+   return(str.Str());
+  }
+//+------------------------------------------------------------------+
+//| Deal action                                                      |
+//+------------------------------------------------------------------+
+inline LPCWSTR SMTFormat::FormatDealAction(CMTStr &str,const UINT action)
+  {
+//--- clear
+   str.Clear();
+//--- check type
+   switch(action)
+     {
+      case IMTDeal::DEAL_BUY       : str.Assign(L"buy");        break;
+      case IMTDeal::DEAL_SELL      : str.Assign(L"sell");       break;
+      case IMTDeal::DEAL_BALANCE   : str.Assign(L"balance");    break;
+      case IMTDeal::DEAL_CREDIT    : str.Assign(L"credit");     break;
+      case IMTDeal::DEAL_CHARGE    : str.Assign(L"charge");     break;
+      case IMTDeal::DEAL_CORRECTION: str.Assign(L"correction"); break;
+      case IMTDeal::DEAL_BONUS     : str.Assign(L"bonus");      break;
+      case IMTDeal::DEAL_COMMISSION: str.Assign(L"commission"); break;
+      case IMTDeal::DEAL_COMMISSION_DAILY  : str.Assign(L"daily commission");         break;
+      case IMTDeal::DEAL_COMMISSION_MONTHLY: str.Assign(L"monthly commission");       break;
+      case IMTDeal::DEAL_AGENT_DAILY       : str.Assign(L"daily agent commission");   break;
+      case IMTDeal::DEAL_AGENT_MONTHLY     : str.Assign(L"monthly agent commission"); break;
+      case IMTDeal::DEAL_INTERESTRATE      : str.Assign(L"interest rate");            break;
+      case IMTDeal::DEAL_BUY_CANCELED      : str.Assign(L"canceled buy"); 	      break;
+      case IMTDeal::DEAL_SELL_CANCELED     : str.Assign(L"canceled sell");            break;
+      case IMTDeal::DEAL_DIVIDEND          : str.Assign(L"dividend");                 break;
+      case IMTDeal::DEAL_DIVIDEND_FRANKED  : str.Assign(L"franked dividend");         break;
+      case IMTDeal::DEAL_TAX               : str.Assign(L"tax");                      break;
+      case IMTDeal::DEAL_AGENT             : str.Assign(L"agent commission");         break;
+      case IMTDeal::DEAL_SO_COMPENSATION   : str.Assign(L"so compensation");          break;
+     }
+//--- return
+   return(str.Str());
+  }
+//+------------------------------------------------------------------+
+//| Deal direction                                                   |
+//+------------------------------------------------------------------+
+inline LPCWSTR SMTFormat::FormatDealEntry(CMTStr &str,const UINT entry)
+  {
+//--- clear
+   str.Clear();
+//--- check type   
+   switch(entry)
+     {
+      case IMTDeal::ENTRY_IN    : str.Assign(L"in");     break;
+      case IMTDeal::ENTRY_OUT   : str.Assign(L"out");    break;
+      case IMTDeal::ENTRY_INOUT : str.Assign(L"in/out"); break;
+      case IMTDeal::ENTRY_OUT_BY: str.Assign(L"out by"); break;
+     }
+//--- return
+   return(str.Str());
+  }
+//+------------------------------------------------------------------+
+//| Modify flags                                                     |
+//+------------------------------------------------------------------+
+inline LPCWSTR SMTFormat::FormatModifyFlags(CMTStr &str,const UINT modify_flags)
+  {
+//--- description
+   static struct
+     {
+      UINT     flag;
+      LPCWSTR  desc;
+     } modify_flags_desc[]=
+     {
+      { IMTOrder::MODIFY_FLAGS_ADMIN,       L"Administrator"    },
+      { IMTOrder::MODIFY_FLAGS_MANAGER,     L"Manager"          },
+      { IMTOrder::MODIFY_FLAGS_POSITION,    L"Position"         },
+      { IMTOrder::MODIFY_FLAGS_RESTORE,     L"Restore"          },
+      { IMTOrder::MODIFY_FLAGS_API_ADMIN,   L"Administrator API"},
+      { IMTOrder::MODIFY_FLAGS_API_MANAGER, L"Manager API"      },
+      { IMTOrder::MODIFY_FLAGS_API_SERVER,  L"Server API"       },
+      { IMTOrder::MODIFY_FLAGS_API_GATEWAY, L"Gateway API"      }
+     };
+//--- counter
+   UINT added=0;
+//--- collect description
+   str.Clear();
+   for(UINT i=0;i<_countof(modify_flags_desc);i++)
+     if(modify_flags_desc[i].flag&modify_flags)
+       {
+        //--- add comma
+        if(added++)
+          str.Append(L", ");
+        //--- write
+        str.Append(modify_flags_desc[i].desc);
+       }
+//--- result
+   return(str.Str());
+  }
+//+------------------------------------------------------------------+
+//|                                                                  |
+//+------------------------------------------------------------------+
+inline LPCWSTR SMTFormat::FormatDouble(CMTStr &str,UINT64 val,UINT digits)
+  {
+   static const wchar_t cd[]={ L'0',L'1',L'2',L'3',L'4',L'5',L'6',L'7',L'8',L'9',0 };
+   wchar_t tmp[256]=L"",*cp,*dst;
+   UINT    i,len;
+//--- 
+   str.Clear();
+   cp=tmp;
+//--- check
+   if(digits>8) return(str.Str());
+//--- 
+   if(digits>0)
+     {
+      for(i=0;i<digits;i++)
+        {
+         *cp++=cd[val%10];
+         val/=10;
+        }
+      *cp++=SIG_DECIMAL;
+     }
+//--- integer part
+   *cp++=cd[val%10];
+   for(val/=10,i=1;val!=0;val/=10,i++)
+      *cp++=cd[val%10];
+   *cp=0;
+//--- check size
+   len=UINT(cp-tmp);
+   if(len>=str.Max()-1) return(str.Str());
+//--- string reverse 
+   dst=str.Buffer(); cp=tmp+len-1;
+   while(cp>=tmp) *dst++=*cp--;
+   *dst=0;
+   str.Refresh();
+//---
+   return(str.Str());
+  }
+//+------------------------------------------------------------------+
+//|                                                                  |
+//+------------------------------------------------------------------+
+inline LPCWSTR SMTFormat::FormatMoney(CMTStr &str,UINT64 val,UINT digits)
+  {
+   static const wchar_t cd[]={ L'0',L'1',L'2',L'3',L'4',L'5',L'6',L'7',L'8',L'9',0 };
+   wchar_t tmp[256]=L"",*cp,*dst;
+   UINT    i,len;
+//--- 
+   str.Clear();
+   cp=tmp;
+//--- checks
+   if(digits>8) return(str.Str());
+//---
+   if(digits>0)
+     {
+      for(i=0;i<digits;i++)
+        {
+         *cp++=cd[val%10];
+         val/=10;
+        }
+      *cp++=SIG_DECIMAL;
+     }
+//--- integer part
+   *cp++=cd[val%10];
+   for(val/=10,i=1;val!=0;val/=10,i++)
+     {
+      if(i%3==0) *cp++=SIG_THOUSAND;
+      *cp++=cd[val%10];
+     }
+   *cp=0;
+//--- check size
+   len=UINT(cp-tmp);
+   if(len>=str.Max()-1) return(str.Str());
+//--- reverse string
+   dst=str.Buffer(); cp=tmp+len-1;
+   while(cp>=tmp) *dst++=*cp--;
+   *dst=0;
+   str.Refresh();
+//---
+   return(str.Str());
+  }
+//+------------------------------------------------------------------+
+//|                                                                  |
+//+------------------------------------------------------------------+
+inline void SMTFormat::TrimZeros(CMTStr &str,UINT extra_digits)
+  {
+   UINT len=str.Len(),digits=0;
+//--- remove zero
+   while(len>0 && str[len-1]==L'0' && digits<extra_digits) { len--; digits++; }
+   str.Trim(len);
+//--- remove points
+   if(len>0 && str[len-1]==L'.') str.Trim(len-1);
+  }
+//+------------------------------------------------------------------+

+ 276 - 0
MT5SDK/Classes/MT5APIMath.h

@@ -0,0 +1,276 @@
+//+------------------------------------------------------------------+
+//|                                                 MetaTrader 5 API |
+//|                   Copyright 2000-2019, MetaQuotes Software Corp. |
+//|                                        http://www.metaquotes.net |
+//+------------------------------------------------------------------+
+#pragma once
+#include <string.h>
+#include <math.h>
+//+------------------------------------------------------------------+
+//| Volume constants                                                 |
+//+------------------------------------------------------------------+
+#define MTAPI_VOLUME_DIV        (10000.0)
+#define MTAPI_VOLUME_DIGITS     (4)
+#define MTAPI_VOLUME_MAX        ((UINT64)10000000000)
+//+------------------------------------------------------------------+
+//| Volume with extended accuracy constants                          |
+//+------------------------------------------------------------------+
+#define MTAPI_VOLUME_EXT_DIV    (100000000.0)
+#define MTAPI_VOLUME_EXT_DIGITS (8)
+#define MTAPI_VOLUME_EXT_MAX    ((UINT64)10000000000000000000)
+//+------------------------------------------------------------------+
+//| Price constants                                                  |
+//+------------------------------------------------------------------+
+#define MTAPI_PRICE_MAX         (100000000)
+#define MTAPI_PRICE_DIGITS_MAX  (11)
+//+------------------------------------------------------------------+
+//| Mathematical operations                                          |
+//+------------------------------------------------------------------+
+class SMTMath
+  {
+private:
+   static const double s_decimal[16];
+   static const double s_fdecimal[16];
+   static const double s_rounder_math;
+
+public:
+   //--- common functions
+   static double     DecPow(INT digits);
+   //--- price functions
+   static double     PriceNormalize(const double price,UINT digits);
+   static INT64      PriceToInt(const double price,const UINT digits);
+   static UINT64     PriceToIntPos(const double price,const UINT digits);
+   static double     PriceToDouble(const INT64 value,UINT digits);
+   //--- volume functions
+   static UINT64     VolumeToInt(const double volume);
+   static double     VolumeToDouble(const UINT64 volume);
+   static double     VolumeToSize(const UINT64 volume,double contract_size);
+   static UINT64     VolumeFromSize(const double size,double contract_size);
+   static UINT64     VolumeFromVolumeExt(const UINT64 volume);
+   //--- volume with extended accuracy functions
+   static UINT64     VolumeExtToInt(const double volume);
+   static double     VolumeExtToDouble(const UINT64 volume);
+   static double     VolumeExtToSize(const UINT64 volume,double contract_size);
+   static UINT64     VolumeExtFromSize(const double size,double contract_size);
+   static UINT64     VolumeExtFromVolume(const UINT64 volume);
+   //--- money digits
+   static double     MoneyAdd(const double left,const double right,const UCHAR digits);
+   static bool       MoneyEqual(const double left,const double right,const UCHAR digits);
+   static UINT       MoneyDigits(LPCWSTR currency);
+  };
+//+------------------------------------------------------------------+
+//| 16 powers                                                        |
+//+------------------------------------------------------------------+
+const __declspec(selectany) double SMTMath::s_decimal[16]=
+  {
+   1.0,
+   10.0,
+   100.0,
+   1000.0,
+   10000.0,
+   100000.0,
+   1000000.0,
+   10000000.0,
+   100000000.0,
+   1000000000.0,
+   10000000000.0,
+   100000000000.0,
+   1000000000000.0,
+   10000000000000.0,
+   100000000000000.0,
+   1000000000000000.0,
+   };
+//+------------------------------------------------------------------+
+//| Negative 16 powers                                               |
+//+------------------------------------------------------------------+
+const __declspec(selectany) double SMTMath::s_fdecimal[16]=
+  {
+   1.0,
+   0.1,
+   0.01,
+   0.001,
+   0.0001,
+   0.00001,
+   0.000001,
+   0.0000001,
+   0.00000001,
+   0.000000001,
+   0.0000000001,
+   0.00000000001,
+   0.000000000001,
+   0.0000000000001,
+   0.00000000000001,
+   0.000000000000001,
+   };
+//+------------------------------------------------------------------+
+//| Rounder constant                                                 |
+//+------------------------------------------------------------------+
+const __declspec(selectany) double SMTMath::s_rounder_math=0.5000001;
+//+------------------------------------------------------------------+
+//| Decimal power                                                    |
+//+------------------------------------------------------------------+
+inline double SMTMath::DecPow(INT digits)
+  {
+//--- check sign
+   if(digits>0 && digits<_countof(s_decimal))
+      return(s_decimal[digits]);
+   else
+      if(digits<0 && -digits<_countof(s_fdecimal))
+         return(s_fdecimal[-digits]);
+//--- use standard pow
+   return(pow(10.0,digits));
+  }
+//+------------------------------------------------------------------+
+//| Price normalization                                              |
+//+------------------------------------------------------------------+
+inline double SMTMath::PriceNormalize(const double val,UINT digits)
+  {
+   double dbl_integer;
+//--- check digits
+   if(digits>MTAPI_PRICE_DIGITS_MAX)
+      digits=MTAPI_PRICE_DIGITS_MAX;
+//--- calculate dividers
+   double p=s_decimal[digits];
+   dbl_integer=double(__int64(val));
+   double dbl_fract=(val-dbl_integer)*p;
+//--- check sign
+   if(val>0) dbl_fract+=s_rounder_math;
+   else      dbl_fract-=s_rounder_math;
+//--- calc fractional part
+   dbl_fract=double(__int64(dbl_fract));
+//--- summary
+   return(dbl_integer+dbl_fract/p);
+  }
+//+------------------------------------------------------------------+
+//| Price conversion from double to integer                          |
+//+------------------------------------------------------------------+
+inline INT64 SMTMath::PriceToInt(const double price,const UINT digits)
+  {
+//--- check
+   if(digits>MTAPI_PRICE_DIGITS_MAX || price<=0.0 || price>_I64_MAX)
+      return(0);
+//--- calculate
+   return((INT64)((price>=0.0) ? (price*s_decimal[digits]+s_rounder_math):(price*s_decimal[digits]-s_rounder_math)));
+  }
+//+------------------------------------------------------------------+
+//| Price conversion from double to integer                          |
+//+------------------------------------------------------------------+
+inline UINT64 SMTMath::PriceToIntPos(const double price,const UINT digits)
+  {
+//--- check
+   if(price<=0.0)
+      return(PriceToInt(price,digits));
+//--- calculate
+   return((UINT64)(price*s_decimal[digits]+s_rounder_math));
+  }
+//+------------------------------------------------------------------+
+//| Price conversion from integer to double                          |
+//+------------------------------------------------------------------+
+inline double SMTMath::PriceToDouble(const INT64 value,UINT digits)
+  {
+//--- check
+   if(digits>MTAPI_PRICE_DIGITS_MAX)
+      digits=MTAPI_PRICE_DIGITS_MAX;
+//--- divide
+   return(PriceNormalize(double(value)/s_decimal[digits],digits));
+  }
+//+------------------------------------------------------------------+
+//| Volume conversion from double to integer                         |
+//+------------------------------------------------------------------+
+inline UINT64 SMTMath::VolumeToInt(const double volume)
+  {
+   return(PriceToIntPos(volume,MTAPI_VOLUME_DIGITS));
+  }
+//+------------------------------------------------------------------+
+//| Volume conversion from integer to double                         |
+//+------------------------------------------------------------------+
+inline double SMTMath::VolumeToDouble(const UINT64 volume)
+  {
+   return(PriceNormalize(volume/double(MTAPI_VOLUME_DIV),MTAPI_VOLUME_DIGITS));
+  }
+//+------------------------------------------------------------------+
+//| Volume conversion from lots to amount                            |
+//+------------------------------------------------------------------+
+inline double SMTMath::VolumeToSize(const UINT64 volume,double contract_size)
+  {
+   return(PriceNormalize(volume/double(MTAPI_VOLUME_DIV)*contract_size,MTAPI_VOLUME_DIGITS));
+  }
+//+------------------------------------------------------------------+
+//| Volume conversion from amount to lots                            |
+//+------------------------------------------------------------------+
+inline UINT64 SMTMath::VolumeFromSize(const double size,double contract_size)
+  {
+   return((UINT64)PriceNormalize((size/contract_size)*double(MTAPI_VOLUME_DIV),0));
+  }
+//+------------------------------------------------------------------+
+//| Volume conversion from extended accuracy volume                  |
+//+------------------------------------------------------------------+
+inline UINT64 SMTMath::VolumeFromVolumeExt(const UINT64 volume_ext)
+  {
+   return(volume_ext/10000);
+  }
+//+------------------------------------------------------------------+
+//| Volume conversion from double to integer                         |
+//+------------------------------------------------------------------+
+inline UINT64 SMTMath::VolumeExtToInt(const double volume)
+  {
+   return(PriceToIntPos(volume,MTAPI_VOLUME_EXT_DIGITS));
+  }
+//+------------------------------------------------------------------+
+//| Volume conversion from integer to double                         |
+//+------------------------------------------------------------------+
+inline double SMTMath::VolumeExtToDouble(const UINT64 volume)
+  {
+   return(PriceNormalize(volume/double(MTAPI_VOLUME_EXT_DIV),MTAPI_VOLUME_EXT_DIGITS));
+  }
+//+------------------------------------------------------------------+
+//| Volume conversion from lots to amount                            |
+//+------------------------------------------------------------------+
+inline double SMTMath::VolumeExtToSize(const UINT64 volume,double contract_size)
+  {
+   return(PriceNormalize(volume/double(MTAPI_VOLUME_EXT_DIV)*contract_size,MTAPI_VOLUME_EXT_DIGITS));
+  }
+//+------------------------------------------------------------------+
+//| Volume conversion from amount to lots                            |
+//+------------------------------------------------------------------+
+inline UINT64 SMTMath::VolumeExtFromSize(const double size,double contract_size)
+  {
+   return((UINT64)PriceNormalize((size/contract_size)*double(MTAPI_VOLUME_EXT_DIV),0));
+  }
+//+------------------------------------------------------------------+
+//| Volume conversion to extended accuracy volume                  |
+//+------------------------------------------------------------------+
+inline UINT64 SMTMath::VolumeExtFromVolume(const UINT64 volume)
+  {
+   return(volume*10000);
+  }
+//+------------------------------------------------------------------+
+//| Money add                                                        |
+//+------------------------------------------------------------------+
+inline double SMTMath::MoneyAdd(const double left,const double right,const UCHAR digits)
+  {
+   return(PriceNormalize(left+right,digits));
+  }
+//+------------------------------------------------------------------+
+//| Money Compare                                                    |
+//+------------------------------------------------------------------+
+inline bool SMTMath::MoneyEqual(const double left,const double right,const UCHAR digits)
+  {
+   return(fabs(left-right)<DecPow(-(digits+1)));
+  }
+//+------------------------------------------------------------------+
+//| Digits by currency                                               |
+//+------------------------------------------------------------------+
+inline UINT SMTMath::MoneyDigits(LPCWSTR currency)
+  {
+//--- check param
+   if(currency)
+     {
+      if(_wcsicmp(currency,L"JPY")==0) return(0);
+      if(_wcsicmp(currency,L"VND")==0) return(0);
+     }
+//--- 2 digits by default
+   return(2);
+  }
+//+------------------------------------------------------------------+
+

+ 132 - 0
MT5SDK/Classes/MT5APIMemPack.h

@@ -0,0 +1,132 @@
+//+------------------------------------------------------------------+
+//|                                                 MetaTrader 5 API |
+//|                   Copyright 2000-2019, MetaQuotes Software Corp. |
+//|                                        http://www.metaquotes.net |
+//+------------------------------------------------------------------+
+#pragma once
+//+------------------------------------------------------------------+
+//| Class of memory block                                            |
+//+------------------------------------------------------------------+
+class CMTMemPack
+  {
+private:
+   //--- constants
+   enum
+     {
+      REALLOC_STEP  =1024                  // buffer reallocation step
+     };
+
+private:
+   //--- data
+   char             *m_buffer;             // data
+   UINT              m_buffer_len;         // data length
+   UINT              m_buffer_max;         // maximum number of bytes in buffer
+
+public:
+   //--- constructor/destructor
+                     CMTMemPack();
+                    ~CMTMemPack();
+   //--- correct the length in block
+   void              Clear()         { m_buffer_len=0; }
+   void              Shutdown();
+   bool              Reallocate(UINT growsize);
+   //--- add unformatted data
+   bool              Add(const void *buf,UINT len);
+   //--- swap array contents
+   void              Swap(CMTMemPack &pack);
+   //--- buffer access
+   char*             Buffer()        { return(m_buffer);     }
+   const UINT        Len() const     { return(m_buffer_len); }
+   void              Len(UINT val)   { if(val<=m_buffer_max) m_buffer_len=val; }
+   UINT              Max() const     { return(m_buffer_max); }
+  };
+//+------------------------------------------------------------------+
+//| Constructor with memory pre-allocation                           |
+//+------------------------------------------------------------------+
+inline CMTMemPack::CMTMemPack()
+   : m_buffer(NULL),
+     m_buffer_len(0),
+     m_buffer_max(0)
+  {
+  }
+//+------------------------------------------------------------------+
+//|                                                                  |
+//+------------------------------------------------------------------+
+inline CMTMemPack::~CMTMemPack()
+  {
+   Shutdown();
+  }
+//+------------------------------------------------------------------+
+//| Add data to buffer                                               |
+//+------------------------------------------------------------------+
+inline bool CMTMemPack::Add(const void *buf,UINT len)
+  {
+//--- check
+   if(!buf)
+      return(false);
+//--- check for exceeding buffer size
+   if(m_buffer==NULL || (len+m_buffer_len)>m_buffer_max)
+      if(!Reallocate(len+m_buffer_len+REALLOC_STEP))
+         return(false);
+//--- append data to buffer
+   memcpy(&m_buffer[m_buffer_len],buf,len);
+   m_buffer_len+=len;
+//---
+   return(true);
+  }
+//+------------------------------------------------------------------+
+//| Swap buffer contents                                             |
+//+------------------------------------------------------------------+
+inline void CMTMemPack::Swap(CMTMemPack &pack)
+  {
+   char *buffer;             // buffer
+   UINT  buffer_len;         // data length
+   UINT  buffer_max;         // maximum number of bytes in buffer
+//--- check
+   if(this==&pack)
+      return;
+//--- swap, remember own buffer
+   buffer    =m_buffer;
+   buffer_len=m_buffer_len;
+   buffer_max=m_buffer_max;
+//--- replace buffer with received one
+   m_buffer    =pack.m_buffer;
+   m_buffer_len=pack.m_buffer_len;
+   m_buffer_max=pack.m_buffer_max;
+//--- return own buffer
+   pack.m_buffer    =buffer;
+   pack.m_buffer_len=buffer_len;
+   pack.m_buffer_max=buffer_max;
+  }
+//+------------------------------------------------------------------+
+//|  Deallocate memory in MemPack                                    |
+//+------------------------------------------------------------------+
+inline void CMTMemPack::Shutdown()
+  {
+   if(m_buffer) { delete[] m_buffer; m_buffer=NULL; }
+   m_buffer_max=0;
+   m_buffer_len=0;
+  }
+//+------------------------------------------------------------------+
+//| Reallocate data block                                            |
+//+------------------------------------------------------------------+
+inline bool CMTMemPack::Reallocate(UINT growsize)
+  {
+   char *newbuf;
+//--- check sizes
+   if(growsize<=m_buffer_max) return(true);
+//--- try to allocate block of greater size
+   if((newbuf=new(std::nothrow) char[growsize])==NULL)
+      return(false);
+//--- copy values from old buffer
+   if(m_buffer)
+     {
+      if(m_buffer_len>0) memcpy(newbuf,m_buffer,m_buffer_len);
+      delete[] m_buffer;
+     }
+   m_buffer    =newbuf;
+   m_buffer_max=growsize;
+//---
+   return(true);
+  }
+//+------------------------------------------------------------------+

+ 149 - 0
MT5SDK/Classes/MT5APIProcess.h

@@ -0,0 +1,149 @@
+//+------------------------------------------------------------------+
+//|                                                     MetaTrader 5 |
+//|                   Copyright 2000-2019, MetaQuotes Software Corp. |
+//|                                        http://www.metaquotes.net |
+//+------------------------------------------------------------------+
+#pragma once
+#include <windows.h>
+#include "MT5APIStr.h"
+//+------------------------------------------------------------------+
+//| Process manipulation class                                       |
+//+------------------------------------------------------------------+
+class CMTProcess
+  {
+   HANDLE            m_process;
+   HANDLE            m_thread;
+   HANDLE            m_std_write;
+   HANDLE            m_std_read;
+   DWORD             m_process_id;
+   DWORD             m_thread_id;
+
+public:
+                     CMTProcess() : m_process(NULL),m_thread(NULL),m_std_write(NULL),m_std_read(NULL),m_process_id(0),m_thread_id(0) {};
+                    ~CMTProcess() { Close(); }
+   //--- process manipulation
+   bool             Start(CMTStr &command,const DWORD flags=DETACHED_PROCESS,const bool inherit=false);
+   void             Close(void);
+   DWORD            Read(void *buffer,const DWORD length);
+   bool             Priority(DWORD priority_class);
+   bool       	    Wait(const DWORD timeout=INFINITE);
+   DWORD            ThreadID(void) const { return(m_thread_id); }
+   DWORD            ExitCode(void);
+   void             Terminate(void);
+  };
+//+------------------------------------------------------------------+
+//| Process start                                                    |
+//+------------------------------------------------------------------+
+inline bool CMTProcess::Start(CMTStr &command,const DWORD flags/*=CREATE_NO_WINDOW*/,const bool inherit/*=false*/)
+  {
+   STARTUPINFOW          si={0};
+   PROCESS_INFORMATION  pi={0};
+   SECURITY_ATTRIBUTES  sa={ sizeof(sa),NULL,TRUE };
+   HANDLE               read_handle,process=::GetCurrentProcess();
+//--- close previous
+   Close();
+//--- intercept in\out for console threads
+   if(flags&CREATE_NEW_CONSOLE)
+     {
+      //--- create pipe for in\out interception
+      if(::CreatePipe(&read_handle,&m_std_write,&sa,0))
+        {
+         //--- create new read handle
+         ::DuplicateHandle(process,read_handle,process,&m_std_read,0,FALSE,DUPLICATE_SAME_ACCESS);
+         ::CloseHandle(read_handle);
+         read_handle=NULL;
+         //--- fill structure
+         si.cb         =sizeof(si);
+         si.dwFlags    =STARTF_USESTDHANDLES|STARTF_USESHOWWINDOW;
+         si.hStdOutput =m_std_write;
+         si.hStdInput  =NULL;
+         si.hStdError  =m_std_write;
+         si.wShowWindow=SW_HIDE;
+        }
+     }
+//--- create process
+   if(CreateProcessW(NULL,command.Buffer(),NULL,NULL,inherit ? TRUE:FALSE,flags,NULL,NULL,&si,&pi)==FALSE)
+      return(false);
+//--- 
+   m_process   =pi.hProcess;
+   m_process_id=pi.dwProcessId;
+   m_thread    =pi.hThread;
+   m_thread_id =pi.dwThreadId;
+//--- ok
+   return(true);
+  }
+//+------------------------------------------------------------------+
+//| Process close                                                    |
+//+------------------------------------------------------------------+
+inline void CMTProcess::Close(void)
+  {
+//--- close in\out handles
+   if(m_std_write!=NULL) { CloseHandle(m_std_write); m_std_write=NULL; }
+   if(m_std_read!=NULL)  { CloseHandle(m_std_read);  m_std_read=NULL;  }
+//--- close process handle
+   if(m_process!=NULL)   { CloseHandle(m_process);   m_process=NULL;   m_process_id=0; }
+//--- close process thread handle
+   if(m_thread !=NULL)   { CloseHandle(m_thread);    m_thread=NULL;    m_thread_id=0;  }
+  }
+//+------------------------------------------------------------------+
+//| Read stdread                                                     |
+//+------------------------------------------------------------------+
+inline DWORD CMTProcess::Read(void *buffer,const DWORD length)
+  {
+   DWORD readed=0;
+//--- check
+   if(m_std_write==NULL || m_std_read==NULL  || m_process==NULL || buffer==NULL || length<1) return(0);
+//--- read
+   if(::ReadFile(m_std_read,buffer,length,&readed,NULL)==0) readed=0;
+//--- read result
+   return(readed);
+  }
+//+------------------------------------------------------------------+
+//| Priority                                                         |
+//+------------------------------------------------------------------+
+inline bool CMTProcess::Priority(DWORD priority_class)
+  {
+   return(m_process && SetPriorityClass(m_process,priority_class));
+  }
+//+------------------------------------------------------------------+
+//| Process wait                                                     |
+//+------------------------------------------------------------------+
+inline bool CMTProcess::Wait(const DWORD timeout/*=INFINITE*/)
+  {
+//--- checks
+   if(m_process==NULL) return(false);
+//--- waiting
+   DWORD res=WaitForSingleObject(m_process,timeout);
+   if(res==WAIT_OBJECT_0)
+      return(true);
+//--- fail
+   return(false);
+  }
+//+------------------------------------------------------------------+
+//| Process exit code                                                |
+//+------------------------------------------------------------------+
+inline DWORD CMTProcess::ExitCode(void)
+  {
+   DWORD exitCode=0;
+//--- checks
+   if(m_process!=NULL)
+     {
+      //--- exit code
+      GetExitCodeProcess(m_process,&exitCode);
+     }
+//--- result
+   return(exitCode);
+  }
+//+------------------------------------------------------------------+
+//| Process terminate                                                |
+//+------------------------------------------------------------------+
+inline void CMTProcess::Terminate(void)
+  {
+//--- check
+   if(m_process==NULL) return;
+//--- do it
+   TerminateProcess(m_process,0);
+//--- close handles
+   Close();
+  }
+//+------------------------------------------------------------------+

+ 403 - 0
MT5SDK/Classes/MT5APISearch.h

@@ -0,0 +1,403 @@
+//+------------------------------------------------------------------+
+//|                                                 MetaTrader 5 API |
+//|                   Copyright 2000-2019, MetaQuotes Software Corp. |
+//|                                        http://www.metaquotes.net |
+//+------------------------------------------------------------------+
+#pragma once
+//+------------------------------------------------------------------+
+//| Search functions                                                 |
+//+------------------------------------------------------------------+
+class SMTSearch
+  {
+public:
+   typedef int       (__cdecl *SortFunctionPtr)(const void *, const void *);
+public:
+   //--- insert
+   static char*      Insert(void *base,const void *elem,size_t total,const size_t width,SortFunctionPtr compare);
+   //--- quick sort
+   template <class T>
+   static void       QuickSort(T *base,UINT num,SortFunctionPtr compare);
+   //---
+   static void*      Search(const void *key,void *base,size_t total,const size_t width,SortFunctionPtr compare);
+   static void*      SearchGreatOrEq(const void *key,void *base,size_t total,const size_t width,SortFunctionPtr compare);
+   static void*      SearchGreater(const void *key,void *base,size_t total,const size_t width,SortFunctionPtr compare);
+   static void*      SearchLessOrEq(const void *key,void *base,size_t total,const size_t width,SortFunctionPtr compare);
+   static void*      SearchLess(const void *key,void *base,size_t total,const size_t width,SortFunctionPtr compare);
+   static void*      SearchLeft(const void *key,void *base,size_t total,const size_t width,SortFunctionPtr compare);
+   static void*      SearchRight(const void *key,void *base,size_t total,const size_t width,SortFunctionPtr compare);
+private:
+   template <class T>
+   static void       ShortSort (T *lo,T *hi,SortFunctionPtr compare);
+   template <class T>
+   static void       Swap(T *a,T *b);
+  };
+//+------------------------------------------------------------------+
+//| Returns 0 if record already exist                                |
+//| Returns inserted record otherwise                                |
+//| Array should contain enough free space for new element           |
+//+------------------------------------------------------------------+
+inline char* SMTSearch::Insert(void *base,const void *elem,size_t total,const size_t width,SortFunctionPtr compare)
+  {
+//--- check
+   if(base==NULL || elem==NULL || compare==NULL) return(NULL);
+//--- first element?
+   if(total<1) { memcpy(base,elem,width); return(char*)(base); }
+//--- initialize
+   char *lo=(char *)base;
+   char *hi=(char *)base+(total-1)*width,*end=hi;
+   char *mid;
+   size_t         half;
+   int            result;
+//---
+   while(total>0)
+     {
+      half=total/2;
+      mid =lo+half*width;
+      //--- compare
+      if((result=compare(elem,mid))>0) // data[mid]<elem
+        {
+         lo   =mid+width;
+         total=total-half-1;
+        }
+      else
+         if(result<0)                // data[mid]>elem
+           {
+            total=half;
+           }
+         else
+           {
+            // data[mid]==elem
+            return(NULL);
+           }
+     }
+//--- insert new
+   memmove(lo+width,lo,end-lo+width);
+   memcpy(lo,elem,width);
+//---
+   return(lo);
+  }
+//+------------------------------------------------------------------+
+//| Fast sort                                                        |
+//+------------------------------------------------------------------+
+template<class T>
+inline void SMTSearch::ShortSort (T *lo,T *hi,SortFunctionPtr compare)
+  {
+   T *p, *maxval;
+//--- Note: in assertions below, i and j are alway inside original bound of
+//--- array to sort.
+//--- While
+   while(hi > lo)
+     {
+      maxval=lo;
+      for(p=lo+1; p<=hi; p+=1)
+         if (compare(p, maxval) > 0)
+         { maxval=p; }
+      //---
+      Swap(maxval,hi);
+      hi-=1;
+     }
+  }
+//+------------------------------------------------------------------+
+//| Swap two records                                                 |
+//+------------------------------------------------------------------+
+template<class T>
+inline void SMTSearch::Swap(T *a,T *b)
+  {
+   T c(*a);
+   *a=*b;
+   *b=c;
+  }
+//+------------------------------------------------------------------+
+//| Quick sort from CRT                                              |
+//+------------------------------------------------------------------+
+template<class T>
+inline void SMTSearch::QuickSort(T *base,UINT num,SortFunctionPtr compare)
+  {
+   T *lo, *hi;              /* ends of sub-array currently sorting */
+   T *mid;                  /* points to middle of subarray */
+   T *loguy, *higuy;        /* traveling pointers for partition step */
+   size_t size;             /* size of the sub-array */
+   T *lostk[30], *histk[30];
+   int stkptr;              /* stack for saving sub-array to be processed */
+//---
+   if (num < 2) return;
+   stkptr=0;                /* initialize stack */
+   lo=base;
+   hi=base + (num-1);       /* initialize limits */
+//---
+   recurse:
+//---
+   size=(hi - lo) + 1;       /* number of el's to sort */
+//---
+   if (size<=8) ShortSort(lo,hi,compare);
+   else
+     {
+      mid=lo + (size/2);     /* find middle element */
+      Swap(mid,lo);          /* swap it to beginning of array */
+      //---
+      loguy=lo;
+      higuy=hi + 1;
+      //---
+      for(;;)
+        {
+         //---
+         do
+           {
+            loguy+=1;
+           }
+         while(loguy<=hi && compare(loguy, lo)<=0);
+         //---
+         do
+           {
+            higuy-=1;
+           }
+         while(higuy > lo && compare(higuy, lo)>=0);
+         //---
+         if(higuy<loguy) break;
+         //---
+         Swap(loguy, higuy);
+        }
+      //---
+      Swap(lo, higuy);     /* put partition element in place */
+      //---
+      if(higuy-1-lo>=hi-loguy)
+        {
+         if(lo + 1 < higuy)
+           {
+            lostk[stkptr]=lo;
+            histk[stkptr]=higuy - 1;
+            ++stkptr;
+           }
+         if(loguy < hi)
+           {
+            lo=loguy;
+            goto recurse;           /* do small recursion */
+           }
+        }
+      else
+        {
+         if (loguy < hi)
+           {
+            lostk[stkptr]=loguy;
+            histk[stkptr]=hi;
+            ++stkptr;               /* save big recursion for later */
+           }
+         if(lo + 1 < higuy)
+           {
+            hi=higuy - 1;
+            goto recurse;           /* do small recursion */
+           }
+        }
+     }
+//---
+   --stkptr;
+   if(stkptr>=0)
+     {
+      lo=lostk[stkptr];
+      hi=histk[stkptr];
+      goto recurse;           /* pop subarray from stack */
+     }
+//---
+   return;                 /* all subarrays done */
+  }
+//+------------------------------------------------------------------+
+//| Binary search (from CRT)                                         |
+//+------------------------------------------------------------------+
+inline void* SMTSearch::Search(const void *key,void *base,size_t num,const size_t width,SortFunctionPtr compare)
+  {
+   char *lo=(char *)base;
+   char *hi=(char *)base + (num - 1) * width;
+   char *mid;
+   size_t half;
+   int result;
+//--- validation section 
+   if(base==NULL || num<1 || width<=0 || compare==NULL) return(NULL);
+//---  We allow a NULL key here because it breaks some older code and because we do not dereference
+//---  this ourselves so we can't be sure that it's a problem for the comparison function
+   while(lo<=hi)
+     {
+      if((half=num/2)!=0)
+        {
+         mid=lo + (num & 1 ? half : (half - 1)) * width;
+         if((result=(*compare)(key, mid))==0)
+            return(mid);
+         else
+            if (result < 0)
+              {
+               hi=mid - width;
+               num=num & 1 ? half : half-1;
+              }
+            else
+              {
+               lo=mid + width;
+               num=half;
+              }
+        }
+      else
+         if(num)
+            return((*compare)(key, lo) ? NULL : lo);
+         else
+            break;
+     }
+//---
+   return(NULL);
+  }
+//+------------------------------------------------------------------+
+//| Search great or equal key                                        |
+//+------------------------------------------------------------------+
+inline void* SMTSearch::SearchGreatOrEq(const void *key,void *base,size_t total,const size_t width,SortFunctionPtr compare)
+  {
+//--- check
+   if(key==NULL || base==NULL || total<1 || compare==NULL) return(NULL);
+//--- 
+   char    *lo=(char *)base;
+   char    *end=(char *)base+total*width;
+   char    *mid;
+   size_t   half;
+//---
+   while(total>0)
+     {
+      half=total/2;
+      mid =lo+half*width;
+      //--- compare
+      if(compare(key,mid)>0) // key>data[mid]
+        {
+         lo   =mid+width;
+         total=total-half-1;
+        }
+      else total=half;
+     }
+//--- is exist?
+   return(lo==end)?(NULL):(lo);
+  }
+//+------------------------------------------------------------------+
+//| Search great than key                                            |
+//+------------------------------------------------------------------+
+inline void* SMTSearch::SearchGreater(const void *key,void *base,size_t total,const size_t width,SortFunctionPtr compare)
+  {
+//--- check
+   if(key==NULL || base==NULL || total<1 || compare==NULL) return(NULL);
+//--- 
+   char    *lo=(char *)base;
+   char    *end=(char *)base+total*width;
+   char    *mid;
+   size_t   half;
+//---
+   while(total>0)
+     {
+      half=total/2;
+      mid =lo+half*width;
+      //--- compare
+      if(compare(key,mid)>=0) // key>=data[mid]
+        {
+         lo   =mid+width;
+         total=total-half-1;
+        }
+      else total=half;
+     }
+//--- is exist?
+   return(lo==end)?(NULL):(lo);
+  }
+//+------------------------------------------------------------------+
+//| Search less or equal key                                         |
+//+------------------------------------------------------------------+
+inline void* SMTSearch::SearchLessOrEq(const void *key,void *base,size_t total,const size_t width,SortFunctionPtr compare)
+  {
+//--- check
+   if(key==NULL || base==NULL || total<1 || compare==NULL) return(NULL);
+//--- 
+   char    *lo=(char *)base;
+   char    *beg=(char *)base;
+   char    *mid;
+   size_t   half;
+//---
+   while(total>0)
+     {
+      half=total/2;
+      mid =lo+half*width;
+      //--- compare
+      if(compare(key,mid)>=0) // key>=data[mid]
+        {
+         lo   =mid+width;
+         total=total-half-1;
+        }
+      else total=half;
+     }
+//--- is exist?
+   return(lo==beg)?(NULL):(lo-width);
+  }
+//+------------------------------------------------------------------+
+//| Search less than key                                             |
+//+------------------------------------------------------------------+
+inline void* SMTSearch::SearchLess(const void *key,void *base,size_t total,const size_t width,SortFunctionPtr compare)
+  {
+//--- check
+   if(key==NULL || base==NULL || total<1 || compare==NULL) return(NULL);
+//--- 
+   char    *lo=(char *)base;
+   char    *beg=(char *)base;
+   char    *mid;
+   size_t   half;
+//---
+   while(total>0)
+     {
+      half=total/2;
+      mid =lo+half*width;
+      //--- compare
+      if(compare(key,mid)>0) // key>data[mid]
+        {
+         lo   =mid+width;
+         total=total-half-1;
+        }
+      else total=half;
+     }
+//--- is exist?
+   return(lo==beg)?(NULL):(lo-width);
+  }
+//+------------------------------------------------------------------+
+//| Search first equal key                                           |
+//+------------------------------------------------------------------+
+inline void* SMTSearch::SearchLeft(const void *key,void *base,size_t total,const size_t width,SortFunctionPtr compare)
+  {
+//--- check
+   if(key==NULL || base==NULL || total<1 || compare==NULL) return(NULL);
+//--- search left
+   char* start=(char*)SearchLess(key,base,total,width,compare);
+//---
+   if(start!=NULL)
+     {
+      //--- go to next
+      start+=width;
+      //--- check array borders
+      if(start>=((char*)base+total*width)) return(NULL);
+     }
+   else start=(char*)base;
+//--- is equal?
+   if(!compare(key,start)) return(start);
+//--- not found
+   return(NULL);
+  }
+//+------------------------------------------------------------------+
+//| Search last equal key                                            |
+//+------------------------------------------------------------------+
+inline void* SMTSearch::SearchRight(const void *key,void *base,size_t total,const size_t width,SortFunctionPtr compare)
+  {
+//--- check
+   if(key==NULL || base==NULL || total<1 || compare==NULL) return(NULL);
+//--- search right
+   char* end=(char*)SearchGreater(key,base,total,width,compare);
+//---
+   if(end!=NULL)
+     {
+      //--- go to previous
+      end-=width;
+      //--- check array borders
+      if(end<(char*)base) return(NULL);
+     }
+   else end=(char*)base+(total-1)*width;
+//--- is equal?
+   if(!compare(key,end)) return(end);
+//--- not found
+   return(NULL);
+  }
+//+------------------------------------------------------------------+

+ 689 - 0
MT5SDK/Classes/MT5APIStorage.h

@@ -0,0 +1,689 @@
+//+------------------------------------------------------------------+
+//|                                                 MetaTrader 5 API |
+//|                   Copyright 2000-2019, MetaQuotes Software Corp. |
+//|                                        http://www.metaquotes.net |
+//+------------------------------------------------------------------+
+#pragma once
+#include <new.h>
+#include <stdlib.h>
+#include "MT5APISearch.h"
+//+------------------------------------------------------------------+
+//| Dynamic array base class                                         |
+//| For POD data types only!                                         |
+//+------------------------------------------------------------------+
+class CMTArrayBase
+  {
+protected:
+   UCHAR            *m_data;             // array
+   UINT              m_data_total;       // array records total
+   UINT              m_data_max;         // array records max
+   UINT              m_data_width;       // record size in bytes
+   UINT              m_data_step;        // reallocation step
+
+public:
+                     CMTArrayBase(const UINT width,const UINT step);
+   virtual          ~CMTArrayBase();
+   //--- common properties
+   UINT              Total(void) const                        { return(m_data_total);      }
+   UINT              Width(void) const                        { return(m_data_width);      }
+   UINT              Max(void) const                          { return(m_data_max);        }
+   UINT              Step(void) const                         { return(m_data_step);       }
+   bool              Compare(const CMTArrayBase& array) const;
+   //--- global management
+   void              Clear(void)                              { m_data_total=0;            }
+   bool              Zero(void);
+   void              Shutdown(void);
+   void              Compact(void);
+   bool              Assign(const CMTArrayBase& array);
+   void              Swap(CMTArrayBase &arr);
+   bool              Reserve(const UINT size);
+   bool              Resize(const UINT size);   
+   //--- add
+   bool              Add(const void *elem)                    { return Add(elem,1);        }
+   bool              Add(const void *elem,const UINT total);
+   bool              Add(const CMTArrayBase& array);
+   bool              AddRange(const CMTArrayBase& array,const UINT from,const UINT to);
+   bool              AddEmpty(const UINT total);
+   void*             Append(void);
+   bool              Insert(const UINT pos,const void *elem)  { return Insert(pos,elem,1); }
+   bool              Insert(const UINT pos,const void *elem,const UINT total);
+   bool              InsertEmpty(const UINT pos,const UINT total);
+   void*             Insert(const void *elem,SMTSearch::SortFunctionPtr sort_function);
+   //--- delete
+   bool              Delete(const UINT pos);
+   bool              Delete(const void *elem);
+   bool              DeleteRange(const UINT from,const UINT to);
+   bool              Remove(const void *elem,SMTSearch::SortFunctionPtr sort_function);
+   //--- modify
+   bool              Update(const UINT pos,const void *elem);
+   bool              Shift(const UINT pos,const int shift);
+   bool              Trim(const UINT size);
+   //--- data access
+   bool              Next(const UINT pos,void *elem) const;
+   void*             Next(const void *elem) const;
+   void*             Prev(const void *elem) const;
+   const void*       At(const UINT pos) const;
+   void*             At(const UINT pos);
+   int               Position(const void* ptr) const;
+   bool              Range(const UINT from,const UINT to,void* data) const;
+   //--- sort & search
+   void              Sort(SMTSearch::SortFunctionPtr sort_function);
+   void*             Search(const void *key,SMTSearch::SortFunctionPtr sort_function) const;
+   void*             SearchGreatOrEq(const void *key,SMTSearch::SortFunctionPtr sort_function) const;
+   void*             SearchGreater(const void *key,SMTSearch::SortFunctionPtr sort_function) const;
+   void*             SearchLessOrEq(const void *key,SMTSearch::SortFunctionPtr sort_function) const;
+   void*             SearchLess(const void *key,SMTSearch::SortFunctionPtr sort_function) const;
+   void*             SearchLeft(const void *key,SMTSearch::SortFunctionPtr sort_function) const;
+   void*             SearchRight(const void *key,SMTSearch::SortFunctionPtr sort_function) const;
+
+protected:
+                     CMTArrayBase(void):m_data(NULL),m_data_total(0),m_data_max(0),m_data_width(0),m_data_step(0){}
+   bool              Realloc(const UINT total);
+  };
+//+------------------------------------------------------------------+
+//|                                                                  |
+//+------------------------------------------------------------------+
+inline CMTArrayBase::CMTArrayBase(const UINT width,const UINT step) : m_data(NULL),m_data_total(0),
+                                                                  m_data_max(0),m_data_width(width),m_data_step(step)
+  {
+  }
+//+------------------------------------------------------------------+
+//|                                                                  |
+//+------------------------------------------------------------------+
+inline CMTArrayBase::~CMTArrayBase(void)
+  {
+   Shutdown();
+  }
+//+------------------------------------------------------------------+
+//| Zero all elements                                                |
+//+------------------------------------------------------------------+
+inline bool CMTArrayBase::Zero(void)
+  {
+   if(m_data) ZeroMemory(m_data,m_data_width*m_data_max);
+   return(true);
+  }
+//+------------------------------------------------------------------+
+//| Full shutdown with memory free                                   |
+//+------------------------------------------------------------------+
+inline void CMTArrayBase::Shutdown(void)
+  {
+//--- clear all
+   if(m_data) { delete[] m_data; m_data=NULL; }
+//--- zero sizes
+   m_data_total=m_data_max=0;
+  }
+//+------------------------------------------------------------------+
+//| Arrays comparison                                                |
+//+------------------------------------------------------------------+
+inline bool CMTArrayBase::Compare(const CMTArrayBase& array) const
+  {
+//--- check total and with
+   if(m_data_width!=array.m_data_width || m_data_total!=array.m_data_total)
+      return(false);
+//--- check total
+   if(Total())
+     {
+      //--- check data
+      if(!m_data || !array.m_data) return(false);
+      //--- check record by record
+      for(UINT i=0;i<m_data_total;i++)
+         if(memcmp(At(i),array.At(i),m_data_width)!=0) return(false);
+     }
+//--- ok
+   return(true);
+  }
+//+------------------------------------------------------------------+
+//| Memory check and reallocation to store 'total' records          |
+//+------------------------------------------------------------------+
+inline bool CMTArrayBase::Realloc(const UINT total)
+  {
+//--- check
+   if(total<1 || m_data_step<1)                   return(true);
+//--- check size
+   if(m_data && (m_data_total+total)<=m_data_max) return(true);
+//--- calculate reallocation
+   UINT add=((total/m_data_step)+1)*m_data_step;
+//--- allocate new buffer
+   UCHAR *buffer=new(std::nothrow) UCHAR[(m_data_max+add)*m_data_width];
+//--- check
+   if(!buffer) return(false);
+//--- previous data?
+   if(m_data)
+     {
+      if(m_data_total>0) memcpy(buffer,m_data,m_data_width*m_data_total);
+      delete[] m_data;
+     }
+//--- replace
+   m_data     =buffer;
+   m_data_max+=add;
+//--- ok
+   return(true);
+  }
+//+------------------------------------------------------------------+
+//| Compact allocated memory                                         |
+//+------------------------------------------------------------------+
+inline void CMTArrayBase::Compact(void)
+  {
+   UINT   freespace=m_data_max-m_data_total;
+   UCHAR *newdata;
+//--- check
+   if(!m_data || freespace<=m_data_step) return;
+//--- allocate new block
+   newdata=new(std::nothrow) UCHAR[(m_data_total+m_data_step)*m_data_width];
+//--- check memory
+   if(!newdata) return;
+//--- copy old data
+   memcpy(newdata,m_data,m_data_total*m_data_width);
+//--- free old buffer
+   delete[] m_data;
+//--- replace
+   m_data    =newdata;
+   m_data_max=m_data_total+m_data_step;
+  }
+//+------------------------------------------------------------------+
+//| Assign from 'array' and                                          |
+//+------------------------------------------------------------------+
+inline bool CMTArrayBase::Assign(const CMTArrayBase& array)
+  {
+//--- check
+   if(this==&array) return(true);
+//--- check width
+   if(array.m_data_width!=m_data_width) return(false);
+//--- clear self
+   Clear();
+//--- check data
+   if(!array.m_data || array.m_data_total<1) return(true);
+//--- add
+   return(Add(array.m_data,array.m_data_total));
+  }
+//+------------------------------------------------------------------+
+//| Swap arrays content                                              |
+//+------------------------------------------------------------------+
+inline void CMTArrayBase::Swap(CMTArrayBase &arr)
+  {
+   UCHAR *data;
+   UINT   data_total;
+   UINT   data_max;
+//--- check
+   if(this==&arr) return;
+//--- check width
+   if(arr.m_data_width!=m_data_width) return;
+//--- swap them
+   data      =m_data;
+   data_total=m_data_total;
+   data_max  =m_data_max;
+   m_data      =arr.m_data;
+   m_data_total=arr.m_data_total;
+   m_data_max  =arr.m_data_max;
+   arr.m_data      =data;
+   arr.m_data_total=data_total;
+   arr.m_data_max  =data_max;
+  }
+//+------------------------------------------------------------------+
+//| Reserve free space                                               |
+//+------------------------------------------------------------------+
+inline bool CMTArrayBase::Reserve(const UINT size)
+  {
+   if(size<=m_data_max) return(true);
+   else                 return(Realloc(size-m_data_total));
+  }
+//+------------------------------------------------------------------+
+//| Resize array                                                     |
+//+------------------------------------------------------------------+
+inline bool CMTArrayBase::Resize(const UINT size)
+  {
+//--- check
+   if(!m_data)            return(false);
+   if(size==m_data_total) return(true);
+//--- resize or realloc
+   if(size<m_data_total) m_data_total=size;
+   else
+      if(size>m_data_total) return(AddEmpty(size-m_data_total));
+//--- ok
+   return(true);
+  }
+//+------------------------------------------------------------------+
+//| Add total records to tail                                       |
+//+------------------------------------------------------------------+
+inline bool CMTArrayBase::Add(const void *elem,const UINT total)
+  {
+//--- check ptr
+   if(!elem)            return(false);
+//--- check total
+   if(total<1)          return(true);
+//--- check and reallocate memory
+   if(!Realloc(total))  return(false);
+//--- add
+   memcpy((char*)m_data+(m_data_width*m_data_total),(const char*)elem,m_data_width*total);
+   m_data_total+=total;
+//--- ok
+   return(true);
+  }
+//+------------------------------------------------------------------+
+//| Add array                                                        |
+//+------------------------------------------------------------------+
+inline bool CMTArrayBase::Add(const CMTArrayBase& array)
+  {
+//--- check
+   if(this==&array || !array.m_data || array.m_data_total<1) return(true);
+//--- check width
+   if(array.m_data_width!=m_data_width) return(false);
+//--- add
+   return(Add(array.m_data,array.m_data_total));
+  }
+//+------------------------------------------------------------------+
+//| Add records [from,to] from array                                 |
+//+------------------------------------------------------------------+
+inline bool CMTArrayBase::AddRange(const CMTArrayBase& array,const UINT from,const UINT to)
+  {
+//--- check
+   if(this==&array) return(true);
+//--- check width
+   if(array.m_data_width!=m_data_width) return(false);
+//--- check borders
+   if(from>to || to>=array.Total())     return(false);
+//--- add
+   return(Add((char*)array.m_data+(from*array.m_data_width),(to-from)+1));
+  }
+//+------------------------------------------------------------------+
+//| Add total uninitialized records                                 |
+//+------------------------------------------------------------------+
+inline bool CMTArrayBase::AddEmpty(const UINT total)
+  {
+   if(!Realloc(total)) return(false);
+   m_data_total+=total;
+   return(true);
+  }
+//+------------------------------------------------------------------+
+//| Add new uninitialized record and return pointer to them          |
+//+------------------------------------------------------------------+
+inline void* CMTArrayBase::Append(void)
+  {
+//--- check free space
+   if(!Realloc(1)) return(NULL);
+//--- allocate
+   if(m_data_total<m_data_max)
+     {
+      m_data_total++;
+      return((char*)m_data+(m_data_total-1)*m_data_width);
+     }
+//--- something wrong
+   return(NULL);
+  }
+//+------------------------------------------------------------------+
+//| Insert total records into pos position                           |
+//+------------------------------------------------------------------+
+inline bool CMTArrayBase::Insert(const UINT pos,const void *elem,const UINT total)
+  {
+//--- check
+   if(!elem || pos>m_data_total) return(false);
+//--- check free space
+   if(!Realloc(total)) return(false);
+//--- move it if neccessary
+   if(pos<m_data_total)
+      memmove((char*)m_data+((pos+total)*m_data_width),(char*)m_data+(pos*m_data_width),(m_data_total-pos)*m_data_width);
+//--- insert
+   memcpy((char*)m_data+(m_data_width*pos),(const char*)elem,m_data_width*total);
+   m_data_total+=total;
+//--- ok
+   return(true);
+  }
+//+------------------------------------------------------------------+
+//| Insert total uninitialized records into pos position             |
+//+------------------------------------------------------------------+
+inline bool CMTArrayBase::InsertEmpty(const UINT pos,const UINT total)
+  {
+//--- check
+   if(pos>m_data_total) return(false);
+//--- reallocate
+   if(!Realloc(total)) return(false);
+//--- move it
+   if(pos<m_data_total)
+      memmove((char*)m_data+((pos+total)*m_data_width),(char*)m_data+(pos*m_data_width),(m_data_total-pos)*m_data_width);
+//--- correct total
+   m_data_total+=total;
+//--- ok
+   return(true);
+  }
+//+------------------------------------------------------------------+
+//| Insert new record into sorted array                              |
+//| Returns NULL if record already exist or reallocation problem     |
+//| Returns inserted record ptr otherwise                            |
+//+------------------------------------------------------------------+
+inline void* CMTArrayBase::Insert(const void *elem,SMTSearch::SortFunctionPtr sort_function)
+  {
+   void *result=NULL;
+//--- check
+   if(!elem || !sort_function) return(result);
+//--- reallocate
+   if(Realloc(1))
+      if((result=SMTSearch::Insert(m_data,elem,m_data_total,m_data_width,sort_function))!=NULL)
+         m_data_total++;
+//--- result
+   return(result);
+  }
+//+------------------------------------------------------------------+
+//| Delete record by position                                        |
+//+------------------------------------------------------------------+
+inline bool CMTArrayBase::Delete(const UINT pos)
+  {
+//--- check
+   if(pos>=m_data_total || !m_data) return(false);
+//--- remove
+   if((pos+1)<m_data_total)
+      memmove((char*)m_data+(pos*m_data_width),(char*)m_data+((pos+1)*m_data_width),((m_data_total-pos)-1)*m_data_width);
+   m_data_total--;
+//--- ok
+   return(true);
+  }
+//+------------------------------------------------------------------+
+//| Delete record by pointer                                         |
+//+------------------------------------------------------------------+
+inline bool CMTArrayBase::Delete(const void *elem)
+  {
+//--- check
+   if(!elem || !m_data || elem<m_data || elem>=((char*)m_data+m_data_total*m_data_width)) return(false);
+//--- calculate position and delete
+   return Delete(((UINT)((const char*)elem-(char*)m_data)/m_data_width));
+  }
+//+------------------------------------------------------------------+
+//| Delete range [from,to]                                           |
+//+------------------------------------------------------------------+
+inline bool CMTArrayBase::DeleteRange(const UINT from,const UINT to)
+  {
+//--- check
+   if(from>to || to>=m_data_total || !m_data) return(false);
+//--- delete
+   if(from+1<m_data_total)
+      memmove((char*)m_data+(from*m_data_width),
+              (char*)m_data+((to+1)*m_data_width),((m_data_total-to)-1)*m_data_width);
+//--- correct total
+   m_data_total-=((to-from)+1);
+//--- ok
+   return(true);
+  }
+//+------------------------------------------------------------------+
+//| Search and remove record from sorted array                       |
+//+------------------------------------------------------------------+
+inline bool CMTArrayBase::Remove(const void *elem,SMTSearch::SortFunctionPtr sort_function)
+  {
+   void   *temp;
+   UINT64  i;
+//--- check
+   if(!elem || !sort_function || !m_data || m_data_total<1 || m_data_width<1) return(false);
+//--- search it
+   if((temp=SMTSearch::Search(elem,m_data,m_data_total,m_data_width,sort_function))==NULL) return(false);
+//--- calc position
+   i=((UINT64)((char*)temp-(char*)m_data))/m_data_width;
+//--- remove it
+   if(i<m_data_total-1) memmove(temp,(char *)temp+m_data_width,(size_t)((m_data_total-i)-1)*m_data_width);
+   m_data_total--;
+//--- ok
+   return(true);
+  }
+//+------------------------------------------------------------------+
+//| Update record                                                    |
+//+------------------------------------------------------------------+
+inline bool CMTArrayBase::Update(const UINT pos,const void *elem)
+  {
+//--- check
+   if(!elem || pos>=m_data_total || !m_data) return(false);
+//--- update
+   memcpy((char*)m_data+(pos*m_data_width),(const char*)elem,m_data_width);
+//--- ok
+   return(true);
+  }
+//+------------------------------------------------------------------+
+//| Shift record from pos                                            |
+//+------------------------------------------------------------------+
+inline bool CMTArrayBase::Shift(const UINT pos,const int shift)
+  {
+   UINT i,newpos=UINT((int)pos+shift);
+//--- check
+   if(pos>=m_data_total || newpos>=m_data_total || !m_data) return(false);
+//--- we need one more record
+   if(!Realloc(1)) return(false);
+//--- save current
+   memcpy((char*)m_data+(m_data_total*m_data_width),(char*)m_data+(pos*m_data_width),m_data_width);
+//--- shift record by record
+   if(newpos>pos)
+      for(i=pos+1;i<=newpos;i++) memcpy((char*)m_data+((i-1)*m_data_width),(char*)m_data+(i*m_data_width),m_data_width);
+   else
+      for(i=pos;i>newpos;i--)    memcpy((char*)m_data+(i*m_data_width),(char*)m_data+((i-1)*m_data_width),m_data_width);
+//--- restore current
+   memcpy((char*)m_data+(newpos*m_data_width),(char*)m_data+(m_data_total*m_data_width),m_data_width);
+//--- ok
+   return(true);
+  }
+//+------------------------------------------------------------------+
+//| Remove size first elements                                       |
+//+------------------------------------------------------------------+
+inline bool CMTArrayBase::Trim(const UINT size)
+  {
+//--- check
+   if(!m_data || size>m_data_total) return(false);
+//--- trim
+   m_data_total-=size;
+   memmove((char*)m_data,(char*)m_data+size*m_data_width,m_data_width*m_data_total);
+//--- ok
+   return(true);
+  }
+//+------------------------------------------------------------------+
+//| Next record by position                                          |
+//+------------------------------------------------------------------+
+inline bool CMTArrayBase::Next(const UINT pos,void *elem) const
+  {
+//--- check
+   if(pos>=m_data_total || !elem || !m_data) return(false);
+//--- copy and return
+   memcpy((char*)elem,(char*)m_data+(pos*m_data_width),m_data_width);
+   return(true);
+  }
+//+------------------------------------------------------------------+
+//| Next record by ptr                                               |
+//+------------------------------------------------------------------+
+inline void* CMTArrayBase::Next(const void *elem) const
+  {
+//--- check
+   if(!elem || !m_data || elem<m_data || elem>=((char*)m_data+(m_data_total-1)*m_data_width)) return(NULL);
+//--- return next element
+   return((char*)elem+m_data_width);
+  }
+//+------------------------------------------------------------------+
+//| Prev record by ptr                                               |
+//+------------------------------------------------------------------+
+inline void* CMTArrayBase::Prev(const void *elem) const
+  {
+//--- check
+   if(!elem || !m_data || elem<=m_data || elem>((char*)m_data+(m_data_total-1)*m_data_width)) return(NULL);
+//--- return next element
+   return((char*)elem-m_data_width);
+  }
+//+------------------------------------------------------------------+
+//| Ptr by position                                                  |
+//+------------------------------------------------------------------+
+inline const void* CMTArrayBase::At(const UINT pos) const
+  {
+   return((const char*)m_data+(pos*m_data_width));
+  }
+//lint –restore
+//+------------------------------------------------------------------+
+//| Ptr by position                                                  |
+//+------------------------------------------------------------------+
+inline void* CMTArrayBase::At(const UINT pos)
+  {
+   return((char*)m_data+(pos*m_data_width));
+  }
+//+------------------------------------------------------------------+
+//| Position by ptr                                                  |
+//+------------------------------------------------------------------+
+inline int CMTArrayBase::Position(const void* ptr) const
+  {
+//--- check
+   if(!ptr || !m_data || !m_data_width || ptr<m_data || ptr>=(char*)m_data+(m_data_total*m_data_width)) return(-1);
+//--- calc offset
+   ldiv_t res=ldiv((long)((const char*)ptr-(char*)m_data),(long)m_data_width);
+//--- check ptr
+   return(res.rem ? -1 : int(res.quot));
+  }
+//+------------------------------------------------------------------+
+//| Receive range                                                    |
+//+------------------------------------------------------------------+
+inline bool CMTArrayBase::Range(const UINT from,const UINT to,void* data) const
+  {
+//--- check
+   if(from>to || from>=m_data_total || to>=m_data_total || !data || !m_data) return(false);
+//--- copy
+   memcpy(data,(char*)m_data+(from*m_data_width),((to-from)+1)*m_data_width);
+   return(true);
+  }
+//+------------------------------------------------------------------+
+//| Sort array                                                       |
+//+------------------------------------------------------------------+
+inline void CMTArrayBase::Sort(SMTSearch::SortFunctionPtr sort_function)
+  {
+   if(m_data && m_data_total>0 && sort_function)
+      qsort(m_data,m_data_total,m_data_width,sort_function);
+  }
+//+------------------------------------------------------------------+
+//| Search by key value on sorted array                              |
+//+------------------------------------------------------------------+
+inline void* CMTArrayBase::Search(const void *key,SMTSearch::SortFunctionPtr sort_function) const
+  {
+//--- check
+   if(key && m_data && m_data_total>0 && sort_function)
+      return(SMTSearch::Search(key,m_data,m_data_total,m_data_width,sort_function));
+//--- something wrong
+   return(NULL);
+  }
+//+------------------------------------------------------------------+
+//| Search great or equal than key value on sorted array             |
+//+------------------------------------------------------------------+
+inline void* CMTArrayBase::SearchGreatOrEq(const void *key,SMTSearch::SortFunctionPtr sort_function) const
+  {
+//--- check
+   if(key && m_data && m_data_total>0 && sort_function)
+      return(SMTSearch::SearchGreatOrEq(key,m_data,m_data_total,m_data_width,sort_function));
+//--- something wrong
+   return(NULL);
+  }
+//+------------------------------------------------------------------+
+//| Search great than key value on sorted array                      |
+//+------------------------------------------------------------------+
+inline void* CMTArrayBase::SearchGreater(const void *key,SMTSearch::SortFunctionPtr sort_function) const
+  {
+//--- check
+   if(key && m_data && m_data_total>0 && sort_function)
+      return(SMTSearch::SearchGreater(key,m_data,m_data_total,m_data_width,sort_function));
+//--- something wrong
+   return(NULL);
+  }
+//+------------------------------------------------------------------+
+//| Search less or equal than key value on sorted array              |
+//+------------------------------------------------------------------+
+inline void* CMTArrayBase::SearchLessOrEq(const void *key,SMTSearch::SortFunctionPtr sort_function) const
+  {
+//--- check
+   if(key && m_data && m_data_total>0 && sort_function)
+      return(SMTSearch::SearchLessOrEq(key,m_data,m_data_total,m_data_width,sort_function));
+//--- something wrong
+   return(NULL);
+  }
+//+------------------------------------------------------------------+
+//| Search less than key value on sorted array                       |
+//+------------------------------------------------------------------+
+inline void* CMTArrayBase::SearchLess(const void *key,SMTSearch::SortFunctionPtr sort_function) const
+  {
+//--- check
+   if(key && m_data && m_data_total>0 && sort_function)
+      return(SMTSearch::SearchLess(key,m_data,m_data_total,m_data_width,sort_function));
+//--- something wrong
+   return(NULL);
+  }
+//+------------------------------------------------------------------+
+//| Search first element with key equal to key value on sorted array |
+//+------------------------------------------------------------------+
+inline void* CMTArrayBase::SearchLeft(const void *key,SMTSearch::SortFunctionPtr sort_function) const
+  {
+//--- check
+   if(key && m_data && m_data_total>0 && sort_function)
+      return(SMTSearch::SearchLeft(key,m_data,m_data_total,m_data_width,sort_function));
+//--- something wrong
+   return(NULL);
+  }
+//+------------------------------------------------------------------+
+//| Search last element with key equal to key value on sorted array  |
+//+------------------------------------------------------------------+
+inline void* CMTArrayBase::SearchRight(const void *key,SMTSearch::SortFunctionPtr sort_function) const
+  {
+//--- check
+   if(key && m_data && m_data_total>0 && sort_function)
+      return(SMTSearch::SearchRight(key,m_data,m_data_total,m_data_width,sort_function));
+//--- something wrong
+   return(NULL);
+  }
+//+------------------------------------------------------------------+
+//| Dynamic array template                                           |
+//| For POD data types only!                                         |
+//+------------------------------------------------------------------+
+template <class T,UINT step=16> class TMTArray : public CMTArrayBase
+  {
+public:
+                     TMTArray() : CMTArrayBase(sizeof(T),step)            {}
+   virtual          ~TMTArray(){}
+   //--- global management
+   void              Swap(TMTArray<T,step> &arr)                          { CMTArrayBase::Swap(arr);                     }
+   //--- add
+   bool              Add(const T *elem)                                   { return CMTArrayBase::Add(elem);              }
+   bool              Add(const T *elem,const UINT total)                  { return CMTArrayBase::Add(elem,total);        }
+   bool              Add(const TMTArray<T,step>& arr)                     { return CMTArrayBase::Add(arr);               }
+   bool              AddRange(const TMTArray<T,step>& arr,const UINT from,const UINT to)
+   { return CMTArrayBase::AddRange(arr,from,to);  }
+   T*                Append(void)                                         { return(T*)CMTArrayBase::Append();            }
+   bool              Insert(const UINT pos,const T *elem)                 { return CMTArrayBase::Insert(pos,elem);       }
+   bool              Insert(const UINT pos,const T *elem,const UINT total){ return CMTArrayBase::Insert(pos,elem,total); }
+   T*                Insert(const T *elem,SMTSearch::SortFunctionPtr order) { return(T*)CMTArrayBase::Insert(elem,order);}
+   //--- delete
+   bool              Delete(const UINT pos)                               { return CMTArrayBase::Delete(pos);            }
+   bool              Delete(const T *elem)                                { return CMTArrayBase::Delete(elem);           }
+   bool              Remove(const T *elem,SMTSearch::SortFunctionPtr order) { return CMTArrayBase::Remove(elem,order);   }
+   //--- modify
+   bool              Update(const UINT pos,const T *elem)                 { return CMTArrayBase::Update(pos,elem);       }
+   //--- data access
+   bool              Next(const UINT pos,T *elem) const                   { return CMTArrayBase::Next(pos,elem);         }
+   T*                Next(const T* elem) const                            { return(T*)CMTArrayBase::Next(elem);          }
+   T*                Prev(const T* elem)                                  { return(T*)CMTArrayBase::Prev(elem);          }
+   T*                First(void)                                          { return(T*)CMTArrayBase::At(0);               }
+   int               Position(const T* ptr) const                         { return CMTArrayBase::Position(ptr);          }
+   bool              Range(const UINT from,const UINT to,T* data) const   { return CMTArrayBase::Range(from,to,data);    }
+   //--- search
+   T*                Search(const void *key,SMTSearch::SortFunctionPtr sort_function)          const  { return(T*)CMTArrayBase::Search(key,sort_function);          }
+   T*                SearchGreatOrEq(const void *key,SMTSearch::SortFunctionPtr sort_function) const  { return(T*)CMTArrayBase::SearchGreatOrEq(key,sort_function); }
+   T*                SearchGreater(const void *key,SMTSearch::SortFunctionPtr sort_function)   const  { return(T*)CMTArrayBase::SearchGreater(key,sort_function);   }
+   T*                SearchLessOrEq(const void *key,SMTSearch::SortFunctionPtr sort_function)  const  { return(T*)CMTArrayBase::SearchLessOrEq(key,sort_function);  }
+   T*                SearchLess(const void *key,SMTSearch::SortFunctionPtr sort_function)      const  { return(T*)CMTArrayBase::SearchLess(key,sort_function);      }
+   T*                SearchLeft(const void *key,SMTSearch::SortFunctionPtr sort_function)      const  { return(T*)CMTArrayBase::SearchLeft(key,sort_function);      }
+   T*                SearchRight(const void *key,SMTSearch::SortFunctionPtr sort_function)     const  { return(T*)CMTArrayBase::SearchRight(key,sort_function);     }
+   //--- operators
+   const T&          operator[](const UINT pos) const                     { return(*(T*)CMTArrayBase::At(pos));          }
+   T&                operator[](const UINT pos)                           { return(*(T*)CMTArrayBase::At(pos));          }
+   bool              operator==(const TMTArray<T,step>& arr) const        { return(CMTArrayBase::Compare(arr));          }
+   bool              operator!=(const TMTArray<T,step>& arr) const        { return(!CMTArrayBase::Compare(arr));         }
+   TMTArray<T,step>& operator= (const TMTArray<T,step>& arr)              { if(this!=&arr) Assign(arr); return(*this);   }
+
+private:
+                     TMTArray(const TMTArray&) {};
+  };
+//+------------------------------------------------------------------+
+//| Predefined arrays                                                |
+//+------------------------------------------------------------------+
+typedef TMTArray<UCHAR>   MTByteArray;
+typedef TMTArray<wchar_t> MTCharArray;
+typedef TMTArray<SHORT>   MTShortArray;
+typedef TMTArray<USHORT>  MTUShortArray;
+typedef TMTArray<int>     MTIntArray;
+typedef TMTArray<UINT>    MTUIntArray;
+typedef TMTArray<INT64>   MTInt64Array;
+typedef TMTArray<UINT64>  MTUInt64Array;
+typedef TMTArray<double>  MTDoubleArray;
+//+------------------------------------------------------------------+

+ 1049 - 0
MT5SDK/Classes/MT5APIStr.h

@@ -0,0 +1,1049 @@
+//+------------------------------------------------------------------+
+//|                                                 MetaTrader 5 API |
+//|                   Copyright 2000-2019, MetaQuotes Software Corp. |
+//|                                        http://www.metaquotes.net |
+//+------------------------------------------------------------------+
+#pragma once
+#include <new.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <memory.h>
+#include <winnls.h>
+//+------------------------------------------------------------------+
+//| String base class                                                |
+//+------------------------------------------------------------------+
+class CMTStr
+  {
+protected:
+   wchar_t          *m_str;                 // string body
+   UINT              m_str_len;             // string length
+   const UINT        m_str_max;             // string buffer max size
+
+public:
+                     CMTStr(wchar_t *buf,const UINT size):m_str(buf),m_str_len(0),m_str_max(size) { if(m_str) m_str[0]=0; }
+   virtual          ~CMTStr()                   { m_str=NULL; m_str_len=0;                   }
+   //--- base functionality
+   void              Clear()                    { m_str_len=0; if(m_str) m_str[0]=0;         }
+   bool              Empty() const              { return(m_str_len<1 || m_str==NULL || m_str[0]==0); }
+   UINT              Len()   const              { return(m_str_len);                         }
+   static UINT       Len(LPCWSTR str)           { return(str ? (UINT)wcslen(str):0);         }
+   UINT              Max()   const              { return(m_str_max);                         }
+   const wchar_t*    Str()   const              { return(m_str);                             }
+   wchar_t*          Buffer()                   { return(m_str);                             }
+   void              Refresh()                  { m_str_len=(m_str ? (UINT)wcsnlen(m_str,m_str_max):0);  }
+   const wchar_t     operator[](UINT ind) const { return((ind<m_str_len && m_str) ? m_str[ind] : L'\0'); }
+   bool              operator!() const          { return(m_str_len==0);                                  }
+   CMTStr&           operator= (const CMTStr& src) { if(this!=&src) Assign(src); return(*this);          }
+   //--- assign
+   void              Assign(const CMTStr &from);
+   void              Assign(LPCWSTR from);
+   void              Assign(LPCWSTR from,const UINT from_len);
+   void              Assign(LPCSTR from);
+   void              Assign(LPCSTR from,const UINT from_len);
+   //--- operations
+   int               Format(LPCWSTR fmt,...);
+   void              ToLower();
+   void              ToUpper();
+   void              Trim(UINT len);
+   void              TrimSpaces();
+   static void       TrimSpaces(LPWSTR str);
+   void              ReplaceChar(wchar_t findchar,wchar_t repchar);
+   void              Replace(wchar_t *findstr,const wchar_t *repstr);
+   void              Delete(UINT pos,UINT len);
+   template <UINT dstsize>
+   static void       Delete(wchar_t (&dst)[dstsize],UINT pos,UINT len) { Delete(dst,dstsize,pos,len); }
+   static void       Delete(LPWSTR dst,UINT dstsize,UINT pos,UINT len);
+   static void       ToLower(LPWSTR str,UINT size);
+   static void       ToUpper(LPWSTR str,UINT size);
+   template <UINT size>
+   static void       ToLower(wchar_t (&str)[size]) { ToLower(str,size); }
+   template <UINT size>
+   static void       ToUpper(wchar_t (&str)[size]) { ToUpper(str,size); }
+   template <UINT strsize>
+   static int        FormatStr(wchar_t (&str)[strsize],LPCWSTR fmt,...);
+   static int        FormatStr(LPWSTR str,UINT size,LPCWSTR fmt,...);
+   template <UINT strsize>
+   static void       Terminate(wchar_t (&str)[strsize]) { str[strsize-1]=L'\0'; }
+   //--- append
+   void              Append(LPCWSTR appstring);
+   void              Append(const CMTStr &appstring);
+   void              Append(wchar_t appchar);
+   template <UINT dstsize>
+   static void       Append(wchar_t (&dst)[dstsize],LPCWSTR src) { Append(dst,dstsize,src); }
+   static void       Append(LPWSTR dst,UINT dstsize,LPCWSTR src);
+   //--- insert
+   void              Insert(UINT pos,LPCWSTR insstring);
+   void              Insert(UINT pos,const CMTStr &insstring);
+   void              Insert(UINT pos,wchar_t inschar);
+   //--- copy
+   void              Copy(LPWSTR string,UINT maxlen) const;
+   void              Copy(LPSTR string,UINT maxlen) const;
+   template <UINT dstsize>
+   static void       Copy(wchar_t (&dst)[dstsize],LPCWSTR src)               { Copy(dst,dstsize,src);          }
+   template <UINT dstsize>
+   static void       Copy(wchar_t (&dst)[dstsize],LPCWSTR src,UINT srccount) { Copy(dst,dstsize,src,srccount); }
+   static void       Copy(LPWSTR dst,UINT dstsize,LPCWSTR src);
+   static void       Copy(LPWSTR dst,UINT dstsize,LPCWSTR src,UINT srccount);
+   template <UINT dstsize>
+   static void       Copy(char (&dst)[dstsize],LPCWSTR src)    { Copy(dst,dstsize,src); }
+   static void       Copy(LPSTR dst,UINT dstsize,LPCWSTR src);
+   static void       Copy(LPWSTR dst,UINT dstsize,LPCSTR src);
+   static void       CopyCodePage(LPWSTR dst,UINT dstsize,LPCSTR src,UINT codepage);
+   //--- compare
+   int               Compare(LPCWSTR str) const;
+   int               Compare(LPCWSTR str,UINT count) const;
+   int               Compare(const CMTStr& str) const;
+   static int        Compare(LPCWSTR str1,LPCWSTR str2);
+   static int        Compare(LPCWSTR str1,LPCWSTR str2,UINT count);
+   //--- compare no case
+   int               CompareNoCase(LPCWSTR str) const;
+   int               CompareNoCase(LPCWSTR str,UINT count) const;
+   int               CompareNoCase(const CMTStr& str) const;
+   static int        CompareNoCase(LPCWSTR str1,LPCWSTR str2);
+   static int        CompareNoCase(LPCWSTR str1,LPCWSTR str2,UINT count);
+   //--- check groups mask
+   static bool       CheckGroupMask(LPCWSTR groupsmask,LPCWSTR group);
+   //--- find symbol & substring
+   int               Find(LPCWSTR substring,UINT startpos) const;
+   int               Find(LPCWSTR substring) const;
+   int               FindNoCase(LPCWSTR substring,UINT startpos) const;
+   int               FindNoCase(LPCWSTR substring) const { return FindNoCase(substring,(UINT)0); }
+   int               FindR(LPCWSTR substring) const;
+   int               FindChar(const wchar_t character) const;
+   int               FindRChar(const wchar_t character) const;
+   static int        Find(LPCWSTR str,LPCWSTR substr);
+   static int        FindNoCase(LPCWSTR str,LPCWSTR substr);
+   static int        FindR(LPCWSTR str,LPCWSTR substr);
+   static int        FindChar(LPCWSTR str,wchar_t character);
+   static int        FindRChar(LPCWSTR str,wchar_t character);
+   //--- error description method
+   LPCWSTR           ErrorMsg(const DWORD error);
+
+protected:
+                     CMTStr();
+                     CMTStr(const CMTStr &from);
+   CMTStr(LPWSTR buf,const UINT size,LPCWSTR from):m_str(buf),m_str_len(0),m_str_max(size)
+     {
+      if(m_str) m_str[0]=0;
+      Assign(from);
+     }
+private:
+   static bool        CheckGroupTemplate(LPWSTR expr,LPCWSTR group);
+  };
+//+------------------------------------------------------------------+
+//| Stack string template                                            |
+//+------------------------------------------------------------------+
+template <UINT buflen> class TMTStrStatic : public CMTStr
+  {
+   wchar_t           m_buffer[buflen];
+public:
+                     TMTStrStatic()                       : CMTStr(m_buffer,buflen)      {}
+                     TMTStrStatic(LPCWSTR from)           : CMTStr(m_buffer,buflen,from) {}
+                     TMTStrStatic(const TMTStrStatic& from) : CMTStr(m_buffer,buflen) { Assign(from); }
+                     TMTStrStatic(const CMTStr&       from) : CMTStr(m_buffer,buflen) { Assign(from); }
+  };
+//+------------------------------------------------------------------+
+//| Stack strings types                                              |
+//+------------------------------------------------------------------+
+typedef TMTStrStatic<16>   CMTStr16;
+typedef TMTStrStatic<32>   CMTStr32;
+typedef TMTStrStatic<64>   CMTStr64;
+typedef TMTStrStatic<128>  CMTStr128;
+typedef TMTStrStatic<256>  CMTStr256;
+typedef TMTStrStatic<260>  CMTStrPath;
+typedef TMTStrStatic<512>  CMTStr512;
+typedef TMTStrStatic<1024> CMTStr1024;
+typedef TMTStrStatic<2048> CMTStr2048;
+typedef TMTStrStatic<4096> CMTStr4096;
+//+------------------------------------------------------------------+
+//| Assign from CMTStr                                               |
+//+------------------------------------------------------------------+
+inline void CMTStr::Assign(const CMTStr &from)
+  {
+//--- check
+   if(m_str)
+     {
+      UINT newlen=from.Len();
+      //--- calc new length
+      if(newlen>=m_str_max) newlen=m_str_max-1;
+      memcpy(m_str,from.Str(),newlen*sizeof(wchar_t));
+      m_str_len=newlen;
+      //--- terminate
+      m_str[m_str_len]=0;
+     }
+//---
+  }
+//+------------------------------------------------------------------+
+//| Assign from ptr                                                  |
+//+------------------------------------------------------------------+
+inline void CMTStr::Assign(LPCWSTR from)
+  {
+//--- check
+   if(m_str)
+     {
+      //--- check empty string
+      if(!from) m_str_len=0;
+      else
+        {
+         UINT newlen=(UINT)wcsnlen(from,m_str_max);
+         //--- calculate new length and copy
+         if(newlen>=m_str_max) newlen=m_str_max-1;
+         memcpy(m_str,from,newlen*sizeof(wchar_t));
+         m_str_len=newlen;
+        }
+      //--- terminate string
+      m_str[m_str_len]=0;
+     }
+  }
+//+------------------------------------------------------------------+
+//| Assign from ptr with len                                         |
+//+------------------------------------------------------------------+
+inline void CMTStr::Assign(LPCWSTR from,const UINT from_len)
+  {
+//--- check
+   if(m_str)
+     {
+      //--- check empty string
+      if(!from) m_str_len=0;
+      else
+        {
+         UINT newlen=(UINT)wcsnlen(from,(from_len<m_str_max)?(from_len):(m_str_max));
+         //--- calculate new length and copy
+         if(newlen>=m_str_max) newlen=m_str_max-1;
+         memcpy(m_str,from,newlen*sizeof(wchar_t));
+         m_str_len=newlen;
+        }
+      //--- terminate string
+      m_str[m_str_len]=0;
+     }
+  }
+//+------------------------------------------------------------------+
+//| Assign from one-byte string                                      |
+//+------------------------------------------------------------------+
+inline void CMTStr::Assign(LPCSTR from)
+  {
+//--- check
+   if(m_str)
+     {
+      //--- check empty string
+      if(!from) m_str[0]=0;
+      else
+        {
+         //--- copy string
+         int len=::MultiByteToWideChar(CP_ACP,0,from,-1,m_str,int(m_str_max-1));
+         //--- check result
+         if(len==0 && GetLastError()==ERROR_INSUFFICIENT_BUFFER) m_str[m_str_max-1]=0;
+         else
+           {
+            //--- len must be greater or equal than 0
+            len=(0>len)?(0):(len);
+            //--- limit len
+            len=(len<((int)m_str_max-1))?(len):((int)m_str_max-1);
+            //--- terminate string
+            m_str[len]=0;
+           }
+        }
+      //--- refresh
+      Refresh();
+     }
+  }
+//+------------------------------------------------------------------+
+//| Assign from one-byte string with length                          |
+//+------------------------------------------------------------------+
+inline void CMTStr::Assign(LPCSTR from,const UINT from_len)
+  {
+//--- check
+   if(m_str)
+     {
+      //--- check empty string
+      if(!from) m_str[0]=0;
+      else
+        {
+         //--- copy string
+         int len=::MultiByteToWideChar(CP_ACP,0,from,int(from_len),m_str,int(m_str_max-1));
+         //--- check result
+         if(len==0 && GetLastError()==ERROR_INSUFFICIENT_BUFFER) m_str[m_str_max-1]=0;
+         else
+           {
+            //--- len must be greater or equal than 0
+            len=(0>len)?(0):(len);
+            //--- limit len
+            len=(len<((int)m_str_max-1))?(len):((int)m_str_max-1);
+            //--- terminate string
+            m_str[len]=0;
+           }
+        }
+      //--- refresh
+      Refresh();
+     }
+  }
+//+------------------------------------------------------------------+
+//| Copy from ptr with len                                           |
+//+------------------------------------------------------------------+
+inline void CMTStr::Copy(LPWSTR string,UINT maxlen) const
+  {
+   if(string && maxlen>0 && m_str) wcsncpy_s(string,maxlen,m_str,_TRUNCATE);
+  }
+//+------------------------------------------------------------------+
+//| Copy from one-byte string with len                               |
+//+------------------------------------------------------------------+
+inline void CMTStr::Copy(LPSTR string,UINT maxlen) const
+  {
+   if(string && maxlen>0 && m_str)
+      ::WideCharToMultiByte(CP_ACP,0,m_str,-1,string,int(maxlen),NULL,NULL);
+  }
+//+------------------------------------------------------------------+
+//| Static copy from string with len                                 |
+//+------------------------------------------------------------------+
+inline void CMTStr::Copy(LPWSTR dst,UINT dstsize,LPCWSTR src)
+  {
+   if(dst && src && dstsize>0)
+     {
+      //--- copy string
+      wcsncpy_s(dst,dstsize,src,_TRUNCATE);
+      //--- remove trash symbols from CRT in Debug
+      #ifdef _DEBUG
+      for(UINT pos=Len(dst)+1;pos<dstsize;pos++) dst[pos]=(wchar_t)0;
+      #endif
+     }
+  }
+//+------------------------------------------------------------------+
+//| Static copy from string with len                                 |
+//+------------------------------------------------------------------+
+inline void CMTStr::Copy(LPWSTR dst,UINT dstsize,LPCWSTR src,UINT srccount)
+  {
+   if(dst && src && dstsize>0 && srccount>0)
+     {
+      //--- copy string
+      wcsncpy_s(dst,dstsize,src,dstsize>srccount ? srccount:_TRUNCATE);
+      //--- remove trash symbols from CRT in Debug
+      #ifdef _DEBUG
+      for(UINT pos=Len(dst)+1;pos<dstsize;pos++) dst[pos]=(wchar_t)0;
+      #endif
+     }
+  }
+//+------------------------------------------------------------------+
+//| Copy from one-byte to unicode string                             |
+//+------------------------------------------------------------------+
+inline void CMTStr::Copy(LPSTR dst,UINT dstsize,LPCWSTR src)
+  {
+   if(dst && src && dstsize>0)
+      ::WideCharToMultiByte(CP_ACP,0,src,-1,dst,int(dstsize),NULL,NULL);
+  }
+//+------------------------------------------------------------------+
+//| Copy from unicode to one-byte string                             |
+//+------------------------------------------------------------------+
+inline void CMTStr::Copy(LPWSTR dst,UINT dstsize,LPCSTR src)
+  {
+   if(dst && src)
+      ::MultiByteToWideChar(CP_ACP,0,src,-1,dst,int(dstsize));
+  }
+//+------------------------------------------------------------------+
+//| Copy from unicode to one-byte string with codepage               |
+//+------------------------------------------------------------------+
+inline void CMTStr::CopyCodePage(LPWSTR dst,UINT dstsize,LPCSTR src,UINT codepage)
+  {
+   if(dst && src)
+      ::MultiByteToWideChar(codepage,0,src,-1,dst,int(dstsize));
+  }
+//+------------------------------------------------------------------+
+//| String format                                                    |
+//+------------------------------------------------------------------+
+inline int CMTStr::Format(LPCWSTR fmt,...)
+  {
+   int len=-1;
+//---
+   if(fmt && m_str)
+     {
+      va_list marker;
+      //--- format text
+      va_start(marker,fmt);
+      len=_vsnwprintf_s(m_str,m_str_max,_TRUNCATE,fmt,marker);
+      va_end(marker);
+      //--- check result
+      if(len>=0) m_str_len=UINT(len);
+      else       m_str_len=(UINT)wcsnlen(m_str,m_str_max);
+     }
+//---
+   return(len);
+  }
+//+------------------------------------------------------------------+
+//| Convert to lower case                                            |
+//+------------------------------------------------------------------+
+inline void CMTStr::ToLower()
+  {
+   if(m_str) _wcslwr_s(m_str,m_str_max);
+  }
+//+------------------------------------------------------------------+
+//| Convert to upper case                                            |
+//+------------------------------------------------------------------+
+inline void CMTStr::ToUpper()
+  {
+   if(m_str) _wcsupr_s(m_str,m_str_max);
+  }
+//+------------------------------------------------------------------+
+//| Trim symbols from right                                          |
+//+------------------------------------------------------------------+
+inline void CMTStr::Trim(UINT len)
+  {
+   if(m_str && len<m_str_len)
+     {
+      m_str_len=len;
+      m_str[m_str_len]=0;
+     }
+  }
+//+------------------------------------------------------------------+
+//| Trim spaces                                                      |
+//+------------------------------------------------------------------+
+inline void CMTStr::TrimSpaces()
+  {
+   UINT pos;
+//--- check
+   if(m_str_len==0 || !m_str) return;
+//--- remove lead spaces
+   for(pos=0;m_str[pos]==L' ';) pos++;
+   if(pos>0)
+     {
+      memmove(&m_str[0],&m_str[pos],(m_str_len-pos+1)*sizeof(m_str[0]));
+      m_str_len-=pos;
+     }
+//--- remove last spaces
+   for(pos=m_str_len;pos>0;pos--)
+     {
+      if(m_str[pos-1]==L' ') m_str[pos-1]=L'\0';
+      else break;
+     }
+//--- refresh length
+   m_str_len=pos;
+  }
+//+------------------------------------------------------------------+
+//| Trim spaces                                                      |
+//+------------------------------------------------------------------+
+inline void CMTStr::TrimSpaces(LPWSTR str)
+  {
+   size_t len,pos;
+//--- check
+   if(!str || (len=wcslen(str))==0) return;
+//--- remove lead spaces
+   for(pos=0;str[pos]==L' ';) pos++;
+   if(pos>0)
+     {
+      memmove(&str[0],&str[pos],(len-pos+1)*sizeof(str[0]));
+      len-=pos;
+     }
+//--- remove last spaces
+   for(pos=len;pos>0;pos--)
+      if(str[pos-1]==L' ') str[pos-1]=L'\0';
+      else break;
+  }
+//+------------------------------------------------------------------+
+//| Replace symbol                                                   |
+//+------------------------------------------------------------------+
+inline void CMTStr::ReplaceChar(wchar_t findchar,wchar_t repchar)
+  {
+//--- check
+   if(m_str_len==0 || !m_str) return;
+//--- replace
+   for(UINT pos=0;pos<m_str_len;pos++)
+      if(m_str[pos]==findchar) m_str[pos]=repchar;
+  }
+//+------------------------------------------------------------------+
+//| Replace substring                                                |
+//+------------------------------------------------------------------+
+inline void CMTStr::Replace(wchar_t *findstr,const wchar_t *repstr)
+  {
+//--- check
+   if(findstr && repstr && m_str)
+     {
+      wchar_t *from=m_str;
+      wchar_t *cp;
+      size_t   newsize=0,findstr_len=wcslen(findstr);
+      wchar_t *newstr =NULL;
+      //--- search
+      while((cp=wcsstr(from,findstr))!=NULL)
+        {
+         //--- buffer allocated?
+         if(!newstr)
+           {
+            newsize=m_str_max;
+            newstr =new(std::nothrow) wchar_t[newsize];
+            //--- fail
+            if(newstr==NULL) break;
+           }
+         *cp=0;
+         m_str_len=_snwprintf_s(newstr,newsize,_TRUNCATE,L"%s%s%s",m_str,repstr,cp+findstr_len);
+         //--- copy
+         if(m_str_len>=m_str_max) m_str_len=m_str_max-1;
+         memcpy(m_str,newstr,m_str_len*sizeof(wchar_t));
+         m_str[m_str_len]=0;
+         //--- next position
+         from=m_str+(cp-m_str)+wcslen(repstr);
+        }
+      //--- free buffer
+      if(newstr)
+        {
+         delete[] newstr;
+         newstr=NULL;
+        }
+     }
+  }
+//+------------------------------------------------------------------+
+//| Delete len symbols from pos position                             |
+//+------------------------------------------------------------------+
+inline void CMTStr::Delete(UINT pos,UINT len)
+  {
+//--- check
+   if(pos>=m_str_len || len==0 || !m_str) return;
+//--- remove
+   if(pos+len>m_str_len) len=m_str_len-pos;
+   if(pos+len<m_str_len)
+      for(UINT i=pos;i<m_str_len-len;i++)
+         m_str[i]=m_str[i+len];
+   m_str_len-=len;
+   m_str[m_str_len]=L'\0';
+  }
+//+------------------------------------------------------------------+
+//| Delete len symbols from pos position                             |
+//+------------------------------------------------------------------+
+inline void CMTStr::Delete(LPWSTR dst,UINT dstsize,UINT pos,UINT len)
+  {
+   UINT dstlen;
+//--- check
+   if(!dst || dstsize==0) return;
+   dstlen=Len(dst);
+   if(pos>=dstlen-1)      return;
+//--- remove
+   if(pos+len>dstlen) len=dstlen-pos;
+   if(pos+len<dstlen)
+      for(UINT i=pos;i<dstlen-len;i++)
+         dst[i]=dst[i+len];
+   dst[dstlen-len]=L'\0';
+  }
+//+------------------------------------------------------------------+
+//| Convert to lower case                                            |
+//+------------------------------------------------------------------+
+inline void CMTStr::ToLower(LPWSTR str,UINT size)
+  {
+   if(str && size>0) _wcslwr_s(str,size);
+  }
+//+------------------------------------------------------------------+
+//| Convert to upper case                                            |
+//+------------------------------------------------------------------+
+inline void CMTStr::ToUpper(LPWSTR str,UINT size)
+  {
+   if(str && size>0) _wcsupr_s(str,size);
+  }
+//+------------------------------------------------------------------+
+//| Static string format                                             |
+//+------------------------------------------------------------------+
+template<UINT strsize>
+inline int CMTStr::FormatStr(wchar_t (&str)[strsize],LPCWSTR fmt,...)
+  {
+   int len=-1;
+//---
+   if(str && strsize>1 && fmt)
+     {
+      va_list marker;
+      //--- format text
+      va_start(marker,fmt);
+      len=_vsnwprintf_s(str,strsize,_TRUNCATE,fmt,marker);
+      va_end(marker);
+      //--- check
+      if(len>0) str[len]=L'\0';
+     }
+//---
+   return(len);
+  }
+//+------------------------------------------------------------------+
+//| Static string format                                             |
+//+------------------------------------------------------------------+
+inline int CMTStr::FormatStr(LPWSTR str,UINT size,LPCWSTR fmt,...)
+  {
+   int len=-1;
+//---
+   if(str && size>1 && fmt)
+     {
+      va_list marker;
+      //--- format text
+      va_start(marker,fmt);
+      len=_vsnwprintf_s(str,size,_TRUNCATE,fmt,marker);
+      va_end(marker);
+      //--- check
+      if(len>0) str[len]=L'\0';
+     }
+//---
+   return(len);
+  }
+//+------------------------------------------------------------------+
+//| Append to end                                                    |
+//+------------------------------------------------------------------+
+inline void CMTStr::Append(LPCWSTR appstring)
+  {
+   UINT len;
+//--- check appstring
+   if(m_str && appstring && (len=(UINT)wcslen(appstring))>0 && (len+m_str_len)<m_str_max)
+     {
+      memcpy(&m_str[m_str_len],appstring,len*sizeof(m_str[0]));
+      m_str_len+=len;
+      m_str[m_str_len]=0;
+     }
+  }
+//+------------------------------------------------------------------+
+//| Append to end                                                    |
+//+------------------------------------------------------------------+
+inline void CMTStr::Append(const CMTStr &appstring)
+  {
+//--- check appstring
+   if(m_str && appstring.Len()>0 && (appstring.Len()+m_str_len)<m_str_max)
+     {
+      memcpy(&m_str[m_str_len],appstring.Str(),appstring.Len()*sizeof(m_str[0]));
+      m_str_len+=appstring.Len();
+      m_str[m_str_len]=0;
+     }
+  }
+//+------------------------------------------------------------------+
+//| Append symbol to end                                             |
+//+------------------------------------------------------------------+
+inline void CMTStr::Append(wchar_t appchar)
+  {
+//--- check appchar
+   if(m_str && appchar!=L'\0' && (m_str_len+1)<m_str_max)
+     {
+      m_str[m_str_len]=appchar;
+      m_str[++m_str_len]=L'\0';
+     }
+  }
+//+------------------------------------------------------------------+
+//| Append to end                                                    |
+//+------------------------------------------------------------------+
+inline void CMTStr::Append(LPWSTR dst,UINT dstsize,LPCWSTR src)
+  {
+   if(dst && src)
+     {
+      //--- find destination and and calculate free size
+      wchar_t* dst_it=dst;
+      size_t   available=dstsize;
+      while(available>0 && *dst_it!=0)
+        {
+         ++dst_it;
+         --available;
+        }
+      //--- not enough free size?
+      if(available==0)
+         return;
+      //--- copy and check
+      wchar_t* dst_end=dst_it;
+      wchar_t const* src_it=src;
+      while((*dst_it++=*src_it++)!=0 && --available>0)
+        {
+        }
+      //--- not enough free size?
+      if(available==0)
+         *dst_end=0;
+     }
+  }
+//+------------------------------------------------------------------+
+//| Substring insert                                                 |
+//+------------------------------------------------------------------+
+inline void CMTStr::Insert(UINT pos,LPCWSTR insstring)
+  {
+   UINT len;
+//--- check insstring
+   if(m_str && insstring && (len=(UINT)wcslen(insstring))>0 && (len+m_str_len)<m_str_max)
+     {
+      memmove(&m_str[pos+len],&m_str[pos],(m_str_len-pos)*sizeof(m_str[0]));
+      memcpy(&m_str[pos],insstring,len*sizeof(m_str[0]));
+      m_str_len+=len;
+      m_str[m_str_len]=L'\0';
+     }
+  }
+//+------------------------------------------------------------------+
+//| Substring insert                                                 |
+//+------------------------------------------------------------------+
+inline void CMTStr::Insert(UINT pos,const CMTStr &insstring)
+  {
+//--- check insstring
+   if(m_str && insstring.Len()>0 && (insstring.Len()+m_str_len)<m_str_max)
+     {
+      memmove(&m_str[pos+insstring.Len()],&m_str[pos],(m_str_len-pos)*sizeof(m_str[0]));
+      memcpy(&m_str[pos],insstring.Str(),insstring.Len()*sizeof(m_str[0]));
+      m_str_len+=insstring.Len();
+      m_str[m_str_len]=L'\0';
+     }
+  }
+//+------------------------------------------------------------------+
+//| Symbol insert                                                    |
+//+------------------------------------------------------------------+
+inline void CMTStr::Insert(UINT pos,wchar_t inschar)
+  {
+//--- check inschar
+   if(m_str && inschar!=L'\0' && (m_str_len+1)<m_str_max)
+     {
+      memmove(&m_str[pos+1],&m_str[pos],(m_str_len-pos)*sizeof(m_str[0]));
+      m_str[pos]=inschar;
+      m_str[++m_str_len]=L'\0';
+     }
+  }
+//+------------------------------------------------------------------+
+//| Compare                                                          |
+//+------------------------------------------------------------------+
+inline int CMTStr::Compare(LPCWSTR str) const
+  {
+   if(m_str && str) return wcscmp(m_str,str);
+   return(m_str_len<1 ? 0 : 1);
+  }
+//+------------------------------------------------------------------+
+//| Compare                                                          |
+//+------------------------------------------------------------------+
+inline int CMTStr::Compare(LPCWSTR str,UINT count) const
+  {
+   if(m_str && str) return wcsncmp(m_str,str,count);
+   return(m_str_len<1 ? 0 : 1);
+  }
+//+------------------------------------------------------------------+
+//| Compare                                                          |
+//+------------------------------------------------------------------+
+inline int CMTStr::Compare(const CMTStr& str) const
+  {
+   return(m_str ? wcscmp(m_str,str.Str()) : -1);
+  }
+//+------------------------------------------------------------------+
+//| Compare                                                          |
+//+------------------------------------------------------------------+
+inline int CMTStr::Compare(LPCWSTR str1,LPCWSTR str2)
+  {
+   return wcscmp(str1,str2);
+  }
+//+------------------------------------------------------------------+
+//| Compare                                                          |
+//+------------------------------------------------------------------+
+inline int CMTStr::Compare(LPCWSTR str1,LPCWSTR str2,UINT count)
+  {
+   return wcsncmp(str1,str2,count);
+  }
+//+------------------------------------------------------------------+
+//| Compare no case                                                  |
+//+------------------------------------------------------------------+
+inline int CMTStr::CompareNoCase(LPCWSTR str) const
+  {
+   if(m_str && str) return _wcsicmp(m_str,str);
+   return(m_str_len<1 ? 0 : 1);
+  }
+//+------------------------------------------------------------------+
+//| Compare no case                                                  |
+//+------------------------------------------------------------------+
+inline int CMTStr::CompareNoCase(LPCWSTR str,UINT count) const
+  {
+   if(m_str && str) return _wcsnicmp(m_str,str,count);
+   return(m_str_len<1 ? 0 : 1);
+  }
+//+------------------------------------------------------------------+
+//| Compare no case                                                  |
+//+------------------------------------------------------------------+
+inline int CMTStr::CompareNoCase(const CMTStr& str) const
+  {
+   if(m_str && str.m_str) return _wcsicmp(m_str,str.m_str);
+   return(m_str_len<1 ? 0 : 1);
+  }
+//+------------------------------------------------------------------+
+//| Compare no case                                                  |
+//+------------------------------------------------------------------+
+inline int CMTStr::CompareNoCase(LPCWSTR str1,LPCWSTR str2)
+  {
+   return _wcsicmp(str1,str2);
+  }
+//+------------------------------------------------------------------+
+//| Compare no case                                                  |
+//+------------------------------------------------------------------+
+inline int CMTStr::CompareNoCase(LPCWSTR str1,LPCWSTR str2,UINT count)
+  {
+   return _wcsnicmp(str1,str2,count);
+  }
+//+------------------------------------------------------------------+
+//| Check group correspondence to groups mask list                   |
+//+------------------------------------------------------------------+
+inline bool CMTStr::CheckGroupMask(LPCWSTR groupsmask,LPCWSTR group)
+  {
+   const wchar_t *tok_start;
+   wchar_t        mask[256]={0};
+   bool           found=false;
+   int            pos;
+//--- check
+   if(!groupsmask || !group) return(false);
+//--- look through groupmask
+   for(tok_start=groupsmask;*tok_start;tok_start++)
+     {
+      //--- skip spaces and commas
+      if(*tok_start==L' ' || *tok_start==L',') continue;
+      //--- copy mask
+      for(pos=0; *tok_start && *tok_start!=L',' && pos<255; tok_start++,pos++) mask[pos]=*tok_start;
+      //--- skip spaces and commas
+      while(pos>0 && (mask[pos-1]==L' ' || mask[pos-1]==L',')) pos--;
+      mask[pos]=0;
+      //--- check
+      if(mask[0]=='!' && CheckGroupTemplate(mask,group)) return(false);
+      else
+         if(CheckGroupTemplate(mask,group)) found=true;
+      //--- template over
+      if(!*tok_start) break;
+     }
+//--- return result
+   return(found);
+  }
+//+------------------------------------------------------------------+
+//| Find substring                                                   |
+//+------------------------------------------------------------------+
+inline int CMTStr::Find(LPCWSTR substring,UINT startpos) const
+  {
+   if(substring && m_str && m_str_len>0)
+      if(startpos<m_str_len)
+        {
+         wchar_t *position=wcsstr(m_str+startpos,substring);
+         if(position) return int(position-m_str);
+        }
+   return(-1);
+  }
+//+------------------------------------------------------------------+
+//| Find substring                                                   |
+//+------------------------------------------------------------------+
+inline int CMTStr::Find(LPCWSTR substring) const
+  {
+   if(substring && m_str && m_str_len>0)
+     {
+      wchar_t *position=wcsstr(m_str,substring);
+      if(position)
+        {
+         return int(position-m_str);
+        }
+     }
+   return(-1);
+  }
+//+------------------------------------------------------------------+
+//| Find substring no case                                           |
+//+------------------------------------------------------------------+
+inline int CMTStr::FindNoCase(LPCWSTR substring,UINT startpos) const
+  {
+   UINT sublen=0;
+//---
+   if(substring && (sublen=(UINT)wcslen(substring))>0 && m_str && m_str_len>0)
+      if(startpos<m_str_len)
+         for(UINT pos=startpos;m_str_len-pos>=sublen;pos++)
+            if(_wcsnicmp(m_str+pos,substring,sublen)==0)
+               return int(pos);
+   return(-1);
+  }
+//+------------------------------------------------------------------+
+//| Find substring reverse                                           |
+//+------------------------------------------------------------------+
+inline int CMTStr::FindR(LPCWSTR substring) const
+  {
+   int pos=0,end=0,beg=-1;
+//--- check
+   if(substring && m_str && m_str_len>0 && Len(substring)>0)
+     {
+      //--- find from end
+      while((pos=CMTStr::Find(&m_str[end],substring))>=0)
+        {
+         beg=end+pos;
+         end+=pos+1;
+        }
+     }
+//--- result
+   return(beg);
+  }
+//+------------------------------------------------------------------+
+//| Find symbol                                                      |
+//+------------------------------------------------------------------+
+inline int CMTStr::FindChar(const wchar_t character) const
+  {
+   if(m_str && m_str_len>0)
+     {
+      wchar_t *ptr=wcschr(m_str,character);
+      if(ptr) return int(ptr-m_str);
+     }
+   return(-1);
+  }
+//+------------------------------------------------------------------+
+//| Find symbol reverse                                              |
+//+------------------------------------------------------------------+
+inline int CMTStr::FindRChar(const wchar_t character) const
+  {
+   if(m_str && m_str_len>0)
+     {
+      wchar_t *ptr=wcsrchr(m_str,character);
+      if(ptr) return int(ptr-m_str);
+     }
+   return(-1);
+  }
+//+------------------------------------------------------------------+
+//| Find substring                                                   |
+//+------------------------------------------------------------------+
+inline int CMTStr::Find(LPCWSTR str,LPCWSTR substr)
+  {
+   if(str && substr && substr[0]!=L'\0')
+     {
+      LPCWSTR ptr=wcsstr(str,substr);
+      if(ptr) return int(ptr-str);
+     }
+   return(-1);
+  }
+//+------------------------------------------------------------------+
+//| Find substring no case                                           |
+//+------------------------------------------------------------------+
+inline int CMTStr::FindNoCase(LPCWSTR str,LPCWSTR substr)
+  {
+   UINT len=0,sublen=0;
+//---
+   if(str && substr && (len=(UINT)wcslen(str))>0 && (sublen=(UINT)wcslen(substr))>0)
+      for(UINT pos=0;len-pos>=sublen;pos++)
+         if(_wcsnicmp(str+pos,substr,sublen)==0)
+            return int(pos);
+   return(-1);
+  }
+//+------------------------------------------------------------------+
+//| Find substring reverse                                           |
+//+------------------------------------------------------------------+
+inline int CMTStr::FindR(LPCWSTR str,LPCWSTR substr)
+  {
+   int pos=0,end=0,beg=-1;
+//--- check
+   if(str && substr && Len(str)>0 && Len(substr)>0)
+     {
+      //--- find
+      while((pos=CMTStr::Find(&str[end],substr))>=0)
+        {
+         beg=end+pos;
+         end+=pos+1;
+        }
+     }
+//--- result
+   return(beg);
+  }
+//+------------------------------------------------------------------+
+//| Find char                                                        |
+//+------------------------------------------------------------------+
+inline int CMTStr::FindChar(LPCWSTR str,wchar_t character)
+  {
+   if(str)
+     {
+      LPCWSTR ptr=wcschr(str,character);
+      if(ptr) return int(ptr-str);
+     }
+   return(-1);
+  }
+//+------------------------------------------------------------------+
+//| Find symbol reverse                                              |
+//+------------------------------------------------------------------+
+inline int CMTStr::FindRChar(LPCWSTR str,wchar_t character)
+  {
+   if(str)
+     {
+      LPCWSTR ptr=wcsrchr(str,character);
+      if(ptr) return int(ptr-str);
+     }
+   return(-1);
+  }
+//+------------------------------------------------------------------+
+//| Check group by expression                                        |
+//+------------------------------------------------------------------+
+inline bool CMTStr::CheckGroupTemplate(LPWSTR expr,LPCWSTR group)
+  {
+   wchar_t *mask=NULL,*mask_ast=NULL;
+   bool     ast=false;
+//--- check
+   if(!expr || !group) return(false);
+//--- skip multiple '!'
+   for(mask=expr; *mask=='!'; mask++){}
+//--- check for '*' at start
+   for(; *mask && *mask=='*'; mask++)
+     {
+      ast     =true;
+      mask_ast=mask;
+     }
+//--- group loop
+   for(; *group && *mask; group++)
+     {
+      //--- check symbols
+      if(*group!=*mask)
+        {
+         if(!ast) return(false);
+         else     continue;
+        }
+      //--- check word
+      for(; *mask && *mask!='*' && *group; mask++, group++)
+         if(*group!=*mask)
+           {
+            if(!ast) return(false);
+            else
+              {
+               mask=mask_ast;
+               break;
+              }
+           }
+      //--- check group
+      if(!*mask && !*group) return(true);
+      if(!*mask)
+        {
+         if(!ast) return(false);
+         else     mask=mask_ast;
+        }
+      if(!*group)
+        {
+         if(*mask && *mask!='*') return(false);
+         else
+           {
+            for(; *mask && *mask=='*'; mask++){}
+            if(!*mask) return(true);
+            return(false);
+           }
+        }
+      else
+        {
+         for(; *mask && *mask=='*'; mask++)
+            mask_ast=mask;
+         if(!*mask) return(true);
+         ast=true;
+         group--;
+        }
+     }
+//--- mask empty?
+   if(*mask) return(false);
+   return(true);
+  }
+//+------------------------------------------------------------------+
+//| Windows error description                                        |
+//+------------------------------------------------------------------+
+inline LPCWSTR CMTStr::ErrorMsg(DWORD error)
+  {
+   CMTStrPath text;
+//--- check
+   if(!m_str) return(m_str);
+//--- get description
+   ::FormatMessageW(FORMAT_MESSAGE_IGNORE_INSERTS|FORMAT_MESSAGE_FROM_SYSTEM,
+                   NULL,error,
+                   MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),
+                   text.Buffer(),text.Max(),
+                   NULL);
+   text.Refresh();
+//--- remove \r & \n in last symbol
+   if(text.m_str_len && (text.m_str[text.m_str_len-1]==L'\r' || text.m_str[text.m_str_len-1]==L'\n'))
+     {
+      text.m_str[text.m_str_len-1]=L'\0';
+      text.m_str_len--;
+     }
+//--- remove \r & \n in prelast symbol
+   if(text.m_str_len && (text.m_str[text.m_str_len-1]==L'\r' || text.m_str[text.m_str_len-1]==L'\n'))
+     {
+      text.m_str[text.m_str_len-1]=L'\0';
+      text.m_str_len--;
+     }
+//--- format both code and description
+   Format(L"%s (%u)",text.Str(),error);
+   return(m_str);
+  }
+//+------------------------------------------------------------------+
+//| Error description macro                                          |
+//+------------------------------------------------------------------+
+#define MT_ERROR_MSG() CMTStr64().ErrorMsg(GetLastError())
+//+------------------------------------------------------------------+

+ 23 - 0
MT5SDK/Classes/MT5APISync.h

@@ -0,0 +1,23 @@
+//+------------------------------------------------------------------+
+//|                                                 MetaTrader 5 API |
+//|                   Copyright 2000-2019, MetaQuotes Software Corp. |
+//|                                        http://www.metaquotes.net |
+//+------------------------------------------------------------------+
+#pragma once
+//+------------------------------------------------------------------+
+//| Thread synchronization class                                     |
+//+------------------------------------------------------------------+
+class CMTSync
+  {
+private:
+   CRITICAL_SECTION  m_cs;
+
+public:
+                     CMTSync(void)      { ZeroMemory(&m_cs,sizeof(m_cs)); InitializeCriticalSection(&m_cs); }
+                    ~CMTSync(void)      { DeleteCriticalSection(&m_cs);                  }
+
+   inline void       Lock(void)         { EnterCriticalSection(&m_cs);                   }
+   inline void       Unlock(void)       { LeaveCriticalSection(&m_cs);                   }
+   inline bool       TryLock(void)      { return(TryEnterCriticalSection(&m_cs)!=FALSE); }
+  };
+//+------------------------------------------------------------------+

+ 122 - 0
MT5SDK/Classes/MT5APIThread.h

@@ -0,0 +1,122 @@
+//+------------------------------------------------------------------+
+//|                                                     MetaTrader 5 |
+//|                   Copyright 2000-2019, MetaQuotes Software Corp. |
+//|                                        http://www.metaquotes.net |
+//+------------------------------------------------------------------+
+#pragma once
+#include <process.h>
+//+------------------------------------------------------------------+
+//| Thread manipulation class                                        |
+//+------------------------------------------------------------------+
+class CMTThread
+  {
+private:
+   HANDLE            m_thread;
+public:
+                     CMTThread(void);
+                    ~CMTThread(void);
+   //---
+   inline bool       Start(unsigned (__stdcall *thread_func)(void*),void *thread_param,const UINT stack_size);
+   inline bool       Shutdown(const UINT timeout=INFINITE);
+   inline void       Terminate(void);
+   inline bool       IsBusy(void);
+   inline HANDLE     Handle(void) const { return(m_thread); }
+   inline bool       Priority(int priority);
+  };
+//+------------------------------------------------------------------+
+//| Constructor                                                      |
+//+------------------------------------------------------------------+
+inline CMTThread::CMTThread(void) : m_thread(NULL)
+  {
+  }
+//+------------------------------------------------------------------+
+//| Destructor                                                       |
+//+------------------------------------------------------------------+
+inline CMTThread::~CMTThread(void)
+  {
+//--- wait for shutdown
+   Shutdown();
+//--- close handle
+   if(m_thread!=NULL)
+     {
+      CloseHandle(m_thread);
+      m_thread=NULL;
+     }
+  }
+//+------------------------------------------------------------------+
+//| Thread start                                                     |
+//+------------------------------------------------------------------+
+inline bool CMTThread::Start(unsigned (__stdcall *thread_func)(void*),void *thread_param,const UINT stack_size)
+  {
+   DWORD id=0;
+//--- thread has been started...
+   if(m_thread!=NULL)
+     {
+      GetExitCodeThread(m_thread,&id);
+      //--- still active
+      if(id==STILL_ACTIVE) 
+         return(false);
+      //--- close handle
+      CloseHandle(m_thread);
+      m_thread=NULL;
+     }
+//--- start thread
+   if((m_thread=(HANDLE)_beginthreadex(NULL,stack_size,thread_func,(void*)thread_param,STACK_SIZE_PARAM_IS_A_RESERVATION,(UINT*)&id))==NULL) 
+      return(false);
+//--- ok
+   return(true);
+  }
+//+------------------------------------------------------------------+
+//| Thread shutdown                                                  |
+//+------------------------------------------------------------------+
+inline bool CMTThread::Shutdown(const UINT timeout/*=INIFINITE*/)
+  {
+//--- check
+   if(m_thread==NULL) 
+      return(true);
+//--- wait for thread shutdown
+   return(WaitForSingleObject(m_thread,timeout)==WAIT_OBJECT_0);
+  }
+//+------------------------------------------------------------------+
+//| Thread termination                                               |
+//+------------------------------------------------------------------+
+inline void CMTThread::Terminate(void)
+  {
+//--- check
+   if(m_thread) 
+     {
+      //--- kill thread
+      TerminateThread(m_thread,0);
+      //--- close handle
+      CloseHandle(m_thread);
+      m_thread=NULL;
+     }
+//---
+  }
+//+------------------------------------------------------------------+
+//| Check thread activity                                            |
+//+------------------------------------------------------------------+
+inline bool CMTThread::IsBusy(void)
+  {
+//--- check
+   if(!m_thread) 
+      return(false);
+//--- request state
+   DWORD res=0;
+   GetExitCodeThread(m_thread,&res);
+   if(res==STILL_ACTIVE) 
+      return(true);
+//--- close handle
+   CloseHandle(m_thread);
+   m_thread=NULL;
+//--- thread finished
+   return(false);
+  }
+//+------------------------------------------------------------------+
+//| Thread priority modification                                     |
+//+------------------------------------------------------------------+
+inline bool CMTThread::Priority(int priority)
+  {
+   return(m_thread && SetThreadPriority(m_thread,priority));
+  }
+//+------------------------------------------------------------------+

+ 220 - 0
MT5SDK/Classes/MT5APITime.h

@@ -0,0 +1,220 @@
+//+------------------------------------------------------------------+
+//|                                                 MetaTrader 5 API |
+//|                   Copyright 2000-2019, MetaQuotes Software Corp. |
+//|                                        http://www.metaquotes.net |
+//+------------------------------------------------------------------+
+#pragma once
+#include <sys/types.h>
+#include <sys/timeb.h>
+//+------------------------------------------------------------------+
+//| Seconds macro                                                    |
+//+------------------------------------------------------------------+
+#define SECONDS_IN_MINUTE    INT64(60)
+#define SECONDS_IN_HOUR      INT64(60*SECONDS_IN_MINUTE)
+#define SECONDS_IN_DAY       INT64(24*SECONDS_IN_HOUR)
+#define SECONDS_IN_WEEK      INT64(7*SECONDS_IN_DAY)
+#define SECONDS_IN_MONTH     INT64(30*SECONDS_IN_DAY)
+//+------------------------------------------------------------------+
+//| Minutes macro                                                    |
+//+------------------------------------------------------------------+
+#define MINUTES_IN_HOUR      (60)
+#define MINUTES_IN_DAY       (24*MINUTES_IN_HOUR)
+#define MINUTES_IN_WEEK      (7*MINUTES_IN_DAY)
+//+------------------------------------------------------------------+
+//| Time management functions                                        |
+//+------------------------------------------------------------------+
+class SMTTime
+  {
+private:
+   static const INT64 s_max_time64_t;
+   static const LPCWSTR s_months_names[13];
+   static const LPCWSTR s_months_short_names[13];
+
+public:
+   //--- time functions
+   static bool       ParseTime(const INT64 ctm,tm *ttm);
+   static INT64      MakeTime(tm *ttm);
+   static LPCWSTR    MonthName(const UCHAR month);
+   static LPCWSTR    MonthNameShort(const UCHAR month);
+   static INT64      WeekBegin(const INT64 ctm);
+   static INT64      DayBegin(const INT64 ctm);
+   static INT64      MonthBegin(const INT64 ctm);
+   static INT64      YearBegin(const INT64 ctm);
+   //---  SYSTEMTIME
+   static INT64       STToTime(const SYSTEMTIME &st);
+   static SYSTEMTIME& TimeToST(INT64 ctm,SYSTEMTIME& st);
+   //--- year, month & time hour
+   static UINT       Year(const INT64 ctm);
+   static UINT       Month(const INT64 ctm);
+   static UINT       Day(const INT64 ctm);
+   static UINT       Hour(const INT64 ctm);
+   static UINT       Min(const INT64 ctm);
+   static UINT       Sec(const INT64 ctm);
+  };
+//+------------------------------------------------------------------+
+//|                                                                  |
+//+------------------------------------------------------------------+
+const __declspec(selectany) INT64   SMTTime::s_max_time64_t=0x793406fffi64;
+//+------------------------------------------------------------------+
+//|                                                                  |
+//+------------------------------------------------------------------+
+const __declspec(selectany)LPCWSTR  SMTTime::s_months_names[13]      ={ L"January",L"February",L"March",L"April",L"May",L"June",L"July",L"August",L"September",L"October",L"November",L"December",L"Unknown" };
+//+------------------------------------------------------------------+
+//|                                                                  |
+//+------------------------------------------------------------------+
+const __declspec(selectany)LPCWSTR  SMTTime::s_months_short_names[13]={ L"Jan",L"Feb",L"Mar",L"Apr",L"May",L"Jun",L"Jul",L"Aug",L"Sep",L"Oct",L"Nov",L"Dec",L"Unk" };
+//+------------------------------------------------------------------+
+//| Time parsing                                                     |
+//+------------------------------------------------------------------+
+inline bool SMTTime::ParseTime(const INT64 ctm,tm *ttm)
+  {
+//--- check
+   if(!ttm) return(false);
+//--- check time
+   if(ctm<0 || ctm>=s_max_time64_t)
+     {
+      ZeroMemory(ttm,sizeof(*ttm));
+      return(false);
+     }
+//--- parse
+   return(_gmtime64_s(ttm,&ctm)==0);
+  }
+//+------------------------------------------------------------------+
+//| Time conversion                                                  |
+//+------------------------------------------------------------------+
+inline INT64 SMTTime::MakeTime(tm *ttm)
+  {
+//--- check
+   if(!ttm) return(0);
+//--- make time
+   return(_mkgmtime64(ttm));
+  }
+//+------------------------------------------------------------------+
+//| Month full name                                                  |
+//+------------------------------------------------------------------+
+inline LPCWSTR SMTTime::MonthName(const UCHAR month)
+  {
+   if(month>11) return s_months_names[12];
+   else         return s_months_names[month];
+  }
+//+------------------------------------------------------------------+
+//| Month short name                                                 |
+//+------------------------------------------------------------------+
+inline LPCWSTR SMTTime::MonthNameShort(const UCHAR month)
+  {
+   if(month>11) return s_months_short_names[12];
+   else         return s_months_short_names[month];
+  }
+//+------------------------------------------------------------------+
+//| Week begin calculation (Sunday)                                  |
+//+------------------------------------------------------------------+
+inline INT64 SMTTime::WeekBegin(const INT64 ctm)
+  {
+   if(ctm<345600) return(0);
+   INT64 wday=(ctm%604800);
+   wday+=(wday>=259200)?(-259200):(345600);
+   return(ctm-wday);
+  }
+//+------------------------------------------------------------------+
+//| Day begin calculation                                            |
+//+------------------------------------------------------------------+
+inline INT64 SMTTime::DayBegin(const INT64 ctm)
+  {
+   return((ctm/SECONDS_IN_DAY)*SECONDS_IN_DAY);
+  }
+//+------------------------------------------------------------------+
+//| Month begin calculation                                          |
+//+------------------------------------------------------------------+
+inline INT64 SMTTime::MonthBegin(const INT64 ctm)
+  {
+   tm ttm;
+//--- parse datetime
+   ParseTime(ctm,&ttm);
+//---
+   ttm.tm_mday=1;
+   ttm.tm_hour=ttm.tm_min=ttm.tm_sec=0;
+//--- calc time
+   return(_mkgmtime64(&ttm));
+  }
+//+------------------------------------------------------------------+
+//| Year begin calculation                                           |
+//+------------------------------------------------------------------+
+inline INT64 SMTTime::YearBegin(const INT64 ctm)
+  {
+   tm ttm;
+//--- parse datetime
+   ParseTime(ctm,&ttm);
+//--- 
+   ttm.tm_mday=1;
+   ttm.tm_mon =0;
+   ttm.tm_hour=ttm.tm_min=ttm.tm_sec=0;
+//--- calc time
+   return(_mkgmtime64(&ttm));
+  }
+//+------------------------------------------------------------------+
+//| UNIX time to SYSTEMTIME conversion                               |
+//+------------------------------------------------------------------+
+inline SYSTEMTIME& SMTTime::TimeToST(INT64 ctm,SYSTEMTIME& st)
+  {
+   tm ttm={};
+//--- clean
+   ZeroMemory(&st,sizeof(st));
+//--- convert
+   if(SMTTime::ParseTime(ctm,&ttm))
+     {
+      st.wYear     =WORD(1900+ttm.tm_year);
+      st.wMonth    =WORD(1+ttm.tm_mon);
+      st.wDayOfWeek=WORD(ttm.tm_wday);
+      st.wDay      =WORD(ttm.tm_mday);
+      st.wHour     =WORD(ttm.tm_hour);
+      st.wMinute   =WORD(ttm.tm_min);
+      st.wSecond   =WORD(ttm.tm_sec);
+     }
+//---
+   return(st);
+  }
+//+------------------------------------------------------------------+
+//| SYSTEMTIME to UNIX time conversion                               |
+//+------------------------------------------------------------------+
+inline INT64 SMTTime::STToTime(const SYSTEMTIME &st)
+  {
+   INT64 ctm;
+   tm    ttm={};
+//---
+   ttm.tm_year=st.wYear-1900;
+   ttm.tm_mon =st.wMonth-1;
+   ttm.tm_mday=st.wDay;
+   ttm.tm_wday=st.wDayOfWeek;
+   ttm.tm_hour=st.wHour;
+   ttm.tm_min =st.wMinute;
+   ttm.tm_sec =st.wSecond;
+   ttm.tm_isdst=0;
+//--- 
+   if((ctm=_mkgmtime64(&ttm))<0) ctm=0;
+   return(ctm);
+  }
+//+------------------------------------------------------------------+
+//| Year by datetime                                                 |
+//+------------------------------------------------------------------+
+inline UINT SMTTime::Year(const INT64 ctm) { tm ttm; ParseTime(ctm,&ttm); return(UINT(ttm.tm_year+1900)); }
+//+------------------------------------------------------------------+
+//| Month by datetime                                                |
+//+------------------------------------------------------------------+
+inline UINT SMTTime::Month(const INT64 ctm){ tm ttm; ParseTime(ctm,&ttm); return(UINT(ttm.tm_mon+1));     }
+//+------------------------------------------------------------------+
+//| Day by datetime                                                  |
+//+------------------------------------------------------------------+
+inline UINT SMTTime::Day(const INT64 ctm)  { tm ttm; ParseTime(ctm,&ttm); return(UINT(ttm.tm_mday));      }
+//+------------------------------------------------------------------+
+//| Hour by datetime                                                 |
+//+------------------------------------------------------------------+
+inline UINT SMTTime::Hour(const INT64 ctm) { tm ttm; ParseTime(ctm,&ttm); return(UINT(ttm.tm_hour));      }
+//+------------------------------------------------------------------+
+//| Minute by datetime                                               |
+//+------------------------------------------------------------------+
+inline UINT SMTTime::Min(const INT64 ctm)  { tm ttm; ParseTime(ctm,&ttm); return(UINT(ttm.tm_min));       }
+//+------------------------------------------------------------------+
+//| Second by datetime                                               |
+//+------------------------------------------------------------------+
+inline UINT SMTTime::Sec(const INT64 ctm)  { tm ttm; ParseTime(ctm,&ttm); return(UINT(ttm.tm_sec));       }
+//+------------------------------------------------------------------+

+ 92 - 0
MT5SDK/Config/MT5APIConfigCommon.h

@@ -0,0 +1,92 @@
+//+------------------------------------------------------------------+
+//|                                                 MetaTrader 5 API |
+//|                   Copyright 2000-2019, MetaQuotes Software Corp. |
+//|                                        http://www.metaquotes.net |
+//+------------------------------------------------------------------+
+#pragma once
+//+------------------------------------------------------------------+
+//| Common MetaTrader 5 Platform config                              |
+//+------------------------------------------------------------------+
+class IMTConCommon
+  {
+public:
+   //--- LiveUpdate modes
+   enum EnUpdateMode
+     {
+      UPDATE_DISABLE    =0,  // disable LiveUpdate
+      UPDATE_ENABLE     =1,  // enable LiveUpdate
+      UPDATE_ENABLE_BETA=2,  // enable LiveUpdate, including beta releases
+      //--- enumeration borders
+      UPDATE_FIRST      =UPDATE_DISABLE,
+      UPDATE_LAST       =UPDATE_ENABLE_BETA
+     };
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTConCommon* param)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- server name
+   virtual LPCWSTR   Name(void) const=0;
+   virtual MTAPIRES  Name(LPCWSTR name)=0;
+   //--- server full name
+   virtual LPCWSTR   NameFull(void) const=0;
+   //--- owner full name (from license)
+   virtual LPCWSTR   Owner(void) const=0;
+   //--- owner short name (from license)
+   virtual LPCWSTR   OwnerID(void) const=0;
+   //--- owner host (from license)
+   virtual LPCWSTR   OwnerHost(void) const=0;
+   //--- owner email (from license)
+   virtual LPCWSTR   OwnerEmail(void) const=0;
+   //--- product full name (from license)
+   virtual LPCWSTR   Product(void) const=0;
+   //--- license expiration date
+   virtual INT64     ExpirationLicense(void) const=0;
+   //--- license support date
+   virtual INT64     ExpirationSupport(void) const=0;
+   //--- max. trade servers count (from license)
+   virtual UINT      LimitTradeServers(void) const=0;
+   //--- max. web servers count (from license)
+   virtual UINT      LimitWebServers(void) const=0;
+   //--- max. real accounts count (from license)
+   virtual UINT      LimitAccounts(void) const=0;
+   //--- max. trade deals count (from license)
+   virtual UINT      LimitDeals(void) const=0;
+   //--- max. client groups count (from license)
+   virtual UINT      LimitGroups(void) const=0;
+   //--- LiveUpdate mode
+   virtual UINT      LiveUpdateMode(void) const=0;
+   virtual MTAPIRES  LiveUpdateMode(const UINT mode)=0;
+   //--- Total users
+   virtual UINT      TotalUsers(void) const=0;
+   //--- Total real users
+   virtual UINT      TotalUsersReal(void) const=0;
+   //--- Total deals
+   virtual UINT      TotalDeals(void) const=0;
+   //--- Total orders
+   virtual UINT      TotalOrders(void) const=0;
+   //--- Total history orders
+   virtual UINT      TotalOrdersHistory(void) const=0;
+   //--- Total positions
+   virtual UINT      TotalPositions(void) const=0;
+   //--- max. symbols count (from license)
+   virtual UINT      LimitSymbols(void) const=0;
+   //--- Account Allocation URL
+   virtual LPCWSTR   AccountURL(void) const=0;
+   virtual MTAPIRES  AccountURL(LPCWSTR url)=0;
+   //--- Account Deposit URL
+   virtual LPCWSTR   AccountDepositURL(void) const=0;
+   virtual MTAPIRES  AccountDepositURL(LPCWSTR url)=0;
+   //--- Account Withdrawal URL
+   virtual LPCWSTR   AccountWithdrawalURL(void) const=0;
+   virtual MTAPIRES  AccountWithdrawalURL(LPCWSTR url)=0;
+  };
+//+------------------------------------------------------------------+
+//| Common config events notification interface                      |
+//+------------------------------------------------------------------+
+class IMTConCommonSink
+  {
+public:
+   virtual void      OnCommonUpdate(const IMTConCommon* /*config*/) {  }
+   virtual void      OnCommonSync(void)                             {  }
+  };
+//+------------------------------------------------------------------+

+ 60 - 0
MT5SDK/Config/MT5APIConfigEmail.h

@@ -0,0 +1,60 @@
+//+------------------------------------------------------------------+
+//|                                                 MetaTrader 5 API |
+//|                   Copyright 2000-2019, MetaQuotes Software Corp. |
+//|                                        http://www.metaquotes.net |
+//+------------------------------------------------------------------+
+#pragma once
+//+------------------------------------------------------------------+
+//| Email server config                                              |
+//+------------------------------------------------------------------+
+class IMTConEmail
+  {
+public:
+   //--- allowed flags
+   enum EnFlags
+     {
+      FLAG_NONE               =0, // none
+      FLAG_ENABLED            =1, // mail server is enabled
+      FLAG_DEFAULT            =2, // mail server is default
+      //--- flags borders
+      FLAG_FIRST              =FLAG_ENABLED,
+      FLAG_ALL                =FLAG_ENABLED|FLAG_DEFAULT
+     };
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTConEmail* email)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- name
+   virtual LPCWSTR   Name(void) const=0;
+   virtual MTAPIRES  Name(LPCWSTR name)=0;
+   //--- sender email
+   virtual LPCWSTR   SenderMail(void) const=0;
+   virtual MTAPIRES  SenderMail(LPCWSTR mail)=0;
+   //--- sender name
+   virtual LPCWSTR   SenderName(void) const=0;
+   virtual MTAPIRES  SenderName(LPCWSTR name)=0;
+   //--- server
+   virtual LPCWSTR   Server(void) const=0;
+   virtual MTAPIRES  Server(LPCWSTR server)=0;
+   //--- login
+   virtual LPCWSTR   Login(void) const=0;
+   virtual MTAPIRES  Login(LPCWSTR login)=0;
+   //--- password
+   virtual LPCWSTR   Password(void) const=0;
+   virtual MTAPIRES  Password(LPCWSTR password)=0;
+   //--- EnFlags
+   virtual UINT64    Flags(void) const=0;
+   virtual MTAPIRES  Flags(const UINT64 flags)=0;
+  };
+//+------------------------------------------------------------------+
+//| Mail config events notification interface                        |
+//+------------------------------------------------------------------+
+class IMTConEmailSink
+  {
+public:
+   virtual void      OnEmailAdd(const IMTConEmail*    /*config*/) {  }
+   virtual void      OnEmailUpdate(const IMTConEmail* /*config*/) {  }
+   virtual void      OnEmailDelete(const IMTConEmail* /*config*/) {  }
+   virtual void      OnEmailSync(void)                            {  }
+  };
+//+------------------------------------------------------------------+

+ 202 - 0
MT5SDK/Config/MT5APIConfigFeeder.h

@@ -0,0 +1,202 @@
+//+------------------------------------------------------------------+
+//|                                                 MetaTrader 5 API |
+//|                   Copyright 2000-2019, MetaQuotes Software Corp. |
+//|                                        http://www.metaquotes.net |
+//+------------------------------------------------------------------+
+#pragma once
+#include "MT5APIConfigParam.h"
+//+------------------------------------------------------------------+
+//| Datafeed module description                                      |
+//+------------------------------------------------------------------+
+class IMTConFeederModule
+  {
+public:
+   //--- necessary fields flags
+   enum EnFeedersFieldFlags
+     {
+      FEED_FIELD_SERVER=1,            // server field
+      FEED_FIELD_LOGIN =2,            // login field
+      FEED_FIELD_PASS  =4,            // password field
+      FEED_FIELD_PARAM =8,            // parameters
+      //--- enumeration borders
+      FEED_FIELD_NONE  =0,
+      FEED_FIELD_ALL   =FEED_FIELD_SERVER|FEED_FIELD_LOGIN|FEED_FIELD_PASS|FEED_FIELD_PARAM
+     };
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTConFeederModule* param)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- default datafeed name
+   virtual LPCWSTR   Name(void) const=0;
+   //--- vendor name
+   virtual LPCWSTR   Vendor(void) const=0;
+   //--- datafeed description
+   virtual LPCWSTR   Description(void) const=0;
+   //--- datafeed file name
+   virtual LPCWSTR   Module(void) const=0;
+   //--- default feed server address
+   virtual LPCWSTR   FeedServer(void) const=0;
+   //--- default feed server login
+   virtual LPCWSTR   FeedLogin(void) const=0;
+   //--- default feed server password
+   virtual LPCWSTR   FeedPassword(void) const=0;
+   //--- datafeed version
+   virtual UINT      Version(void) const=0;
+   //--- datafeed available modes (IMTConFeeder::EnFeedersFlags)
+   virtual UINT      Modes(void) const=0;
+   //--- changeable EnFeedersFieldFlags
+   virtual UINT      Fields(void) const=0;
+   //--- default datafeed parameters
+   virtual UINT      ParameterTotal(void) const=0;
+   virtual MTAPIRES  ParameterNext(const UINT pos,IMTConParam* param) const=0;
+   virtual MTAPIRES  ParameterGet(LPCWSTR name,IMTConParam* param) const=0;
+  };
+//+------------------------------------------------------------------+
+//| Symbols name and price translation config                        |
+//+------------------------------------------------------------------+
+class IMTConFeederTranslate
+  {
+public:
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTConFeederTranslate* param)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- symbol name in datafeed
+   virtual LPCWSTR   Source(void) const=0;
+   virtual MTAPIRES  Source(LPCWSTR source)=0;
+   //--- symbol name in MT5
+   virtual LPCWSTR   Symbol(void) const=0;
+   virtual MTAPIRES  Symbol(LPCWSTR symbol)=0;
+   //--- bid markup in points
+   virtual INT       BidMarkup(void) const=0;
+   virtual MTAPIRES  BidMarkup(const INT markup)=0;
+   //--- ask markup in points
+   virtual INT       AskMarkup(void) const=0;
+   virtual MTAPIRES  AskMarkup(const INT markup)=0;
+   //--- digits
+   virtual UINT      Digits(void) const=0;
+  };
+//+------------------------------------------------------------------+
+//| Datafeed config interface                                        |
+//+------------------------------------------------------------------+
+class IMTConFeeder
+  {
+public:
+   //--- datafeed working flags
+   enum EnFeedersFlags
+     {
+      FEED_FLAG_QUOTES =1,            // feeder should send quotes
+      FEED_FLAG_NEWS   =2,            // feeder should send news
+      FEED_FLAG_REMOTE =8,            // feeder works as remote service
+      //--- flags borders
+      FEED_FLAG_NONE   =0,
+      FEED_FLAG_ALL    =FEED_FLAG_QUOTES|FEED_FLAG_NEWS|FEED_FLAG_REMOTE
+     };
+   //--- datafeed working modes
+   enum EnFeedersMode
+     {
+      FEEDER_DISABLED  =0,
+      FEEDER_ENABLED   =1,
+      //--- enumeration borders
+      FEEDER_FIRST     =FEEDER_DISABLED,
+      FEEDER_LAST      =FEEDER_ENABLED
+     };
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTConFeeder* param)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- datafeed name
+   virtual LPCWSTR   Name(void) const=0;
+   virtual MTAPIRES  Name(LPCWSTR name)=0;
+   //--- datafeed module filename
+   virtual LPCWSTR   Module(void) const=0;
+   virtual MTAPIRES  Module(LPCWSTR name)=0;
+   //--- feed server address
+   virtual LPCWSTR   FeedServer(void) const=0;
+   virtual MTAPIRES  FeedServer(LPCWSTR server)=0;
+   //--- feed server login
+   virtual LPCWSTR   FeedLogin(void) const=0;
+   virtual MTAPIRES  FeedLogin(LPCWSTR login)=0;
+   //--- feed server password
+   virtual LPCWSTR   FeedPassword(void) const=0;
+   virtual MTAPIRES  FeedPassword(LPCWSTR password)=0;
+   //--- EnFeedersMode
+   virtual UINT      Mode(void) const=0;
+   virtual MTAPIRES  Mode(const UINT mode)=0;
+   //--- EnFeedersFlags
+   virtual UINT      Flags(void) const=0;
+   virtual MTAPIRES  Flags(const UINT flags)=0;
+   //--- comma separated news keywords
+   virtual LPCWSTR   Keywords(void) const=0;
+   virtual MTAPIRES  Keywords(LPCWSTR keywords)=0;
+   //--- news category
+   virtual LPCWSTR   Categories(void) const=0;
+   virtual MTAPIRES  Categories(LPCWSTR categories)=0;
+   //--- obsolete value
+   virtual UINT      ObsoleteValue(void) const=0;
+   virtual MTAPIRES  ObsoleteValue(const UINT value)=0;
+   //--- datafeed reconnect timeout
+   virtual UINT      TimeoutReconnect(void) const=0;
+   virtual MTAPIRES  TimeoutReconnect(const UINT timeout)=0;
+   //--- datafeed sleep timeout
+   virtual UINT      TimeoutSleep(void) const=0;
+   virtual MTAPIRES  TimeoutSleep(const UINT timeout)=0;
+   //--- reconnect attempts before timeout
+   virtual UINT      TimeoutAttempts(void) const=0;
+   virtual MTAPIRES  TimeoutAttempts(const UINT attempts)=0;
+   //--- datafeed additional parameters access
+   virtual MTAPIRES  ParameterAdd(IMTConParam* param)=0;
+   virtual MTAPIRES  ParameterUpdate(const UINT pos,const IMTConParam* param)=0;
+   virtual MTAPIRES  ParameterDelete(const UINT pos)=0;
+   virtual MTAPIRES  ParameterClear(void)=0;
+   virtual MTAPIRES  ParameterShift(const UINT pos,const int shift)=0;
+   virtual UINT      ParameterTotal(void) const=0;
+   virtual MTAPIRES  ParameterNext(const UINT pos,IMTConParam* param) const=0;
+   virtual MTAPIRES  ParameterGet(LPCWSTR name,IMTConParam* param) const=0;
+   //--- list of symbols for translating quotes
+   virtual MTAPIRES  SymbolAdd(LPCWSTR path)=0;
+   virtual MTAPIRES  SymbolUpdate(const UINT pos,LPCWSTR path)=0;
+   virtual MTAPIRES  SymbolDelete(const UINT pos)=0;
+   virtual MTAPIRES  SymbolClear(void)=0;
+   virtual MTAPIRES  SymbolShift(const UINT pos,const int shift)=0;
+   virtual UINT      SymbolTotal(void) const=0;
+   virtual LPCWSTR   SymbolNext(const UINT pos) const=0;
+   //--- list of symbols translations
+   virtual MTAPIRES  TranslateAdd(IMTConFeederTranslate* param)=0;
+   virtual MTAPIRES  TranslateUpdate(const UINT pos,const IMTConFeederTranslate* param)=0;
+   virtual MTAPIRES  TranslateDelete(const UINT pos)=0;
+   virtual MTAPIRES  TranslateClear(void)=0;
+   virtual MTAPIRES  TranslateShift(const UINT pos,const int shift)=0;
+   virtual UINT      TranslateTotal(void) const=0;
+   virtual MTAPIRES  TranslateNext(const UINT pos,IMTConFeederTranslate* param) const=0;
+   virtual MTAPIRES  TranslateGet(LPCWSTR symbol,IMTConFeederTranslate* param) const=0;
+   //--- gateway server address
+   virtual LPCWSTR   GatewayServer(void) const=0;
+   virtual MTAPIRES  GatewayServer(LPCWSTR server)=0;
+   //--- gateway server login
+   virtual UINT64    GatewayLogin(void) const=0;
+   virtual MTAPIRES  GatewayLogin(UINT64 login)=0;
+   //--- gateway server password
+   virtual LPCWSTR   GatewayPassword(void) const=0;
+   virtual MTAPIRES  GatewayPassword(LPCWSTR password)=0;
+   //--- feeder state information
+   virtual bool      StateConnected(void) const=0;
+   virtual UINT      StateReceivedTicks(void) const=0;
+   virtual UINT      StateReceivedBooks(void) const=0;
+   virtual UINT      StateReceivedNews(void) const=0;
+   virtual UINT      StateTrafficIn(void) const=0;
+   virtual UINT      StateTrafficOut(void) const=0;
+  };
+//+------------------------------------------------------------------+
+//| Datafeed config events notification interface                    |
+//+------------------------------------------------------------------+
+class IMTConFeederSink
+  {
+public:
+   virtual void      OnFeederAdd(const IMTConFeeder*    /*feeder*/) {  }
+   virtual void      OnFeederUpdate(const IMTConFeeder* /*feeder*/) {  }
+   virtual void      OnFeederDelete(const IMTConFeeder* /*feeder*/) {  }
+   virtual void      OnFeederSync(void)                             {  }
+  };
+//+------------------------------------------------------------------+
+

+ 52 - 0
MT5SDK/Config/MT5APIConfigFirewall.h

@@ -0,0 +1,52 @@
+//+------------------------------------------------------------------+
+//|                                                 MetaTrader 5 API |
+//|                   Copyright 2000-2019, MetaQuotes Software Corp. |
+//|                                        http://www.metaquotes.net |
+//+------------------------------------------------------------------+
+#pragma once
+//+------------------------------------------------------------------+
+//| Server firewall config                                           |
+//+------------------------------------------------------------------+
+class IMTConFirewall
+  {
+public:
+   //--- firewall actions
+   enum EnAction
+     {
+      ACCESS_BLOCK    =0,              // block
+      ACCESS_PERMIT   =1,              // permit
+      ACCESS_WHITELIST=2,              // permit always
+      //--- enumeration borders
+      ACCESS_FIRST    =ACCESS_BLOCK,
+      ACCESS_LAST     =ACCESS_WHITELIST
+     };
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTConFirewall* param)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- action with connection (EnAction)
+   virtual UINT      Action(void) const=0;
+   virtual MTAPIRES  Action(const UINT action)=0;
+   //--- IP range from
+   virtual LPCWSTR   From(void) const=0;
+   virtual MTAPIRES  From(LPCWSTR name)=0;
+   //--- IP range to
+   virtual LPCWSTR   To(void) const=0;
+   virtual MTAPIRES  To(LPCWSTR value)=0;
+   //--- comment
+   virtual LPCWSTR   Comment(void) const=0;
+   virtual MTAPIRES  Comment(LPCWSTR comment)=0;
+  };
+//+------------------------------------------------------------------+
+//| Firewall config events notification interface                    |
+//+------------------------------------------------------------------+
+class IMTConFirewallSink
+  {
+public:
+   virtual void      OnFirewallAdd(const IMTConFirewall*    /*config*/) {  }
+   virtual void      OnFirewallUpdate(const IMTConFirewall* /*config*/) {  }
+   virtual void      OnFirewallDelete(const IMTConFirewall* /*config*/) {  }
+   virtual void      OnFirewallSync(void)                               {  }
+  };
+//+------------------------------------------------------------------+
+

+ 251 - 0
MT5SDK/Config/MT5APIConfigFund.h

@@ -0,0 +1,251 @@
+//+------------------------------------------------------------------+
+//|                                                 MetaTrader 5 API |
+//|                   Copyright 2000-2019, MetaQuotes Software Corp. |
+//|                                        http://www.metaquotes.net |
+//+------------------------------------------------------------------+
+#pragma once
+//+------------------------------------------------------------------+
+//| Fund trade account                                               |
+//+------------------------------------------------------------------+
+class IMTConFundAccount
+  {
+public:
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTConFundAccount* account)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- login
+   virtual UINT64    Login(void) const=0;
+   virtual MTAPIRES  Login(const UINT64 login)=0;
+   //--- name
+   virtual LPCWSTR   Name(void) const=0;
+   //--- balance
+   virtual double    Balance(void) const=0;
+   //--- equity
+   virtual double    Equity(void) const=0;
+   //--- currency
+   virtual LPCWSTR   Currency(void) const=0;
+   //--- currency digits
+   virtual UINT      CurrencyDigits(void) const=0;
+  };
+//+------------------------------------------------------------------+
+//| Fund investor                                                    |
+//+------------------------------------------------------------------+
+class IMTConFundInvestor
+  {
+public:
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTConFundInvestor* investor)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- login
+   virtual UINT64    Login(void) const=0;
+   virtual MTAPIRES  Login(const UINT64 login)=0;
+   //--- name
+   virtual LPCWSTR   Name(void) const=0;
+   //--- shares
+   virtual UINT64    SharesVolume(void) const=0;
+  };
+//+------------------------------------------------------------------+
+//| Fund config                                                      |
+//+------------------------------------------------------------------+
+class IMTConFund
+  {
+public:
+   //--- flags
+   enum EnFlags
+     {
+      FLAG_NONE               =0x00000000,
+      FLAG_ENABLED            =0x00000001,
+      //---
+      FLAG_ALL                =FLAG_ENABLED
+     };
+   //--- type
+   enum EnType
+     {
+      TYPE_OPEN_END           =0,
+      TYPE_CLOSED_END         =1,
+      //---
+      TYPE_FIRST              =TYPE_OPEN_END,
+      TYPE_LAST               =TYPE_CLOSED_END,
+     };
+   //--- recalculation
+   enum EnRecalculation
+     {
+      RECALCULATION_MINUTELY=0,
+      RECALCULATION_HOURLY  =1,
+      RECALCULATION_DAILY   =2,
+      RECALCULATION_MANUAL  =3,
+      //---
+      RECALCULATION_FIRST   =RECALCULATION_MINUTELY,
+      RECALCULATION_LAST    =RECALCULATION_MANUAL,
+     };
+   //--- fees mode
+   enum EnFeeMode
+     {
+      FEE_MODE_AUTOMATIC    =0,
+      FEE_MODE_REPORT       =1,
+      //---
+      FEE_MODE_FIRST        =FEE_MODE_AUTOMATIC,
+      FEE_MODE_LAST         =FEE_MODE_REPORT,
+     };
+   //--- management fee charge
+   enum EnFeePeriod
+     {
+      FEE_PERIOD_DAILY      =0,
+      FEE_PERIOD_MONTHLY    =1,
+      FEE_PERIOD_QUARTERLY  =2,
+      FEE_PERIOD_ANNUAL     =3,
+      //---
+      FEE_PERIOD_FIRST      =FEE_PERIOD_DAILY,
+      FEE_PERIOD_LAST       =FEE_PERIOD_ANNUAL
+     };
+   //--- assets mode for fee calculation 
+   enum EnFeeAssests
+     {
+      FEE_ASSETS_END         =0,
+      FEE_ASSETS_BEGIN       =1,
+      FEE_ASSETS_AVERAGE     =2,
+      //---
+      FEE_ASSETS_FIRST       =FEE_ASSETS_END,
+      FEE_ASSETS_LAST        =FEE_ASSETS_AVERAGE,
+     };
+   //--- success fee calculation modes
+   enum EnFeeSuccessCalc
+     {
+      FEE_SUCCESS_CALC_HURDLE_HWM_SOFT=0,
+      FEE_SUCCESS_CALC_HURDLE_HWM_HARD=1,
+      //---
+      FEE_SUCCESS_CALC_FIRST     =FEE_SUCCESS_CALC_HURDLE_HWM_SOFT,
+      FEE_SUCCESS_CALC_LAST      =FEE_SUCCESS_CALC_HURDLE_HWM_HARD
+     };
+   //--- success fee modes
+   enum EnFeeSuccessModes
+     {
+      FEE_SUCCESS_MODE_BEFORE_MF =0,
+      FEE_SUCCESS_MODE_AFTER_MF  =1,
+      //---
+      FEE_SUCCESS_MODE_FIRST     =FEE_SUCCESS_MODE_BEFORE_MF,
+      FEE_SUCCESS_MODE_LAST      =FEE_SUCCESS_MODE_AFTER_MF
+     };
+   //--- High Water Mark calaculation modes
+   enum EnFeeSuccessHWMType
+     {
+      FEE_SUCCESS_HWM_TYPE_FULL  =0,
+      FEE_SUCCESS_HWM_TYPE_QUATER=1,
+      FEE_SUCCESS_HWM_TYPE_YEAR  =2,
+      //---
+      FEE_SUCCESS_HWM_TYPE_FIRST =FEE_SUCCESS_HWM_TYPE_FULL,
+      FEE_SUCCESS_HWM_TYPE_LAST  =FEE_SUCCESS_HWM_TYPE_YEAR
+     };
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTConFund* fund)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- name
+   virtual LPCWSTR   Name(void) const=0;
+   virtual MTAPIRES  Name(LPCWSTR name)=0;
+   //--- Symbol
+   virtual LPCWSTR   Symbol(void) const=0;
+   virtual MTAPIRES  Symbol(LPCWSTR symbol)=0;
+   //--- Symbol Perfomance
+   virtual LPCWSTR   SymbolPerfomance(void) const=0;
+   virtual MTAPIRES  SymbolPerfomance(LPCWSTR symbol)=0;
+   //--- Symbol Assets
+   virtual LPCWSTR   SymbolAssets(void) const=0;
+   virtual MTAPIRES  SymbolAssets(LPCWSTR symbol)=0;
+   //--- Server
+   virtual UINT64    Server(void) const=0;
+   virtual MTAPIRES  Server(const UINT64 manager)=0;
+   //--- Manager
+   virtual UINT64    Manager(void) const=0;
+   virtual MTAPIRES  Manager(const UINT64 manager)=0;
+   //--- Flags
+   virtual UINT64    Flags(void) const=0;
+   virtual MTAPIRES  Flags(const UINT64 flags)=0;
+   //--- Type
+   virtual UINT      Type(void) const=0;
+   virtual MTAPIRES  Type(const UINT type)=0;
+   //--- Recalculation
+   virtual UINT      Recalculation(void) const=0;
+   virtual MTAPIRES  Recalculation(const UINT recalculation)=0;
+   //--- start period
+   virtual INT64     StartDate(void) const=0;
+   virtual MTAPIRES  StartDate(const INT64 date)=0;
+   //--- end period
+   virtual INT64     EndDate(void) const=0;
+   virtual MTAPIRES  EndDate(const INT64 date)=0;
+   //--- currency
+   virtual LPCWSTR   Currency(void) const=0;
+   virtual MTAPIRES  Currency(LPCWSTR currency)=0;
+   //--- Max capital
+   virtual double    MaxCapital(void) const=0;
+   virtual MTAPIRES  MaxCapital(const double max_capital)=0;
+   //--- Max investors
+   virtual UINT      MaxInvestors(void) const=0;
+   virtual MTAPIRES  MaxInvestors(const UINT max_investors)=0;
+   //--- Fee mode
+   virtual UINT      FeeMode(void) const=0;
+   virtual MTAPIRES  FeeMode(const UINT mode)=0;
+   //--- Fee period
+   virtual UINT      FeePeriod(void) const=0;
+   virtual MTAPIRES  FeePeriod(const UINT period)=0;
+   //--- Fee account
+   virtual UINT64    FeeAccount(void) const=0;
+   virtual MTAPIRES  FeeAccount(const UINT64 fee_account)=0;
+   //--- Management fee Type
+   virtual UINT      FeeManagementType(void) const=0;
+   virtual MTAPIRES  FeeManagementType(const UINT fee)=0;
+   //--- Management fee value
+   virtual double    FeeManagementValue(void) const=0;
+   virtual MTAPIRES  FeeManagementValue(const double fee)=0;
+   //--- Management assets mode
+   virtual UINT      FeeManagementAssets(void) const=0;
+   virtual MTAPIRES  FeeManagementAssets(const UINT mode)=0;
+   //--- Success fee calculation mode
+   virtual UINT      FeeSuccessCalc(void) const=0;
+   virtual MTAPIRES  FeeSuccessCalc(const UINT mode)=0;
+   //--- Success fee apply mode
+   virtual UINT      FeeSuccessMode(void) const=0;
+   virtual MTAPIRES  FeeSuccessMode(const UINT mode)=0;
+   //--- Success fee apply mode
+   virtual double    FeeSuccessValue(void) const=0;
+   virtual MTAPIRES  FeeSuccessValue(const double value)=0;
+   //--- Success fee High Water Mark calculation mode
+   virtual UINT      FeeSuccessHWM(void) const=0;
+   virtual MTAPIRES  FeeSuccessHWM(const UINT mode)=0;
+   //--- Success fee hurdle rate
+   virtual double    FeeSuccessHurdleRate(void) const=0;
+   virtual MTAPIRES  FeeSuccessHurdleRate(const double rate)=0;
+   //--- accounts
+   virtual MTAPIRES  AccountAdd(IMTConFundAccount* account)=0;
+   virtual MTAPIRES  AccountUpdate(const UINT pos,const IMTConFundAccount* account)=0;
+   virtual MTAPIRES  AccountDelete(const UINT pos)=0;
+   virtual MTAPIRES  AccountClear(void)=0;
+   virtual MTAPIRES  AccountShift(const UINT pos,const int shift)=0;
+   virtual UINT      AccountTotal(void) const=0;
+   virtual MTAPIRES  AccountNext(const UINT pos,IMTConFundAccount* account) const=0;
+   //--- investors
+   virtual MTAPIRES  InvestorAdd(IMTConFundInvestor* investor)=0;
+   virtual MTAPIRES  InvestorUpdate(const UINT pos,const IMTConFundInvestor* investor)=0;
+   virtual MTAPIRES  InvestorDelete(const UINT pos)=0;
+   virtual MTAPIRES  InvestorClear(void)=0;
+   virtual MTAPIRES  InvestorShift(const UINT pos,const int shift)=0;
+   virtual UINT      InvestorTotal(void) const=0;
+   virtual MTAPIRES  InvestorNext(const UINT pos,IMTConFundInvestor* investor) const=0;
+   //--- fund state
+   virtual double    StateCurrentCaptital(void) const=0;
+   virtual UINT      StateCurrentInvestors(void) const=0;
+  };
+//+------------------------------------------------------------------+
+//| Mail config events notification interface                        |
+//+------------------------------------------------------------------+
+class IMTConFundSink
+  {
+public:
+   virtual void      OnFundAdd(const IMTConFund*    /*config*/) {  }
+   virtual void      OnFundUpdate(const IMTConFund* /*config*/) {  }
+   virtual void      OnFundDelete(const IMTConFund* /*config*/) {  }
+   virtual void      OnFundSync(void)                           {  }
+  };
+//+------------------------------------------------------------------+

+ 218 - 0
MT5SDK/Config/MT5APIConfigGateway.h

@@ -0,0 +1,218 @@
+//+------------------------------------------------------------------+
+//|                                                 MetaTrader 5 API |
+//|                   Copyright 2000-2019, MetaQuotes Software Corp. |
+//|                                        http://www.metaquotes.net |
+//+------------------------------------------------------------------+
+#pragma once
+//+------------------------------------------------------------------+
+//| Gateway module config                                            |
+//+------------------------------------------------------------------+
+class IMTConGatewayModule
+  {
+   //--- changeable fields flags
+   enum EnGatewayFieldMask
+     {
+      GATEWAY_FIELD_SERVER=1,         // server field
+      GATEWAY_FIELD_LOGIN =2,         // login field
+      GATEWAY_FIELD_PASS  =4,         // password field
+      GATEWAY_FIELD_PARAM =8,         // parameters
+      //--- enumeration borders
+      GATEWAY_FIELD_NONE  =0,
+      GATEWAY_FIELD_ALL   =GATEWAY_FIELD_SERVER|GATEWAY_FIELD_LOGIN|GATEWAY_FIELD_PASS|GATEWAY_FIELD_PARAM
+     };
+public:
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTConGatewayModule* param)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- default gateway name
+   virtual LPCWSTR   Name(void) const=0;
+   //--- vendor name
+   virtual LPCWSTR   Vendor(void) const=0;
+   //--- gateway description
+   virtual LPCWSTR   Description(void) const=0;
+   //--- gateway file name
+   virtual LPCWSTR   Module(void) const=0;
+   //--- gateway default server address for trading
+   virtual LPCWSTR   TradingServer(void) const=0;
+   //--- gateway default login for trading
+   virtual LPCWSTR   TradingLogin(void) const=0;
+   //--- gateway default password for trading
+   virtual LPCWSTR   TradingPassword(void) const=0;
+   //--- gateway version
+   virtual UINT      Version(void) const=0;
+   //--- gateway available flags (IMTConGateway::EnGatewayFlags)
+   virtual UINT      Flags(void) const=0;
+   //--- changeable EnFeedersFieldFlags
+   virtual UINT      Fields(void) const=0;
+   //--- default gateway parameters
+   virtual UINT      ParameterTotal(void) const=0;
+   virtual MTAPIRES  ParameterNext(const UINT pos,IMTConParam* param) const=0;
+   virtual MTAPIRES  ParameterGet(LPCWSTR name,IMTConParam* param) const=0;
+   //--- gateway given name
+   virtual LPCWSTR   Gateway(void) const=0;
+  };
+//+------------------------------------------------------------------+
+//| Symbols name and price translation config                        |
+//+------------------------------------------------------------------+
+class IMTConGatewayTranslate
+  {
+public:
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTConGatewayTranslate* param)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- symbol name in datafeed
+   virtual LPCWSTR   Source(void) const=0;
+   virtual MTAPIRES  Source(LPCWSTR source)=0;
+   //--- symbol name in MT5
+   virtual LPCWSTR   Symbol(void) const=0;
+   virtual MTAPIRES  Symbol(LPCWSTR symbol)=0;
+   //--- bid markup in points
+   virtual INT       BidMarkup(void) const=0;
+   virtual MTAPIRES  BidMarkup(const INT markup)=0;
+   //--- ask markup in points
+   virtual INT       AskMarkup(void) const=0;
+   virtual MTAPIRES  AskMarkup(const INT markup)=0;
+   //--- digits
+   virtual UINT      Digits(void) const=0;
+  };
+//+------------------------------------------------------------------+
+//| Gateway config interface                                         |
+//+------------------------------------------------------------------+
+class IMTConGateway
+  {
+public:
+   //--- gateway working flags
+   enum EnGatewayFlags
+     {
+      GATEWAY_FLAG_REMOTE         =1,        // gateway works as remote service
+      GATEWAY_FLAG_IMPORT_SYMBOLS =2,        // gateway can import symbols to MetaTrader platform
+      GATEWAY_FLAG_IGNORE_QUOTES  =4,        // ignore quotes from gateway
+      GATEWAY_FLAG_IMPORT_BALANCES=8,        // gateway can import client balances to MetaTrader platform
+      GATEWAY_FLAG_EXTENDED_LOG   =16,       // gateway writes extended log
+      GATEWAY_FLAG_SUPP_POSITIONS =32,       // gateway support request of trading positions from external trading system
+      //--- flags borders
+      GATEWAY_FLAG_NONE           =0,
+      GATEWAY_FLAG_ALL            =GATEWAY_FLAG_REMOTE|GATEWAY_FLAG_IMPORT_SYMBOLS|
+      GATEWAY_FLAG_IGNORE_QUOTES|GATEWAY_FLAG_IMPORT_BALANCES|
+      GATEWAY_FLAG_EXTENDED_LOG|GATEWAY_FLAG_SUPP_POSITIONS
+     };
+   //--- gateway modes
+   enum EnGatewayMode
+     {
+      GATEWAY_DISABLED  =0,
+      GATEWAY_ENABLED   =1,
+      //--- enumeration borders
+      GATEWAY_FIRST     =GATEWAY_DISABLED,
+      GATEWAY_LAST      =GATEWAY_ENABLED
+     };
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTConGateway* param)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- gateway name
+   virtual LPCWSTR   Name(void) const=0;
+   virtual MTAPIRES  Name(LPCWSTR name)=0;
+   //--- gateway trade request routing id (dealer id)
+   virtual UINT64    ID(void) const=0;
+   virtual MTAPIRES  ID(const UINT64 id)=0;
+   //--- gateway module name
+   virtual LPCWSTR   Module(void) const=0;
+   virtual MTAPIRES  Module(LPCWSTR name)=0;
+   //--- gateway server address for trading
+   virtual LPCWSTR   TradingServer(void) const=0;
+   virtual MTAPIRES  TradingServer(LPCWSTR server)=0;
+   //--- gateway login for trading
+   virtual LPCWSTR   TradingLogin(void) const=0;
+   virtual MTAPIRES  TradingLogin(LPCWSTR login)=0;
+   //--- gateway password for trading
+   virtual LPCWSTR   TradingPassword(void) const=0;
+   virtual MTAPIRES  TradingPassword(LPCWSTR password)=0;
+   //--- gateway server address
+   virtual LPCWSTR   GatewayServer(void) const=0;
+   virtual MTAPIRES  GatewayServer(LPCWSTR server)=0;
+   //--- EnGatewayMode
+   virtual UINT      Mode(void) const=0;
+   virtual MTAPIRES  Mode(const UINT mode)=0;
+   //--- EnGatewayFlags
+   virtual UINT      Flags(void) const=0;
+   virtual MTAPIRES  Flags(const UINT flags)=0;
+   //--- obsolete value
+   virtual UINT      ObsoleteValue(void) const=0;
+   virtual MTAPIRES  ObsoleteValue(const UINT value)=0;
+   //--- gateway reconnect timeout
+   virtual UINT      TimeoutReconnect(void) const=0;
+   virtual MTAPIRES  TimeoutReconnect(const UINT timeout)=0;
+   //--- gateway sleep timeout
+   virtual UINT      TimeoutSleep(void) const=0;
+   virtual MTAPIRES  TimeoutSleep(const UINT timeout)=0;
+   //--- gateway attempts before timeout
+   virtual UINT      TimeoutAttempts(void) const=0;
+   virtual MTAPIRES  TimeoutAttempts(const UINT attempts)=0;
+   //--- gateway additional parameters access
+   virtual MTAPIRES  ParameterAdd(IMTConParam* param)=0;
+   virtual MTAPIRES  ParameterUpdate(const UINT pos,const IMTConParam* param)=0;
+   virtual MTAPIRES  ParameterDelete(const UINT pos)=0;
+   virtual MTAPIRES  ParameterClear(void)=0;
+   virtual MTAPIRES  ParameterShift(const UINT pos,const int shift)=0;
+   virtual UINT      ParameterTotal(void) const=0;
+   virtual MTAPIRES  ParameterNext(const UINT pos,IMTConParam* param) const=0;
+   virtual MTAPIRES  ParameterGet(LPCWSTR name,IMTConParam* param) const=0;
+   //--- list of symbols for translating quotes
+   virtual MTAPIRES  SymbolAdd(LPCWSTR path)=0;
+   virtual MTAPIRES  SymbolUpdate(const UINT pos,LPCWSTR path)=0;
+   virtual MTAPIRES  SymbolDelete(const UINT pos)=0;
+   virtual MTAPIRES  SymbolClear(void)=0;
+   virtual MTAPIRES  SymbolShift(const UINT pos,const int shift)=0;
+   virtual UINT      SymbolTotal(void) const=0;
+   virtual LPCWSTR   SymbolNext(const UINT pos) const=0;
+   //--- list of users groups who works through gateway
+   virtual MTAPIRES  GroupAdd(LPCWSTR path)=0;
+   virtual MTAPIRES  GroupUpdate(const UINT pos,LPCWSTR path)=0;
+   virtual MTAPIRES  GroupDelete(const UINT pos)=0;
+   virtual MTAPIRES  GroupClear(void)=0;
+   virtual MTAPIRES  GroupShift(const UINT pos,const int shift)=0;
+   virtual UINT      GroupTotal(void) const=0;
+   virtual LPCWSTR   GroupNext(const UINT pos) const=0;
+   //--- list of symbols translations
+   virtual MTAPIRES  TranslateAdd(IMTConGatewayTranslate* param)=0;
+   virtual MTAPIRES  TranslateUpdate(const UINT pos,const IMTConGatewayTranslate* param)=0;
+   virtual MTAPIRES  TranslateDelete(const UINT pos)=0;
+   virtual MTAPIRES  TranslateClear(void)=0;
+   virtual MTAPIRES  TranslateShift(const UINT pos,const int shift)=0;
+   virtual UINT      TranslateTotal(void) const=0;
+   virtual MTAPIRES  TranslateNext(const UINT pos,IMTConGatewayTranslate* param) const=0;
+   virtual MTAPIRES  TranslateGet(LPCWSTR symbol,IMTConGatewayTranslate* param) const=0;
+   //--- gateway server login
+   virtual UINT64    GatewayLogin(void) const=0;
+   virtual MTAPIRES  GatewayLogin(UINT64 login)=0;
+   //--- gateway server password
+   virtual LPCWSTR   GatewayPassword(void) const=0;
+   virtual MTAPIRES  GatewayPassword(LPCWSTR password)=0;
+   //--- list of symbols translations
+   virtual MTAPIRES  TranslateGetSource(LPCWSTR source,IMTConGatewayTranslate* param) const=0;
+   //--- gateway given name
+   virtual LPCWSTR   Gateway(void) const=0;
+   //--- gateway state information
+   virtual bool      StateConnected(void) const=0;
+   virtual UINT      StateReceivedTicks(void) const=0;
+   virtual UINT      StateReceivedBooks(void) const=0;
+   virtual UINT      StateTrafficIn(void) const=0;
+   virtual UINT      StateTrafficOut(void) const=0;
+   virtual UINT      StateTradesTotal(void) const=0;
+   virtual UINT      StateTradesAverageTime(void) const=0;
+  };
+//+------------------------------------------------------------------+
+//| Gateway config events notification interface                     |
+//+------------------------------------------------------------------+
+class IMTConGatewaySink
+  {
+public:
+   virtual void      OnGatewayAdd(const IMTConGateway*    /*gateway*/) {  }
+   virtual void      OnGatewayUpdate(const IMTConGateway* /*gateway*/) {  }
+   virtual void      OnGatewayDelete(const IMTConGateway* /*gateway*/) {  }
+   virtual void      OnGatewaySync(void)                               {  }
+  };
+//+------------------------------------------------------------------+
+

+ 698 - 0
MT5SDK/Config/MT5APIConfigGroup.h

@@ -0,0 +1,698 @@
+//+------------------------------------------------------------------+
+//|                                                MetaTrader 5 API  |
+//|                   Copyright 2000-2019, MetaQuotes Software Corp. |
+//|                                        http://www.metaquotes.net |
+//+------------------------------------------------------------------+
+#pragma once
+//+------------------------------------------------------------------+
+//| Commission tier config                                           |
+//+------------------------------------------------------------------+
+class IMTConCommTier
+  {
+public:
+   //--- commission charge mode
+   enum EnCommissionMode
+     {
+      COMM_MONEY_DEPOSIT       =0,  // in money, in group deposit currency
+      COMM_MONEY_SYMBOL_BASE   =1,  // in money, in symbol base currency
+      COMM_MONEY_SYMBOL_PROFIT =2,  // in money, in symbol profit currency
+      COMM_MONEY_SYMBOL_MARGIN =3,  // in money, in symbol margin currency
+      COMM_PIPS                =4,  // in pips
+      COMM_PERCENT             =5,  // in percent
+      COMM_MONEY_SPECIFIED     =6,  // in money, in specified currency
+      //--- enumeration borders
+      COMM_FIRST               =COMM_MONEY_DEPOSIT,
+      COMM_LAST                =COMM_MONEY_SPECIFIED
+     };
+   //--- commission type by volume
+   enum EnCommissionVolumeType
+     {
+      COMM_TYPE_DEAL           =0,  // commission per deal
+      COMM_TYPE_VOLUME         =1,  // commission per volume
+      //--- enumeration borders
+      COMM_TYPE_FIRST          =COMM_TYPE_DEAL,
+      COMM_TYPE_LAST           =COMM_TYPE_VOLUME
+     };
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTConCommTier* group)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- EnCommissionMode
+   virtual UINT      Mode(void) const=0;
+   virtual MTAPIRES  Mode(const UINT mode)=0;
+   //--- EnCommissionVolumeType
+   virtual UINT      Type(void) const=0;
+   virtual MTAPIRES  Type(const UINT type)=0;
+   //--- commission value
+   virtual double    Value(void) const=0;
+   virtual MTAPIRES  Value(const double value)=0;
+   //--- minimal commission value
+   virtual double    Minimal(void) const=0;
+   virtual MTAPIRES  Minimal(const double value)=0;
+   //--- tier range from
+   virtual double    RangeFrom(void) const=0;
+   virtual MTAPIRES  RangeFrom(const double value)=0;
+   //--- tier range to
+   virtual double    RangeTo(void) const=0;
+   virtual MTAPIRES  RangeTo(const double value)=0;
+   //--- commission currency (for Mode==COMM_MONEY_SPECIFIED)
+   virtual LPCWSTR   Currency(void) const=0;
+   virtual MTAPIRES  Currency(LPCWSTR currency)=0;
+   //--- maximal commission value
+   virtual double    Maximal(void) const=0;
+   virtual MTAPIRES  Maximal(const double value)=0;
+  };
+//+------------------------------------------------------------------+
+//| Commission config interface                                      |
+//+------------------------------------------------------------------+
+class IMTConCommission
+  {
+public:
+   //--- commission mode
+   enum EnCommMode
+     {
+      COMM_STANDARD            =0,  // standard commission
+      COMM_AGENT               =1,  // agent commission
+      //--- enumeration borders
+      COMM_FIRST               =COMM_STANDARD,
+      COMM_LAST                =COMM_AGENT
+     };
+   //--- commission range mode
+   enum EnCommRangeMode
+     {
+      COMM_RANGE_VOLUME         =0,  // range in volumes
+      COMM_RANGE_TURNOVER_MONEY =1,  // turnover in money
+      COMM_RANGE_TURNOVER_VOLUME=2,  // turnover in volume
+      //--- enumeration borders
+      COMM_RANGE_FIRST         =COMM_RANGE_VOLUME,
+      COMM_RANGE_LAST          =COMM_RANGE_TURNOVER_VOLUME
+     };
+   //--- commission charge modes
+   enum EnCommChargeMode
+     {
+      COMM_CHARGE_DAILY        =0, // charge at the end of daily
+      COMM_CHARGE_MONTHLY      =1, // charge at the end of month
+      COMM_CHARGE_INSTANT      =2, // charge instantly
+      //--- enumeration borders
+      COMM_CHARGE_FIRST        =COMM_CHARGE_DAILY,
+      COMM_CHARGE_LAST         =COMM_CHARGE_INSTANT
+     };
+   //--- deal entry mode
+   enum EnCommEntryMode
+     {
+      COMM_ENTRY_ALL           =0, // both in and out
+      COMM_ENTRY_IN            =1, // in deals
+      COMM_ENTRY_OUT           =2, // out deals
+      //--- enumeration borders
+      COMM_ENTRY_FIRST         =COMM_ENTRY_ALL,
+      COMM_ENTRY_LAST          =COMM_ENTRY_OUT
+     };
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTConCommission* group)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- commission name
+   virtual LPCWSTR   Name(void) const=0;
+   virtual MTAPIRES  Name(LPCWSTR name)=0;
+   //--- description
+   virtual LPCWSTR   Description(void) const=0;
+   virtual MTAPIRES  Description(LPCWSTR descr)=0;
+   //--- symbols path
+   virtual LPCWSTR   Path(void) const=0;
+   virtual MTAPIRES  Path(LPCWSTR path)=0;
+   //--- EnCommMode
+   virtual UINT      Mode(void) const=0;
+   virtual MTAPIRES  Mode(const UINT mode)=0;
+   //--- EnCommRangeMode
+   virtual UINT      RangeMode(void) const=0;
+   virtual MTAPIRES  RangeMode(const UINT mode)=0;
+   //--- EnCommChargeMode
+   virtual UINT      ChargeMode(void) const=0;
+   virtual MTAPIRES  ChargeMode(const UINT mode)=0;
+   //--- commission tiers
+   virtual MTAPIRES  TierAdd(IMTConCommTier* tier)=0;
+   virtual MTAPIRES  TierUpdate(const UINT pos,const IMTConCommTier* tier)=0;
+   virtual MTAPIRES  TierDelete(const UINT pos)=0;
+   virtual MTAPIRES  TierClear(void)=0;
+   virtual MTAPIRES  TierShift(const UINT pos,const int shift)=0;
+   virtual UINT      TierTotal(void) const=0;
+   virtual MTAPIRES  TierNext(const UINT pos,IMTConCommTier* tier) const=0;
+   //---- turnover calculation currency
+   virtual LPCWSTR   TurnoverCurrency(void) const=0;
+   virtual MTAPIRES  TurnoverCurrency(LPCWSTR currency)=0;
+   //--- EnCommEntryMode
+   virtual UINT      EntryMode(void) const=0;
+   virtual MTAPIRES  EntryMode(const UINT mode)=0;
+  };
+//+------------------------------------------------------------------+
+//| Symbols configuration for clients group                          |
+//+------------------------------------------------------------------+
+class IMTConGroupSymbol
+  {
+public:
+   //--- Requests Execution flags
+   enum EnREFlags
+     {
+      RE_FLAGS_NONE           =0,  // none
+      RE_FLAGS_ORDER          =1,  // confirm orders after price confirmation
+      //--- enumeration borders
+      RE_FLAGS_ALL            =RE_FLAGS_ORDER
+     };
+   //--- Permissions
+   enum EnPermissionsFlags
+     {
+      PERMISSION_NONE         =0,  // none
+      PERMISSION_BOOK         =1,  // allow books for group
+      //--- enumeration borders
+      PERMISSION_DEFAULT      =PERMISSION_BOOK,
+      PERMISSION_ALL          =PERMISSION_BOOK
+     };
+
+public:
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTConGroupSymbol* group)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- setup default values for all fields
+   virtual MTAPIRES  Default(void)=0;
+   //--- symbol or symbol groups path
+   virtual LPCWSTR   Path(void) const=0;
+   virtual MTAPIRES  Path(LPCWSTR path)=0;
+   //--- IMTConSymbol::EnTradeMode
+   virtual UINT      TradeMode(void) const=0;
+   virtual MTAPIRES  TradeMode(const UINT mode)=0;
+   virtual UINT      TradeModeDefault(void) const=0;
+   //--- IMTConSymbol::EnCalcMode
+   virtual UINT      ExecMode(void) const=0;
+   virtual MTAPIRES  ExecMode(const UINT mode)=0;
+   virtual UINT      ExecModeDefault(void) const=0;
+   //--- IMTConSymbol::EnTradeFillingFlags
+   virtual UINT      FillFlags(void) const=0;
+   virtual MTAPIRES  FillFlags(const UINT flags)=0;
+   virtual UINT      FillFlagsDefault(void) const=0;
+   //--- IMTConSymbol::EnTradeExpirationFlags
+   virtual UINT      ExpirFlags(void) const=0;
+   virtual MTAPIRES  ExpirFlags(const UINT flags)=0;
+   virtual UINT      ExpirFlagsDefault(void) const=0;
+   //--- spread difference (0 - floating spread)
+   virtual INT       SpreadDiff(void) const=0;
+   virtual MTAPIRES  SpreadDiff(const INT spread)=0;
+   virtual INT       SpreadDiffDefault(void) const=0;
+   //--- spread difference balance
+   virtual INT       SpreadDiffBalance(void) const=0;
+   virtual MTAPIRES  SpreadDiffBalance(const INT spread)=0;
+   virtual INT       SpreadDiffBalanceDefault(void) const=0;
+   //--- stops level
+   virtual INT       StopsLevel(void) const=0;
+   virtual MTAPIRES  StopsLevel(const INT level)=0;
+   virtual INT       StopsLevelDefault(void) const=0;
+   //--- freeze level
+   virtual INT       FreezeLevel(void) const=0;
+   virtual MTAPIRES  FreezeLevel(const INT level)=0;
+   virtual INT       FreezeLevelDefault(void) const=0;
+   //--- minimal volume
+   virtual UINT64    VolumeMin(void) const=0;
+   virtual MTAPIRES  VolumeMin(const UINT64 volume)=0;
+   virtual UINT64    VolumeMinDefault(void) const=0;
+   //--- maximal volume
+   virtual UINT64    VolumeMax(void) const=0;
+   virtual MTAPIRES  VolumeMax(const UINT64 volume)=0;
+   virtual UINT64    VolumeMaxDefault(void) const=0;
+   //--- volume step
+   virtual UINT64    VolumeStep(void) const=0;
+   virtual MTAPIRES  VolumeStep(const UINT64 volume)=0;
+   virtual UINT64    VolumeStepDefault(void) const=0;
+   //--- cumulative positions and orders limit
+   virtual UINT64    VolumeLimit(void) const=0;
+   virtual MTAPIRES  VolumeLimit(const UINT64 volume)=0;
+   virtual UINT64    VolumeLimitDefault(void) const=0;
+   //--- IMTConSymbol::EnMarginFlags
+   virtual UINT      MarginFlags(void) const=0;
+   virtual MTAPIRES  MarginFlags(const UINT flags)=0;
+   virtual UINT      MarginFlagsDefault(void) const=0;
+   //--- initial margin
+   virtual double    MarginInitial(void) const=0;
+   virtual MTAPIRES  MarginInitial(const double margin)=0;
+   virtual double    MarginInitialDefault(void) const=0;
+   //--- maintenance margin
+   virtual double    MarginMaintenance(void) const=0;
+   virtual MTAPIRES  MarginMaintenance(const double margin)=0;
+   virtual double    MarginMaintenanceDefault(void) const=0;
+   //--- long orders and positions margin rate
+   virtual double    MarginLong(void) const=0;
+   virtual MTAPIRES  MarginLong(const double margin)=0;
+   virtual double    MarginLongDefault(void) const=0;
+   //--- short orders and positions margin rate
+   virtual double    MarginShort(void) const=0;
+   virtual MTAPIRES  MarginShort(const double margin)=0;
+   virtual double    MarginShortDefault(void) const=0;
+   //--- limit orders and positions margin rate
+   virtual double    MarginLimit(void) const=0;
+   virtual MTAPIRES  MarginLimit(const double margin)=0;
+   virtual double    MarginLimitDefault(void) const=0;
+   //--- stop orders and positions margin rate
+   virtual double    MarginStop(void) const=0;
+   virtual MTAPIRES  MarginStop(const double margin)=0;
+   virtual double    MarginStopDefault(void) const=0;
+   //--- stop-limit orders and positions margin rate
+   virtual double    MarginStopLimit(void) const=0;
+   virtual MTAPIRES  MarginStopLimit(const double margin)=0;
+   virtual double    MarginStopLimitDefault(void) const=0;
+   //--- IMTConSymbol::EnSwapMode
+   virtual UINT      SwapMode(void) const=0;
+   virtual MTAPIRES  SwapMode(const UINT mode)=0;
+   virtual UINT      SwapModeDefault(void) const=0;
+   //--- long positions swaps rate
+   virtual double    SwapLong(void) const=0;
+   virtual MTAPIRES  SwapLong(const double swap)=0;
+   virtual double    SwapLongDefault(void) const=0;
+   //--- short positions swaps rate
+   virtual double    SwapShort(void) const=0;
+   virtual MTAPIRES  SwapShort(const double swap)=0;
+   virtual double    SwapShortDefault(void) const=0;
+   //--- 3 time swaps day, EnSwapDay
+   virtual int       Swap3Day(void) const=0;
+   virtual MTAPIRES  Swap3Day(const int day)=0;
+   virtual int       Swap3DayDefault(void) const=0;
+   //--- request execution timeout
+   virtual UINT      RETimeout(void) const=0;
+   virtual MTAPIRES  RETimeout(const UINT timeout)=0;
+   virtual UINT      RETimeoutDefault(void) const=0;
+   //--- instant execution check mode
+   virtual UINT      IECheckMode(void) const=0;
+   virtual MTAPIRES  IECheckMode(const UINT mode)=0;
+   virtual UINT      IECheckModeDefault(void) const=0;
+   //--- instant execution timeout
+   virtual UINT      IETimeout(void) const=0;
+   virtual MTAPIRES  IETimeout(const UINT timeout)=0;
+   virtual UINT      IETimeoutDefault(void) const=0;
+   //--- instant execution profit slippage
+   virtual UINT      IESlipProfit(void) const=0;
+   virtual MTAPIRES  IESlipProfit(const UINT slippage)=0;
+   virtual UINT      IESlipProfitDefault(void) const=0;
+   //--- instant execution losing slippage
+   virtual UINT      IESlipLosing(void) const=0;
+   virtual MTAPIRES  IESlipLosing(const UINT slippage)=0;
+   virtual UINT      IESlipLosingDefault(void) const=0;
+   //--- instant execution max volume
+   virtual UINT64    IEVolumeMax(void) const=0;
+   virtual MTAPIRES  IEVolumeMax(const UINT64 volume)=0;
+   virtual UINT64    IEVolumeMaxDefault(void) const=0;
+   //--- IMTConSymbol::EnOrderFlags
+   virtual UINT      OrderFlags(void) const=0;
+   virtual MTAPIRES  OrderFlags(const UINT flags)=0;
+   virtual UINT      OrderFlagsDefault(void) const=0;
+   //--- orders and positions margin rates
+   virtual double    MarginRateInitial(const UINT type) const=0;
+   virtual MTAPIRES  MarginRateInitial(const UINT type,const double margin_rate)=0;
+   virtual double    MarginRateInitialDefault(void) const=0;
+   //--- orders and positions margin rates
+   virtual double    MarginRateMaintenance(const UINT type) const=0;
+   virtual MTAPIRES  MarginRateMaintenance(const UINT type,const double margin_rate)=0;
+   virtual double    MarginRateMaintenanceDefault(void) const=0;
+   //--- trade symbol liqudity rate in margin calculation
+   virtual double    MarginRateLiquidity(void) const=0;
+   virtual MTAPIRES  MarginRateLiquidity(const double rate)=0;
+   virtual double    MarginRateLiquidityDefault(void) const=0;
+   //--- request execution flags IMTConGroupSymbol::EnREFlags
+   virtual UINT      REFlags(void) const=0;
+   virtual MTAPIRES  REFlags(const UINT flags)=0;
+   virtual UINT      REFlagsDefault(void) const=0;
+   //--- hedged positions margin rate
+   virtual double    MarginHedged(void) const=0;
+   virtual MTAPIRES  MarginHedged(const double margin)=0;
+   virtual double    MarginHedgedDefault(void) const=0;
+   //--- permissions flags
+   virtual UINT      PermissionsFlags(void) const=0;
+   virtual MTAPIRES  PermissionsFlags(const UINT flags)=0;
+   //--- margin currency rate
+   virtual double    MarginRateCurrency(void) const=0;
+   virtual MTAPIRES  MarginRateCurrency(const double margin_rate)=0;
+   virtual double    MarginRateCurrencyDefault(void) const=0;
+   //--- book depth limit
+   virtual UINT      BookDepthLimit(void) const=0;
+   virtual MTAPIRES  BookDepthLimit(const UINT depth)=0;
+   //--- instant execution flags
+   virtual UINT      IEFlags(void) const=0;
+   virtual MTAPIRES  IEFlags(const UINT flags)=0;
+   virtual UINT      IEFlagsDefault(void) const=0;
+   //--- minimal volume
+   virtual UINT64    VolumeMinExt(void) const=0;
+   virtual MTAPIRES  VolumeMinExt(const UINT64 volume)=0;
+   virtual UINT64    VolumeMinExtDefault(void) const=0;
+   //--- maximal volume
+   virtual UINT64    VolumeMaxExt(void) const=0;
+   virtual MTAPIRES  VolumeMaxExt(const UINT64 volume)=0;
+   virtual UINT64    VolumeMaxExtDefault(void) const=0;
+   //--- volume step
+   virtual UINT64    VolumeStepExt(void) const=0;
+   virtual MTAPIRES  VolumeStepExt(const UINT64 volume)=0;
+   virtual UINT64    VolumeStepExtDefault(void) const=0;
+   //--- cumulative positions and orders limit
+   virtual UINT64    VolumeLimitExt(void) const=0;
+   virtual MTAPIRES  VolumeLimitExt(const UINT64 volume)=0;
+   virtual UINT64    VolumeLimitExtDefault(void) const=0;
+   //--- instant execution max volume
+   virtual UINT64    IEVolumeMaxExt(void) const=0;
+   virtual MTAPIRES  IEVolumeMaxExt(const UINT64 volume)=0;
+   virtual UINT64    IEVolumeMaxExtDefault(void) const=0;
+  };
+//+------------------------------------------------------------------+
+//| Group configuration interface                                    |
+//+------------------------------------------------------------------+
+class IMTConGroup
+  {
+public:
+   //--- group permissions flags
+   enum EnPermissionsFlags
+     {
+      PERMISSION_NONE              =0x00000000,  // default
+      PERMISSION_CERT_CONFIRM      =0x00000001,  // certificate confirmation neccessary
+      PERMISSION_ENABLE_CONNECTION =0x00000002,  // clients connections allowed
+      PERMISSION_RESET_PASSWORD    =0x00000004,  // reset password after first logon
+      PERMISSION_FORCED_OTP_USAGE  =0x00000008,  // forced usage OTP
+      PERMISSION_RISK_WARNING      =0x00000010,  // show risk warning window on start
+      PERMISSION_REGULATION_PROTECT=0x00000020,  // country-specific regulatory protection
+      //--- enumeration borders
+      PERMISSION_ALL         =PERMISSION_CERT_CONFIRM     | PERMISSION_ENABLE_CONNECTION | PERMISSION_RESET_PASSWORD|
+      PERMISSION_FORCED_OTP_USAGE | PERMISSION_RISK_WARNING      | PERMISSION_REGULATION_PROTECT
+     };
+   //--- authorization mode
+   enum EnAuthMode
+     {
+      AUTH_STANDARD               =0,  // standard authorization
+      AUTH_RSA1024                =1,  // RSA1024 certificate
+      AUTH_RSA2048                =2,  // RSA2048 certificate
+      AUTH_RSA_CUSTOM             =3,  // RSA custom
+      //--- enumeration borders
+      AUTH_FIRST                  =AUTH_STANDARD,
+      AUTH_LAST                   =AUTH_RSA2048
+     };
+   //--- Oen-Time-Password mode
+   enum EnAuthOTPMode
+     {
+      AUTH_OTP_DISABLED           =0,
+      AUTH_OTP_TOTP_SHA256        =1,
+      AUTH_OTP_TOTP_SHA256_WEB    =2,
+      //--- enumeration borders
+      AUTH_OTP_FIRST              =AUTH_OTP_DISABLED,
+      AUTH_OTP_LAST               =AUTH_OTP_TOTP_SHA256_WEB
+     };
+   //--- reports generation mode
+   enum EnReportsMode
+     {
+      REPORTS_DISABLED            =0,  // reports disabled
+      REPORTS_STANDARD            =1,  // standard mode
+      //--- enumeration borders
+      REPORTS_FIRST               =REPORTS_DISABLED,
+      REPORTS_LAST                =REPORTS_STANDARD
+     };
+   //--- reports generation flags
+   enum EnReportsFlags
+     {
+      REPORTSFLAGS_NONE           =0,  // none
+      REPORTSFLAGS_EMAIL          =1,  // send reports through email
+      REPORTSFLAGS_SUPPORT        =2,  // send reports copies on support email
+      //--- enumeration borders
+      REPORTSFLAGS_ALL            =REPORTSFLAGS_NONE|REPORTSFLAGS_EMAIL
+     };
+   //--- news modes
+   enum EnNewsMode
+     {
+      NEWS_MODE_DISABLED          =0,  // disable news
+      NEWS_MODE_HEADERS           =1,  // enable only news headers
+      NEWS_MODE_FULL              =2,  // enable full news
+      //--- enumeration borders
+      NEWS_MODE_FIRST             =NEWS_MODE_DISABLED,
+      NEWS_MODE_LAST              =NEWS_MODE_FULL
+     };
+   //--- internal email modes
+   enum EnMailMode
+     {
+      MAIL_MODE_DISABLED          =0,  // disable internal email
+      MAIL_MODE_FULL              =1,  // enable internal email
+      //--- enumeration borders
+      MAIL_MODE_FIRST             =MAIL_MODE_DISABLED,
+      MAIL_MODE_LAST              =MAIL_MODE_FULL
+     };
+   //--- client history limits
+   enum EnHistoryLimit
+     {
+      TRADE_HISTORY_ALL           =0,  // unlimited
+      TRADE_HISTORY_MONTHS_1      =1,  // one month
+      TRADE_HISTORY_MONTHS_3      =2,  // 3 months
+      TRADE_HISTORY_MONTHS_6      =3,  // 6 months
+      TRADE_HISTORY_YEAR_1        =4,  // 1 year
+      TRADE_HISTORY_YEAR_2        =5,  // 2 years
+      TRADE_HISTORY_YEAR_3        =6,  // 3 years
+      //--- enumeration borders
+      TRADE_HISTORY_FIRST         =TRADE_HISTORY_ALL,
+      TRADE_HISTORY_LAST          =TRADE_HISTORY_YEAR_3
+     };
+   //--- free margin calculation modes
+   enum EnFreeMarginMode
+     {
+      FREE_MARGIN_NOT_USE_PL      =0,  // don't use floating profit and loss
+      FREE_MARGIN_USE_PL          =1,  // use floating profit and loss
+      FREE_MARGIN_PROFIT          =2,  // use floating profit only
+      FREE_MARGIN_LOSS            =3,  // use floating loss only
+      //--- enumeration borders
+      FREE_MARGIN_FIRST           =FREE_MARGIN_NOT_USE_PL,
+      FREE_MARGIN_LAST            =FREE_MARGIN_LOSS
+     };
+   //--- EnTransferMode
+   enum EnTransferMode
+     {
+      TRANSFER_MODE_DISABLED      =0,
+      TRANSFER_MODE_NAME          =1,
+      TRANSFER_MODE_GROUP         =2,
+      TRANSFER_MODE_NAME_GROUP    =3,
+      //--- enumeration borders
+      TRANSFER_MODE_FIRST         =TRANSFER_MODE_DISABLED,
+      TRANSFER_MODE_LAST          =TRANSFER_MODE_NAME_GROUP
+     };
+   //--- stop-out mode
+   enum EnStopOutMode
+     {
+      STOPOUT_PERCENT             =0,  // stop-out in percent
+      STOPOUT_MONEY               =1,  // stop-out in money
+      //--- enumeration borders
+      STOPOUT_FIRST               =STOPOUT_PERCENT,
+      STOPOUT_LAST                =STOPOUT_MONEY
+     };
+   //--- fixed profit calculation in free margin
+   enum EnMarginFreeProfitMode
+     {
+      FREE_MARGIN_PROFIT_PL       =0,  // both fixed loss and profit on free margin
+      FREE_MARGIN_PROFIT_LOSS     =1,  // only fixed loss on free margin
+      //--- enumeration borders
+      FREE_MARGIN_PROFIT_FIRST    =FREE_MARGIN_PROFIT_PL,
+      FREE_MARGIN_PROFIT_LAST     =FREE_MARGIN_PROFIT_LOSS
+     };
+   //--- group risk management mode 
+   enum EnMarginMode
+     {
+      MARGIN_MODE_RETAIL           =0, // Retail FX, Retail CFD, Retail Futures
+      MARGIN_MODE_EXCHANGE_DISCOUNT=1, // Exchange, margin discount rates based 
+      MARGIN_MODE_RETAIL_HEDGED    =2, // Retail FX, Retail CFD, Retail Futures with hedged positions
+      //--- enumeration borders
+      MARGIN_MODE_FIRST           =MARGIN_MODE_RETAIL,
+      MARGIN_MODE_LAST            =MARGIN_MODE_RETAIL_HEDGED
+     };
+   //--- margin calculation flags
+   enum EnMarginFlags
+     {
+      MARGIN_FLAGS_NONE           =0,        // none
+      MARGIN_FLAGS_CLEAR_ACC      =1,        // clear accumulated profit at end of day
+      //--- enumeration borders
+      MARGIN_FLAGS_ALL            =MARGIN_FLAGS_CLEAR_ACC
+     };
+   //--- trade rights flags
+   enum EnTradeFlags
+     {
+      TRADEFLAGS_NONE             =0x00000000,  // none
+      TRADEFLAGS_SWAPS            =0x00000001,  // allow swaps charges
+      TRADEFLAGS_TRAILING         =0x00000002,  // allow trailing stops
+      TRADEFLAGS_EXPERTS          =0x00000004,  // allow expert advisors
+      TRADEFLAGS_EXPIRATION       =0x00000008,  // allow orders expiration
+      TRADEFLAGS_SIGNALS_ALL      =0x00000010,  // allow trade signals
+      TRADEFLAGS_SIGNALS_OWN      =0x00000020,  // allow trade signals only from own server
+      TRADEFLAGS_SO_COMPENSATION  =0x00000040,  // allow negative balance compensation after stop out
+      TRADEFLAGS_SO_FULLY_HEDGED  =0x00000080,  // allow stop out fully hegded accounts
+      TRADEFLAGS_FIFO_CLOSE       =0x00000100,  // allow to close positions by FIFO rule
+      //--- enumeration borders
+      TRADEFLAGS_DEFAULT          =TRADEFLAGS_SWAPS|TRADEFLAGS_TRAILING|TRADEFLAGS_EXPERTS|TRADEFLAGS_EXPIRATION|TRADEFLAGS_SIGNALS_ALL,
+      TRADEFLAGS_ALL              =TRADEFLAGS_SWAPS|TRADEFLAGS_TRAILING|TRADEFLAGS_EXPERTS|TRADEFLAGS_EXPIRATION|TRADEFLAGS_SIGNALS_ALL|TRADEFLAGS_SIGNALS_OWN|
+      TRADEFLAGS_SO_COMPENSATION|TRADEFLAGS_SO_FULLY_HEDGED|TRADEFLAGS_FIFO_CLOSE
+     };
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTConGroup* group)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- group name
+   virtual LPCWSTR   Group(void) const=0;
+   virtual MTAPIRES  Group(LPCWSTR group)=0;
+   //--- group trade server ID
+   virtual UINT64    Server(void) const=0;
+   virtual MTAPIRES  Server(const UINT64 server)=0;
+   //--- EnPermissionsFlags
+   virtual UINT64    PermissionsFlags(void) const=0;
+   virtual MTAPIRES  PermissionsFlags(const UINT64 flags)=0;
+   //--- EnAuthMode
+   virtual UINT      AuthMode(void) const=0;
+   virtual MTAPIRES  AuthMode(const UINT mode)=0;
+   //--- minimal password length
+   virtual UINT      AuthPasswordMin(void) const=0;
+   virtual MTAPIRES  AuthPasswordMin(const UINT mode)=0;
+   //--- company name
+   virtual LPCWSTR   Company(void) const=0;
+   virtual MTAPIRES  Company(LPCWSTR company)=0;
+   //--- company web page URL
+   virtual LPCWSTR   CompanyPage(void) const=0;
+   virtual MTAPIRES  CompanyPage(LPCWSTR page)=0;
+   //--- company email
+   virtual LPCWSTR   CompanyEmail(void) const=0;
+   virtual MTAPIRES  CompanyEmail(LPCWSTR email)=0;
+   //--- company support site URL
+   virtual LPCWSTR   CompanySupportPage(void) const=0;
+   virtual MTAPIRES  CompanySupportPage(LPCWSTR page)=0;
+   //--- company support email
+   virtual LPCWSTR   CompanySupportEmail(void) const=0;
+   virtual MTAPIRES  CompanySupportEmail(LPCWSTR email)=0;
+   //--- company catalog name (for reports and email templates)
+   virtual LPCWSTR   CompanyCatalog(void) const=0;
+   virtual MTAPIRES  CompanyCatalog(LPCWSTR catalog)=0;
+   //--- deposit currency
+   virtual LPCWSTR   Currency(void) const=0;
+   virtual MTAPIRES  Currency(LPCWSTR currency)=0;
+   virtual UINT      CurrencyDigits(void) const=0;
+   //--- EnReportsMode
+   virtual UINT      ReportsMode(void) const=0;
+   virtual MTAPIRES  ReportsMode(const UINT mode)=0;
+   //--- EnReportsFlags
+   virtual UINT64    ReportsFlags(void) const=0;
+   virtual MTAPIRES  ReportsFlags(const UINT64 flags)=0;
+   //--- reports SMTP server address:ports 
+   virtual LPCWSTR   ReportsSMTP(void) const=0;
+   virtual MTAPIRES  ReportsSMTP(LPCWSTR server)=0;
+   //--- reports SMTP server login
+   virtual LPCWSTR   ReportsSMTPLogin(void) const=0;
+   virtual MTAPIRES  ReportsSMTPLogin(LPCWSTR login)=0;
+   //--- reports SMTP server password
+   virtual LPCWSTR   ReportsSMTPPass(void) const=0;
+   virtual MTAPIRES  ReportsSMTPPass(LPCWSTR password)=0;
+   //--- EnNewsMode
+   virtual UINT      NewsMode(void) const=0;
+   virtual MTAPIRES  NewsMode(const UINT mode)=0;
+   //--- news category filter string
+   virtual LPCWSTR   NewsCategory(void) const=0;
+   virtual MTAPIRES  NewsCategory(LPCWSTR category)=0;
+   //--- allowed news languages (Windows API LANGID used)
+   virtual MTAPIRES  NewsLangAdd(const UINT language)=0;
+   virtual MTAPIRES  NewsLangUpdate(const UINT pos,const UINT language)=0;
+   virtual MTAPIRES  NewsLangDelete(const UINT pos)=0;
+   virtual MTAPIRES  NewsLangClear(void)=0;
+   virtual UINT      NewsLangTotal(void) const=0;
+   virtual UINT      NewsLangNext(const UINT pos) const=0;
+   //--- EnMailMode
+   virtual UINT      MailMode(void) const=0;
+   virtual MTAPIRES  MailMode(const UINT mode)=0;
+   //--- EnTradeFlags
+   virtual UINT64    TradeFlags(void) const=0;
+   virtual MTAPIRES  TradeFlags(const UINT64 flags)=0;
+   //--- interest rate for free deposit money
+   virtual double    TradeInterestrate(void) const=0;
+   virtual MTAPIRES  TradeInterestrate(const double rate)=0;
+   //--- virtual credit
+   virtual double    TradeVirtualCredit(void) const=0;
+   virtual MTAPIRES  TradeVirtualCredit(const double credit)=0;
+   //--- EnFreeMarginMode
+   virtual UINT      MarginFreeMode(void) const=0;
+   virtual MTAPIRES  MarginFreeMode(const UINT freemode)=0;
+   //--- EnStopOutMode
+   virtual UINT      MarginSOMode(void) const=0;
+   virtual MTAPIRES  MarginSOMode(const UINT level)=0;
+   //--- Margin Call level value
+   virtual double    MarginCall(void) const=0;
+   virtual MTAPIRES  MarginCall(const double level)=0;
+   //--- Sto-Out level value
+   virtual double    MarginStopOut(void) const=0;
+   virtual MTAPIRES  MarginStopOut(const double level)=0;
+   //--- default demo accounts leverage
+   virtual UINT      DemoLeverage(void) const=0;
+   virtual MTAPIRES  DemoLeverage(const UINT leverage)=0;
+   //--- default demo accounts deposit
+   virtual double    DemoDeposit(void) const=0;
+   virtual MTAPIRES  DemoDeposit(const double deposit)=0;
+   //--- EnHistoryLimit
+   virtual UINT      LimitHistory(void) const=0;
+   virtual MTAPIRES  LimitHistory(const UINT limit)=0;
+   //--- max. order limit
+   virtual UINT      LimitOrders(void) const=0;
+   virtual MTAPIRES  LimitOrders(const UINT limit)=0;
+   //--- max. selected symbols limit
+   virtual UINT      LimitSymbols(void) const=0;
+   virtual MTAPIRES  LimitSymbols(const UINT limit)=0;
+   //--- commissions
+   virtual MTAPIRES  CommissionAdd(IMTConCommission* commission)=0;
+   virtual MTAPIRES  CommissionUpdate(const UINT pos,const IMTConCommission* commission)=0;
+   virtual MTAPIRES  CommissionDelete(const UINT pos)=0;
+   virtual MTAPIRES  CommissionClear(void)=0;
+   virtual MTAPIRES  CommissionShift(const UINT pos,const int shift)=0;
+   virtual UINT      CommissionTotal(void) const=0;
+   virtual MTAPIRES  CommissionNext(const UINT pos,IMTConCommission* commission) const=0;
+   virtual MTAPIRES  CommissionGet(LPCWSTR name,IMTConCommission* commission) const=0;
+   //--- groups symbols settings
+   virtual MTAPIRES  SymbolAdd(IMTConGroupSymbol* symbol)=0;
+   virtual MTAPIRES  SymbolUpdate(const UINT pos,const IMTConGroupSymbol* symbol)=0;
+   virtual MTAPIRES  SymbolDelete(const UINT pos)=0;
+   virtual MTAPIRES  SymbolClear(void)=0;
+   virtual MTAPIRES  SymbolShift(const UINT pos,const int shift)=0;
+   virtual UINT      SymbolTotal(void) const=0;
+   virtual MTAPIRES  SymbolNext(const UINT pos,IMTConGroupSymbol* symbol) const=0;
+   virtual MTAPIRES  SymbolGet(LPCWSTR name,IMTConGroupSymbol* symbol) const=0;
+   //--- margin free profit accounting mode
+   virtual UINT      MarginFreeProfitMode(void) const=0;
+   virtual MTAPIRES  MarginFreeProfitMode(const UINT mode)=0;
+   //--- group risk management mode - EnMarginMode
+   virtual UINT      MarginMode(void) const=0;
+   virtual MTAPIRES  MarginMode(const UINT mode)=0;
+   //--- OTP authentication mode - EnAuthOTPMode
+   virtual UINT      AuthOTPMode(void) const=0;
+   virtual MTAPIRES  AuthOTPMode(const UINT mode)=0;
+   //--- deposit transfer mode - EnTransferMode
+   virtual UINT      TradeTransferMode(void) const=0;
+   virtual MTAPIRES  TradeTransferMode(const UINT mode)=0;
+   //--- margin calculation flags EnMarginFlags
+   virtual UINT64    MarginFlags(void) const=0;
+   virtual MTAPIRES  MarginFlags(const UINT64 flags)=0;
+   //--- max. positions limit
+   virtual UINT      LimitPositions(void) const=0;
+   virtual MTAPIRES  LimitPositions(const UINT limit)=0;
+   //--- deposit currency digits
+   virtual MTAPIRES  CurrencyDigitsSet(const UINT currency_digits)=0;
+   //--- reports SMTP email account
+   virtual LPCWSTR   ReportsEmail(void) const=0;
+   virtual MTAPIRES  ReportsEmail(LPCWSTR email)=0;
+   //--- company deposit URL
+   virtual LPCWSTR   CompanyDepositPage(void) const=0;
+   virtual MTAPIRES  CompanyDepositPage(LPCWSTR url)=0;
+   //--- company deposit URL
+   virtual LPCWSTR   CompanyWithdrawalPage(void) const=0;
+   virtual MTAPIRES  CompanyWithdrawalPage(LPCWSTR url)=0;
+   //--- demo groups in days, orders and positions will be deleted after this period
+   virtual UINT      DemoInactivityPeriod(void) const=0;
+   virtual MTAPIRES  DemoInactivityPeriod(const UINT period)=0;
+  };
+//+------------------------------------------------------------------+
+//| Group config events notification interface                       |
+//+------------------------------------------------------------------+
+class IMTConGroupSink
+  {
+public:
+   virtual void      OnGroupAdd(const IMTConGroup*    /*config*/) {  }
+   virtual void      OnGroupUpdate(const IMTConGroup* /*config*/) {  }
+   virtual void      OnGroupDelete(const IMTConGroup* /*config*/) {  }
+   virtual void      OnGroupSync(void)                            {  }
+  };
+//+------------------------------------------------------------------+ 

+ 109 - 0
MT5SDK/Config/MT5APIConfigHistory.h

@@ -0,0 +1,109 @@
+//+------------------------------------------------------------------+
+//|                                         MetaTrader 5 API Server  |
+//|                   Copyright 2000-2019, MetaQuotes Software Corp. |
+//|                                        http://www.metaquotes.net |
+//+------------------------------------------------------------------+
+#pragma once
+//+------------------------------------------------------------------+
+//| History synchronization config                                   |
+//+------------------------------------------------------------------+
+class IMTConHistorySync
+  {
+public:
+   //--- mode enumeration
+   enum EnHistoryMode
+     {
+      HISTORY_DISABLED =0,
+      HISTORY_ENABLED  =1,
+      //--- enumeration borders
+      HISTORY_FIRST    =HISTORY_DISABLED,
+      HISTORY_LAST     =HISTORY_ENABLED,
+     };
+   //--- synchronization modex
+   enum EnHistorySyncMode
+     {
+      MODE_REPLACE     =0, // syncronization with full previous data replace
+      MODE_MERGE       =1, // syncronization with merge with previous data
+      //--- enumeration borders
+      MODE_FIRST       =MODE_REPLACE,
+      MODE_LAST        =MODE_MERGE,
+     };
+   //--- server types
+   enum EnHistorySyncServer
+     {
+      SERVER_MT4       =0, // MT4
+      SERVER_MT5       =1, // MT5
+      //--- enumeration borders
+      SERVER_FIRST     =SERVER_MT4,
+      SERVER_LAST      =SERVER_MT5,
+     };
+   //--- synchronization flags
+   enum EnHistorySyncFlags
+     {
+      FLAG_SESSIONS     =1, // check quote session due synchronization
+      FLAG_SYNONYMS     =2, // synchronize synonim symbols history
+      //--- enumeration borders
+      FLAG_NONE          =0,
+      FLAG_ALL          =FLAG_SESSIONS|FLAG_SYNONYMS,
+     };
+   //--- synchronization data
+   enum EnHistoryData
+     {
+      DATA_HISTORY_CHARTS=0, // charts only
+      DATA_HISTORY_TICKS =1, // ticks only
+      DATA_HISTORY_ALL   =2, // charts and ticks
+      //--- enumeration borders
+      DATA_HISTORY_FIRST =DATA_HISTORY_CHARTS,
+      DATA_HISTORY_LAST  =DATA_HISTORY_ALL
+     };
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTConHistorySync* param)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- server address
+   virtual LPCWSTR   Server(void) const=0;
+   virtual MTAPIRES  Server(LPCWSTR server)=0;
+   //--- server type
+   virtual UINT      ServerType(void) const=0;
+   virtual MTAPIRES  ServerType(const UINT type)=0;
+   //--- mode
+   virtual UINT      Mode(void) const=0;
+   virtual MTAPIRES  Mode(const UINT mode)=0;
+   //--- synchronization mode
+   virtual UINT      ModeSync(void) const=0;
+   virtual MTAPIRES  ModeSync(const UINT type)=0;
+   //--- time correction in minutes, 0 - autodetect
+   virtual int       TimeCorrection(void) const=0;
+   virtual MTAPIRES  TimeCorrection(const int correction)=0;
+   //--- synchronized history start
+   virtual INT64     From(void) const=0;
+   virtual MTAPIRES  From(const INT64 from)=0;
+   //--- synchronized history finish
+   virtual INT64     To(void) const=0;
+   virtual MTAPIRES  To(const INT64 to)=0;
+   //--- synchronized symbols list
+   virtual MTAPIRES  SymbolAdd(LPCWSTR path)=0;
+   virtual MTAPIRES  SymbolUpdate(const UINT pos,LPCWSTR path)=0;
+   virtual MTAPIRES  SymbolShift(const UINT pos,const int shift)=0;
+   virtual MTAPIRES  SymbolDelete(const UINT pos)=0;
+   virtual UINT      SymbolTotal(void) const=0;
+   virtual LPCWSTR   SymbolNext(const UINT pos) const=0;
+   //--- synchronization flags
+   virtual UINT64    Flags(void) const=0;
+   virtual MTAPIRES  Flags(const UINT64 flags)=0;
+   //--- synchronization data
+   virtual UINT      HistoryData(void) const=0;
+   virtual MTAPIRES  HistoryData(const UINT data)=0;
+  };
+//+------------------------------------------------------------------+
+//| History config events notification interface                     |
+//+------------------------------------------------------------------+
+class IMTConHistorySyncSink
+  {
+public:
+   virtual void      OnHistorySyncAdd(const IMTConHistorySync*    /*config*/) {  }
+   virtual void      OnHistorySyncUpdate(const IMTConHistorySync* /*config*/) {  }
+   virtual void      OnHistorySyncDelete(const IMTConHistorySync* /*config*/) {  }
+   virtual void      OnHistorySyncSync(void)                                  {  }
+  };
+//+------------------------------------------------------------------+

+ 72 - 0
MT5SDK/Config/MT5APIConfigHoliday.h

@@ -0,0 +1,72 @@
+//+------------------------------------------------------------------+
+//|                                                 MetaTrader 5 API |
+//|                   Copyright 2000-2019, MetaQuotes Software Corp. |
+//|                                        http://www.metaquotes.net |
+//+------------------------------------------------------------------+
+#pragma once
+//+------------------------------------------------------------------+
+//| Holidays config interface                                        |
+//+------------------------------------------------------------------+
+class IMTConHoliday
+  {
+public:
+   //--- holiday modes
+   enum EnHolidayMode
+     {
+      HOLIDAY_DISABLED=0,
+      HOLIDAY_ENABLED =1,
+      //--- enumeration borders
+      HOLIDAY_FIRST   =HOLIDAY_DISABLED,
+      HOLIDAY_LAST    =HOLIDAY_ENABLED,
+     };
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTConHoliday* holiday)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- holiday description
+   virtual LPCWSTR   Description(void) const=0;
+   virtual MTAPIRES  Description(LPCWSTR descr)=0;
+   //--- EnHolidayMode
+   virtual UINT      Mode(void) const=0;
+   virtual MTAPIRES  Mode(const UINT mode)=0;
+   //--- holiday year (for example: 2010, 0 - every year)
+   virtual UINT      Year(void) const=0;
+   virtual MTAPIRES  Year(const UINT year)=0;
+   //--- holiday month (1-January, 12-December)
+   virtual UINT      Month(void) const=0;
+   virtual MTAPIRES  Month(const UINT month)=0;
+   //--- holiday day (1-31)
+   virtual UINT      Day(void) const=0;
+   virtual MTAPIRES  Day(const UINT day)=0;
+   //--- holiday working time from (in minutes - 100 means 01:40)
+   virtual UINT      WorkFrom(void) const=0;
+   virtual MTAPIRES  WorkFrom(const UINT from)=0;
+   virtual UINT      WorkFromHours(void) const=0;
+   virtual UINT      WorkFromMinutes(void) const=0;
+   //--- holiday working time to (in minutes - 100 means 01:40)
+   virtual UINT      WorkTo(void) const=0;
+   virtual MTAPIRES  WorkTo(const UINT from)=0;
+   virtual UINT      WorkToHours(void) const=0;
+   virtual UINT      WorkToMinutes(void) const=0;
+   //--- holiday symbols list
+   virtual MTAPIRES  SymbolAdd(LPCWSTR path)=0;
+   virtual MTAPIRES  SymbolUpdate(const UINT pos,LPCWSTR path)=0;
+   virtual MTAPIRES  SymbolDelete(const UINT pos)=0;
+   virtual MTAPIRES  SymbolClear(void)=0;
+   virtual MTAPIRES  SymbolShift(const UINT pos,const int shift)=0;
+   virtual UINT      SymbolTotal(void) const=0;
+   virtual LPCWSTR   SymbolNext(const UINT pos) const=0;
+  };
+//+------------------------------------------------------------------+
+//| Holiday config events notification interface                     |
+//+------------------------------------------------------------------+
+class IMTConHolidaySink
+  {
+public:
+   virtual void      OnHolidayAdd(const IMTConHoliday*    /*config*/) {  }
+   virtual void      OnHolidayUpdate(const IMTConHoliday* /*config*/) {  }
+   virtual void      OnHolidayDelete(const IMTConHoliday* /*config*/) {  }
+   virtual void      OnHolidaySync(void)                              {  }
+  };
+//+------------------------------------------------------------------+
+

+ 167 - 0
MT5SDK/Config/MT5APIConfigManager.h

@@ -0,0 +1,167 @@
+//+------------------------------------------------------------------+
+//|                                         MetaTrader 5 API Server  |
+//|                   Copyright 2000-2019, MetaQuotes Software Corp. |
+//|                                        http://www.metaquotes.net |
+//+------------------------------------------------------------------+
+#pragma once
+//+------------------------------------------------------------------+
+//| Manager access config interface                                  |
+//+------------------------------------------------------------------+
+class IMTConManagerAccess
+  {
+public:
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTConManagerAccess* access)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- ip address range from
+   virtual LPCWSTR   From(void) const=0;
+   virtual MTAPIRES  From(LPCWSTR name)=0;
+   //--- ip address range to
+   virtual LPCWSTR   To(void) const=0;
+   virtual MTAPIRES  To(LPCWSTR value)=0;
+  };
+//+------------------------------------------------------------------+
+//| Manager config interface                                         |
+//+------------------------------------------------------------------+
+class IMTConManager
+  {
+public:
+   enum EnManagerRights
+     {
+      RIGHT_ADMIN              =0,       // permission to connect using MetaTrader 5 Administrator
+      RIGHT_MANAGER            =1,       // permission to connect using MetaTrader 5 Manager
+      //---
+      RIGHT_CFG_SERVERS        =10,      // permission to configure network
+      RIGHT_CFG_ACCESS         =11,      // permission to configure IP access list
+      RIGHT_CFG_TIME           =12,      // permission to configure operation time
+      RIGHT_CFG_HOLIDAYS       =13,      // permission to configure holidays
+      RIGHT_CFG_HST_SYNC       =14,      // permission to configure history charts synchronization
+      RIGHT_CFG_SYMBOLS        =15,      // permission to configure symbols
+      RIGHT_CFG_GROUPS         =16,      // permission to configure groups
+      RIGHT_CFG_MANAGERS       =17,      // permission to configure managers' permissions
+      RIGHT_CFG_DATAFEEDS      =18,      // permission to configure datafeeds
+      RIGHT_CFG_REQUESTS       =19,      // permission to configure request routing
+      RIGHT_SRV_JOURNALS       =20,      // permission to access server logs
+      RIGHT_SRV_REPORTS        =21,      // permission to receive automatic server reports
+      RIGHT_CHARTS             =22,      // permission to edit charts
+      RIGHT_EMAIL              =23,      // permission to send emails
+      RIGHT_ACCOUNTANT         =24,      // permission of accountant (charge/discharge)
+      RIGHT_ACC_READ           =25,      // permission to access accounts
+      RIGHT_ACC_DETAILS        =26,      // permission to access account personal details
+      RIGHT_ACC_MANAGER        =27,      // permission to edit accounts
+      RIGHT_ACC_ONLINE         =28,      // permission to view currently connected clients
+      RIGHT_TRADES_READ        =29,      // permission to access orders and positions
+      RIGHT_TRADES_MANAGER     =30,      // permission to edit trade records
+      RIGHT_QUOTES             =31,      // permission to throw in quotes
+      RIGHT_RISK_MANAGER       =32,      // permission of risk manager
+      RIGHT_REPORTS            =33,      // permission to receive reports
+      RIGHT_NEWS               =34,      // permission to send news
+      RIGHT_CFG_GATEWAYS       =35,      // permission to configure gateways
+      RIGHT_CFG_PLUGINS        =36,      // permission to configure plugins
+      RIGHT_TRADES_DEALER      =37,      // permission of dealer
+      RIGHT_CFG_REPORTS        =38,      // permission to configure reports
+      RIGHT_EXPORT             =39,      // permission to export data
+      RIGHT_SYMBOL_DETAILS     =40,      // permission to modify spread and execution mode
+      RIGHT_TECHSUPPORT        =41,      // permission to access technical support page
+      RIGHT_TRADES_SUPERVISOR  =42,      // permission of supervisor
+      RIGHT_QUOTES_RAW         =43,      // permission to see raw quotes without spread difference
+      RIGHT_MARKET             =44,      // permission to access applications market
+      RIGHT_GROUP_DETAILS      =45,      // permission to edit groups
+      RIGHT_NOTIFICATIONS      =46,      // permission to send notifications
+      RIGHT_ACC_DELETE         =47,      // permission to delete accounts
+      RIGHT_TRADES_DELETE      =48,      // permission to delete trades
+      RIGHT_CONFIRM_ACTIONS    =49,      // permission to confirm actions by confirmation dialog
+      RIGHT_CFG_ECN            =50,      // permission to configure ECN
+      RIGHT_FINTEZA_ACCESS     =64,      // permission to access Finteza
+      RIGHT_FINTEZA_WEBSITES   =65,      // permission to access Finteza websites
+      RIGHT_FINTEZA_CAMPAIGNS  =66,      // permission to access Finteza campaigns
+      RIGHT_FINTEZA_REPORTS    =67,      // permission to access Finteza reports
+      RIGHT_CLIENTS_ACCESS     =96,      // permission to access clients
+      RIGHT_CLIENTS_CREATE     =97,      // permission to create clients
+      RIGHT_CLIENTS_EDIT       =98,      // permission to edit clients
+      RIGHT_CLIENTS_DELETE     =99,      // permission to delete clients
+      RIGHT_DOCUMENTS_ACCESS   =100,     // permission to access documents
+      RIGHT_DOCUMENTS_CREATE   =101,     // permission to create documents
+      RIGHT_DOCUMENTS_EDIT     =102,     // permission to edits documents
+      RIGHT_DOCUMENTS_DELETE   =103,     // permission to delete documents
+      RIGHT_DOCUMENTS_FILES_ADD=104,     // permission to add files for documents
+      RIGHT_DOCUMENTS_FILES_DELETE=105,  // permission to delete files for documents
+      RIGHT_COMMENTS_ACCESS    =106,     // permission to access comments
+      RIGHT_COMMENTS_CREATE    =107,     // permission to create comments
+      RIGHT_COMMENTS_DELETE    =108,     // permission to delete comments
+      //--- enumeration borders
+      RIGHT_FIRST              =RIGHT_ADMIN,
+      RIGHT_LAST               =128,
+     };
+   //--- right flags
+   enum EnManagerRightFlags
+     {
+      RIGHT_FLAGS_DENIED       =0,  // right denied
+      RIGHT_FLAGS_GRANTED      =1,  // right granted
+      //--- enumeration borders
+      RIGHT_FLAGS_NONE         =0,
+      RIGHT_FLAGS_ALL          =RIGHT_FLAGS_GRANTED
+     };
+   //--- data access limitation
+   enum EnManagerLimit
+     {
+      MANAGER_LIMIT_ALL        =0,  // unlimited
+      MANAGER_LIMIT_MONTHS_1   =1,  // 1 month
+      MANAGER_LIMIT_MONTHS_3   =2,  // 3 months
+      MANAGER_LIMIT_MONTHS_6   =3,  // 6 months
+      MANAGER_LIMIT_YEAR_1     =4,  // 1 year
+      MANAGER_LIMIT_YEAR_2     =5,  // 2 years
+      MANAGER_LIMIT_YEAR_3     =6,  // 3 years
+      //--- enumeration borders
+      MANAGER_LIMIT_FIRST      =MANAGER_LIMIT_ALL,
+      MANAGER_LIMIT_LAST       =MANAGER_LIMIT_YEAR_3
+     };
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTConManager* manager)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- login
+   virtual UINT64    Login(void) const=0;
+   virtual MTAPIRES  Login(const UINT64 login)=0;
+   //--- internal email mailbox name
+   virtual LPCWSTR   Mailbox(void) const=0;
+   virtual MTAPIRES  Mailbox(LPCWSTR mailbox)=0;
+   //--- trade server id
+   virtual UINT64    Server(void) const=0;
+   //--- logs access limit EnManagerLimit
+   virtual UINT      LimitLogs(void) const=0;
+   virtual MTAPIRES  LimitLogs(const UINT limit)=0;
+   //--- reports access limit EnManagerLimit
+   virtual UINT      LimitReports(void) const=0;
+   virtual MTAPIRES  LimitReports(const UINT limit)=0;
+   //--- rights
+   virtual UINT      Right(const UINT right) const=0;
+   virtual MTAPIRES  Right(const UINT right,const UINT flags)=0;
+   //--- allowed groups list
+   virtual MTAPIRES  GroupAdd(LPCWSTR path)=0;
+   virtual MTAPIRES  GroupUpdate(const UINT pos,LPCWSTR path)=0;
+   virtual MTAPIRES  GroupShift(const UINT pos,const int shift)=0;
+   virtual MTAPIRES  GroupDelete(const UINT pos)=0;
+   virtual UINT      GroupTotal(void) const=0;
+   virtual LPCWSTR   GroupNext(const UINT pos) const=0;
+   //--- allowed addressed list
+   virtual MTAPIRES  AccessAdd(IMTConManagerAccess* access)=0;
+   virtual MTAPIRES  AccessUpdate(const UINT pos,const IMTConManagerAccess* access)=0;
+   virtual MTAPIRES  AccessDelete(const UINT pos)=0;
+   virtual MTAPIRES  AccessShift(const UINT pos,const int shift)=0;
+   virtual UINT      AccessTotal(void) const=0;
+   virtual MTAPIRES  AccessNext(const UINT pos,IMTConManagerAccess* access) const=0;
+  };
+//+------------------------------------------------------------------+
+//| Managers config events notification interface                    |
+//+------------------------------------------------------------------+
+class IMTConManagerSink
+  {
+public:
+   virtual void      OnManagerAdd(const IMTConManager*    /*config*/) {  }
+   virtual void      OnManagerUpdate(const IMTConManager* /*config*/) {  }
+   virtual void      OnManagerDelete(const IMTConManager* /*config*/) {  }
+   virtual void      OnManagerSync(void)                              {  }
+  };
+//+------------------------------------------------------------------+

+ 96 - 0
MT5SDK/Config/MT5APIConfigMessenger.h

@@ -0,0 +1,96 @@
+//+------------------------------------------------------------------+
+//|                                                 MetaTrader 5 API |
+//|                   Copyright 2000-2019, MetaQuotes Software Corp. |
+//|                                        http://www.metaquotes.net |
+//+------------------------------------------------------------------+
+#pragma once
+//+------------------------------------------------------------------+
+//| Messenger config                                                 |
+//+------------------------------------------------------------------+
+class IMTConMessenger
+  {
+public:
+   //--- allowed flags
+   enum EnFlags
+     {
+      FLAG_NONE               =0, // none
+      FLAG_ENABLED            =1, // messenger is enabled
+      FLAG_DEFAULT            =2, // messenger is default
+      //--- flags borders
+      FLAG_FIRST              =FLAG_ENABLED,
+      FLAG_ALL                =FLAG_ENABLED|FLAG_DEFAULT
+     };
+   //--- providers
+   enum EnProviderType
+     {
+      //---- SMS
+      PROVIDER_SMS_BULKSMS    =0,
+      PROVIDER_SMS_CLICKATELL =1,
+      PROVIDER_SMS_WEBSMS     =2,
+      //--- SMS ranges
+      PROVIDER_SMS_FIRST      =PROVIDER_SMS_BULKSMS,
+      PROVIDER_SMS_LAST       =99,
+      //---- Instant Messengers
+      PROVIDER_IM_TELEGRAM    =100,
+      PROVIDER_IM_WHATSAPP    =101,
+      PROVIDER_IM_VIBER       =102,
+      //--- Instant Messengers ranges
+      PROVIDER_IM_FIRST       =PROVIDER_IM_TELEGRAM,
+      PROVIDER_IM_LAST        =199,
+      //---- Push Services
+      PROVIDER_PUSH_METAQUOTES=200,
+      PROVIDER_PUSH_UNIVERSAL =201,
+      //--- Push Services ranges
+      PROVIDER_PUSH_FIRST     =PROVIDER_PUSH_METAQUOTES,
+      PROVIDER_PUSH_LAST      =299,
+     };
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTConMessenger* messenger)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- name
+   virtual LPCWSTR   Name(void) const=0;
+   virtual MTAPIRES  Name(LPCWSTR name)=0;
+   //--- sender
+   virtual LPCWSTR   Sender(void) const=0;
+   virtual MTAPIRES  Sender(LPCWSTR sender)=0;
+   //--- provider type
+   virtual UINT      ProviderType(void) const=0;
+   virtual MTAPIRES  ProviderType(const UINT provider)=0;
+   //--- provider address
+   virtual LPCWSTR   ProviderAddress(void) const=0;
+   virtual MTAPIRES  ProviderAddress(LPCWSTR address)=0;
+   //--- provider login
+   virtual LPCWSTR   ProviderLogin(void) const=0;
+   virtual MTAPIRES  ProviderLogin(LPCWSTR login)=0;
+   //--- provider password
+   virtual LPCWSTR   ProviderPassword(void) const=0;
+   virtual MTAPIRES  ProviderPassword(LPCWSTR password)=0;
+   //--- provider token
+   virtual LPCWSTR   ProviderToken(void) const=0;
+   virtual MTAPIRES  ProviderToken(LPCWSTR token)=0;
+   //--- provider SubID
+   virtual LPCWSTR   ProviderSubId(void) const=0;
+   virtual MTAPIRES  ProviderSubId(LPCWSTR subid)=0;
+   //--- provider currency
+   virtual LPCWSTR   ProviderCurrency(void) const=0;
+   virtual MTAPIRES  ProviderCurrency(LPCWSTR currency)=0;
+   //--- provider currency rate
+   virtual double    ProviderCurrencyRate(void) const=0;
+   virtual MTAPIRES  ProviderCurrencyRate(const double rate)=0;
+   //--- EnFlags
+   virtual UINT64    Flags(void) const=0;
+   virtual MTAPIRES  Flags(const UINT64 flags)=0;
+  };
+//+------------------------------------------------------------------+
+//| Messenger config events notification interface                   |
+//+------------------------------------------------------------------+
+class IMTConMessengerSink
+  {
+public:
+   virtual void      OnMessengerAdd(const IMTConMessenger*    /*config*/) {  }
+   virtual void      OnMessengerUpdate(const IMTConMessenger* /*config*/) {  }
+   virtual void      OnMessengerDelete(const IMTConMessenger* /*config*/) {  }
+   virtual void      OnMessengerSync(void)                            {  }
+  };
+//+------------------------------------------------------------------+

+ 606 - 0
MT5SDK/Config/MT5APIConfigNetwork.h

@@ -0,0 +1,606 @@
+//+------------------------------------------------------------------+
+//|                                                 MetaTrader 5 API |
+//|                   Copyright 2000-2019, MetaQuotes Software Corp. |
+//|                                        http://www.metaquotes.net |
+//+------------------------------------------------------------------+
+#pragma once
+//+------------------------------------------------------------------+
+//| Logins, orders and deals range                                   |
+//+------------------------------------------------------------------+
+class IMTConServerRange
+  {
+public:
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTConServerRange* param)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- from
+   virtual UINT64    From(void) const=0;
+   virtual MTAPIRES  From(const UINT64 from)=0;
+   //--- to
+   virtual UINT64    To(void) const=0;
+   virtual MTAPIRES  To(const UINT64 to)=0;
+   //--- used range
+   virtual UINT64    UsedFrom(void) const=0;
+   virtual UINT64    UsedTo(void) const=0;
+  };
+//+------------------------------------------------------------------+
+//| Network addresses range                                          |
+//+------------------------------------------------------------------+
+class IMTConAddressRange
+  {
+public:
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTConAddressRange* range)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- ip address range from
+   virtual LPCWSTR   From(void) const=0;
+   virtual MTAPIRES  From(LPCWSTR name)=0;
+   //--- ip address range to
+   virtual LPCWSTR   To(void) const=0;
+   virtual MTAPIRES  To(LPCWSTR value)=0;
+  };
+//+------------------------------------------------------------------+
+//| Server cluster server connection state                           |
+//+------------------------------------------------------------------+
+class IMTConClusterState
+  {
+public:
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTConClusterState* state)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- server id
+   virtual UINT64    Id(void) const=0;
+   //--- connection state
+   virtual bool      Connected(void) const=0;
+   virtual LPCWSTR   ConnectedAddress(void) const=0;
+   virtual INT64     ConnectedTime(void) const=0;
+   //--- connection stats
+   virtual INT64     StatsDay(void) const=0;
+   virtual UINT      StatsPing(void) const=0;
+   virtual UINT      StatsPingMin(void) const=0;
+   virtual UINT      StatsPingMax(void) const=0;
+   virtual UINT      StatsSpeed(void) const=0;
+   virtual UINT      StatsSpeedMin(void) const=0;
+   virtual UINT      StatsSpeedMax(void) const=0;
+  };
+//+------------------------------------------------------------------+
+//| Trade and main platform server configuration                     |
+//+------------------------------------------------------------------+
+class IMTConServerTrade
+  {
+public:
+   //--- demo account allocation mode
+   enum EnDemoMode
+     {
+      DEMO_DISABLED         =0, // demo account allocation disabled 
+      DEMO_PROLONG          =1, // prolong demo acounts after reconnect
+      DEMO_FIXED            =2, // demo account with fixed period
+      //--- enumeration borders
+      DEMO_FIRST            =DEMO_DISABLED,
+      DEMO_LAST             =DEMO_FIXED
+     };
+   //--- enumeration borders
+   enum EnOvernightMode
+     {
+      OVERNIGHT_END_DAY     =0, // overnight performed at the end of the trading day
+      OVERNIGHT_START_DAY   =1, // overnight performed at the begin of the trading day
+      //--- enumeration borders
+      OVERNIGHT_FIRST       =OVERNIGHT_END_DAY,
+      OVERNIGHT_LAST        =OVERNIGHT_START_DAY
+     };
+   //--- overmonth mode 
+   enum EnOvermonthMode
+     {
+      OVERMONTH_LAST_DAY    =0, // overmonth performed at the last month day
+      OVERMONTH_FIRST_DAY   =1, // overmonth performed at the first month day
+      //--- enumeration borders
+      OVERMONTH_FIRST       =OVERMONTH_LAST_DAY,
+      OVERMONTH_LAST        =OVERMONTH_FIRST_DAY
+     };
+   //--- overnigh days enumeration
+   enum EnOvernightDays
+     {
+      OVERNIGHT_DAYS_SUN         =0x00000001,
+      OVERNIGHT_DAYS_MON         =0x00000002,
+      OVERNIGHT_DAYS_TUE         =0x00000004,
+      OVERNIGHT_DAYS_WED         =0x00000008,
+      OVERNIGHT_DAYS_THU         =0x00000010,
+      OVERNIGHT_DAYS_FRI         =0x00000020,
+      OVERNIGHT_DAYS_SAT         =0x00000040,
+      //--- rollovers schedule
+      OVERNIGHT_DAYS_ROLLOVER_SUN=0x00000080,
+      OVERNIGHT_DAYS_ROLLOVER_MON=0x00000100,
+      OVERNIGHT_DAYS_ROLLOVER_TUE=0x00000200,
+      OVERNIGHT_DAYS_ROLLOVER_WED=0x00000400,
+      OVERNIGHT_DAYS_ROLLOVER_THU=0x00000800,
+      OVERNIGHT_DAYS_ROLLOVER_FRI=0x00001000,
+      OVERNIGHT_DAYS_ROLLOVER_SAT=0x00002000,
+      //--- enumeration borders
+      OVERNIGHT_DAYS_NONE        =0x00000000,
+      OVERNIGHT_DAYS_DEFAULT =OVERNIGHT_DAYS_MON | OVERNIGHT_DAYS_TUE | OVERNIGHT_DAYS_WED | OVERNIGHT_DAYS_THU | OVERNIGHT_DAYS_FRI |
+      OVERNIGHT_DAYS_ROLLOVER_MON | OVERNIGHT_DAYS_ROLLOVER_TUE | OVERNIGHT_DAYS_ROLLOVER_WED | OVERNIGHT_DAYS_ROLLOVER_THU | OVERNIGHT_DAYS_ROLLOVER_FRI,
+      OVERNIGHT_DAYS_ALL     =OVERNIGHT_DAYS_SUN | OVERNIGHT_DAYS_MON | OVERNIGHT_DAYS_TUE | OVERNIGHT_DAYS_WED | OVERNIGHT_DAYS_THU | OVERNIGHT_DAYS_FRI | OVERNIGHT_DAYS_SAT |
+      OVERNIGHT_DAYS_ROLLOVER_SUN | OVERNIGHT_DAYS_ROLLOVER_MON | OVERNIGHT_DAYS_ROLLOVER_TUE | OVERNIGHT_DAYS_ROLLOVER_WED | OVERNIGHT_DAYS_ROLLOVER_THU |
+      OVERNIGHT_DAYS_ROLLOVER_FRI | OVERNIGHT_DAYS_ROLLOVER_SAT
+     };
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTConServerTrade* param)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- demo accounts mode EnDemoMode
+   virtual UINT      DemoMode(void) const=0;
+   virtual MTAPIRES  DemoMode(const UINT mode)=0;
+   //--- demo accounts period
+   virtual UINT      DemoPeriod(void) const=0;
+   virtual MTAPIRES  DemoPeriod(const UINT period)=0;
+   //--- overnight mode
+   virtual UINT      OvernightMode(void) const=0;
+   virtual MTAPIRES  OvernightMode(const UINT mode)=0;
+   //--- overnight time (in minutes)
+   virtual UINT      OvernightTime(void) const=0;
+   virtual MTAPIRES  OvernightTime(const UINT time)=0;
+   virtual INT64     OvernightTimeLast(void) const=0;
+   virtual INT64     OvernightTimePrev(void) const=0;
+   //--- overnight mode
+   virtual UINT      OvermonthMode(void) const=0;
+   virtual MTAPIRES  OvermonthMode(const UINT mode)=0;
+   //--- overmonth time (in minutes)
+   virtual INT64     OvermonthTimeLast(void) const=0;
+   virtual INT64     OvermonthTimePrev(void) const=0;
+   //--- client logins ranges for this trade server
+   virtual MTAPIRES  LoginsRangeAdd(IMTConServerRange* range)=0;
+   virtual MTAPIRES  LoginsRangeUpdate(const UINT pos,const IMTConServerRange* range)=0;
+   virtual MTAPIRES  LoginsRangeDelete(const UINT pos)=0;
+   virtual MTAPIRES  LoginsRangeClear(void)=0;
+   virtual MTAPIRES  LoginsRangeShift(const UINT pos,const int shift)=0;
+   virtual UINT      LoginsRangeTotal(void) const=0;
+   virtual MTAPIRES  LoginsRangeNext(const UINT pos,IMTConServerRange* range) const=0;
+   //--- orders tickets ranges for this trade server
+   virtual MTAPIRES  OrdersRangeAdd(IMTConServerRange* range)=0;
+   virtual MTAPIRES  OrdersRangeUpdate(const UINT pos,const IMTConServerRange* range)=0;
+   virtual MTAPIRES  OrdersRangeDelete(const UINT pos)=0;
+   virtual MTAPIRES  OrdersRangeClear(void)=0;
+   virtual MTAPIRES  OrdersRangeShift(const UINT pos,const int shift)=0;
+   virtual UINT      OrdersRangeTotal(void) const=0;
+   virtual MTAPIRES  OrdersRangeNext(const UINT pos,IMTConServerRange* range) const=0;
+   //--- deals tickets ranges for this trade server
+   virtual MTAPIRES  DealsRangeAdd(IMTConServerRange* range)=0;
+   virtual MTAPIRES  DealsRangeUpdate(const UINT pos,const IMTConServerRange* range)=0;
+   virtual MTAPIRES  DealsRangeDelete(const UINT pos)=0;
+   virtual MTAPIRES  DealsRangeClear(void)=0;
+   virtual MTAPIRES  DealsRangeShift(const UINT pos,const int shift)=0;
+   virtual UINT      DealsRangeTotal(void) const=0;
+   virtual MTAPIRES  DealsRangeNext(const UINT pos,IMTConServerRange* range) const=0;
+   //--- trade totals
+   virtual UINT      TotalUsers(void) const=0;
+   virtual UINT      TotalUsersReal(void) const=0;
+   virtual UINT      TotalDeals(void) const=0;
+   virtual UINT      TotalOrders(void) const=0;
+   virtual UINT      TotalOrdersHistory(void) const=0;
+   virtual UINT      TotalPositions(void) const=0;
+   //--- overnight days EnOvernightDays
+   virtual UINT      OvernightDays(void) const=0;
+   virtual MTAPIRES  OvernightDays(const UINT days)=0;
+  };
+//+------------------------------------------------------------------+
+//| History server configuration                                     |
+//+------------------------------------------------------------------+
+class IMTConServerHistory
+  {
+public:
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTConServerHistory* param)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- datafeeds switch timeout
+   virtual UINT      DatafeedsTimeout(void) const=0;
+   virtual MTAPIRES  DatafeedsTimeout(const UINT timeout)=0;
+   //--- max news buffer
+   virtual UINT      NewsMax(void) const=0;
+   virtual MTAPIRES  NewsMax(const UINT news_max)=0;
+  };
+//+------------------------------------------------------------------+
+//| Backup server configuration                                      |
+//+------------------------------------------------------------------+
+class IMTConServerBackup
+  {
+public:
+   //--- backup flags
+   enum EnBackupFlags
+     {
+      FLAG_ENABLE_BACKUPS =0x00000001,
+      FLAG_ENABLE_TICKS   =0x00000002,
+      FLAG_ENABLE_FAILOVER=0x00000004,
+      FLAG_ENABLE_LOGS    =0x00000008
+     };
+   //--- backup period
+   enum EnBackupPeriod
+     {
+      BACKUP_DISABLED   =0,
+      BACKUP_15MINUTES  =1,
+      BACKUP_30MINUTES  =2,
+      BACKUP_1HOUR      =3,
+      BACKUP_4HOURS     =4,
+      BACKUP_1DAY       =5,
+      //--- enumeration borders
+      BACKUP_FIRST      =BACKUP_DISABLED,
+      BACKUP_LAST       =BACKUP_1DAY
+     };
+   //--- backup copy time to live
+   enum EnBackupTTL
+     {
+      BACKUP_TTL_1DAY   =1,
+      BACKUP_TTL_3DAYS  =2,
+      BACKUP_TTL_1WEEK  =3,
+      BACKUP_TTL_1MONTH =4,
+      BACKUP_TTL_3MONTHS=5,
+      BACKUP_TTL_6MONTHS=6,
+      //--- enumeration borders
+      BACKUP_TTL_FIRST  =BACKUP_TTL_1DAY,
+      BACKUP_TTL_LAST   =BACKUP_TTL_6MONTHS
+     };
+   //--- SQL export modes
+   enum EnSQLExportMode
+     {
+      SQL_MODE_NONE      =0,
+      SQL_MODE_MSSQL     =1,
+      SQL_MODE_FIREBIRD  =2,
+      SQL_MODE_MYSQL     =3,
+      SQL_MODE_ORACLE    =4,
+      SQL_MODE_POSTGRESQL=5,
+      //--- enumeration borders
+      SQL_MODE_FIRST    =SQL_MODE_NONE,
+      SQL_MODE_LAST     =SQL_MODE_POSTGRESQL,
+     };
+   //--- SQL export flags
+   enum EnSQLExportFlags
+     {
+      SQL_FLAG_NONE      =0x00000000,
+      SQL_FLAG_PARTITIONS=0x00000001, // split by years
+      SQL_FLAG_SKIP_DEMO =0x00000002, // skip demo accounts
+      //--- enumeration borders
+      SQL_FLAG_ALL       =SQL_FLAG_PARTITIONS|SQL_FLAG_SKIP_DEMO
+     };
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTConServerBackup* param)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- master server
+   virtual UINT64    MasterServer(void) const=0;
+   virtual MTAPIRES  MasterServer(const UINT64 id)=0;
+   //--- backup path
+   virtual LPCWSTR   BackupPath(void) const=0;
+   virtual MTAPIRES  BackupPath(LPCWSTR path)=0;
+   //--- full backup time (minutes)
+   virtual UINT      BackupFullTime(void) const=0;
+   virtual MTAPIRES  BackupFullTime(const UINT time)=0;
+   //--- backup period - EnBackupPeriod
+   virtual UINT      BackupPeriod(void) const=0;
+   virtual MTAPIRES  BackupPeriod(const UINT period)=0;
+   //--- backup copy TTL - EnBackupTTL
+   virtual UINT      BackupTTL(void) const=0;
+   virtual MTAPIRES  BackupTTL(const UINT period)=0;
+   //--- backup flags - EnBackupFlags
+   virtual UINT64    BackupFlags(void) const=0;
+   virtual MTAPIRES  BackupFlags(const UINT64 flags)=0;
+   //--- sql export mode
+   virtual UINT      SQLExportMode(void) const=0;
+   virtual MTAPIRES  SQLExportMode(const UINT mode)=0;
+   //--- sql export flags
+   virtual UINT64    SQLExportFlags(void) const=0;
+   virtual MTAPIRES  SQLExportFlags(const UINT64 flags)=0;
+   //--- sql export open trades refresh period in minutes
+   virtual UINT      SQLExportPeriod(void) const=0;
+   virtual MTAPIRES  SQLExportPeriod(const UINT period)=0;
+   //--- sql export server
+   virtual LPCWSTR   SQLExportServer(void) const=0;
+   virtual MTAPIRES  SQLExportServer(LPCWSTR server)=0;
+   //--- sql export login
+   virtual LPCWSTR   SQLExportLogin(void) const=0;
+   virtual MTAPIRES  SQLExportLogin(LPCWSTR login)=0;
+   //--- sql export password
+   virtual LPCWSTR   SQLExportPassword(void) const=0;
+   virtual MTAPIRES  SQLExportPassword(LPCWSTR password)=0;
+   //--- sql export folder
+   virtual LPCWSTR   SQLExportFolder(void) const=0;
+   virtual MTAPIRES  SQLExportFolder(LPCWSTR folder)=0;
+   //--- last synchronization with master server
+   virtual INT64     BackupLastSync(void) const=0;
+  };
+//+------------------------------------------------------------------+
+//| Access server configuration                                      |
+//+------------------------------------------------------------------+
+class IMTConServerAccess
+  {
+public:
+   //--- access mask
+   enum EnAccessMask
+     {
+      ACCESS_ALLOW_CLIENT     =1,
+      ACCESS_ALLOW_MANAGER    =2,
+      ACCESS_ALLOW_ADMIN      =4,
+      ACCESS_ALLOW_RESERVED   =8,
+      ACCESS_ALLOW_MANAGER_API=16,
+      ACCESS_ALLOW_WEB_API    =32,
+      //--- enumeration borders
+      ACCESS_ALLOW_NONE       =0,
+      ACCESS_ALLOW_ALL        =ACCESS_ALLOW_CLIENT|ACCESS_ALLOW_MANAGER|ACCESS_ALLOW_ADMIN|ACCESS_ALLOW_RESERVED|ACCESS_ALLOW_MANAGER_API|ACCESS_ALLOW_WEB_API
+     };
+   //--- access flags
+   enum EnAccessFlags
+     {
+      ACCESS_FLAGS_INVISIBLE  =1,
+      //--- enumeration borders
+      ACCESS_FLAGS_NONE       =0,
+      ACCESS_FLAGS_ALL        =ACCESS_FLAGS_INVISIBLE
+     };
+   //--- EnServerPriority
+   enum EnServerPriority
+     {
+      PRIORITY_HIGHEST        =0,
+      PRIORITY_LOWEST         =15,
+      PRIORITY_IDLE           =255,
+      //---
+      PRIORITY_FIRST          =PRIORITY_HIGHEST,
+      PRIORITY_LAST           =PRIORITY_IDLE
+     };
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTConServerAccess* param)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- priority
+   virtual UINT      Priority(void) const=0;
+   virtual MTAPIRES  Priority(const UINT priority)=0;
+   virtual UINT      PriorityCurrent(void) const=0;
+   //--- access flags EnAccessMask
+   virtual UINT      AccessMask(void) const=0;
+   virtual MTAPIRES  AccessMask(const UINT mask)=0;
+   //--- max news buffer
+   virtual UINT      NewsMax(void) const=0;
+   virtual MTAPIRES  NewsMax(const UINT news_max)=0;
+   //--- antiflood
+   virtual UINT      AntifloodEnabled(void) const=0;
+   virtual MTAPIRES  AntifloodEnabled(const UINT enabled)=0;
+   //--- antiflood connects criterion
+   virtual UINT      AntifloodConnects(void) const=0;
+   virtual MTAPIRES  AntifloodConnects(const UINT connects)=0;
+   //--- antiflood connects criterion
+   virtual UINT      AntifloodErrors(void) const=0;
+   virtual MTAPIRES  AntifloodErrors(const UINT errors)=0;
+   //--- list of public addresses (address:port) available for terminals
+   virtual MTAPIRES  PointsAdd(LPCWSTR path)=0;
+   virtual MTAPIRES  PointsUpdate(const UINT pos,LPCWSTR address)=0;
+   virtual MTAPIRES  PointsDelete(const UINT pos)=0;
+   virtual MTAPIRES  PointsClear(void)=0;
+   virtual MTAPIRES  PointsShift(const UINT pos,const int shift)=0;
+   virtual UINT      PointsTotal(void) const=0;
+   virtual LPCWSTR   PointsNext(const UINT pos) const=0;
+   //--- list of internal addresses (address:port) for server listening
+   virtual MTAPIRES  BindingsAdd(LPCWSTR path)=0;
+   virtual MTAPIRES  BindingsUpdate(const UINT pos,LPCWSTR address)=0;
+   virtual MTAPIRES  BindingsDelete(const UINT pos)=0;
+   virtual MTAPIRES  BindingsClear(void)=0;
+   virtual MTAPIRES  BindingsShift(const UINT pos,const int shift)=0;
+   virtual UINT      BindingsTotal(void) const=0;
+   virtual LPCWSTR   BindingsNext(const UINT pos) const=0;
+   //--- list of trade attended trade servers
+   virtual MTAPIRES  ServersAdd(const UINT64 server_id)=0;
+   virtual MTAPIRES  ServersUpdate(const UINT pos,UINT64 server_id)=0;
+   virtual MTAPIRES  ServersDelete(const UINT pos)=0;
+   virtual MTAPIRES  ServersClear(void)=0;
+   virtual MTAPIRES  ServersShift(const UINT pos,const int shift)=0;
+   virtual UINT      ServersTotal(void) const=0;
+   virtual UINT64    ServersNext(const UINT pos) const=0;
+   //--- access flags EnAccessFlags
+   virtual UINT      AccessFlags(void) const=0;
+   virtual MTAPIRES  AccessFlags(const UINT flags)=0;
+  };
+//+------------------------------------------------------------------+
+//| Ant DDoS server configuration                                     |
+//+------------------------------------------------------------------+
+class IMTConServerAntiDDoS
+  {
+public:
+   //--- access mask
+   enum EnAccessMask
+     {
+      ACCESS_ALLOW_CLIENT     =1,
+      ACCESS_ALLOW_MANAGER    =2,
+      ACCESS_ALLOW_ADMIN      =4,
+      ACCESS_ALLOW_CLIENT_API =8,
+      ACCESS_ALLOW_MANAGER_API=16,
+      ACCESS_ALLOW_WEB_API    =32,
+      //--- enumeration borders
+      ACCESS_ALLOW_NONE       =0,
+      ACCESS_ALLOW_ALL        =ACCESS_ALLOW_CLIENT|ACCESS_ALLOW_MANAGER|ACCESS_ALLOW_ADMIN|ACCESS_ALLOW_CLIENT_API|ACCESS_ALLOW_MANAGER_API|ACCESS_ALLOW_WEB_API
+     };
+   //--- EnServerPriority
+   enum EnServerPriority
+     {
+      PRIORITY_HIGHEST        =0,
+      PRIORITY_LOWEST         =15,
+      PRIORITY_IDLE           =255,
+      //---
+      PRIORITY_FIRST          =PRIORITY_HIGHEST,
+      PRIORITY_LAST           =PRIORITY_IDLE
+     };
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTConServerAntiDDoS* param)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- priority
+   virtual UINT      Priority(void) const=0;
+   virtual MTAPIRES  Priority(const UINT priority)=0;
+   //--- access flags EnAccessMask
+   virtual UINT      AccessMask(void) const=0;
+   virtual MTAPIRES  AccessMask(const UINT mask)=0;
+   //--- list of public addresses (address:port) available for terminals
+   virtual MTAPIRES  PointsAdd(LPCWSTR path)=0;
+   virtual MTAPIRES  PointsUpdate(const UINT pos,LPCWSTR address)=0;
+   virtual MTAPIRES  PointsDelete(const UINT pos)=0;
+   virtual MTAPIRES  PointsClear(void)=0;
+   virtual MTAPIRES  PointsShift(const UINT pos,const int shift)=0;
+   virtual UINT      PointsTotal(void) const=0;
+   virtual LPCWSTR   PointsNext(const UINT pos) const=0;
+   //--- list of trade attended trade servers
+   virtual MTAPIRES  ServersAdd(const UINT64 server_id)=0;
+   virtual MTAPIRES  ServersUpdate(const UINT pos,UINT64 server_id)=0;
+   virtual MTAPIRES  ServersDelete(const UINT pos)=0;
+   virtual MTAPIRES  ServersClear(void)=0;
+   virtual MTAPIRES  ServersShift(const UINT pos,const int shift)=0;
+   virtual UINT      ServersTotal(void) const=0;
+   virtual UINT64    ServersNext(const UINT pos) const=0;
+   //--- list of source addresses
+   virtual MTAPIRES  SourcesAdd(IMTConAddressRange* range)=0;
+   virtual MTAPIRES  SourcesUpdate(const UINT pos,const IMTConAddressRange* range)=0;
+   virtual MTAPIRES  SourcesDelete(const UINT pos)=0;
+   virtual MTAPIRES  SourcesShift(const UINT pos,const int shift)=0;
+   virtual UINT      SourcesTotal(void) const=0;
+   virtual MTAPIRES  SourcesNext(const UINT pos,IMTConAddressRange* access) const=0;
+  };
+//+------------------------------------------------------------------+
+//| Common platform server configuration                             |
+//+------------------------------------------------------------------+
+class IMTConServer
+  {
+public:
+   //--- server types
+   enum EnServerTypes
+     {
+      NET_MAIN_TRADE_SERVER   =0,
+      NET_TRADE_SERVER        =1,
+      NET_HISTORY_SERVER      =2,
+      NET_ACCESS_SERVER       =3,
+      NET_BACKUP_SERVER       =4,
+      NET_OBSOLETE_SERVER_1   =5,
+      NET_OBSOLETE_SERVER_2   =6,
+      NET_ANTIDDOS_SERVER     =7,
+      //--- enumeration borders
+      NET_SERVER_FIRST        =NET_MAIN_TRADE_SERVER,
+      NET_SERVER_LAST         =NET_ANTIDDOS_SERVER
+     };
+   //--- failover mode
+   enum EnFailoverModes
+     {
+      FAILOVER_MODE_DISABLED  =0,  // disabled
+      FAILOVER_MODE_BY_MOST   =1,  // server is unaccessible for most witness servers
+      FAILOVER_MODE_BY_ALL    =2,  // server is unaccessible for all witness servers
+      //--- enumeration borders
+      FAILOVER_MODE_FIRST     =FAILOVER_MODE_DISABLED,
+      FAILOVER_MODE_LAST      =FAILOVER_MODE_BY_ALL
+     };
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTConServer* param)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- server type
+   virtual UINT      Type(void) const=0;
+   virtual MTAPIRES  Type(const UINT type)=0;
+   //--- server name
+   virtual LPCWSTR   Name(void) const=0;
+   virtual MTAPIRES  Name(LPCWSTR name)=0;
+   //--- address 
+   virtual LPCWSTR   Address(void) const=0;
+   virtual MTAPIRES  Address(LPCWSTR name)=0;
+   //--- server id
+   virtual UINT64    Id(void) const=0;
+   virtual MTAPIRES  Id(const UINT64 id)=0;
+   //--- password
+   virtual MTAPIRES  Password(LPCWSTR password)=0;
+   virtual MTAPIRES  PasswordCheck(LPCWSTR password) const=0;
+   //--- service time in minutes
+   virtual UINT      ServiceTime(void) const=0;
+   virtual MTAPIRES  ServiceTime(const UINT stime)=0;
+   //--- list of network adapters
+   virtual LPCWSTR   AdaptersCurrent(void) const=0;
+   virtual MTAPIRES  AdaptersCurrent(LPCWSTR current)=0;
+   virtual UINT      AdaptersTotal(void) const=0;
+   virtual LPCWSTR   AdaptersNext(const UINT pos) const=0;
+   //--- list of available ips
+   virtual UINT      AddressTotal(void) const=0;
+   virtual UINT      AddressNext(const UINT pos) const=0;
+   //--- server info
+   virtual UINT      Version(void) const=0;
+   virtual UINT      Build(void) const=0;
+   virtual LPCWSTR   BuildDate(void) const=0;
+   virtual INT64     LastBootTime(void) const=0;
+   virtual bool      Connected(void) const=0;
+   virtual LPCWSTR   OS(void) const=0;
+   //--- cpu info
+   virtual LPCWSTR   CPU(void) const=0;
+   virtual UINT      CPUTotal(void) const=0;
+   virtual UINT      CPUUsageMax(void) const=0;
+   virtual UINT      CPUUsageCritical(void) const=0;
+   //--- memory info (in MB)
+   virtual UINT      MemoryTotal(void) const=0;
+   virtual UINT      MemoryFree(void) const=0;
+   virtual UINT      MemoryFreeMin(void) const=0;
+   virtual UINT      MemoryFreeCritical(void) const=0;
+   //--- hdd info (in MB)
+   virtual UINT      HDDTotal(void) const=0;
+   virtual UINT      HDDFree(void) const=0;
+   virtual UINT      HDDFreeCritical(void) const=0;
+   virtual UINT      HDDFragments(void) const=0;
+   virtual UINT      HDDFragmentsCritical(void) const=0;
+   virtual UINT      HDDSpeedRead(void) const=0;
+   virtual UINT      HDDSpeedReadCritical(void) const=0;
+   virtual UINT      HDDSpeedWrite(void) const=0;
+   virtual UINT      HDDSpeedWriteCritical(void) const=0;
+   //--- connections info
+   virtual UINT      ConnectsMax(void) const=0;
+   virtual UINT      ConnectsCritical(void) const=0;
+   //--- network info (Kbyte/s)
+   virtual UINT      NetworkMax(void) const=0;
+   virtual UINT      NetworkCritical(void) const=0;
+   //--- specific server interfaces
+   virtual IMTConServerTrade* TradeServer(void)=0;
+   virtual IMTConServerHistory* HistoryServer(void)=0;
+   virtual IMTConServerAccess* AccessServer(void)=0;
+   virtual IMTConServerBackup* BackupServer(void)=0;
+   virtual IMTConServerAntiDDoS* AntiDDoSServer(void)=0;
+   virtual void*     ReservedServer1(void)=0;
+   virtual void*     ReservedServer2(void)=0;
+   virtual void*     ReservedServer3(void)=0;
+   virtual void*     ReservedServer4(void)=0;
+   //--- list of external addresses (address:port) for connections to server
+   virtual MTAPIRES  PointsAdd(LPCWSTR path)=0;
+   virtual MTAPIRES  PointsUpdate(const UINT pos,LPCWSTR address)=0;
+   virtual MTAPIRES  PointsDelete(const UINT pos)=0;
+   virtual MTAPIRES  PointsClear(void)=0;
+   virtual MTAPIRES  PointsShift(const UINT pos,const int shift)=0;
+   virtual UINT      PointsTotal(void) const=0;
+   virtual LPCWSTR   PointsNext(const UINT pos) const=0;
+   //--- list of internal addresses (address:port) for server listening
+   virtual MTAPIRES  BindingsAdd(LPCWSTR path)=0;
+   virtual MTAPIRES  BindingsUpdate(const UINT pos,LPCWSTR address)=0;
+   virtual MTAPIRES  BindingsDelete(const UINT pos)=0;
+   virtual MTAPIRES  BindingsClear(void)=0;
+   virtual MTAPIRES  BindingsShift(const UINT pos,const int shift)=0;
+   virtual UINT      BindingsTotal(void) const=0;
+   virtual LPCWSTR   BindingsNext(const UINT pos) const=0;
+   //--- failover mode
+   virtual UINT      FailoverMode(void) const=0;
+   virtual MTAPIRES  FailoverMode(const UINT mode)=0;
+   //--- failover timeout
+   virtual UINT      FailoverTimeout(void) const=0;
+   virtual MTAPIRES  FailoverTimeout(const UINT timeout)=0;
+   //--- cluster servers state
+   virtual UINT      ClusterStateTotal(void) const=0;
+   virtual MTAPIRES  ClusterStateNext(const UINT pos,IMTConClusterState* state) const=0;
+   virtual MTAPIRES  ClusterStateGet(const UINT64 id,IMTConClusterState* state) const=0;
+  };
+//+------------------------------------------------------------------+
+//| Time config events notification interface                        |
+//+------------------------------------------------------------------+
+class IMTConServerSink
+  {
+public:
+   virtual void      OnConServerAdd(const IMTConServer*    /*server*/) {  }
+   virtual void      OnConServerUpdate(const IMTConServer* /*server*/) {  }
+   virtual void      OnConServerDelete(const IMTConServer* /*server*/) {  }
+   virtual void      OnConServerSync(void)                             {  }
+  };
+//+------------------------------------------------------------------+

+ 98 - 0
MT5SDK/Config/MT5APIConfigParam.h

@@ -0,0 +1,98 @@
+//+------------------------------------------------------------------+
+//|                                                 MetaTrader 5 API |
+//|                   Copyright 2000-2019, MetaQuotes Software Corp. |
+//|                                        http://www.metaquotes.net |
+//+------------------------------------------------------------------+
+#pragma once
+//+------------------------------------------------------------------+
+//| Name-value parameter interface                                   |
+//+------------------------------------------------------------------+
+class IMTConParam
+  {
+public:
+   //--- parameter types
+   enum ParamType
+     {
+      TYPE_STRING    =0,   // string
+      TYPE_INT       =1,   // integer
+      TYPE_FLOAT     =2,   // floating
+      TYPE_TIME      =3 ,  // time only
+      TYPE_DATE      =4 ,  // date only
+      TYPE_DATETIME  =5 ,  // date & time
+      TYPE_GROUPS    =6,   // groups list
+      TYPE_SYMBOLS   =7,   // symbols list
+      //--- enumeration borders
+      TYPE_FIRST     =TYPE_STRING,
+      TYPE_LAST      =TYPE_SYMBOLS
+     };
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTConParam* param)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- parameter name
+   virtual LPCWSTR   Name(void) const=0;
+   virtual MTAPIRES  Name(LPCWSTR name)=0;
+   //--- parameter type
+   virtual UINT      Type(void) const=0;
+   virtual MTAPIRES  Type(const UINT type)=0;
+   //--- parameter value (raw string)
+   virtual LPCWSTR   Value(void) const=0;
+   virtual MTAPIRES  Value(LPCWSTR value)=0;
+   //--- parameter value string
+   virtual LPCWSTR   ValueString(void) const=0;
+   virtual MTAPIRES  ValueString(LPCWSTR value)=0;
+   //--- parameter value integer
+   virtual INT64     ValueInt(void) const=0;
+   virtual MTAPIRES  ValueInt(const INT64 value)=0;
+   //--- parameter value float
+   virtual double    ValueFloat(void) const=0;
+   virtual MTAPIRES  ValueFloat(const double value)=0;
+   //--- parameter value time
+   virtual INT64     ValueTime(void) const=0;
+   virtual MTAPIRES  ValueTime(const INT64 value)=0;
+   //--- parameter value datetime
+   virtual INT64     ValueDatetime(void) const=0;
+   virtual MTAPIRES  ValueDatetime(const INT64 value)=0;
+   //--- parameter value groups
+   virtual LPCWSTR   ValueGroups(void) const=0;
+   virtual MTAPIRES  ValueGroups(LPCWSTR value)=0;
+   //--- parameter value symbols
+   virtual LPCWSTR   ValueSymbols(void) const=0;
+   virtual MTAPIRES  ValueSymbols(LPCWSTR value)=0;
+  };
+//+------------------------------------------------------------------+
+//| Name-value parameter array interface                             |
+//+------------------------------------------------------------------+
+class IMTConParamArray
+  {
+public:
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTConParamArray* array)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- add
+   virtual MTAPIRES  Add(IMTConParam* param)=0;
+   virtual MTAPIRES  AddCopy(const IMTConParam* param)=0;
+   virtual MTAPIRES  Add(IMTConParamArray* array)=0;
+   virtual MTAPIRES  AddCopy(const IMTConParamArray* array)=0;
+   //--- delete & detach
+   virtual MTAPIRES  Delete(const UINT pos)=0;
+   virtual IMTConParam* Detach(const UINT pos)=0;
+   //--- update
+   virtual MTAPIRES  Update(const UINT pos,IMTConParam* param)=0;
+   virtual MTAPIRES  UpdateCopy(const UINT pos,const IMTConParam* param)=0;
+   virtual MTAPIRES  Shift(const UINT pos,const int shift)=0;
+   //--- data access
+   virtual UINT      Total(void) const=0;
+   virtual IMTConParam* Next(const UINT index) const=0;
+   //--- sorting and search
+   virtual MTAPIRES  Sort(MTSortFunctionPtr sort_function)=0;
+   virtual int       Search(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchGreatOrEq(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchGreater(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchLessOrEq(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchLess(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchLeft(const void *key,MTSortFunctionPtr sort_function) const=0;
+   virtual int       SearchRight(const void *key,MTSortFunctionPtr sort_function) const=0;
+  };
+//+------------------------------------------------------------------+

+ 101 - 0
MT5SDK/Config/MT5APIConfigPlugin.h

@@ -0,0 +1,101 @@
+//+------------------------------------------------------------------+
+//|                                                 MetaTrader 5 API |
+//|                   Copyright 2000-2019, MetaQuotes Software Corp. |
+//|                                        http://www.metaquotes.net |
+//+------------------------------------------------------------------+
+#pragma once
+#include "MT5APIConfigParam.h"
+//+------------------------------------------------------------------+
+//| Plugin module configuration                                      |
+//+------------------------------------------------------------------+
+class IMTConPluginModule
+  {
+public:
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTConPluginModule* param)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- default plugin name
+   virtual LPCWSTR   Name(void) const=0;
+   //--- vendor name
+   virtual LPCWSTR   Vendor(void) const=0;
+   //--- plugin description
+   virtual LPCWSTR   Description(void) const=0;
+   //--- plugin file name
+   virtual LPCWSTR   Module(void) const=0;
+   //--- MT5 server-owner id
+   virtual UINT64    Server(void) const=0;
+   //--- plugin version
+   virtual UINT      Version(void) const=0;
+   //--- plugin Server API version
+   virtual UINT      VersionAPI(void) const=0;
+   //--- plugin default parameters
+   virtual UINT      ParameterTotal(void) const=0;
+   virtual MTAPIRES  ParameterNext(const UINT pos,IMTConParam* param) const=0;
+   virtual MTAPIRES  ParameterGet(LPCWSTR name,IMTConParam* param) const=0;
+  };
+//+------------------------------------------------------------------+
+//| Plugin instance configuration                                    |
+//+------------------------------------------------------------------+
+class IMTConPlugin
+  {
+public:
+   //--- plugin working flags
+   enum EnPluginFlags
+     {
+      PLUGIN_FLAG_MAN_CONFIG=1,  // allow configure plugin by managers
+      PLUGIN_FLAG_PROFILING =2,  // allow plugin profiling
+      //--- flags borders
+      PLUGIN_FLAG_NONE     =0,
+      PLUGIN_FLAG_ALL      =PLUGIN_FLAG_MAN_CONFIG|PLUGIN_FLAG_PROFILING
+     };
+   //--- plugin mode
+   enum EnPluginMode
+     {
+      PLUGIN_DISABLED   =0,
+      PLUGIN_ENABLED    =1,
+      //--- enumeration borders
+      PLUGIN_FIRST      =PLUGIN_DISABLED,
+      PLUGIN_LAST       =PLUGIN_ENABLED,
+     };
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTConPlugin* param)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- plugin name
+   virtual LPCWSTR   Name(void) const=0;
+   virtual MTAPIRES  Name(LPCWSTR name)=0;
+   //--- MT5 server ID
+   virtual UINT64    Server(void) const=0;
+   virtual MTAPIRES  Server(const UINT64 server)=0;
+   //--- plugin file name
+   virtual LPCWSTR   Module(void) const=0;
+   virtual MTAPIRES  Module(LPCWSTR name)=0;
+   //--- plugin mode
+   virtual UINT      Mode(void) const=0;
+   virtual MTAPIRES  Mode(const UINT mode)=0;
+   //--- plugin parameters
+   virtual MTAPIRES  ParameterAdd(IMTConParam* param)=0;
+   virtual MTAPIRES  ParameterUpdate(const UINT pos,const IMTConParam* param)=0;
+   virtual MTAPIRES  ParameterDelete(const UINT pos)=0;
+   virtual MTAPIRES  ParameterClear(void)=0;
+   virtual MTAPIRES  ParameterShift(const UINT pos,const int shift)=0;
+   virtual UINT      ParameterTotal(void) const=0;
+   virtual MTAPIRES  ParameterNext(const UINT pos,IMTConParam* param) const=0;
+   virtual MTAPIRES  ParameterGet(LPCWSTR name,IMTConParam* param) const=0;
+   //--- EnPluginFlags
+   virtual UINT      Flags(void) const=0;
+   virtual MTAPIRES  Flags(const UINT flags)=0;
+  };
+//+------------------------------------------------------------------+
+//| Plugin events notification interface                             |
+//+------------------------------------------------------------------+
+class IMTConPluginSink
+  {
+public:
+   virtual void      OnPluginAdd(const IMTConPlugin*    /*plugin*/) {  }
+   virtual void      OnPluginUpdate(const IMTConPlugin* /*plugin*/) {  }
+   virtual void      OnPluginDelete(const IMTConPlugin* /*plugin*/) {  }
+   virtual void      OnPluginSync(void)                             {  }
+  };
+//+------------------------------------------------------------------+

+ 128 - 0
MT5SDK/Config/MT5APIConfigReport.h

@@ -0,0 +1,128 @@
+//+------------------------------------------------------------------+
+//|                                                 MetaTrader 5 API |
+//|                   Copyright 2000-2019, MetaQuotes Software Corp. |
+//|                                        http://www.metaquotes.net |
+//+------------------------------------------------------------------+
+#pragma once
+#include "MT5APIConfigParam.h"
+//+------------------------------------------------------------------+
+//| Plugin module configuration                                      |
+//+------------------------------------------------------------------+
+class IMTConReportModule
+  {
+public:
+   //--- snapshot mode flags
+   enum EnSnapshots
+     {
+      SNAPSHOT_NONE          =0x0,       // without snapshots
+      SNAPSHOT_USERS         =0x1,       // users database snapshot for request
+      SNAPSHOT_USERS_FULL    =0x2,       // full users database snapshot
+      SNAPSHOT_ACCOUNTS      =0x4,       // trade account states snapshot
+      SNAPSHOT_ACCOUNTS_FULL =0x8,       // trade account states snapshot for request
+      SNAPSHOT_ORDERS        =0x10,      // orders database snapshot
+      SNAPSHOT_ORDERS_FULL   =0x20,      // orders database snapshot for request
+      SNAPSHOT_POSITIONS     =0x40,      // positions database snapshot
+      SNAPSHOT_POSITIONS_FULL=0x80,      // positions database snapshot for request
+      //---
+      SNAPSHOT_FIRST         =SNAPSHOT_NONE,
+      SNAPSHOT_LAST          =SNAPSHOT_POSITIONS_FULL,
+     };
+   //--- types reports
+   enum EnTypes
+     {
+      TYPE_NONE              =0x0,        // no support
+      TYPE_HTML              =0x1,        // HTML
+      TYPE_TABLE             =0x2,        // binary table
+      //---
+      TYPE_FIRST             =TYPE_NONE,
+      TYPE_LAST              =TYPE_TABLE,
+      TYPE_ALL               =TYPE_HTML|TYPE_TABLE
+     };
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTConReportModule* param)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- default report name
+   virtual LPCWSTR   Name(void) const=0;
+   //--- vendor name
+   virtual LPCWSTR   Vendor(void) const=0;
+   //--- report description
+   virtual LPCWSTR   Description(void) const=0;
+   //--- report file name
+   virtual LPCWSTR   Module(void) const=0;
+   //--- report index in file
+   virtual UINT      Index(void) const=0;
+   //--- MT5 server-owner id
+   virtual UINT64    Server(void) const=0;
+   //--- plugin version
+   virtual UINT      Version(void) const=0;
+   //--- plugin Server API version
+   virtual UINT      VersionAPI(void) const=0;
+   //--- neccessary Internet Explorer version
+   virtual UINT      VersionIE(void) const=0;
+   //--- available types
+   virtual UINT      Types(void) const=0;
+   //--- neccessary data snapshots
+   virtual UINT      Snapshots(void) const=0;
+   //--- report default parameters
+   virtual UINT      ParameterTotal(void) const=0;
+   virtual MTAPIRES  ParameterNext(const UINT pos,IMTConParam* param) const=0;
+   virtual MTAPIRES  ParameterGet(LPCWSTR name,IMTConParam* param) const=0;
+   //--- report request input params
+   virtual UINT      InputTotal(void) const=0;
+   virtual MTAPIRES  InputNext(const UINT pos,IMTConParam* param) const=0;
+   virtual MTAPIRES  InputGet(LPCWSTR name,IMTConParam* param) const=0;
+  };
+//+------------------------------------------------------------------+
+//| Plugin instance configuration                                    |
+//+------------------------------------------------------------------+
+class IMTConReport
+  {
+public:
+   //--- report mode
+   enum EnReportMode
+     {
+      REPORT_DISABLED=0,
+      REPORT_ENABLED =1,
+      //--- enumeration borders
+      REPORT_FIRST   =REPORT_DISABLED,
+      REPORT_LAST    =REPORT_ENABLED,
+     };
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTConReport* param)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- plugin name
+   virtual LPCWSTR   Name(void) const=0;
+   virtual MTAPIRES  Name(LPCWSTR name)=0;
+   //--- MT5 server ID
+   virtual UINT64    Server(void) const=0;
+   virtual MTAPIRES  Server(const UINT64 server)=0;
+   //--- plugin report name
+   virtual LPCWSTR   Module(void) const=0;
+   virtual MTAPIRES  Module(LPCWSTR name)=0;
+   //--- plugin mode
+   virtual UINT      Mode(void) const=0;
+   virtual MTAPIRES  Mode(const UINT mode)=0;
+   //--- plugin parameters
+   virtual MTAPIRES  ParameterAdd(IMTConParam* param)=0;
+   virtual MTAPIRES  ParameterUpdate(const UINT pos,const IMTConParam* param)=0;
+   virtual MTAPIRES  ParameterDelete(const UINT pos)=0;
+   virtual MTAPIRES  ParameterClear(void)=0;
+   virtual MTAPIRES  ParameterShift(const UINT pos,const int shift)=0;
+   virtual UINT      ParameterTotal(void) const=0;
+   virtual MTAPIRES  ParameterNext(const UINT pos,IMTConParam* param) const=0;
+   virtual MTAPIRES  ParameterGet(LPCWSTR name,IMTConParam* param) const=0;
+  };
+//+------------------------------------------------------------------+
+//| Plugin events notification interface                             |
+//+------------------------------------------------------------------+
+class IMTConReportSink
+  {
+public:
+   virtual void      OnReportAdd(const IMTConReport*    /*report*/) {  }
+   virtual void      OnReportUpdate(const IMTConReport* /*report*/) {  }
+   virtual void      OnReportDelete(const IMTConReport* /*report*/) {  }
+   virtual void      OnReportSync(void)                             {  }
+  };
+//+------------------------------------------------------------------+

+ 367 - 0
MT5SDK/Config/MT5APIConfigRoute.h

@@ -0,0 +1,367 @@
+//+------------------------------------------------------------------+
+//|                                                 MetaTrader 5 API |
+//|                   Copyright 2000-2019, MetaQuotes Software Corp. |
+//|                                        http://www.metaquotes.net |
+//+------------------------------------------------------------------+
+#pragma once
+//+------------------------------------------------------------------+
+//| Trade request routing condition                                  |
+//+------------------------------------------------------------------+
+class IMTConCondition
+  {
+public:
+   //--- condition types
+   enum EnRouteCondition
+     {
+      //--- trade request parameters
+      CONDITION_DATETIME            =0,       // datetime
+      CONDITION_SYMBOL              =1,       // symbol
+      CONDITION_VOLUME              =2,       // volume
+      CONDITION_MARKET_DEVIATION    =3,       // deviation from market
+      CONDITION_TIME                =4,       // time (in minutes from 00:00)
+      CONDITION_WEEKDAY             =5,       // day of week 0 - sunday
+      CONDITION_COMMENT             =6,       // find substring in request comment
+      CONDITION_EXPERT              =7,       // request placed by expert
+      CONDITION_SIGNAL              =8,       // request placed by signal
+      CONDITION_DEALER_LOGIN        =9,       // dealer processed specified order or position
+      CONDITION_SOURCE_LOGIN        =10,      // dealer processed specified order or position
+      CONDITION_MARKET_DEVIATION_SPR=11,      // deviation from market in spreads
+      CONDITION_GAP                 =12,      // symbol in gap mode
+      //--- client data
+      CONDITION_LOGIN               =1000,    // login
+      CONDITION_GROUP               =1001,    // group
+      CONDITION_COUNTRY             =1002,    // country
+      CONDITION_CITY                =1003,    // city
+      CONDITION_COLOR               =1004,    // color
+      CONDITION_LEVERAGE            =1005,    // leverage
+      CONDITION_COMMENT_CLIENT      =1006,    // client record comment
+      //--- client trade account
+      CONDITION_MARGIN              =2000,    // margin
+      CONDITION_MARGIN_LEVEL        =2001,    // margin level
+      CONDITION_MARGIN_FREE         =2002,    // free margin
+      CONDITION_EQUITY              =2003,    // equity
+      CONDITION_BALANCE             =2004,    // balance
+      CONDITION_PROFIT              =2005,    // profit
+      //--- trading statistic
+      CONDITION_DAILY_DEALS         =3000,    // deals count
+      CONDITION_DAILY_DEALS_PERIOD  =3001,    // average period between deals
+      CONDITION_DAILY_PROFIT        =3002,    // fixed profit
+      //--- position and orders parameters
+      CONDITION_POSITION_VOLUME     =4000,    // position volume
+      CONDITION_POSITION_PROFIT     =4001,    // position profit
+      CONDITION_POSITION_AGE        =4002,    // position age
+      CONDITION_POSITION_MODIFY_TIME=4003,    // modify last time
+      CONDITION_POSITION_AVERAGE_TIME=4004,   // position average time
+      CONDITION_POSITION_TOTAL       =4005,   // total client positions
+      CONDITION_POSITION_TOTAL_SYMBOL=4006,   // client positions by request symbol
+      CONDITION_ORDER_TOTAL          =4007,   // total client orders
+      CONDITION_ORDER_TOTAL_SYMBOL   =4008,   // client orders by request symbol
+      CONDITION_POSITION_SL_TOUCHED  =4009,   // position SL touched
+      CONDITION_POSITION_TP_TOUCHED  =4010,   // position TP touched
+      CONDITION_ORDER_SL_TOUCHED     =4011,   // order SL touched
+      CONDITION_ORDER_TP_TOUCHED     =4012,   // order TP touched
+      CONDITION_ORDER_ENTRY_IN       =4013,   // order entry in
+      CONDITION_ORDER_ENTRY_OUT      =4014,   // order entry out
+      //--- market conditions
+      CONDITION_MARKET_MAX_CHANGE1  =5000,    // reserved
+      CONDITION_MARKET_MAX_CHANGE2  =5001,    // reserved
+      CONDITION_MARKET_MAX_CHANGE3  =5002,    // reserved
+      CONDITION_MARKET_MAX_CHANGE4  =5003,    // reserved
+      CONDITION_MARKET_MAX_CHANGE5  =5004,    // reserved
+      CONDITION_MARKET_MAX_CHANGE6  =5005,    // reserved
+      CONDITION_MARKET_MAX_CHANGE7  =5006,    // reserved
+      CONDITION_MARKET_MAX_CHANGE8  =5007,    // reserved
+      CONDITION_MARKET_MAX_CHANGE9  =5008,    // reserved
+      CONDITION_MARKET_MAX_CHANGE10 =5009,    // reserved
+      //--- enumeration borders
+      CONDITION_FIRST               =CONDITION_DATETIME,
+      CONDITION_LAST                =CONDITION_ORDER_ENTRY_OUT
+     };
+   //--- compare method
+   enum EnConditionRule
+     {
+      RULE_EQ                       =0,       // equal      (==)
+      RULE_NOT_EQ                   =1,       // not equal  (!=) 
+      RULE_GREATER                  =2,       // greater    (> )
+      RULE_NOT_LESS                 =3,       // not less   (>=)
+      RULE_LESS                     =4,       // less       (< )
+      RULE_NOT_GREATER              =5,       // not greater(<=)
+      //--- enumeration borders
+      RULE_FIRST                    =RULE_EQ,
+      RULE_LAST                     =RULE_NOT_GREATER
+     };
+   //--- condition value type
+   enum EnConditionType
+     {
+      TYPE_NONE                     =0,       // none
+      TYPE_STRING                   =1,       // string
+      TYPE_INT                      =2,       // integer
+      TYPE_UINT                     =3,       // unsigned integer
+      TYPE_DOUBLE                   =4,       // double
+      TYPE_COLOR                    =5,       // color
+      TYPE_MONEY                    =6,       // money
+      TYPE_VOLUME                   =7,       // volume
+      TYPE_DATETIME                 =8,       // datetime
+      TYPE_LEVERAGE                 =9,       // leverage
+      TYPE_BOOL                     =10,      // boolean
+      TYPE_TIME                     =11,      // time
+      TYPE_WEEKDAY                  =12,      // weekday
+      //--- enumeration borders
+      TYPE_FIRST                    =TYPE_NONE,
+      TYPE_LAST                     =TYPE_WEEKDAY
+     };
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTConCondition* config)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- condition
+   virtual UINT      Condition(void) const=0;
+   virtual MTAPIRES  Condition(const UINT condition)=0;
+   //--- rule
+   virtual UINT      Rule(void) const=0;
+   virtual MTAPIRES  Rule(const UINT rule)=0;
+   //--- type
+   virtual UINT      ValueType(void) const=0;
+   //--- value int
+   virtual INT64     ValueInt(void) const=0;
+   virtual MTAPIRES  ValueInt(const INT64 value)=0;
+   //--- value uint
+   virtual UINT64    ValueUInt(void) const=0;
+   virtual MTAPIRES  ValueUInt(const UINT64 value)=0;
+   //--- value double
+   virtual double    ValueDouble(void) const=0;
+   virtual MTAPIRES  ValueDouble(const double value)=0;
+   //--- value string
+   virtual LPCWSTR   ValueString(void) const=0;
+   virtual MTAPIRES  ValueString(LPCWSTR value)=0;
+   //--- value color
+   virtual COLORREF  ValueColor(void) const=0;
+   virtual MTAPIRES  ValueColor(const COLORREF value)=0;
+   //--- value money
+   virtual double    ValueMoney(void) const=0;
+   virtual MTAPIRES  ValueMoney(const double value)=0;
+   //--- value volume
+   virtual UINT64    ValueVolume(void) const=0;
+   virtual MTAPIRES  ValueVolume(const UINT64 value)=0;
+   //--- value datetime
+   virtual INT64     ValueDatetime(void) const=0;
+   virtual MTAPIRES  ValueDatetime(const INT64 value)=0;
+   //--- value leverage
+   virtual INT64     ValueLeverage(void) const=0;
+   virtual MTAPIRES  ValueLeverage(const INT64 value)=0;
+   //--- value bool
+   virtual bool      ValueBool(void) const=0;
+   virtual MTAPIRES  ValueBool(const bool value)=0;
+   //--- value time
+   virtual UINT      ValueTime(void) const=0;
+   virtual MTAPIRES  ValueTime(const UINT value)=0;
+   //--- value weekday
+   virtual UINT      ValueWeekDay(void) const=0;
+   virtual MTAPIRES  ValueWeekDay(const UINT value)=0;
+   //--- value volume with extended accuracy
+   virtual UINT64    ValueVolumeExt(void) const=0;
+   virtual MTAPIRES  ValueVolumeExt(const UINT64 value)=0;
+  };
+//+------------------------------------------------------------------+
+//| Trade request routing dealer                                     |
+//+------------------------------------------------------------------+
+class IMTConRouteDealer
+  {
+public:
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTConRouteDealer* config)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- login
+   virtual UINT64    Login(void) const=0;
+   virtual MTAPIRES  Login(const UINT64 login)=0;
+   //--- name
+   virtual LPCWSTR   Name(void) const=0;
+  };
+//+------------------------------------------------------------------+
+//| Trade request routing rule                                       |
+//+------------------------------------------------------------------+
+class IMTConRoute
+  {
+public:
+   //--- modes
+   enum EnRouteMode
+     {
+      MODE_DISABLED                 =0,
+      MODE_ENABLED                  =1,
+      //--- enumeration borders
+      MODE_FIRST                    =MODE_DISABLED,
+      MODE_LAST                     =MODE_ENABLED
+     };
+   //--- trade request flags
+   enum EnRouteFlags
+     {
+      REQUEST_NONE                  =0x00000000,  // empty
+      //--- client requests
+      REQUEST_PRICE                 =0x00000001,  // price request
+      REQUEST_REQUEST               =0x00000002,  // market order on request execution
+      REQUEST_INSTANT               =0x00000004,  // market order on instant execution
+      REQUEST_MARKET                =0x00000008,  // market order on market execution
+      REQUEST_EXCHANGE              =0x00000010,  // market order on exchange execution
+      REQUEST_PENDING               =0x00000020,  // pending order place
+      REQUEST_SLTP                  =0x00000040,  // SL/TP modification
+      REQUEST_MODIFY                =0x00000080,  // pending order modification
+      REQUEST_REMOVE                =0x00000100,  // pending order modification
+      //--- activations
+      REQUEST_ACTIVATE              =0x00000200,  // pending order activation
+      REQUEST_STOPLIMIT             =0x00000400,  // Stop-Limit order activation
+      REQUEST_SL                    =0x00000800,  // SL activation
+      REQUEST_TP                    =0x00001000,  // TP activation
+      REQUEST_STOPOUT_ORDER         =0x00002000,  // order Stop-Out
+      REQUEST_STOPOUT_POSITION      =0x00004000,  // position Stop-Out
+      REQUEST_EXPIRATION            =0x00008000,  // order expiration
+      //--- dealer request
+      REQUEST_DEALER_POS_EXECUTE    =0x00010000,  // position placing by dealer
+      REQUEST_DEALER_ORD_PENDING    =0x00020000,  // order placing by dealer
+      REQUEST_DEALER_POS_MODIFY     =0x00040000,  // position modification by dealer
+      REQUEST_DEALER_ORD_MODIFY     =0x00080000,  // order modification by dealer
+      REQUEST_DEALER_ORD_REMOVE     =0x00100000,  // order remove  by dealer
+      REQUEST_DEALER_ORD_ACTIVATE   =0x00200000,  // order actvation by dealer
+      REQUEST_DEALER_ORD_SLIMIT     =0x00400000,  // Stop-Limit order  actvation by dealer
+      REQUEST_DEALER_CLOSE_BY       =0x00800000,  // close by hedged position by dealer
+      //--- client requests
+      REQUEST_CLOSE_BY              =0x01000000,  // close by hedged position
+      //--- all
+      REQUEST_ALL                   =REQUEST_PRICE | REQUEST_REQUEST | REQUEST_INSTANT | REQUEST_MARKET |
+      REQUEST_EXCHANGE   | REQUEST_PENDING         | REQUEST_SLTP    | REQUEST_MODIFY  | REQUEST_REMOVE |
+      REQUEST_ACTIVATE   | REQUEST_STOPLIMIT       | REQUEST_SL      | REQUEST_TP      | REQUEST_STOPOUT_ORDER |
+      REQUEST_STOPOUT_POSITION | REQUEST_EXPIRATION| REQUEST_DEALER_POS_EXECUTE | REQUEST_DEALER_ORD_PENDING   |
+      REQUEST_DEALER_POS_MODIFY|REQUEST_DEALER_ORD_MODIFY | REQUEST_DEALER_ORD_REMOVE | REQUEST_DEALER_ORD_ACTIVATE | REQUEST_DEALER_ORD_SLIMIT | REQUEST_DEALER_CLOSE_BY |
+      REQUEST_CLOSE_BY,
+      //--- enumeration borders
+      REQUEST_FIRST                 =REQUEST_NONE,
+      REQUEST_LAST                  =REQUEST_ALL
+     };
+   //--- order-position types
+   enum EnTypeFlags
+     {
+      TYPE_NONE                     =0x0000,  // none
+      TYPE_BUY                      =0x0001,  // BUY
+      TYPE_SELL                     =0x0002,  // SELL
+      TYPE_BUY_LIMIT                =0x0004,  // BUY LIMIT
+      TYPE_SELL_LIMIT               =0x0008,  // SELL LIMIT
+      TYPE_BUY_STOP                 =0x0010,  // BUY STOP
+      TYPE_SELL_STOP                =0x0020,  // SELL STOP
+      TYPE_BUY_STOP_LIMIT           =0x0040,  // BUY STOP LIMIT
+      TYPE_SELL_STOP_LIMIT          =0x0080,  // SELL STOP LIMIT
+      //--- all
+      TYPE_ALL                      =TYPE_BUY|TYPE_SELL|TYPE_BUY_LIMIT|TYPE_SELL_LIMIT|
+      TYPE_BUY_STOP|TYPE_SELL_STOP|TYPE_BUY_STOP_LIMIT|TYPE_SELL_STOP_LIMIT,
+      //--- enumeration borders
+      TYPE_FIRST                    =TYPE_NONE,
+      TYPE_LAST                     =TYPE_ALL
+     };
+   //--- actions
+   enum EnRouteAction
+     {
+      //--- intermediate actions
+      ACTION_DELAY_TIME             =0,       // N seconds timeout
+      ACTION_DELAY_TICK             =1,       // N ticks timeout
+      ACTION_CLEAR_TP               =2,       // clear TP
+      ACTION_CLEAR_SL               =3,       // clear SL
+      ACTION_CLEAR_SLTP             =4,       // clear SL & TP
+      //--- final actions
+      ACTION_DEALER                 =1001,    // route request to dealers\gateways
+      ACTION_DEALER_ONLINE          =1002,    // route request to online dealers\gateways
+      ACTION_REJECT                 =1003,    // reject request
+      ACTION_REQUOTE                =1004,    // requote request using current market
+      ACTION_CONFIRM_CLIENT         =1005,    // confirm using client price
+      ACTION_CONFIRM_MARKET         =1006,    // confirm using market price
+      ACTION_CANCEL_ORDER           =1007,    // reject request and cancel order
+      //--- enumeration borders
+      ACTION_FIRST                  =ACTION_DELAY_TIME,
+      ACTION_LAST                   =ACTION_CANCEL_ORDER
+     };
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTConRoute* config)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- name
+   virtual LPCWSTR   Name(void) const=0;
+   virtual MTAPIRES  Name(LPCWSTR name)=0;
+   //--- request EnRouteMode
+   virtual UINT      Mode(void) const=0;
+   virtual MTAPIRES  Mode(const UINT mode)=0;
+   //--- request EnRouteFlags
+   virtual UINT      Request(void) const=0;
+   virtual MTAPIRES  Request(const UINT request)=0;
+   //--- order-posiion type EnRouteType
+   virtual UINT      Type(void) const=0;
+   virtual MTAPIRES  Type(const UINT type)=0;
+   //--- action for request EnRouteAction
+   virtual UINT      Action(void) const=0;
+   virtual MTAPIRES  Action(const UINT action)=0;
+   //--- action value type IMTConRouteCondition::EnConditionType
+   virtual UINT      ParamType(void) const=0;
+   //--- value int
+   virtual INT64     ParamInt(void) const=0;
+   virtual MTAPIRES  ParamInt(const INT64 value)=0;
+   //--- value uind
+   virtual UINT64    ParamUInt(void) const=0;
+   virtual MTAPIRES  ParamUInt(const UINT64 value)=0;
+   //--- value double
+   virtual double    ParamDouble(void) const=0;
+   virtual MTAPIRES  ParamDouble(const double value)=0;
+   //--- value string
+   virtual LPCWSTR   ParamString(void) const=0;
+   virtual MTAPIRES  ParamString(LPCWSTR value)=0;
+   //--- value color
+   virtual COLORREF  ParamColor(void) const=0;
+   virtual MTAPIRES  ParamColor(const COLORREF value)=0;
+   //--- value money
+   virtual double    ParamMoney(void) const=0;
+   virtual MTAPIRES  ParamMoney(const double value)=0;
+   //--- value volume
+   virtual UINT64    ParamVolume(void) const=0;
+   virtual MTAPIRES  ParamVolume(const UINT64 value)=0;
+   //--- value datetime
+   virtual INT64     ParamDatetime(void) const=0;
+   virtual MTAPIRES  ParamDatetime(const INT64 value)=0;
+   //--- value leverage
+   virtual INT64     ParamLeverage(void) const=0;
+   virtual MTAPIRES  ParamLeverage(const INT64 value)=0;
+   //--- value bool
+   virtual bool      ParamBool(void) const=0;
+   virtual MTAPIRES  ParamBool(const bool value)=0;
+   //--- value time
+   virtual UINT      ParamTime(void) const=0;
+   virtual MTAPIRES  ParamTime(const UINT value)=0;
+   //--- conditions
+   virtual MTAPIRES  ConditionAdd(IMTConCondition* condition)=0;
+   virtual MTAPIRES  ConditionUpdate(const UINT pos,const IMTConCondition* condition)=0;
+   virtual MTAPIRES  ConditionDelete(const UINT pos)=0;
+   virtual MTAPIRES  ConditionClear(void)=0;
+   virtual MTAPIRES  ConditionShift(const UINT pos,const int shift)=0;
+   virtual UINT      ConditionTotal(void) const=0;
+   virtual MTAPIRES  ConditionNext(const UINT pos,IMTConCondition* condition) const=0;
+   //--- dealers
+   virtual MTAPIRES  DealerAdd(IMTConRouteDealer* dealer)=0;
+   virtual MTAPIRES  DealerUpdate(const UINT pos,const IMTConRouteDealer* dealer)=0;
+   virtual MTAPIRES  DealerDelete(const UINT pos)=0;
+   virtual MTAPIRES  DealerClear(void)=0;
+   virtual MTAPIRES  DealerShift(const UINT pos,const int shift)=0;
+   virtual UINT      DealerTotal(void) const=0;
+   virtual MTAPIRES  DealerNext(const UINT pos,IMTConRouteDealer* dealer) const=0;
+   virtual MTAPIRES  DealerGet(const UINT64 login,IMTConRouteDealer* dealer) const=0;
+   //--- value volume with extended accuracy
+   virtual UINT64    ParamVolumeExt(void) const=0;
+   virtual MTAPIRES  ParamVolumeExt(const UINT64 value)=0;
+  };
+//+------------------------------------------------------------------+
+//| Config events notification interface                             |
+//+------------------------------------------------------------------+
+class IMTConRouteSink
+  {
+public:
+   virtual void      OnRouteAdd(const IMTConRoute*    /*config*/) {  }
+   virtual void      OnRouteUpdate(const IMTConRoute* /*config*/) {  }
+   virtual void      OnRouteDelete(const IMTConRoute* /*config*/) {  }
+   virtual void      OnRouteSync(void)                            {  }
+  };
+//+------------------------------------------------------------------+
+  

+ 105 - 0
MT5SDK/Config/MT5APIConfigSpread.h

@@ -0,0 +1,105 @@
+//+------------------------------------------------------------------+
+//|                                                 MetaTrader 5 API |
+//|                   Copyright 2000-2019, MetaQuotes Software Corp. |
+//|                                        http://www.metaquotes.net |
+//+------------------------------------------------------------------+
+#pragma once
+//+------------------------------------------------------------------+
+//| Spread leg config                                                |
+//+------------------------------------------------------------------+
+class IMTConSpreadLeg
+  {
+public:
+   //--- leg modes
+   enum EnLegMode
+     {
+      LEG_MODE_SYMBOL    =0, // symbol specified by Symbol
+      LEG_MODE_FUTURES   =1, // symbol specified by basis in Symbol + expiration range TimeFrom-TimeTo
+      //--- enumeration borders
+      LEG_MODE_FIRST     =LEG_MODE_SYMBOL,
+      LEG_MODE_LAST      =LEG_MODE_FUTURES
+     };
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTConSpreadLeg* leg)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- mode
+   virtual UINT      Mode(void) const=0;
+   virtual MTAPIRES  Mode(const UINT mode)=0;
+   //--- symbol
+   virtual LPCWSTR   Symbol(void) const=0;
+   virtual MTAPIRES  Symbol(LPCWSTR symbol)=0;
+   //--- time from
+   virtual INT64     TimeFrom(void) const=0;
+   virtual MTAPIRES  TimeFrom(const INT64 from)=0;
+   //--- time to
+   virtual INT64     TimeTo(void) const=0;
+   virtual MTAPIRES  TimeTo(const INT64 to)=0;
+   //--- ratio
+   virtual UINT64    Ratio(void) const=0;
+   virtual MTAPIRES  Ratio(const UINT64 ratio)=0;
+   //--- ratio double
+   virtual double    RatioDbl(void) const=0;
+   virtual MTAPIRES  RatioDbl(const double ratio)=0;
+  };
+//+------------------------------------------------------------------+
+//| Spread config                                                    |
+//+------------------------------------------------------------------+
+class IMTConSpread
+  {
+public:
+   //--- spread types
+   enum EnSpreadMarginType
+     {
+      MARGIN_TYPE_VALUE    =0,
+      MARGIN_TYPE_MAXIMAL  =1,
+      MARGIN_TYPE_CME_INTER=2,
+      MARGIN_TYPE_CME_INTRA=3,
+      //--- enumeration borders
+      MARGIN_TYPE_FIRST    =MARGIN_TYPE_VALUE,
+      MARGIN_TYPE_LAST     =MARGIN_TYPE_CME_INTRA
+     };
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTConSpread* spread)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- id
+   virtual UINT      ID(void) const=0;
+   //--- margin type
+   virtual UINT      MarginType(void) const=0;
+   virtual MTAPIRES  MarginType(const UINT type)=0;
+   //--- initial margin
+   virtual double    MarginInitial(void) const=0;
+   virtual MTAPIRES  MarginInitial(const double margin)=0;
+   //--- maintenance margin
+   virtual double    MarginMaintenance(void) const=0;
+   virtual MTAPIRES  MarginMaintenance(const double margin)=0;
+   //--- leg A
+   virtual MTAPIRES  ALegAdd(IMTConSpreadLeg* leg)=0;
+   virtual MTAPIRES  ALegUpdate(const UINT pos,const IMTConSpreadLeg* leg)=0;
+   virtual MTAPIRES  ALegDelete(const UINT pos)=0;
+   virtual MTAPIRES  ALegClear(void)=0;
+   virtual MTAPIRES  ALegShift(const UINT pos,const int shift)=0;
+   virtual UINT      ALegTotal(void) const=0;
+   virtual MTAPIRES  ALegNext(const UINT pos,IMTConSpreadLeg* leg) const=0;
+   //--- leg B
+   virtual MTAPIRES  BLegAdd(IMTConSpreadLeg* leg)=0;
+   virtual MTAPIRES  BLegUpdate(const UINT pos,const IMTConSpreadLeg* leg)=0;
+   virtual MTAPIRES  BLegDelete(const UINT pos)=0;
+   virtual MTAPIRES  BLegClear(void)=0;
+   virtual MTAPIRES  BLegShift(const UINT pos,const int shift)=0;
+   virtual UINT      BLegTotal(void) const=0;
+   virtual MTAPIRES  BLegNext(const UINT pos,IMTConSpreadLeg* leg) const=0;
+  };
+//+------------------------------------------------------------------+
+//| Spread config events notification interface                      |
+//+------------------------------------------------------------------+
+class IMTConSpreadSink
+  {
+public:
+   virtual void      OnSpreadAdd(const IMTConSpread*    /*config*/) {  }
+   virtual void      OnSpreadUpdate(const IMTConSpread* /*config*/) {  }
+   virtual void      OnSpreadDelete(const IMTConSpread* /*config*/) {  }
+   virtual void      OnSpreadSync(void)                             {  }
+  };
+//+------------------------------------------------------------------+

+ 602 - 0
MT5SDK/Config/MT5APIConfigSymbol.h

@@ -0,0 +1,602 @@
+//+------------------------------------------------------------------+
+//|                                                 MetaTrader 5 API |
+//|                   Copyright 2000-2019, MetaQuotes Software Corp. |
+//|                                        http://www.metaquotes.net |
+//+------------------------------------------------------------------+
+#pragma once
+//+------------------------------------------------------------------+
+//| Symbol trade and quotes sessions config                          |
+//+------------------------------------------------------------------+
+class IMTConSymbolSession
+  {
+public:
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTConSymbolSession* symbol)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- session start in minutes (60 = 01:00)
+   virtual UINT      Open(void) const=0;
+   virtual MTAPIRES  Open(const UINT open)=0;
+   //--- session start hours and minutes
+   virtual UINT      OpenHours(void) const=0;
+   virtual UINT      OpenMinutes(void) const=0;
+   //--- session end in minutes (60 = 01:00)
+   virtual UINT      Close(void) const=0;
+   virtual MTAPIRES  Close(const UINT close)=0;
+   //--- session end hours and minutes
+   virtual UINT      CloseHours(void) const=0;
+   virtual UINT      CloseMinutes(void) const=0;
+  };
+//+------------------------------------------------------------------+
+//| Symbol config                                                    |
+//+------------------------------------------------------------------+
+class IMTConSymbol
+  {
+public:
+   //--- allowed filling modes flags
+   enum EnFillingFlags
+     {
+      FILL_FLAGS_NONE         =0, // none
+      FILL_FLAGS_FOK          =1, // allowed FOK
+      FILL_FLAGS_IOC          =2, // allowed IOC
+      //--- flags borders
+      FILL_FLAGS_FIRST        =FILL_FLAGS_FOK,
+      FILL_FLAGS_ALL          =FILL_FLAGS_FOK|FILL_FLAGS_IOC
+     };
+   //--- allowed order expiration modes flags
+   enum EnExpirationFlags
+     {
+      TIME_FLAGS_NONE         =0, // none
+      TIME_FLAGS_GTC          =1, // allowed Good Till Cancel
+      TIME_FLAGS_DAY          =2, // allowed Good Till Day
+      TIME_FLAGS_SPECIFIED    =4, // allowed specified expiration date
+      TIME_FLAGS_SPECIFIED_DAY=8, // allowed specified expiration date as day
+      //--- flags borders
+      TIME_FLAGS_FIRST        =TIME_FLAGS_GTC,
+      TIME_FLAGS_ALL          =TIME_FLAGS_GTC|TIME_FLAGS_DAY|TIME_FLAGS_SPECIFIED|TIME_FLAGS_SPECIFIED_DAY
+     };
+   //--- allowed order flags
+   enum EnOrderFlags
+     {
+      ORDER_FLAGS_NONE        =0,  // none
+      ORDER_FLAGS_MARKET      =1,  // market orders
+      ORDER_FLAGS_LIMIT       =2,  // limit orders
+      ORDER_FLAGS_STOP        =4,  // stop orders
+      ORDER_FLAGS_STOP_LIMIT  =8,  // stop limit orders
+      ORDER_FLAGS_SL          =16, // sl orders
+      ORDER_FLAGS_TP          =32, // tp orders
+      ORDER_FLAGS_CLOSEBY     =64, // close-by orders
+      //--- flags borders
+      ORDER_FLAGS_FIRST       =ORDER_FLAGS_MARKET,
+      ORDER_FLAGS_ALL         =ORDER_FLAGS_MARKET|ORDER_FLAGS_LIMIT|ORDER_FLAGS_STOP|ORDER_FLAGS_STOP_LIMIT|ORDER_FLAGS_SL|ORDER_FLAGS_TP|ORDER_FLAGS_CLOSEBY
+     };
+   //--- allowed trade modes
+   enum EnTradeMode
+     {
+      TRADE_DISABLED          =0, // trade disabled
+      TRADE_LONGONLY          =1, // only long positions allowed
+      TRADE_SHORTONLY         =2, // only short positions allowed
+      TRADE_CLOSEONLY         =3, // only position closure
+      TRADE_FULL              =4, // all trade operations are allowed
+      //--- enumeration borders
+      TRADE_FIRST             =TRADE_DISABLED,
+      TRADE_LAST              =TRADE_FULL
+     };
+   //--- order execution modes
+   enum EnExecutionMode
+     {
+      EXECUTION_REQUEST       =0, // Request Execution
+      EXECUTION_INSTANT       =1, // Instant Execution
+      EXECUTION_MARKET        =2, // Market Execution
+      EXECUTION_EXCHANGE      =3, // Exchange Execution
+      //--- enumeration borders
+      EXECUTION_FIRST         =EXECUTION_REQUEST,
+      EXECUTION_LAST          =EXECUTION_EXCHANGE
+     };
+   //--- profit and margin calculation modes
+   enum EnCalcMode
+     {
+      //--- market maker modes
+      TRADE_MODE_FOREX              =0,
+      TRADE_MODE_FUTURES            =1,
+      TRADE_MODE_CFD                =2,
+      TRADE_MODE_CFDINDEX           =3,
+      TRADE_MODE_CFDLEVERAGE        =4,
+      TRADE_MODE_FOREX_NO_LEVERAGE  =5,
+      //--- market makers enumerations
+      TRADE_MODE_MM_FIRST           =TRADE_MODE_FOREX,
+      TRADE_MODE_MM_LAST            =TRADE_MODE_FOREX_NO_LEVERAGE,
+      //--- exchange modes
+      TRADE_MODE_EXCH_STOCKS        =32,
+      TRADE_MODE_EXCH_FUTURES       =33,
+      TRADE_MODE_EXCH_FUTURES_FORTS =34,
+      TRADE_MODE_EXCH_OPTIONS       =35,
+      TRADE_MODE_EXCH_OPTIONS_MARGIN=36,
+      TRADE_MODE_EXCH_BONDS         =37,
+      TRADE_MODE_EXCH_STOCKS_MOEX   =38,
+      TRADE_MODE_EXCH_BONDS_MOEX    =39,
+      //--- exchange enumerations
+      TRADE_MODE_EXCH_FIRST         =TRADE_MODE_EXCH_STOCKS,
+      TRADE_MODE_EXCH_LAST          =TRADE_MODE_EXCH_BONDS_MOEX,
+      //--- service modes
+      TRADE_MODE_SERV_COLLATERAL    =64,
+      //--- service enumerations
+      TRADE_MODE_SERV_FIRST         =TRADE_MODE_SERV_COLLATERAL,
+      TRADE_MODE_SERV_LAST          =TRADE_MODE_SERV_COLLATERAL,
+      //--- enumeration borders
+      TRADE_MODE_FIRST              =TRADE_MODE_FOREX,
+      TRADE_MODE_LAST               =TRADE_MODE_SERV_COLLATERAL
+     };
+   //--- orders expiration modes
+   enum EnGTCMode
+     {
+      ORDERS_GTC              =0,
+      ORDERS_DAILY            =1,
+      ORDERS_DAILY_NO_STOPS   =2,
+      //--- enumeration borders
+      ORDERS_FIRST            =ORDERS_GTC,
+      ORDERS_LAST             =ORDERS_DAILY_NO_STOPS
+     };
+   //--- tick collection flags
+   enum EnTickFlags
+     {
+      TICK_REALTIME           =1,  // allow realtime tick apply
+      TICK_COLLECTRAW         =2,  // allow to collect raw ticks
+      TICK_FEED_STATS         =4,  // allow to receive price statisticks from datafeeds
+      //--- flags borders
+      TICK_NONE               =0,
+      TICK_ALL                =TICK_REALTIME|TICK_COLLECTRAW|TICK_FEED_STATS
+     };
+   //--- chart mode
+   enum EnChartMode
+     {
+      CHART_MODE_BID_PRICE    =0,
+      CHART_MODE_LAST_PRICE   =1,
+      CHART_MODE_OLD          =255,
+      //--- enumeration borders
+      CHART_MODE_FIRST        =CHART_MODE_BID_PRICE,
+      CHART_MODE_LAST         =CHART_MODE_OLD
+     };
+   //--- margin check modes
+   enum EnMarginFlags
+     {
+      MARGIN_FLAGS_NONE             =0,  // none
+      MARGIN_FLAGS_CHECK_PROCESS    =1,  // check margin after dealer confirmation
+      MARGIN_FLAGS_CHECK_SLTP       =2,  // check margin on SL-TP trigger
+      MARGIN_FLAGS_HEDGE_LARGE_LEG  =4,  // check margin for hedged positions using large leg
+      //--- flags borders
+      MARGIN_FLAGS_FIRST            =MARGIN_FLAGS_NONE,
+      MARGIN_FLAGS_LAST             =MARGIN_FLAGS_HEDGE_LARGE_LEG
+     };
+   //--- swaps calculation modes
+   enum EnSwapMode
+     {
+      SWAP_DISABLED           =0,
+      SWAP_BY_POINTS          =1,
+      SWAP_BY_SYMBOL_CURRENCY =2,
+      SWAP_BY_MARGIN_CURRENCY =3,
+      SWAP_BY_GROUP_CURRENCY  =4,
+      SWAP_BY_INTEREST_CURRENT=5,
+      SWAP_BY_INTEREST_OPEN   =6,
+      SWAP_REOPEN_BY_CLOSE_PRICE=7,
+      SWAP_REOPEN_BY_BID        =8,
+      SWAP_BY_PROFIT_CURRENCY   =9,
+      //--- enumeration borders
+      SWAP_FIRST              =SWAP_DISABLED,
+      SWAP_LAST               =SWAP_BY_PROFIT_CURRENCY
+     };
+   //--- swaps days
+   enum EnSwapDays
+     {
+      SWAP_DAY_SUNDAY         =0,
+      SWAP_DAY_MONDAY         =1,
+      SWAP_DAY_TUESDAY        =2,
+      SWAP_DAY_WEDNESDAY      =3,
+      SWAP_DAY_THURSDAY       =4,
+      SWAP_DAY_FRIDAY         =5,
+      SWAP_DAY_SATURDAY       =6,
+      SWAP_DAY_DISABLED       =7,
+      //--- enumeration borders
+      SWAP_DAY_FIRST          =SWAP_DAY_SUNDAY,
+      SWAP_DAY_LAST           =SWAP_DAY_DISABLED
+     };
+   //--- Instant Execution Flags
+   enum EnInstantFlags
+     {
+      INSTANT_FLAGS_NONE     =0,
+      INSTANT_FLAGS_FAST_CONFIRMATION=1,
+      //--- enumeration borders
+      INSTANT_FLAGS_ALL      =INSTANT_FLAGS_FAST_CONFIRMATION
+     };
+   //--- Instant Execution Modes
+   enum EnInstantMode
+     {
+      INSTANT_CHECK_NORMAL    =0,
+      //--- enumeration borders
+      INSTANT_CHECK_FIRST     =INSTANT_CHECK_NORMAL,
+      INSTANT_CHECK_LAST      =INSTANT_CHECK_NORMAL
+     };
+   //--- Request Execution Flags
+   enum EnRequestFlags
+     {
+      REQUEST_FLAGS_NONE      =0,  // node
+      REQUEST_FLAGS_ORDER     =1,  // trade orders should be additional confirmed after quotation
+      //--- flags borders
+      REQUEST_FLAGS_ALL       =REQUEST_FLAGS_ORDER
+     };
+   //--- Common Trade Flags
+   enum EnTradeFlags
+     {
+      TRADE_FLAGS_NONE            =0,   // none
+      TRADE_FLAGS_PROFIT_BY_MARKET=1,   // convert fx profit using market prices
+      TRADE_FLAGS_ALLOW_SIGNALS   =2,   // allow trade signals for symbol
+      //--- flags borders
+      TRADE_FLAGS_ALL             =TRADE_FLAGS_PROFIT_BY_MARKET|TRADE_FLAGS_ALLOW_SIGNALS,
+      TRADE_FLAGS_DEFAULT         =TRADE_FLAGS_ALLOW_SIGNALS
+     };
+   //--- Margin Rate Types
+   enum EnMarginRateTypes
+     {
+      MARGIN_RATE_BUY         =0,
+      MARGIN_RATE_SELL        =1,
+      MARGIN_RATE_BUY_LIMIT   =2,
+      MARGIN_RATE_SELL_LIMIT  =3,
+      MARGIN_RATE_BUY_STOP    =4,
+      MARGIN_RATE_SELL_STOP   =5,
+      MARGIN_RATE_BUY_STOP_LIMIT =6,
+      MARGIN_RATE_SELL_STOP_LIMIT=7,
+      //--- enumeration borders
+      MARGIN_RATE_FIRST       =MARGIN_RATE_BUY,
+      MARGIN_RATE_LAST        =MARGIN_RATE_SELL_STOP_LIMIT
+     };
+   //--- Options Mode
+   enum EnOptionMode
+     {
+      OPTION_MODE_EUROPEAN_CALL=0,
+      OPTION_MODE_EUROPEAN_PUT =1,
+      OPTION_MODE_AMERICAN_CALL=2,
+      OPTION_MODE_AMERICAN_PUT =3,
+      //--- enumeration borders
+      OPTION_MODE_FIRST        =OPTION_MODE_EUROPEAN_CALL,
+      OPTION_MODE_LAST         =OPTION_MODE_AMERICAN_PUT
+     };
+   //--- Splice Type
+   enum EnSpliceType
+     {
+      SPLICE_NONE              =0,
+      SPLICE_UNADJUSTED        =1,
+      SPLICE_ADJUSTED          =2,
+      //--- enumeration borders
+      SPLICE_FIRST             =SPLICE_NONE,
+      SPLICE_LAST              =SPLICE_ADJUSTED
+     };
+   //--- Splice Time Type
+   enum EnSpliceTimeType
+     {
+      SPLICE_TIME_EXPIRATION   =0,
+      //--- enumeration borders
+      SPLICE_TIME_FIRST        =SPLICE_TIME_EXPIRATION,
+      SPLICE_TIME_LAST         =SPLICE_TIME_EXPIRATION
+     };
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTConSymbol* symbol)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- name
+   virtual LPCWSTR   Symbol(void) const=0;
+   virtual MTAPIRES  Symbol(LPCWSTR symbol)=0;
+   //--- hierarchical symbol path (including symbol name)
+   virtual LPCWSTR   Path(void) const=0;
+   virtual MTAPIRES  Path(LPCWSTR path)=0;
+   //--- ISIN
+   virtual LPCWSTR   ISIN(void) const=0;
+   virtual MTAPIRES  ISIN(LPCWSTR isin)=0;
+   //--- local description
+   virtual LPCWSTR   Description(void) const=0;
+   virtual MTAPIRES  Description(LPCWSTR descr)=0;
+   //--- internation description
+   virtual LPCWSTR   International(void) const=0;
+   virtual MTAPIRES  International(LPCWSTR intern)=0;
+   //--- basic symbol name
+   virtual LPCWSTR   Basis(void) const=0;
+   virtual MTAPIRES  Basis(LPCWSTR basis)=0;
+   //--- source symbol name
+   virtual LPCWSTR   Source(void) const=0;
+   virtual MTAPIRES  Source(LPCWSTR source)=0;
+   //--- symbol specification page URL
+   virtual LPCWSTR   Page(void) const=0;
+   virtual MTAPIRES  Page(LPCWSTR page)=0;
+   //--- symbol base currency
+   virtual LPCWSTR   CurrencyBase(void) const=0;
+   virtual MTAPIRES  CurrencyBase(LPCWSTR currency)=0;
+   virtual UINT      CurrencyBaseDigits(void) const=0;
+   //--- symbol profit currency
+   virtual LPCWSTR   CurrencyProfit(void) const=0;
+   virtual MTAPIRES  CurrencyProfit(LPCWSTR currency)=0;
+   virtual UINT      CurrencyProfitDigits(void) const=0;
+   //--- symbol margin currency
+   virtual LPCWSTR   CurrencyMargin(void) const=0;
+   virtual MTAPIRES  CurrencyMargin(LPCWSTR currency)=0;
+   virtual UINT      CurrencyMarginDigits(void) const=0;
+   //--- symbol color
+   virtual COLORREF  Color(void) const=0;
+   virtual MTAPIRES  Color(const COLORREF color)=0;
+   //--- symbol background color
+   virtual COLORREF  ColorBackground(void) const=0;
+   virtual MTAPIRES  ColorBackground(const COLORREF color)=0;
+   //--- symbol digits
+   virtual UINT      Digits(void) const=0;
+   virtual MTAPIRES  Digits(const UINT digits)=0;
+   //--- symbol digits derivation (1/10^digits & 10^digits)
+   virtual double    Point(void) const=0;
+   virtual double    Multiply(void) const=0;
+   //--- EnTickFlags
+   virtual UINT64    TickFlags(void) const=0;
+   virtual MTAPIRES  TickFlags(const UINT64 flags)=0;
+   //--- Depth of Market depth (both legs)
+   virtual UINT      TickBookDepth(void) const=0;
+   virtual MTAPIRES  TickBookDepth(const UINT depth)=0;
+   //--- filtration soft level
+   virtual UINT      FilterSoft(void) const=0;
+   virtual MTAPIRES  FilterSoft(const UINT filter)=0;
+   //--- filtration soft level counter
+   virtual UINT      FilterSoftTicks(void) const=0;
+   virtual MTAPIRES  FilterSoftTicks(const UINT ticks)=0;
+   //--- filtration hard level
+   virtual UINT      FilterHard(void) const=0;
+   virtual MTAPIRES  FilterHard(const UINT filter)=0;
+   //--- filtration hard level counter
+   virtual UINT      FilterHardTicks(void) const=0;
+   virtual MTAPIRES  FilterHardTicks(const UINT ticks)=0;
+   //--- filtration discard level
+   virtual UINT      FilterDiscard(void) const=0;
+   virtual MTAPIRES  FilterDiscard(const UINT ticks)=0;
+   //--- spread max value
+   virtual UINT      FilterSpreadMax(void) const=0;
+   virtual MTAPIRES  FilterSpreadMax(const UINT spread)=0;
+   //--- spread min value
+   virtual UINT      FilterSpreadMin(void) const=0;
+   virtual MTAPIRES  FilterSpreadMin(const UINT spread)=0;
+   //--- EnTradeMode
+   virtual UINT      TradeMode(void) const=0;
+   virtual MTAPIRES  TradeMode(const UINT mode)=0;
+   //--- EnCalcMode
+   virtual UINT      CalcMode(void) const=0;
+   virtual MTAPIRES  CalcMode(const UINT mode)=0;
+   //--- EnExecutionMode
+   virtual UINT      ExecMode(void) const=0;
+   virtual MTAPIRES  ExecMode(const UINT mode)=0;
+   //--- EnGTCMode
+   virtual UINT      GTCMode(void) const=0;
+   virtual MTAPIRES  GTCMode(const UINT mode)=0;
+   //--- EnFillingFlags
+   virtual UINT      FillFlags(void) const=0;
+   virtual MTAPIRES  FillFlags(const UINT flags)=0;
+   //--- EnExpirationFlags
+   virtual UINT      ExpirFlags(void) const=0;
+   virtual MTAPIRES  ExpirFlags(const UINT flags)=0;
+   //--- symbol spread (0-floating)
+   virtual UINT      Spread(void) const=0;
+   virtual MTAPIRES  Spread(const UINT spread)=0;
+   //--- spread balance
+   virtual INT       SpreadBalance(void) const=0;
+   virtual MTAPIRES  SpreadBalance(const INT spread)=0;
+   //--- spread difference
+   virtual INT       SpreadDiff(void) const=0;
+   virtual MTAPIRES  SpreadDiff(const INT diff)=0;
+   //--- spread difference balance
+   virtual INT       SpreadDiffBalance(void) const=0;
+   virtual MTAPIRES  SpreadDiffBalance(const INT spread)=0;
+   //--- tick value
+   virtual double    TickValue(void) const=0;
+   virtual MTAPIRES  TickValue(const double value)=0;
+   //--- tick size
+   virtual double    TickSize(void) const=0;
+   virtual MTAPIRES  TickSize(const double size)=0;
+   //--- contract size
+   virtual double    ContractSize(void) const=0;
+   virtual MTAPIRES  ContractSize(const double size)=0;
+   //--- stops level
+   virtual INT       StopsLevel(void) const=0;
+   virtual MTAPIRES  StopsLevel(const INT level)=0;
+   //--- freeze level
+   virtual INT       FreezeLevel(void) const=0;
+   virtual MTAPIRES  FreezeLevel(const INT level)=0;
+   //--- quotes timeout 
+   virtual UINT      QuotesTimeout(void) const=0;
+   virtual MTAPIRES  QuotesTimeout(const UINT timeout)=0;
+   //--- minimal volume
+   virtual UINT64    VolumeMin(void) const=0;
+   virtual MTAPIRES  VolumeMin(const UINT64 volume)=0;
+   //--- maximal volume
+   virtual UINT64    VolumeMax(void) const=0;
+   virtual MTAPIRES  VolumeMax(const UINT64 volume)=0;
+   //--- volume step
+   virtual UINT64    VolumeStep(void) const=0;
+   virtual MTAPIRES  VolumeStep(const UINT64 volume)=0;
+   //--- cumulative positions and orders limit
+   virtual UINT64    VolumeLimit(void) const=0;
+   virtual MTAPIRES  VolumeLimit(const UINT64 volume)=0;
+   //--- EnMarginFlags
+   virtual UINT      MarginFlags(void) const=0;
+   virtual MTAPIRES  MarginFlags(const UINT mode)=0;
+   //--- initial margin
+   virtual double    MarginInitial(void) const=0;
+   virtual MTAPIRES  MarginInitial(const double margin)=0;
+   //--- maintenance margin
+   virtual double    MarginMaintenance(void) const=0;
+   virtual MTAPIRES  MarginMaintenance(const double margin)=0;
+   //--- long orders and positions margin rate
+   virtual double    MarginLong(void) const=0;
+   virtual MTAPIRES  MarginLong(const double margin)=0;
+   //--- short orders and positions margin rate
+   virtual double    MarginShort(void) const=0;
+   virtual MTAPIRES  MarginShort(const double margin)=0;
+   //--- limit orders and positions margin rate
+   virtual double    MarginLimit(void) const=0;
+   virtual MTAPIRES  MarginLimit(const double margin)=0;
+   //--- stop orders and positions margin rate
+   virtual double    MarginStop(void) const=0;
+   virtual MTAPIRES  MarginStop(const double margin)=0;
+   //--- stop-limit orders and positions margin rate
+   virtual double    MarginStopLimit(void) const=0;
+   virtual MTAPIRES  MarginStopLimit(const double margin)=0;
+   //--- EnSwapMode
+   virtual UINT      SwapMode(void) const=0;
+   virtual MTAPIRES  SwapMode(const UINT mode)=0;
+   //--- long positions swaps rate
+   virtual double    SwapLong(void) const=0;
+   virtual MTAPIRES  SwapLong(const double swap)=0;
+   //--- short positions swaps rate
+   virtual double    SwapShort(void) const=0;
+   virtual MTAPIRES  SwapShort(const double swap)=0;
+   //--- 3 time swaps day, EnSwapDay
+   virtual UINT      Swap3Day(void) const=0;
+   virtual MTAPIRES  Swap3Day(const UINT day)=0;
+   //--- trade start date
+   virtual INT64     TimeStart(void) const=0;
+   virtual MTAPIRES  TimeStart(const INT64 start)=0;
+   //--- trade end date
+   virtual INT64     TimeExpiration(void) const=0;
+   virtual MTAPIRES  TimeExpiration(const INT64 expiration)=0;
+   //--- quote sessions
+   virtual MTAPIRES  SessionQuoteAdd(const UINT wday,IMTConSymbolSession* symbol)=0;
+   virtual MTAPIRES  SessionQuoteUpdate(const UINT wday,const UINT pos,const IMTConSymbolSession* session)=0;
+   virtual MTAPIRES  SessionQuoteDelete(const UINT wday,const UINT pos)=0;
+   virtual MTAPIRES  SessionQuoteClear(const UINT wday)=0;
+   virtual MTAPIRES  SessionQuoteShift(const UINT wday,const UINT pos,const int shift)=0;
+   virtual UINT      SessionQuoteTotal(const UINT wday) const=0;
+   virtual MTAPIRES  SessionQuoteNext(const UINT wday,const UINT pos,IMTConSymbolSession* session) const=0;
+   //--- trade sessions
+   virtual MTAPIRES  SessionTradeAdd(const UINT wday,IMTConSymbolSession* symbol)=0;
+   virtual MTAPIRES  SessionTradeUpdate(const UINT wday,const UINT pos,const IMTConSymbolSession* session)=0;
+   virtual MTAPIRES  SessionTradeDelete(const UINT wday,const UINT pos)=0;
+   virtual MTAPIRES  SessionTradeClear(const UINT wday)=0;
+   virtual MTAPIRES  SessionTradeShift(const UINT wday,const UINT pos,const int shift)=0;
+   virtual UINT      SessionTradeTotal(const UINT wday) const=0;
+   virtual MTAPIRES  SessionTradeNext(const UINT wday,const UINT pos,IMTConSymbolSession* session) const=0;
+   //--- request execution flags
+   virtual UINT      REFlags(void) const=0;
+   virtual MTAPIRES  REFlags(const UINT flags)=0;
+   //--- request execution timeout
+   virtual UINT      RETimeout(void) const=0;
+   virtual MTAPIRES  RETimeout(const UINT timeout)=0;
+   //--- instant execution check mode 
+   virtual UINT      IECheckMode(void) const=0;
+   virtual MTAPIRES  IECheckMode(const UINT mode)=0;
+   //--- instant execution timeout
+   virtual UINT      IETimeout(void) const=0;
+   virtual MTAPIRES  IETimeout(const UINT timeout)=0;
+   //--- instant execution profit slippage
+   virtual UINT      IESlipProfit(void) const=0;
+   virtual MTAPIRES  IESlipProfit(const UINT slippage)=0;
+   //--- instant execution losing slippage
+   virtual UINT      IESlipLosing(void) const=0;
+   virtual MTAPIRES  IESlipLosing(const UINT slippage)=0;
+   //--- instant execution max volume
+   virtual UINT64    IEVolumeMax(void) const=0;
+   virtual MTAPIRES  IEVolumeMax(const UINT64 volume)=0;
+   //--- settle price (for futures)
+   virtual double    PriceSettle(void) const=0;
+   virtual MTAPIRES  PriceSettle(const double price)=0;
+   //--- price limit max (for futures)
+   virtual double    PriceLimitMax(void) const=0;
+   virtual MTAPIRES  PriceLimitMax(const double price)=0;
+   //--- price limit min (for futures)
+   virtual double    PriceLimitMin(void) const=0;
+   virtual MTAPIRES  PriceLimitMin(const double price)=0;
+   //--- EnTradeFlags
+   virtual UINT64    TradeFlags(void) const=0;
+   virtual MTAPIRES  TradeFlags(const UINT64 flags)=0;
+   //--- EnOrderFlags
+   virtual UINT      OrderFlags(void) const=0;
+   virtual MTAPIRES  OrderFlags(const UINT flags)=0;
+   //--- orders and positions margin rates
+   virtual double    MarginRateInitial(const UINT type) const=0;
+   virtual MTAPIRES  MarginRateInitial(const UINT type,const double margin_rate)=0;
+   //--- orders and positions margin rates
+   virtual double    MarginRateMaintenance(const UINT type) const=0;
+   virtual MTAPIRES  MarginRateMaintenance(const UINT type,const double margin_rate)=0;
+   //--- options mode EnOptionMode
+   virtual UINT      OptionsMode(void) const=0;
+   virtual MTAPIRES  OptionsMode(const UINT mode)=0;
+   //--- option strike price value
+   virtual double    PriceStrike(void) const=0;
+   virtual MTAPIRES  PriceStrike(const double price)=0;
+   //--- liqudity rate
+   virtual double    MarginRateLiqudity(void) const=0;
+   virtual MTAPIRES  MarginRateLiqudity(const double margin_rate)=0;
+   //--- bond face value
+   virtual double    FaceValue(void) const=0;
+   virtual MTAPIRES  FaceValue(const double value)=0;
+   //--- bond accrued interest
+   virtual double    AccruedInterest(void) const=0;
+   virtual MTAPIRES  AccruedInterest(const double interest)=0;
+   //--- futures splice type EnSpliceType
+   virtual UINT      SpliceType(void) const=0;
+   virtual MTAPIRES  SpliceType(const UINT type)=0;
+   //--- futures splice time type EnSpliceType
+   virtual UINT      SpliceTimeType(void) const=0;
+   virtual MTAPIRES  SpliceTimeType(const UINT time_type)=0;
+   //--- options splice point in days
+   virtual UINT      SpliceTimeDays(void) const=0;
+   virtual MTAPIRES  SpliceTimeDays(const UINT days)=0;
+   //--- hedged positions margin rate
+   virtual double    MarginHedged(void) const=0;
+   virtual MTAPIRES  MarginHedged(const double margin)=0;
+   //--- currency rate
+   virtual double    MarginRateCurrency(void) const=0;
+   virtual MTAPIRES  MarginRateCurrency(const double margin_rate)=0;
+   //--- gap level
+   virtual UINT      FilterGap(void) const=0;
+   virtual MTAPIRES  FilterGap(const UINT gap)=0;
+   //--- gap level ticks
+   virtual UINT      FilterGapTicks(void) const=0;
+   virtual MTAPIRES  FilterGapTicks(const UINT ticks)=0;
+   //--- chart mode
+   virtual UINT      ChartMode(void) const=0;
+   virtual MTAPIRES  ChartMode(const UINT mode)=0;
+   //---  currency digits
+   virtual MTAPIRES  CurrencyBaseDigitsSet(const UINT digits)=0;
+   virtual MTAPIRES  CurrencyProfitDigitsSet(const UINT digits)=0;
+   virtual MTAPIRES  CurrencyMarginDigitsSet(const UINT digits)=0;
+   //--- instant execution flags with extended accuracy
+   virtual UINT      IEFlags(void) const=0;
+   virtual MTAPIRES  IEFlags(const UINT flags)=0;
+   //--- minimal volume with extended accuracy
+   virtual UINT64    VolumeMinExt(void) const=0;
+   virtual MTAPIRES  VolumeMinExt(const UINT64 volume)=0;
+   //--- maximal volume with extended accuracy
+   virtual UINT64    VolumeMaxExt(void) const=0;
+   virtual MTAPIRES  VolumeMaxExt(const UINT64 volume)=0;
+   //--- volume step with extended accuracy
+   virtual UINT64    VolumeStepExt(void) const=0;
+   virtual MTAPIRES  VolumeStepExt(const UINT64 volume)=0;
+   //--- cumulative positions and orders limit with extended accuracy
+   virtual UINT64    VolumeLimitExt(void) const=0;
+   virtual MTAPIRES  VolumeLimitExt(const UINT64 volume)=0;
+   //--- instant execution max volume with extended accuracy
+   virtual UINT64    IEVolumeMaxExt(void) const=0;
+   virtual MTAPIRES  IEVolumeMaxExt(const UINT64 volume)=0;
+   //--- category
+   virtual LPCWSTR   Category(void) const=0;
+   virtual MTAPIRES  Category(LPCWSTR category)=0;
+   //--- exchange
+   virtual LPCWSTR   Exchange(void) const=0;
+   virtual MTAPIRES  Exchange(LPCWSTR exchange)=0;
+   //--- CFI
+   virtual LPCWSTR   CFI(void) const=0;
+   virtual MTAPIRES  CFI(LPCWSTR cfi)=0;
+  };
+//+------------------------------------------------------------------+
+//| Symbol config events notification interface                      |
+//+------------------------------------------------------------------+
+class IMTConSymbolSink
+  {
+public:
+   virtual void      OnSymbolAdd(const IMTConSymbol*    /*config*/) {  }
+   virtual void      OnSymbolUpdate(const IMTConSymbol* /*config*/) {  }
+   virtual void      OnSymbolDelete(const IMTConSymbol* /*config*/) {  }
+   virtual void      OnSymbolSync(void)                             {  }
+  };
+//+------------------------------------------------------------------+

+ 50 - 0
MT5SDK/Config/MT5APIConfigTime.h

@@ -0,0 +1,50 @@
+//+------------------------------------------------------------------+
+//|                                                 MetaTrader 5 API |
+//|                   Copyright 2000-2019, MetaQuotes Software Corp. |
+//|                                        http://www.metaquotes.net |
+//+------------------------------------------------------------------+
+#pragma once
+//+------------------------------------------------------------------+
+//| Time configuration                                               |
+//+------------------------------------------------------------------+
+class IMTConTime
+  {
+public:
+   //--- day working mode
+   enum EnTimeTableMode
+     {
+      TIME_MODE_DISABLED=0,   // work enabled
+      TIME_MODE_ENABLED =1,   // work disabled
+      //---
+      TIME_MODE_FIRST   =TIME_MODE_DISABLED,
+      TIME_MODE_LAST    =TIME_MODE_ENABLED
+     };
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(IMTConTime* param)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- daylight correction mode
+   virtual bool      Daylight(void) const=0;
+   virtual MTAPIRES  Daylight(const bool enable)=0;
+   //--- server timezone in minutes (0=GMT;-60=GMT-1;60=GMT+1)
+   virtual int       TimeZone(void) const=0;
+   virtual MTAPIRES  TimeZone(const int zone)=0;
+   //--- time synchronization server address (TIME or NTP protocol)
+   virtual LPCWSTR   TimeServer(void) const=0;
+   virtual MTAPIRES  TimeServer(LPCWSTR server)=0;
+   //--- time schedule (wday -> 0-Sunday,6-Saturday, hour-> 0-24, mode-> EnTimeTableMode)
+   virtual MTAPIRES  TimeTableGet(const UINT wday,const UINT hour,UINT& mode) const=0;
+   virtual MTAPIRES  TimeTableSet(const UINT wday,const UINT hour,const UINT mode)=0;
+   //--- current daylight state
+   virtual int       DaylightState(void) const=0;
+  };
+//+------------------------------------------------------------------+
+//| Time config events notification interface                        |
+//+------------------------------------------------------------------+
+class IMTConTimeSink
+  {
+public:
+   virtual void      OnTimeUpdate(const IMTConTime* /*config*/) {  }
+   virtual void      OnTimeSync(void)                           {  }
+  };
+//+------------------------------------------------------------------+

+ 173 - 0
MT5SDK/MT5APIConstants.h

@@ -0,0 +1,173 @@
+//+------------------------------------------------------------------+
+//|                                                 MetaTrader 5 API |
+//|                   Copyright 2000-2019, MetaQuotes Software Corp. |
+//|                                        http://www.metaquotes.net |
+//+------------------------------------------------------------------+
+#pragma once
+#include "MT5APITypes.h"
+//+------------------------------------------------------------------+
+//| MetaTrader 5 API return codes                                    |
+//+------------------------------------------------------------------+
+enum EnMTAPIRetcode
+  {
+//--- successfully codes
+   MT_RET_OK                    =0,       // ok
+   MT_RET_OK_NONE               =1,       // ok, no data
+//--- common errors
+   MT_RET_ERROR                 =2,       // Common error
+   MT_RET_ERR_PARAMS            =3,       // Invalid parameters
+   MT_RET_ERR_DATA              =4,       // Invalid data
+   MT_RET_ERR_DISK              =5,       // Disk error
+   MT_RET_ERR_MEM               =6,       // Memory error
+   MT_RET_ERR_NETWORK           =7,       // Network error
+   MT_RET_ERR_PERMISSIONS       =8,       // Not enough permissions
+   MT_RET_ERR_TIMEOUT           =9,       // Operation timeout
+   MT_RET_ERR_CONNECTION        =10,      // No connection
+   MT_RET_ERR_NOSERVICE         =11,      // Service is not available
+   MT_RET_ERR_FREQUENT          =12,      // Too frequent requests
+   MT_RET_ERR_NOTFOUND          =13,      // Not found
+   MT_RET_ERR_PARTIAL           =14,      // Partial error
+   MT_RET_ERR_SHUTDOWN          =15,      // Server shutdown in progress
+   MT_RET_ERR_CANCEL            =16,      // Operation has been canceled
+   MT_RET_ERR_DUPLICATE         =17,      // Duplicate data
+//--- authentication retcodes
+   MT_RET_AUTH_CLIENT_INVALID   =1000,    // Invalid terminal type
+   MT_RET_AUTH_ACCOUNT_INVALID  =1001,    // Invalid account
+   MT_RET_AUTH_ACCOUNT_DISABLED =1002,    // Account disabled
+   MT_RET_AUTH_ADVANCED         =1003,    // Advanced authorization necessary
+   MT_RET_AUTH_CERTIFICATE      =1004,    // Certificate required
+   MT_RET_AUTH_CERTIFICATE_BAD  =1005,    // Invalid certificate
+   MT_RET_AUTH_NOTCONFIRMED     =1006,    // Certificate is not confirmed
+   MT_RET_AUTH_SERVER_INTERNAL  =1007,    // Attempt to connect to non-access server
+   MT_RET_AUTH_SERVER_BAD       =1008,    // Server isn't authenticated 
+   MT_RET_AUTH_UPDATE_ONLY      =1009,    // Only updates available
+   MT_RET_AUTH_CLIENT_OLD       =1010,    // Client has old version
+   MT_RET_AUTH_MANAGER_NOCONFIG =1011,    // Manager account doesn't have manager config
+   MT_RET_AUTH_MANAGER_IPBLOCK  =1012,    // IP address unallowed for manager
+   MT_RET_AUTH_GROUP_INVALID    =1013,    // Group is not initialized (server restart neccesary)
+   MT_RET_AUTH_CA_DISABLED      =1014,    // Certificate generation disabled
+   MT_RET_AUTH_INVALID_ID       =1015,    // Invalid or disabled server id [check server's id]
+   MT_RET_AUTH_INVALID_IP       =1016,    // Unallowed address [check server's ip address]
+   MT_RET_AUTH_INVALID_TYPE     =1017,    // Invalid server type [check server's id and type]
+   MT_RET_AUTH_SERVER_BUSY      =1018,    // Server is busy
+   MT_RET_AUTH_SERVER_CERT      =1019,    // Invalid server certificate
+   MT_RET_AUTH_ACCOUNT_UNKNOWN  =1020,    // Unknown account
+   MT_RET_AUTH_SERVER_OLD       =1021,    // Old server version
+   MT_RET_AUTH_SERVER_LIMIT     =1022,    // Server cannot be connected due to license limitation
+   MT_RET_AUTH_MOBILE_DISABLED  =1023,    // Mobile connection aren't allowed in server license
+   MT_RET_AUTH_MANAGER_TYPE     =1024,    // Connection type is not permitted for manager
+   MT_RET_AUTH_DEMO_DISABLED    =1025,    // Demo allocation disabled
+   MT_RET_AUTH_RESET_PASSWORD   =1026,    // Master password must be changed
+//--- config management retcodes
+   MT_RET_CFG_LAST_ADMIN        =2000,    // Last admin config deleting
+   MT_RET_CFG_LAST_ADMIN_GROUP  =2001,    // Last admin group cannot be deleted
+   MT_RET_CFG_NOT_EMPTY         =2003,    // Accounts or trades in group/symbol
+   MT_RET_CFG_INVALID_RANGE     =2004,    // Invalid accounts or trades ranges
+   MT_RET_CFG_NOT_MANAGER_LOGIN =2005,    // Manager account is not from manager group
+   MT_RET_CFG_BUILTIN           =2006,    // Built-in protected config
+   MT_RET_CFG_DUPLICATE         =2007,    // Configuration duplicate
+   MT_RET_CFG_LIMIT_REACHED     =2008,    // Configuration limit reached
+   MT_RET_CFG_NO_ACCESS_TO_MAIN =2009,    // Invalid network configuration
+   MT_RET_CFG_DEALER_ID_EXIST   =2010,    // Dealer with same ID exists
+   MT_RET_CFG_BIND_ADDR_EXIST   =2011,    // Bind address already exists
+   MT_RET_CFG_WORKING_TRADE     =2012,    // Attempt to delete working trade server
+   MT_RET_CFG_GATEWAY_NAME_EXIST=2013,    // Gateway with same name exists
+   MT_RET_CFG_SWITCH_TO_BACKUP  =2014,    // Server must be switched to backup mode
+   MT_RET_CFG_NO_BACKUP_MODULE  =2015,    // Backup server module is absent
+   MT_RET_CFG_NO_TRADE_MODULE   =2016,    // Trade server module is absent
+   MT_RET_CFG_NO_HISTORY_MODULE =2017,    // History server module is absent
+   MT_RET_CFG_ANOTHER_SWITCH    =2018,    // Another switching process in progress
+   MT_RET_CFG_NO_LICENSE_FILE    =2019,   // License file is absent
+   MT_RET_CFG_GATEWAY_LOGIN_EXIST=2020,   // Gateway with same login already exist
+//--- client management retcodes
+   MT_RET_USR_LAST_ADMIN        =3001,    // Last admin account deleting
+   MT_RET_USR_LOGIN_EXHAUSTED   =3002,    // Logins range exhausted
+   MT_RET_USR_LOGIN_PROHIBITED  =3003,    // Login reserved at another server
+   MT_RET_USR_LOGIN_EXIST       =3004,    // Account already exists
+   MT_RET_USR_SUICIDE           =3005,    // Attempt of self-deletion
+   MT_RET_USR_INVALID_PASSWORD  =3006,    // Invalid account password
+   MT_RET_USR_LIMIT_REACHED     =3007,    // Users limit reached
+   MT_RET_USR_HAS_TRADES        =3008,    // Account has open trades
+   MT_RET_USR_DIFFERENT_SERVERS =3009,    // Attempt to move account to different server
+   MT_RET_USR_DIFFERENT_CURRENCY=3010,    // Attempt to move account to different currency group
+   MT_RET_USR_IMPORT_BALANCE    =3011,    // Account balance import error
+   MT_RET_USR_IMPORT_GROUP      =3012,    // Account import with invalid group
+   MT_RET_USR_ACCOUNT_EXIST     =3013,    // Account already exist
+//--- trades management retcodes
+   MT_RET_TRADE_LIMIT_REACHED   =4001,    // Orders or deals limit reached
+   MT_RET_TRADE_ORDER_EXIST     =4002,    // Order already exists
+   MT_RET_TRADE_ORDER_EXHAUSTED =4003,    // Orders range exhausted
+   MT_RET_TRADE_DEAL_EXHAUSTED  =4004,    // Deals range exhausted
+   MT_RET_TRADE_MAX_MONEY       =4005,    // Money limit reached
+   MT_RET_TRADE_DEAL_EXIST      =4006,    // Deal already exists
+   MT_RET_TRADE_ORDER_PROHIBITED=4007,    // Order ticket reserved at another server
+   MT_RET_TRADE_DEAL_PROHIBITED =4008,    // Deal ticket reserved at another server
+//--- report generation retcodes
+   MT_RET_REPORT_SNAPSHOT       =5001,    // Base snapshot error
+   MT_RET_REPORT_NOTSUPPORTED   =5002,    // Method doesn't support for this report
+   MT_RET_REPORT_NODATA         =5003,    // No report data
+   MT_RET_REPORT_TEMPLATE_BAD   =5004,    // Bad template
+   MT_RET_REPORT_TEMPLATE_END   =5005,    // End of template (template success processed)
+   MT_RET_REPORT_INVALID_ROW    =5006,    // Invalid row size
+   MT_RET_REPORT_LIMIT_REPEAT   =5007,    // Tag repeat limit reached
+   MT_RET_REPORT_LIMIT_REPORT   =5008,    // Report size limit reached
+//--- price history reports retcodes
+   MT_RET_HST_SYMBOL_NOTFOUND   =6001,    // Symbol not found, try to restart history server
+//--- trade request retcodes
+   MT_RET_REQUEST_INWAY         =10001,   // Request on the way
+   MT_RET_REQUEST_ACCEPTED      =10002,   // Request accepted
+   MT_RET_REQUEST_PROCESS       =10003,   // Request processed
+   MT_RET_REQUEST_REQUOTE       =10004,   // Request Requoted
+   MT_RET_REQUEST_PRICES        =10005,   // Request Prices
+   MT_RET_REQUEST_REJECT        =10006,   // Request rejected
+   MT_RET_REQUEST_CANCEL        =10007,   // Request canceled
+   MT_RET_REQUEST_PLACED        =10008,   // Order from requestplaced
+   MT_RET_REQUEST_DONE          =10009,   // Request executed
+   MT_RET_REQUEST_DONE_PARTIAL  =10010,   // Request executed partially
+   MT_RET_REQUEST_ERROR         =10011,   // Request common error
+   MT_RET_REQUEST_TIMEOUT       =10012,   // Request timeout
+   MT_RET_REQUEST_INVALID       =10013,   // Invalid request
+   MT_RET_REQUEST_INVALID_VOLUME=10014,   // Invalid volume
+   MT_RET_REQUEST_INVALID_PRICE =10015,   // Invalid price
+   MT_RET_REQUEST_INVALID_STOPS =10016,   // Invalid stops or price
+   MT_RET_REQUEST_TRADE_DISABLED=10017,   // Trade disabled
+   MT_RET_REQUEST_MARKET_CLOSED =10018,   // Market closed
+   MT_RET_REQUEST_NO_MONEY      =10019,   // Not enough money
+   MT_RET_REQUEST_PRICE_CHANGED =10020,   // Price changed
+   MT_RET_REQUEST_PRICE_OFF     =10021,   // No prices
+   MT_RET_REQUEST_INVALID_EXP   =10022,   // Invalid order expiration
+   MT_RET_REQUEST_ORDER_CHANGED =10023,   // Order has been changed already
+   MT_RET_REQUEST_TOO_MANY      =10024,   // Too many trade requests
+   MT_RET_REQUEST_NO_CHANGES    =10025,   // Request doesn't contain changes
+   MT_RET_REQUEST_AT_DISABLED_SERVER=10026, // AutoTrading disabled by server
+   MT_RET_REQUEST_AT_DISABLED_CLIENT=10027, // AutoTrading disabled by client
+   MT_RET_REQUEST_LOCKED        =10028,     // Request locked by dealer
+   MT_RET_REQUEST_FROZEN        =10029,     // Order or position frozen
+   MT_RET_REQUEST_INVALID_FILL  =10030,     // Unsupported filling mode
+   MT_RET_REQUEST_CONNECTION    =10031,     // No connection
+   MT_RET_REQUEST_ONLY_REAL     =10032,     // Allowed for real accounts only
+   MT_RET_REQUEST_LIMIT_ORDERS  =10033,     // Orders limit reached
+   MT_RET_REQUEST_LIMIT_VOLUME  =10034,     // Volume limit reached
+   MT_RET_REQUEST_INVALID_ORDER =10035,     // Invalid or prohibited order type
+   MT_RET_REQUEST_POSITION_CLOSED=10036,    // Position doesn't exist
+   MT_RET_REQUEST_EXECUTION_SKIPPED   =10037,  // Execution doesn't belong to this server
+   MT_RET_REQUEST_INVALID_CLOSE_VOLUME=10038,  // Volume to be closed exceeds the position volume
+   MT_RET_REQUEST_CLOSE_ORDER_EXIST   =10039,  // Order to close this position already exists
+   MT_RET_REQUEST_LIMIT_POSITIONS=10040,    // Positions limit reached
+   MT_RET_REQUEST_REJECT_CANCEL  =10041,    // Request rejected, order will be canceled
+   MT_RET_REQUEST_LONG_ONLY      =10042,    // Only long positions are allowed
+   MT_RET_REQUEST_SHORT_ONLY     =10043,    // Only short positions are allowed
+   MT_RET_REQUEST_CLOSE_ONLY     =10044,    // Only position closing is allowed
+   MT_RET_REQUEST_PROHIBITED_BY_FIFO=10045, // Position close prohibited by FIFO rule
+//--- dealer retcodes
+   MT_RET_REQUEST_RETURN        =11000,     // Request returned in queue
+   MT_RET_REQUEST_DONE_CANCEL   =11001,     // Request partially filled, remainder has been canceled
+   MT_RET_REQUEST_REQUOTE_RETURN=11002,     // Request requoted and returned in queue with new prices
+//--- API retcodes
+   MT_RET_ERR_NOTIMPLEMENT      =12000,     // Not implement yet
+   MT_RET_ERR_NOTMAIN           =12001,     // Operation must be performed on main server
+   MT_RET_ERR_NOTSUPPORTED      =12002,     // Command doesn't supported
+   MT_RET_ERR_DEADLOCK          =12003,     // Operation canceled due possible deadlock
+   MT_RET_ERR_LOCKED            =12004      // Operation on locked entity
+  };
+//+------------------------------------------------------------------+

+ 687 - 0
MT5SDK/MT5APIGateway.h

@@ -0,0 +1,687 @@
+//+------------------------------------------------------------------+
+//|                                         MetaTrader 5 API Gateway |
+//|                   Copyright 2000-2019, MetaQuotes Software Corp. |
+//|                                        http://www.metaquotes.net |
+//+------------------------------------------------------------------+
+#pragma once
+#include <wincrypt.h>
+#include "MT5APIConstants.h"
+#include "MT5APITools.h"
+#include "MT5APILogger.h"
+#include "MT5APIPublicKey.h"
+#include "Config\MT5APIConfigFeeder.h"
+#include "Config\MT5APIConfigGateway.h"
+#include "Config\MT5APIConfigSymbol.h"
+#include "Config\MT5APIConfigGroup.h"
+#include "Config\MT5APIConfigNetwork.h"
+#include "Config\MT5APIConfigTime.h"
+#include "Config\MT5APIConfigSpread.h"
+#include "Bases\MT5APIAccount.h"
+#include "Bases\MT5APIBook.h"
+#include "Bases\MT5APIConfirm.h"
+#include "Bases\MT5APIExecution.h"
+#include "Bases\MT5APIMail.h"
+#include "Bases\MT5APIOrder.h"
+#include "Bases\MT5APIPosition.h"
+#include "Bases\MT5APIRequest.h"
+#include "Bases\MT5APITick.h"
+#include "Bases\MT5APIUser.h"
+#include "Bases\MT5APIChart.h"
+//+------------------------------------------------------------------+
+//| Include necessary library                                        |
+//+------------------------------------------------------------------+
+#pragma comment(lib,"advapi32.lib")
+//+------------------------------------------------------------------+
+//| Gateway API version                                              |
+//+------------------------------------------------------------------+
+#define MTGatewayAPIVersion  2190
+#define MTGatewayAPIDate     L"18 Oct 2019"
+//+------------------------------------------------------------------+
+//| Gateway description info                                         |
+//+------------------------------------------------------------------+
+#pragma pack(push,1)
+struct MTGatewayInfo
+  {
+   //--- gateway modes flags
+   enum EnModes
+     {
+      GATEWAY_MODE_QUOTES     =1,                           // receive quotes
+      GATEWAY_MODE_NEWS       =2,                           // receive news
+      GATEWAY_MODE_POSITIONS  =4,                           // gateway can process requests of trade positions
+      //--- enumeration borders
+      GATEWAY_MODE_NONE       =0,
+      GATEWAY_MODE_ALL        =GATEWAY_MODE_QUOTES|GATEWAY_MODE_NEWS|GATEWAY_MODE_POSITIONS
+     };
+   //--- necessary fields flags
+   enum EnFields
+     {
+      GATEWAY_FIELD_SERVER    =1,                           // server field
+      GATEWAY_FIELD_LOGIN     =2,                           // login field
+      GATEWAY_FIELD_PASSWORD  =4,                           // password field
+      GATEWAY_FIELD_PARAMS    =8,                           // parameters
+      //--- enumeration borders
+      GATEWAY_FIELD_NONE      =0,
+      GATEWAY_FIELD_ALL       =GATEWAY_FIELD_SERVER|GATEWAY_FIELD_LOGIN|GATEWAY_FIELD_PASSWORD|GATEWAY_FIELD_PARAMS
+     };
+   //--- data
+   UINT              version;                               // gateway version
+   UINT              version_api;                           // gateway API version
+   wchar_t           name_default[128];                     // gateway default name
+   wchar_t           copyright[128];                        // copyright
+   wchar_t           server_default[128];                   // default dataserver address:port
+   wchar_t           login_default[64];                     // gateway default login
+   wchar_t           password_default[64];                  // gateway default password
+   wchar_t           parameters_default[512];               // additional parameters
+   UINT              mode;                                  // EnModes
+   UINT              fields;                                // EnFields
+   wchar_t           description[512];                      // description
+   wchar_t           module_id[16];                         // gateway module id
+   wchar_t           build_date[16];                        // datafeed\gateway build date
+   wchar_t           build_api_date[16];                    // Gateway API build date
+   UINT              reserved[32];                          // reserved
+  };
+#pragma pack(pop)
+//+------------------------------------------------------------------+
+//| News structure                                                   |
+//+------------------------------------------------------------------+
+#pragma pack(push,1)
+struct MTNews
+  {
+   //--- constants
+   enum constants
+     {
+      MAX_NEWS_BODY_LEN=15*1024*1024                        // max. body len
+     };
+   //--- news topic flags
+   enum EnNewsFlags
+     {
+      FLAG_PRIORITY    =1,                                  // priority flag
+      FLAG_CALENDAR    =2,                                  // calendar item flag
+      FLAG_MIME        =4,                                  // MIME content flag
+      FLAG_ALLOW_DEMO  =8                                   // allow news body for 'topic only' accounts
+     };
+   UINT              language;                              // news language (WinAPI LANGID)
+   wchar_t           subject[256];                          // news subject
+   wchar_t           category[256];                         // news category
+   UINT              flags;                                 // EnNewsFlags
+   wchar_t          *body;                                  // body
+   UINT              body_len;                              // body length
+   UINT              languages_list[32];                    // list of languages available for news
+   INT64             datetime;                              // datetime
+   UINT              reserved[30];                          // reserved
+  };
+#pragma pack(pop)
+//+------------------------------------------------------------------+
+//| Economic event structure                                         |
+//+------------------------------------------------------------------+
+#pragma pack(push,1)
+struct MTEconomicEvent
+  {
+   //--- news topic flags
+   enum EnEconomicEventPriority
+     {
+      PRIORITY_LOW     =0,                                  // low priority of event
+      PRIORITY_NORMAL  =1,                                  // normal priority of event
+      PRIORITY_HIGH    =2                                   // high priority of event
+     };
+   INT64             eventtime;                             // event time
+   wchar_t           name[128];                             // event name
+   wchar_t           currency[32];                          // event currency
+   UINT              priority;                              // event priority
+   wchar_t           period[128];                           // event period
+   wchar_t           val_previous[32];                      // event previous value
+   wchar_t           val_forecast[32];                      // event forecast value
+   wchar_t           val_actual[32];                        // event actual value
+   UINT              language;                              // news language (WinAPI LANGID)
+   UINT              languages_list[32];                    // list of languages available for news
+   UINT              reserved[31];                          // reserved
+  };
+#pragma pack(pop)
+//+------------------------------------------------------------------+
+//| Gateway events notification interface                            |
+//+------------------------------------------------------------------+
+class IMTGatewaySink
+  {
+
+public:
+   //--- connection type
+   enum EnConnectType
+     {
+      CONNECT_TYPE_TRADE   =1,   // Trade server
+      CONNECT_TYPE_HISTORY =2,   // History server
+      CONNECT_TYPE_ECN     =3,   // ECN
+      CONNECT_TYPE_BACKUP  =4,   // Backup server
+     };
+
+public:
+   //--- MetaTrader Server's connection events and hooks
+   virtual MTAPIRES  HookServerConnect(LPCWSTR       /*address*/,
+                                       const UINT    /*type*/,
+                                       const UINT64  /*login*/)        { return(MT_RET_OK);               }
+   virtual void      OnServerDisconnect(LPCWSTR      /*address*/,
+                                        const UINT   /*type*/,
+                                        const UINT64 /*login*/)        {  }
+   //--- gateway events
+   virtual void      OnGatewayConfig(const UINT64 /*login*/,const IMTConGateway* /*config*/) {  }
+   virtual void      OnGatewayConfig(const UINT64 /*login*/,const IMTConFeeder*  /*config*/) {  }
+   virtual void      OnGatewayStart(void)                              {  }
+   virtual void      OnGatewayStop(void)                               {  }
+   virtual void      OnGatewayShutdown(const UINT64 /*login*/)         {  }
+   //--- asynchronous methods notifications
+   //--- DealerLock result notification
+   virtual void      OnDealerLock(const MTAPIRES     /*retcode*/,
+                                  const IMTRequest*  /*request*/,
+                                  const IMTUser*     /*user*/,
+                                  const IMTAccount*  /*account*/,
+                                  const IMTOrder*    /*order*/,
+                                  const IMTPosition* /*position*/)     {  }
+   //--- DealerAnswer result notification
+   virtual void      OnDealerAnswer(const MTAPIRES      /*retcode*/,
+                                    const IMTConfirm*   /*confirm*/)   {  }
+   virtual void      OnDealerAnswer(const UINT64        /*login*/,
+                                    const MTAPIRES      /*retcode*/,
+                                    const IMTExecution* /*execution*/) {  }
+   //--- external trading system positions control hooks
+   virtual MTAPIRES  HookGatewayPositionsRequest(void)                              { return(MT_RET_ERR_NOTIMPLEMENT); }
+   virtual MTAPIRES  HookGatewayPositionsCheck(void)                                { return(MT_RET_ERR_NOTIMPLEMENT); }
+   virtual MTAPIRES  HookGatewayOrdersRequest(void)                                 { return(MT_RET_ERR_NOTIMPLEMENT); }
+   virtual MTAPIRES  HookGatewayAccountRequest(UINT64 /*login*/,
+                                               LPCWSTR      /*account_id*/)         { return(MT_RET_ERR_NOTIMPLEMENT); }
+   virtual void      OnGatewayAccountAnswer(const MTAPIRES           /*retcode*/,
+                                            const INT64              /*request_id*/,
+                                            const IMTUser*           /*user*/,
+                                            const IMTAccount*        /*account*/,
+                                            const IMTOrderArray*     /*orders*/,
+                                            const IMTPositionArray*  /*positions*/) {  }
+   virtual void      OnGatewayAccountSet(const MTAPIRES           /*retcode*/,
+                                         const INT64              /*request_id*/,
+                                         const IMTUser*           /*user*/,
+                                         const IMTAccount*        /*account*/,
+                                         const IMTOrderArray*     /*orders*/,
+                                         const IMTPositionArray*  /*positions*/) {  }
+   //--- quotes symbols changes
+   virtual void      OnServerSymbolAdd(LPCWSTR /*symbol*/)     {  }
+   virtual void      OnServerSymbolDelete(LPCWSTR /*symbol*/)  {  }
+   //--- MetaTrader Server's synchronization event
+   virtual void      OnServerSynchronized(LPCWSTR      /*address*/,
+                                          const UINT   /*type*/,
+                                          const UINT64 /*id*/) {  }
+  };
+//+------------------------------------------------------------------+
+//| Gateway API interface                                            |
+//+------------------------------------------------------------------+
+class IMTGatewayAPI
+  {
+public:
+   //--- dealer flags
+   enum EnDealerRequestFlags
+     {
+      DEALER_FLAG_NONE                 =0x00000000,                    // zero flags
+      DEALER_FLAG_AUTOLOCK             =0x00000001,                    // automatically lock new requests from request queue
+      DEALER_FLAG_USER                 =0x00000002,                    // get IMTUser data on each request
+      DEALER_FLAG_ACCOUNT              =0x00000004,                    // get IMTAccount data on each request
+      DEALER_FLAG_ORDER                =0x00000008,                    // get IMTOrder data on each request
+      DEALER_FLAG_POSITION             =0x00000010,                    // get IMTPosition data on each request
+      DEALER_FLAG_EXTERNAL_ACC         =0x00000020,                    // fill ExternalAccount field on each request
+      DEALER_FLAG_MARKUP_TRADES        =0x00000040                     // allow modify trading prices according to markup settings
+     };
+   //--- interface release
+   virtual void      Release(void)=0;
+   //--- gateway license check
+   virtual MTAPIRES  LicenseCheck(MTLicenseCheck &check)=0;
+   //--- gateway server start-stop
+   virtual MTAPIRES  Start(IMTGatewaySink *sink,LPCWSTR address=NULL)=0;
+   virtual MTAPIRES  Stop(void)=0;
+   //--- gateway external connection state
+   virtual MTAPIRES  StateConnect(const UINT state)=0;
+   virtual MTAPIRES  StateTraffic(const UINT received_bytes,const UINT sent_bytes)=0;
+   virtual MTAPIRES  StateReserved1(void)=0;
+   virtual MTAPIRES  StateReserved2(void)=0;
+   virtual MTAPIRES  StateReserved3(void)=0;
+   virtual MTAPIRES  StateReserved4(void)=0;
+   //--- client connection management
+   virtual MTAPIRES  ClientAdd(const UINT64 login,LPCWSTR password)=0;
+   virtual MTAPIRES  ClientAllowIP(LPCWSTR address)=0;
+   virtual MTAPIRES  ClientReserved1(void)=0;
+   virtual MTAPIRES  ClientReserved2(void)=0;
+   virtual MTAPIRES  ClientReserved3(void)=0;
+   virtual MTAPIRES  ClientReserved4(void)=0;
+   //--- gateway server data access
+   virtual MTAPIRES  ServerIP(MTAPISTR &ip)=0;
+   virtual UINT      ServerPort(void)=0;
+   virtual UINT      ServerConnections(void)=0;
+   virtual MTAPIRES  ServerReserved1(void)=0;
+   virtual MTAPIRES  ServerReserved2(void)=0;
+   virtual MTAPIRES  ServerReserved3(void)=0;
+   virtual MTAPIRES  ServerReserved4(void)=0;
+   //--- log functions
+   virtual MTAPIRES  LoggerOut(const UINT code,LPCWSTR format,...)=0;
+   virtual void      LoggerFlush(void)=0;
+   virtual LPCWSTR   LoggerPath(MTAPISTR& ip)=0;
+   virtual MTAPIRES  LoggerReserved2(void)=0;
+   virtual MTAPIRES  LoggerReserved3(void)=0;
+   virtual MTAPIRES  LoggerReserved4(void)=0;
+   //--- send data functions
+   virtual MTAPIRES  SendTickStats(MTTickStat *stats,const UINT stats_total)=0;
+   virtual MTAPIRES  SendTicks(MTTick *ticks,const UINT ticks_total)=0;
+   virtual MTAPIRES  SendBookDiffs(MTBookDiff *bookdiffs,const UINT bookdiffs_total)=0;
+   virtual MTAPIRES  SendNews(MTNews *news,const UINT news_total)=0;
+   virtual MTAPIRES  SendEconomicEvents(MTEconomicEvent *events,const UINT events_total)=0;
+   virtual MTAPIRES  SendBooks(MTBook *books,const UINT books_total)=0;
+   virtual MTAPIRES  SendReserved1(void)=0;
+   virtual MTAPIRES  SendReserved2(void)=0;
+   //--- feeder configuration
+   virtual IMTConFeeder* FeederCreate(void)=0;
+   virtual IMTConParam* FeederParamCreate(void)=0;
+   virtual IMTConFeederTranslate* FeederTranslateCreate(void)=0;
+   //--- gateway configuration
+   virtual IMTConGateway* GatewayCreate(void)=0;
+   virtual IMTConParam* GatewayParamCreate(void)=0;
+   virtual IMTConGatewayTranslate* GatewayTranslateCreate(void)=0;
+   //--- clients group configuration
+   virtual IMTConGroup* GroupCreate(void)=0;
+   virtual IMTConGroupSymbol* GroupSymbolCreate(void)=0;
+   virtual IMTConCommission* GroupCommissionCreate(void)=0;
+   virtual IMTConCommTier* GroupTierCreate(void)=0;
+   virtual MTAPIRES  GroupSubscribe(IMTConGroupSink *sink)=0;
+   virtual MTAPIRES  GroupUnsubscribe(IMTConGroupSink *sink)=0;
+   virtual UINT      GroupTotal(void)=0;
+   virtual MTAPIRES  GroupNext(const UINT pos,IMTConGroup *group)=0;
+   virtual MTAPIRES  GroupGet(LPCWSTR name,IMTConGroup *group)=0;
+   virtual MTAPIRES  GroupReserved1(void)=0;
+   virtual MTAPIRES  GroupReserved2(void)=0;
+   virtual MTAPIRES  GroupReserved3(void)=0;
+   virtual MTAPIRES  GroupReserved4(void)=0;
+   //--- trade server symbol configuration access
+   virtual IMTConSymbol* SymbolCreate(void)=0;
+   virtual IMTConSymbolSession* SymbolSessionCreate(void)=0;
+   virtual MTAPIRES  SymbolSubscribe(IMTConSymbolSink *sink)=0;
+   virtual MTAPIRES  SymbolUnsubscribe(IMTConSymbolSink *sink)=0;
+   virtual MTAPIRES  SymbolAddPreliminary(IMTConSymbol *symbol)=0;
+   virtual UINT      SymbolTotal(void)=0;
+   virtual MTAPIRES  SymbolNext(const UINT pos,IMTConSymbol *symbol)=0;
+   virtual MTAPIRES  SymbolGet(LPCWSTR name,IMTConSymbol *symbol)=0;
+   virtual MTAPIRES  SymbolGet(LPCWSTR name,LPCWSTR name_group,IMTConSymbol *symbol)=0;
+   virtual MTAPIRES  SymbolUpdate(IMTConSymbol *symbol)=0;
+   virtual MTAPIRES  SymbolDelete(LPCWSTR name)=0;
+   virtual MTAPIRES  SymbolReserved1(void)=0;
+   //--- time config
+   virtual IMTConTime* TimeCreate(void)=0;
+   virtual MTAPIRES  TimeSubscribe(IMTConTimeSink *sink)=0;
+   virtual MTAPIRES  TimeUnsubscribe(IMTConTimeSink *sink)=0;
+   virtual INT64     TimeCurrent(void)=0;
+   virtual MTAPIRES  TimeGet(IMTConTime *common)=0;
+   virtual MTAPIRES  TimeReserved1(void)=0;
+   virtual MTAPIRES  TimeReserved2(void)=0;
+   virtual MTAPIRES  TimeReserved3(void)=0;
+   virtual MTAPIRES  TimeReserved4(void)=0;
+   //--- requests
+   virtual IMTRequest* RequestCreate(void)=0;
+   virtual IMTRequestArray* RequestArrayCreate(void)=0;
+   virtual MTAPIRES  RequestSubscribe(IMTRequestSink *sink)=0;
+   virtual MTAPIRES  RequestUnsubscribe(IMTRequestSink *sink)=0;
+   virtual UINT      RequestTotal(void)=0;
+   virtual MTAPIRES  RequestNext(const UINT pos,IMTRequest *request,IMTUser *user,IMTAccount *account,IMTOrder *order,IMTPosition *position)=0;
+   virtual MTAPIRES  RequestGet(const UINT id,IMTRequest *request,IMTUser *user,IMTAccount *account,IMTOrder *order,IMTPosition *position)=0;
+   virtual MTAPIRES  RequestGetAll(IMTRequestArray *requests)=0;
+   virtual MTAPIRES  RequestReserved1(void)=0;
+   virtual MTAPIRES  RequestReserved2(void)=0;
+   virtual MTAPIRES  RequestReserved3(void)=0;
+   virtual MTAPIRES  RequestReserved4(void)=0;
+   //--- dealing
+   virtual IMTConfirm* DealerConfirmCreate(void)=0;
+   virtual IMTExecution* DealerExecutionCreate(void)=0;
+   virtual MTAPIRES  DealerStart(const UINT flags)=0;
+   virtual MTAPIRES  DealerStop(void)=0;
+   virtual MTAPIRES  DealerGetAsync(void)=0;
+   virtual MTAPIRES  DealerLockAsync(const UINT id)=0;
+   virtual MTAPIRES  DealerAnswerAsync(IMTConfirm *confirm)=0;
+   virtual MTAPIRES  DealerExecuteAsync(IMTExecution *execution)=0;
+   virtual MTAPIRES  DealerReserved1(void)=0;
+   virtual MTAPIRES  DealerReserved2(void)=0;
+   virtual MTAPIRES  DealerReserved3(void)=0;
+   virtual MTAPIRES  DealerReserved4(void)=0;
+   //--- internal email
+   virtual IMTMail*  MailCreate(void)=0;
+   virtual MTAPIRES  MailSend(IMTMail *mail)=0;
+   virtual MTAPIRES  MailReserved1(void)=0;
+   virtual MTAPIRES  MailReserved2(void)=0;
+   virtual MTAPIRES  MailReserved3(void)=0;
+   virtual MTAPIRES  MailReserved4(void)=0;
+   //--- clients database
+   virtual IMTUser*  UserCreate(void)=0;
+   virtual IMTAccount* UserCreateAccount(void)=0;
+   //--- open orders database
+   virtual IMTOrder* OrderCreate(void)=0;
+   //--- trade positions database
+   virtual IMTPosition* PositionCreate(void)=0;
+   //--- custom settings control
+   virtual MTAPIRES  SettingsAdd(const IMTConParam *param)=0;
+   virtual MTAPIRES  SettingsUpdate(const UINT pos,const IMTConParam *param)=0;
+   virtual MTAPIRES  SettingsUpdate(const IMTConParam *param)=0;
+   virtual MTAPIRES  SettingsDelete(const UINT pos)=0;
+   virtual MTAPIRES  SettingsDelete(LPCWSTR name)=0;
+   virtual MTAPIRES  SettingsClear(void)=0;
+   virtual UINT      SettingsTotal(void)=0;
+   virtual MTAPIRES  SettingsNext(const UINT pos,IMTConParam *param)=0;
+   virtual MTAPIRES  SettingsGet(LPCWSTR name,IMTConParam *param)=0;
+   virtual MTAPIRES  SettingsReserved1(void)=0;
+   virtual MTAPIRES  SettingsReserved2(void)=0;
+   virtual MTAPIRES  SettingsReserved3(void)=0;
+   virtual MTAPIRES  SettingsReserved4(void)=0;
+   //--- external trading system positions control
+   virtual IMTConParamArray* GatewayParamArrayCreate(void)=0;
+   virtual IMTPositionArray* GatewayPositionArrayCreate(void)=0;
+   virtual MTAPIRES  GatewayPositionsAnswer(const MTAPIRES result,const INT64 positions_time,const IMTPositionArray *positions)=0;
+   virtual MTAPIRES  GatewayPositionsCheck(const MTAPIRES result,const INT64 positions_time,const IMTPositionArray *positions)=0;
+   virtual MTAPIRES  GatewayPositionsReserved1(void)=0;
+   virtual MTAPIRES  GatewayPositionsReserved2(void)=0;
+   virtual MTAPIRES  GatewayPositionsReserved3(void)=0;
+   virtual MTAPIRES  GatewayPositionsReserved4(void)=0;
+   //--- chart data
+   virtual MTAPIRES  ChartRequest(LPCWSTR symbol,const INT64 from,const INT64 to,MTChartBar *&bars,UINT &bars_total)=0;
+   virtual MTAPIRES  ChartDelete(LPCWSTR symbol,const INT64 *bars_dates,const UINT bars_total)=0;
+   virtual MTAPIRES  ChartUpdate(LPCWSTR symbol,const MTChartBar *bars,const UINT bars_total)=0;
+   virtual MTAPIRES  ChartReplace(LPCWSTR symbol,const INT64 from,const INT64 to,const MTChartBar *bars,const UINT bars_total)=0;
+   virtual MTAPIRES  ChartReserved1(void)=0;
+   virtual MTAPIRES  ChartReserved2(void)=0;
+   virtual MTAPIRES  ChartReserved3(void)=0;
+   virtual MTAPIRES  ChartReserved4(void)=0;
+   //--- memory management
+   virtual void*     Allocate(const UINT bytes)=0;
+   virtual void      Free(void *ptr)=0;
+   //--- spreads configuration
+   virtual IMTConSpread* SpreadCreate(void)=0;
+   virtual IMTConSpreadLeg* SpreadLegCreate(void)=0;
+   virtual MTAPIRES  SpreadSubscribe(IMTConSpreadSink *sink)=0;
+   virtual MTAPIRES  SpreadUnsubscribe(IMTConSpreadSink *sink)=0;
+   virtual MTAPIRES  SpreadAdd(IMTConSpread *spread)=0;
+   virtual MTAPIRES  SpreadDelete(const UINT pos)=0;
+   virtual MTAPIRES  SpreadShift(const UINT pos,const int shift)=0;
+   virtual UINT      SpreadTotal(void)=0;
+   virtual MTAPIRES  SpreadNext(const UINT pos,IMTConSpread *spread)=0;
+   virtual MTAPIRES  SpreadGet(const UINT id,IMTConSpread *spread)=0;
+   virtual MTAPIRES  SpreadReserved1(void)=0;
+   virtual MTAPIRES  SpreadReserved2(void)=0;
+   virtual MTAPIRES  SpreadReserved3(void)=0;
+   virtual MTAPIRES  SpreadReserved4(void)=0;
+   //--- external trading system pending orders control
+   virtual IMTOrderArray* GatewayOrderArrayCreate(void)=0;
+   virtual MTAPIRES  GatewayOrdersAnswer(const MTAPIRES result,const INT64 orders_time,const IMTOrderArray *orders)=0;
+   virtual MTAPIRES  GatewayOrdersReserved1(void)=0;
+   virtual MTAPIRES  GatewayOrdersReserved2(void)=0;
+   virtual MTAPIRES  GatewayOrdersReserved3(void)=0;
+   virtual MTAPIRES  GatewayOrdersReserved4(void)=0;
+   //--- external trading system trading accounts control
+   virtual MTAPIRES  GatewayAccountAnswer(const MTAPIRES result,
+                                          const INT64 accounts_time,
+                                          const IMTUser *user,
+                                          const IMTAccount *account,
+                                          const IMTOrderArray *orders,
+                                          const IMTPositionArray *positions)=0;
+   virtual MTAPIRES  GatewayAccountRequest(const INT64 request_id,
+                                           const IMTUser *user)=0;
+   virtual MTAPIRES  GatewayAccountSet(const INT64 request_id,
+                                       const IMTUser *user,
+                                       const IMTAccount *account,
+                                       const IMTOrderArray *orders,
+                                       const IMTPositionArray *positions)=0;
+   virtual MTAPIRES  GatewayAccountsReserved1(void)=0;
+   virtual MTAPIRES  GatewayAccountsReserved2(void)=0;
+   //--- platform server config
+   virtual IMTConServer* NetServerCreate(void)=0;
+   virtual IMTConServerRange* NetServerRangeCreate(void)=0;
+   virtual MTAPIRES  NetServerSubscribe(IMTConServerSink* sink)=0;
+   virtual MTAPIRES  NetServerUnsubscribe(IMTConServerSink* sink)=0;
+   virtual UINT      NetServerTotal(void)=0;
+   virtual MTAPIRES  NetServerNext(const UINT pos,IMTConServer* config)=0;
+   virtual MTAPIRES  NetServerGet(const UINT64 id,IMTConServer* config)=0;
+   virtual MTAPIRES  NetServerReserved1(void)=0;
+   virtual MTAPIRES  NetServerReserved2(void)=0;
+   virtual MTAPIRES  NetServerReserved3(void)=0;
+   virtual MTAPIRES  NetServerReserved4(void)=0;
+   //--- clients database
+   virtual MTAPIRES  UserSubscribe(IMTUserSink* sink)=0;
+   virtual MTAPIRES  UserUnsubscribe(IMTUserSink* sink)=0;
+   virtual UINT      UserTotal(void)=0;
+   virtual MTAPIRES  UserGet(const UINT64 login,IMTUser* user)=0;
+   virtual MTAPIRES  UserGroup(const UINT64 login,MTAPISTR& group)=0;
+   virtual MTAPIRES  UserLogins(UINT64*& logins,UINT& logins_total)=0;
+   virtual MTAPIRES  UserGetByAccount(LPCWSTR account,IMTUser* user)=0;
+   virtual MTAPIRES  UserReserved1(void)=0;
+   virtual MTAPIRES  UserReserved2(void)=0;
+   virtual MTAPIRES  UserReserved3(void)=0;
+   virtual MTAPIRES  UserReserved4(void)=0;
+   virtual MTAPIRES  UserReserved5(void)=0;
+   virtual MTAPIRES  UserReserved6(void)=0;
+   virtual MTAPIRES  UserReserved7(void)=0;
+   //--- gateway symbol configuration access
+   virtual MTAPIRES  GatewaySymbolAdd(IMTConSymbol *symbol)=0;
+   virtual UINT      GatewaySymbolTotal(void)=0;
+   virtual MTAPIRES  GatewaySymbolNext(const UINT pos,IMTConSymbol *symbol)=0;
+   virtual MTAPIRES  GatewaySymbolGet(LPCWSTR name,IMTConSymbol *symbol)=0;
+   virtual MTAPIRES  GatewaySymbolDelete(LPCWSTR name)=0;
+   virtual MTAPIRES  GatewaySymbolClear(void)=0;
+   virtual MTAPIRES  GatewaySymbolReserver1(void)=0;
+   virtual MTAPIRES  GatewaySymbolReserver2(void)=0;
+   virtual MTAPIRES  GatewaySymbolReserver3(void)=0;
+   virtual MTAPIRES  GatewaySymbolReserver4(void)=0;
+   //--- ticks history
+   virtual MTAPIRES  TickHistoryRequest(LPCWSTR symbol,const INT64 from,const INT64 to,MTTickRate*& ticks,UINT& ticks_total)=0;
+   virtual MTAPIRES  TickHistoryRequestRaw(LPCWSTR symbol,const INT64 from,const INT64 to,MTTickRate*& ticks,UINT& ticks_total)=0;
+   virtual MTAPIRES  TickHistoryAdd(LPCWSTR symbol,const MTTickRate* ticks,const UINT ticks_total)=0;
+   virtual MTAPIRES  TickHistoryReplace(LPCWSTR symbol,const INT64 from_msc,const INT64 to_msc,const MTTickRate* ticks,const UINT ticks_total)=0;
+   virtual MTAPIRES  TickHistoryReserver1(void)=0;
+   virtual MTAPIRES  TickHistoryReserver2(void)=0;
+   virtual MTAPIRES  TickHistoryReserver3(void)=0;
+   virtual MTAPIRES  TickHistoryReserver4(void)=0;
+  };
+//+------------------------------------------------------------------+
+//| Entry point functions declarations                               |
+//+------------------------------------------------------------------+
+typedef /*__declspec(dllexport)*/ MTAPIRES(*MTGatewayVersion_t)     (UINT &version);
+typedef /*__declspec(dllexport)*/ MTAPIRES(*MTGatewayCreate_t)      (MTGatewayInfo &info,IMTGatewayAPI **gateway);
+typedef /*__declspec(dllexport)*/ MTAPIRES(*MTGatewayCreateLocal_t) (MTGatewayInfo &info,IMTGatewayAPI **gateway,int argc,wchar_t** argv);
+//+------------------------------------------------------------------+
+//| Entry point functions names                                      |
+//+------------------------------------------------------------------+
+static const LPCSTR s_MTGatewayVersion             ="MTGatewayVersion";
+static const LPCSTR s_MTGatewayCreate              ="MTGatewayCreate";
+static const LPCSTR s_MTGatewayCreateLocal         ="MTGatewayCreateLocal";
+//+------------------------------------------------------------------+
+//| Gateway factory                                                  |
+//+------------------------------------------------------------------+
+class CMTGatewayAPIFactory
+  {
+   HMODULE           m_hmodule;
+   MTGatewayVersion_t m_mtversion;
+   MTGatewayCreate_t m_mtcreate;
+   MTGatewayCreateLocal_t m_mtcreate_local;
+
+public:
+                     CMTGatewayAPIFactory() : m_hmodule(NULL),m_mtversion(NULL),m_mtcreate(NULL),m_mtcreate_local(NULL) {}
+   //--- initialize & shutdown
+   MTAPIRES          Initialize(void);
+   MTAPIRES          Shutdown(void);
+//--- gateway creation
+   MTAPIRES          Create(MTGatewayInfo &info,IMTGatewayAPI **gateway,int argc=0,wchar_t** argv=NULL) const;
+   //--- check license sign
+   static MTAPIRES   LicenseCheck(IMTGatewayAPI *gateway,LPCWSTR name);
+   //--- version info
+   MTAPIRES          Version(UINT &version) const;
+
+private:
+   bool              FindLibrary(wchar_t *path,const size_t path_maxlen);
+  };
+//+------------------------------------------------------------------+
+//| Library initialization                                           |
+//+------------------------------------------------------------------+
+inline MTAPIRES CMTGatewayAPIFactory::Initialize(void)
+  {
+   wchar_t  path[MAX_PATH]={};
+//--- find the Gateway API DLL
+   if(!FindLibrary(path,_countof(path)-1))
+      return(MT_RET_ERR_NOTFOUND);
+//--- try to load Gateway API DLL from current folder
+   if((m_hmodule=::LoadLibrary(path))==NULL)
+      return(MT_RET_ERR_NOTFOUND);
+//--- load Gateway API DLL
+   if(m_hmodule)
+     {
+      //--- find entry point addresses
+      m_mtversion     =reinterpret_cast<MTGatewayVersion_t>(::GetProcAddress(m_hmodule,s_MTGatewayVersion));
+      m_mtcreate      =reinterpret_cast<MTGatewayCreate_t>(::GetProcAddress(m_hmodule,s_MTGatewayCreate));
+      m_mtcreate_local=reinterpret_cast<MTGatewayCreateLocal_t>(::GetProcAddress(m_hmodule,s_MTGatewayCreateLocal));
+      //--- check results
+      if(!m_mtversion || !m_mtcreate || !m_mtcreate_local)
+        {
+         Shutdown();
+         //--- not found
+         return(MT_RET_ERR_NOTFOUND);
+        }
+     }
+//--- ok
+   return(MT_RET_OK);
+  }
+//+------------------------------------------------------------------+
+//| Library shutdown                                                 |
+//+------------------------------------------------------------------+
+inline MTAPIRES CMTGatewayAPIFactory::Shutdown(void)
+  {
+//--- check & free
+   if(m_hmodule)
+     {
+      ::FreeLibrary((HMODULE)m_hmodule);
+      m_hmodule=NULL;
+     }
+//--- zero members
+   m_mtversion     =NULL;
+   m_mtcreate      =NULL;
+   m_mtcreate_local=NULL;
+//--- ok
+   return(MT_RET_OK);
+  }
+//+------------------------------------------------------------------+
+//| Find the library                                                 |
+//+------------------------------------------------------------------+
+inline bool CMTGatewayAPIFactory::FindLibrary(wchar_t *path,const size_t path_maxlen)
+  {
+   wchar_t  folder[MAX_PATH]={};
+   wchar_t *ptr;
+//--- find the folder
+   ::GetModuleFileNameW(NULL,folder,_countof(folder)-1);
+//--- check for 5 levels
+   for(int i=0;i<5;i++)
+     {
+      //--- remove level
+      if((ptr=wcsrchr(folder,L'\\'))==NULL)
+         break;
+
+      *ptr=L'\0';
+      //--- check the file
+      if(sizeof(void*)==4)
+         swprintf_s(path,path_maxlen,L"%s\\MT5APIGateway.dll",folder);
+      else
+         swprintf_s(path,path_maxlen,L"%s\\MT5APIGateway64.dll",folder);
+
+      if(GetFileAttributesW(path)!=INVALID_FILE_ATTRIBUTES)
+         return(true);
+      //--- check /libs folder
+      if(sizeof(void*)==4)
+         swprintf_s(path,path_maxlen,L"%s\\libs\\MT5APIGateway.dll",folder);
+      else
+         swprintf_s(path,path_maxlen,L"%s\\libs\\MT5APIGateway64.dll",folder);
+
+      if(GetFileAttributesW(path)!=INVALID_FILE_ATTRIBUTES)
+         return(true);
+     }
+//---
+   return(false);
+  }
+//+------------------------------------------------------------------+
+//| Gateway interface creation                                       |
+//+------------------------------------------------------------------+
+inline MTAPIRES CMTGatewayAPIFactory::Create(MTGatewayInfo& info,IMTGatewayAPI **gateway,int argc/*=0*/,wchar_t** argv/*=NULL*/) const
+  {
+   MTAPIRES res=MT_RET_ERROR;
+//--- check members & parameters
+   if(!m_hmodule || !m_mtcreate || !m_mtcreate_local || !gateway)
+      return(MT_RET_ERROR);
+//--- call common or local-mode creation
+   if(!argc || !argv)
+      res=m_mtcreate(info,gateway);
+   else
+      res=m_mtcreate_local(info,gateway,argc,argv);
+//--- result
+   return(res);
+  }
+//+------------------------------------------------------------------+
+//| Gateway license sign check                                       |
+//+------------------------------------------------------------------+
+inline MTAPIRES CMTGatewayAPIFactory::LicenseCheck(IMTGatewayAPI *gateway,LPCWSTR name)
+  {
+//--- checking
+   if(!gateway || !name || name[0]==L'\0')
+      return(MT_RET_ERROR);
+//--- fill license information, copy name
+   MTLicenseCheck license={};
+   HCRYPTPROV     prov=NULL;
+   HCRYPTHASH     hash=NULL;
+   HCRYPTKEY      key =NULL;
+   MTAPIRES       res=MT_RET_ERROR;
+
+   wcscpy_s(license.name,_countof(license.name),name);
+//--- initialize random generator
+   srand((unsigned int)GetTickCount());
+//--- generate sequence of random numbers
+   for(license.random_size=0;license.random_size<sizeof(license.random);license.random_size++)
+      license.random[license.random_size]=char(rand()&0xFF);
+//--- check license
+   gateway->LicenseCheck(license);
+//--- check retcode
+   if(license.retcode!=MT_RET_OK)
+      return(license.retcode);
+//--- check license sign, initialize provider
+   if(CryptAcquireContext(&prov,NULL,MS_DEF_PROV,PROV_RSA_FULL,CRYPT_VERIFYCONTEXT)==FALSE)
+      return(MT_RET_ERROR);
+//--- import public key
+   if(CryptImportKey(prov,(const BYTE*)MT5APIPublicKey,sizeof(MT5APIPublicKey),0,0,&key)!=FALSE)
+     {
+      //--- initialize hash object
+      if(CryptCreateHash(prov,CALG_MD5,0,0,&hash)!=FALSE)
+        {
+         //--- set hash from data
+         if(CryptHashData(hash,(BYTE*)&license,(DWORD)offsetof(MTLicenseCheck,retcode),0)!=FALSE)
+           {
+            //--- verify hash sign, using public key
+            if(CryptVerifySignature(hash,(BYTE*)license.sign,(DWORD)license.sign_size,key,NULL,0)!=FALSE)
+               res=license.retcode;
+            else
+               res=MT_RET_ERR_DATA;
+           }
+        }
+     }
+//--- destroy hash
+   if(hash)
+      CryptDestroyHash(hash);
+//--- destroy key
+   if(key)
+      CryptDestroyKey(key);
+//--- release provider
+   if(prov)
+      CryptReleaseContext(prov,0);
+//--- return result
+   return(res);
+  }
+//+------------------------------------------------------------------+
+//| Version                                                          |
+//+------------------------------------------------------------------+
+inline MTAPIRES CMTGatewayAPIFactory::Version(UINT &version) const
+  {
+//--- check members & parameters
+   if(!m_hmodule || !m_mtversion)
+      return(MT_RET_ERROR);
+//--- result
+   return(m_mtversion(version));
+  }
+//+------------------------------------------------------------------+

+ 83 - 0
MT5SDK/MT5APILogger.h

@@ -0,0 +1,83 @@
+//+------------------------------------------------------------------+
+//|                                                 MetaTrader 5 API |
+//|                   Copyright 2000-2019, MetaQuotes Software Corp. |
+//|                                        http://www.metaquotes.net |
+//+------------------------------------------------------------------+
+#pragma once
+//+------------------------------------------------------------------+
+//| Logger type codes                                                |
+//+------------------------------------------------------------------+
+enum EnMTLogCode
+  {
+   MTLogFolder         =-1,
+   MTLogOK             =0,
+   MTLogWarn           =1,
+   MTLogErr            =2,
+   MTLogAtt            =3,
+   MTLogLogin          =4,
+//--- enumeration borders
+   MTLogFirst          =MTLogFolder,
+   MTLogLast           =MTLogLogin
+  };
+//+------------------------------------------------------------------+
+//| Logger message types                                             |
+//+------------------------------------------------------------------+
+enum EnMTLogType
+  {
+   MTLogTypeAll        =0,
+   MTLogTypeCfg        =1,
+   MTLogTypeSys        =2,
+   MTLogTypeNet        =3,
+   MTLogTypeHst        =4,
+   MTLogTypeUser       =5,
+   MTLogTypeTrade      =6,
+   MTLogTypeAPI        =7,
+   MTLogTypeNotify     =8,
+//--- external tools logs
+   MTLogTypeLiveUpdate =16,
+   MTLogTypeSendMail   =17,
+//--- enumeration borders
+   MTLogTypeFirst      =MTLogTypeAll,
+   MTLogTypeLast       =MTLogTypeSendMail
+  };
+//+------------------------------------------------------------------+
+//| Logger request modes                                             |
+//+------------------------------------------------------------------+
+enum EnMTLogRequestMode
+  {
+   MTLogModeStd        =0,
+   MTLogModeErr        =1,
+   MTLogModeFull       =2,
+//--- enumeration borders
+   MTLogModeFirst      =MTLogModeStd,
+   MTLogModeLast       =MTLogModeFull
+  };
+//+------------------------------------------------------------------+
+//| Logger record flags                                              |
+//+------------------------------------------------------------------+
+enum EnMTLogFlags
+  {
+   LOG_FLAGS_NONE      =0, // none
+   LOG_FLAGS_CORRUPTED =1, // record has invalid checksum (record corrupted)
+//--- enumeration borders
+   LOG_FLAGS_FIRST     =LOG_FLAGS_NONE,
+   LOG_FLAGS_ALL       =LOG_FLAGS_CORRUPTED
+  };
+//+------------------------------------------------------------------+
+//| Log record structure                                             |
+//+------------------------------------------------------------------+
+#pragma pack(push,1)
+struct MTLogRecord
+  {
+   UINT              flags;                     // flags EnMTLogFlags
+   INT               code;                      // code EnMTLogCode
+   UINT              type;                      // type EnMTLogType
+   INT64             datetime;                  // record time
+   wchar_t           source[64];                // record source
+   wchar_t           message[512];              // record message
+   INT64             datetime_msc;              // record time in milliseconds since 1970.01.01
+   int               reserved[2];               // reserved
+  };
+#pragma pack(pop)
+//+------------------------------------------------------------------+
+

+ 1412 - 0
MT5SDK/MT5APIManager.h

@@ -0,0 +1,1412 @@
+//+------------------------------------------------------------------+
+//|                                         MetaTrader 5 API Manager |
+//|                   Copyright 2000-2019, MetaQuotes Software Corp. |
+//|                                        http://www.metaquotes.net |
+//+------------------------------------------------------------------+
+#pragma once
+#include <wincrypt.h>
+#include "MT5APIConstants.h"
+#include "MT5APILogger.h"
+#include "MT5APIPublicKey.h"
+#include "MT5APITools.h"
+#include "Config\MT5APIConfigCommon.h"
+#include "Config\MT5APIConfigFeeder.h"
+#include "Config\MT5APIConfigFirewall.h"
+#include "Config\MT5APIConfigGateway.h"
+#include "Config\MT5APIConfigGroup.h"
+#include "Config\MT5APIConfigHistory.h"
+#include "Config\MT5APIConfigHoliday.h"
+#include "Config\MT5APIConfigManager.h"
+#include "Config\MT5APIConfigNetwork.h"
+#include "Config\MT5APIConfigPlugin.h"
+#include "Config\MT5APIConfigReport.h"
+#include "Config\MT5APIConfigRoute.h"
+#include "Config\MT5APIConfigSpread.h"
+#include "Config\MT5APIConfigSymbol.h"
+#include "Config\MT5APIConfigTime.h"
+#include "Config\MT5APIConfigEmail.h"
+#include "Config\MT5APIConfigMessenger.h"
+#include "Bases\MT5APIAccount.h"
+#include "Bases\MT5APIBook.h"
+#include "Bases\MT5APIByteStream.h"
+#include "Bases\MT5APICertificate.h"
+#include "Bases\MT5APIChart.h"
+#include "Bases\MT5APIConfirm.h"
+#include "Bases\MT5APIDaily.h"
+#include "Bases\MT5APIDeal.h"
+#include "Bases\MT5APIExposure.h"
+#include "Bases\MT5APIMail.h"
+#include "Bases\MT5APINews.h"
+#include "Bases\MT5APIOrder.h"
+#include "Bases\MT5APIPosition.h"
+#include "Bases\MT5APIRequest.h"
+#include "Bases\MT5APISummary.h"
+#include "Bases\MT5APITick.h"
+#include "Bases\MT5APIUser.h"
+#include "Bases\MT5APIOnline.h"
+//+------------------------------------------------------------------+
+//| Include necessary library                                        |
+//+------------------------------------------------------------------+
+#pragma comment(lib,"advapi32.lib")
+//+------------------------------------------------------------------+
+//| Manager API version                                              |
+//+------------------------------------------------------------------+
+#define MTManagerAPIVersion  2190
+#define MTManagerAPIDate     L"18 Oct 2019"
+//+------------------------------------------------------------------+
+//| Proxy description                                                |
+//+------------------------------------------------------------------+
+#pragma pack(push,1)
+struct MTProxyInfo
+  {
+   //--- types of proxy servers
+   enum
+     {
+      PROXY_SOCKS4   =0,                     // SOCKS4
+      PROXY_SOCKS5   =1,                     // SOCKS5
+      PROXY_HTTP     =2,                     // HTTP (including NTLM)
+      PROXY_FIRST    =PROXY_SOCKS4,          // first type
+      PROXY_LAST     =PROXY_HTTP             // last type
+     };
+   //--- proxy description
+   int               enable;                 // proxy enabled or disabled
+   int               type;                   // type of proxy server
+   wchar_t           address[64];            // IP:port of proxy server
+   wchar_t           auth[64];               // login:password
+  };
+#pragma pack(pop)
+//+------------------------------------------------------------------+
+//| Manager API events notification interface                        |
+//+------------------------------------------------------------------+
+class IMTManagerSink
+  {
+public:
+   virtual void      OnDisconnect(void) {  }
+   virtual void      OnTradeAccountSet(const MTAPIRES           /*retcode*/,
+                                       const INT64              /*request_id*/,
+                                       const IMTUser*           /*user*/,
+                                       const IMTAccount*        /*account*/,
+                                       const IMTOrderArray*     /*orders*/,
+                                       const IMTPositionArray*  /*positions*/) {  }
+   virtual void      OnConnect(void) {  }
+  };
+//+------------------------------------------------------------------+
+//| Dealer events notification interface                             |
+//+------------------------------------------------------------------+
+class IMTDealerSink
+  {
+public:
+   virtual void      OnDealerResult(const IMTConfirm* /*result*/)  {  }
+   virtual void      OnDealerAnswer(const IMTRequest* /*request*/) {  }
+  };
+//+------------------------------------------------------------------+
+//| Manager API interface                                            |
+//+------------------------------------------------------------------+
+class IMTManagerAPI
+  {
+public:
+   //--- pumping modes
+   enum EnPumpModes
+     {
+      PUMP_MODE_USERS         =0x00000001,   // pump users
+      PUMP_MODE_ACTIVITY      =0x00000002,   // pump users online activity
+      PUMP_MODE_MAIL          =0x00000004,   // pump mails
+      PUMP_MODE_ORDERS        =0x00000008,   // pump orders
+      PUMP_MODE_NEWS          =0x00000020,   // pump news
+      PUMP_MODE_POSITIONS     =0x00000080,   // pump positions
+      PUMP_MODE_GROUPS        =0x00000100,   // pump group configurations
+      PUMP_MODE_SYMBOLS       =0x00000200,   // pump symbol configurations
+      PUMP_MODE_HOLIDAYS      =0x00000800,   // pump holiday configurations
+      PUMP_MODE_TIME          =0x00001000,   // pump time configuration
+      PUMP_MODE_GATEWAYS      =0x00002000,   // pump gateways configurations
+      PUMP_MODE_REQUESTS      =0x00004000,   // pump requests (for supervisor)
+      PUMP_MODE_PLUGINS       =0x00008000,   // pump plugins configurations
+      //--- enumeration ranges
+      PUMP_MODE_FULL          =0xffffffff    // full pumping
+     };
+   //--- external account sync modes
+   enum EnExternalSyncModes
+     {
+      EXTERNAL_SYNC_ALL      =0,
+      EXTERNAL_SYNC_BALANCE  =1,
+      EXTERNAL_SYNC_POSITIONS=2,
+      EXTERNAL_SYNC_ORDERS   =3,
+      EXTERNAL_SYNC_LAST     =EXTERNAL_SYNC_ORDERS
+     };
+   //--- interface release
+   virtual void      Release(void)=0;
+   //--- Manager license check
+   virtual MTAPIRES  LicenseCheck(MTLicenseCheck& check)=0;
+   //--- memory management
+   virtual void*     Allocate(const UINT bytes)=0;
+   virtual void      Free(void* ptr)=0;
+   //--- proxy
+   virtual void      ProxySet(const MTProxyInfo &proxy)=0;
+   //--- connect/disconnect
+   virtual MTAPIRES  Connect(LPCWSTR server,UINT64 login,LPCWSTR password,LPCWSTR password_cert,UINT64 pump_mode,UINT timeout=INFINITE)=0;
+   virtual void      Disconnect(void)=0;
+   virtual MTAPIRES  Subscribe(IMTManagerSink* sink)=0;
+   virtual MTAPIRES  Unsubscribe(IMTManagerSink* sink)=0;
+   //--- API journal
+   virtual MTAPIRES  LoggerOut(const UINT code,LPCWSTR format,...)=0;
+   virtual void      LoggerFlush(void)=0;
+   virtual MTAPIRES  LoggerServerRequest(const UINT mode,const UINT type,const INT64 from,const INT64 to,LPCWSTR filter,
+                                         MTLogRecord*& records,UINT& records_total)=0;
+   virtual MTAPIRES  LoggerReserved1(void)=0;
+   virtual MTAPIRES  LoggerReserved2(void)=0;
+   virtual MTAPIRES  LoggerReserved3(void)=0;
+   virtual MTAPIRES  LoggerReserved4(void)=0;
+   //--- time configuration
+   virtual IMTConTime* TimeCreate(void)=0;
+   virtual MTAPIRES  TimeSubscribe(IMTConTimeSink* sink)=0;
+   virtual MTAPIRES  TimeUnsubscribe(IMTConTimeSink* sink)=0;
+   virtual MTAPIRES  TimeGet(IMTConTime* config)=0;
+   virtual INT64     TimeServer(void)=0;
+   virtual MTAPIRES  TimeServerRequest(INT64& time_msc)=0;
+   virtual MTAPIRES  TimeReserved2(void)=0;
+   virtual MTAPIRES  TimeReserved3(void)=0;
+   virtual MTAPIRES  TimeReserved4(void)=0;
+   //--- holidays configuration
+   virtual IMTConHoliday* HolidayCreate()=0;
+   virtual MTAPIRES  HolidaySubscribe(IMTConHolidaySink* sink)=0;
+   virtual MTAPIRES  HolidayUnsubscribe(IMTConHolidaySink* sink)=0;
+   virtual UINT      HolidayTotal(void)=0;
+   virtual MTAPIRES  HolidayNext(const UINT pos,IMTConHoliday* config)=0;
+   virtual MTAPIRES  HolidayReserved1(void)=0;
+   virtual MTAPIRES  HolidayReserved2(void)=0;
+   virtual MTAPIRES  HolidayReserved3(void)=0;
+   virtual MTAPIRES  HolidayReserved4(void)=0;
+   //--- clients group configuration
+   virtual IMTConGroup* GroupCreate(void)=0;
+   virtual IMTConGroupSymbol* GroupSymbolCreate(void)=0;
+   virtual IMTConCommission* GroupCommissionCreate(void)=0;
+   virtual IMTConCommTier* GroupTierCreate(void)=0;
+   virtual MTAPIRES  GroupSubscribe(IMTConGroupSink* sink)=0;
+   virtual MTAPIRES  GroupUnsubscribe(IMTConGroupSink* sink)=0;
+   virtual UINT      GroupTotal(void)=0;
+   virtual MTAPIRES  GroupNext(const UINT pos,IMTConGroup* group)=0;
+   virtual MTAPIRES  GroupGet(LPCWSTR name,IMTConGroup* group)=0;
+   virtual MTAPIRES  GroupRequest(LPCWSTR name,IMTConGroup* group)=0;
+   virtual MTAPIRES  GroupReserved1(void)=0;
+   virtual MTAPIRES  GroupReserved2(void)=0;
+   virtual MTAPIRES  GroupReserved3(void)=0;
+   virtual MTAPIRES  GroupReserved4(void)=0;
+   //--- symbols configuration
+   virtual IMTConSymbol* SymbolCreate(void)=0;
+   virtual IMTConSymbolSession* SymbolSessionCreate(void)=0;
+   virtual MTAPIRES  SymbolSubscribe(IMTConSymbolSink* sink)=0;
+   virtual MTAPIRES  SymbolUnsubscribe(IMTConSymbolSink* sink)=0;
+   virtual UINT      SymbolTotal(void)=0;
+   virtual MTAPIRES  SymbolNext(const UINT pos,IMTConSymbol* symbol)=0;
+   virtual MTAPIRES  SymbolGet(LPCWSTR name,IMTConSymbol* symbol)=0;
+   virtual MTAPIRES  SymbolGet(LPCWSTR name,LPCWSTR group,IMTConSymbol* symbol)=0;
+   virtual MTAPIRES  SymbolRequest(LPCWSTR name,IMTConSymbol* symbol)=0;
+   virtual MTAPIRES  SymbolRequest(LPCWSTR name,LPCWSTR group,IMTConSymbol* symbol)=0;
+   virtual MTAPIRES  SymbolExist(const IMTConSymbol* symbol,const IMTConGroup* group)=0;
+   virtual MTAPIRES  SymbolReserved1(void)=0;
+   virtual MTAPIRES  SymbolReserved2(void)=0;
+   virtual MTAPIRES  SymbolReserved3(void)=0;
+   virtual MTAPIRES  SymbolReserved4(void)=0;
+   //--- selected symbols base
+   virtual MTAPIRES  SelectedAdd(LPCWSTR symbol)=0;
+   virtual MTAPIRES  SelectedAddAll(void)=0;
+   virtual MTAPIRES  SelectedDelete(LPCWSTR symbol)=0;
+   virtual MTAPIRES  SelectedDelete(const UINT pos)=0;
+   virtual MTAPIRES  SelectedDeleteAll(void)=0;
+   virtual MTAPIRES  SelectedShift(const UINT pos,const int shift)=0;
+   virtual UINT      SelectedTotal(void)=0;
+   virtual MTAPIRES  SelectedNext(const UINT pos,MTAPISTR &symbol)=0;
+   virtual MTAPIRES  SelectedAddBatch(LPWSTR* symbols,UINT symbols_total)=0;
+   virtual MTAPIRES  SelectedDeleteBatch(LPWSTR* symbols,UINT symbols_total)=0;
+   virtual MTAPIRES  SelectedReserved1(void)=0;
+   virtual MTAPIRES  SelectedReserved2(void)=0;
+   //--- clients database
+   virtual IMTUser*  UserCreate(void)=0;
+   virtual IMTAccount* UserCreateAccount(void)=0;
+   virtual MTAPIRES  UserSubscribe(IMTUserSink* sink)=0;
+   virtual MTAPIRES  UserUnsubscribe(IMTUserSink* sink)=0;
+   virtual MTAPIRES  UserAdd(IMTUser* user,LPCWSTR master_pass,LPCWSTR investor_pass)=0;
+   virtual MTAPIRES  UserDelete(const UINT64 login)=0;
+   virtual MTAPIRES  UserUpdate(IMTUser* user)=0;
+   virtual UINT      UserTotal(void)=0;
+   virtual MTAPIRES  UserGet(const UINT64 login,IMTUser* user)=0;
+   virtual MTAPIRES  UserRequest(const UINT64 login,IMTUser *user)=0;
+   virtual MTAPIRES  UserGroup(const UINT64 login,MTAPISTR& group)=0;
+   virtual MTAPIRES  UserLogins(LPCWSTR group,UINT64*& logins,UINT& logins_total)=0;
+   virtual MTAPIRES  UserPasswordCheck(const UINT type,const UINT64 login,LPCWSTR password)=0;
+   virtual MTAPIRES  UserPasswordChange(const UINT type,const UINT64 login,LPCWSTR password)=0;
+   virtual MTAPIRES  UserCertDelete(const UINT64 login)=0;
+   virtual MTAPIRES  UserCertConfirm(const UINT64 login)=0;
+   virtual MTAPIRES  UserExternalSync(const UINT64 login,const UINT64 gateway_id,LPCWSTR account_id,UINT sync_mode)=0;
+   virtual MTAPIRES  UserAccountGet(const UINT64 login,IMTAccount* account)=0;
+   virtual MTAPIRES  UserAccountRequest(const UINT64 login,IMTAccount* account)=0;
+   virtual IMTCertificate *UserCertCreate(void)=0;
+   virtual MTAPIRES  UserCertUpdate(const UINT64 login,const IMTCertificate *certificate)=0;
+   virtual MTAPIRES  UserCertGet(const UINT64 login,IMTCertificate *certificate)=0;
+   virtual MTAPIRES  UserBalanceCheck(const UINT64 login,const UINT fixflag,double& balance_user,double& balance_history,double& credit_user,double& credit_history)=0;
+   //--- deals database
+   virtual IMTDeal*  DealCreate(void)=0;
+   virtual IMTDealArray* DealCreateArray(void)=0;
+   virtual MTAPIRES  DealRequest(const UINT64 ticket,IMTDeal* deal)=0;
+   virtual MTAPIRES  DealRequest(const UINT64 login,const INT64 from,const INT64 to,IMTDealArray* deals)=0;
+   virtual MTAPIRES  DealSubscribe(IMTDealSink* sink)=0;
+   virtual MTAPIRES  DealUnsubscribe(IMTDealSink* sink)=0;
+   virtual MTAPIRES  DealDelete(const UINT64 ticket)=0;
+   virtual MTAPIRES  DealUpdate(IMTDeal* deal)=0;
+   //--- trade positions database
+   virtual IMTPosition* PositionCreate(void)=0;
+   virtual IMTPositionArray* PositionCreateArray(void)=0;
+   virtual MTAPIRES  PositionSubscribe(IMTPositionSink* sink)=0;
+   virtual MTAPIRES  PositionUnsubscribe(IMTPositionSink* sink)=0;
+   virtual MTAPIRES  PositionGet(const UINT64 login,LPCWSTR symbol,IMTPosition* position)=0;
+   virtual MTAPIRES  PositionGet(const UINT64 login,IMTPositionArray* positions)=0;
+   virtual MTAPIRES  PositionRequest(const UINT64 login,IMTPositionArray* positions)=0;
+   virtual MTAPIRES  PositionGetByTicket(const UINT64 ticket,IMTPosition* position)=0;
+   virtual MTAPIRES  PositionDelete(IMTPosition* position)=0;
+   virtual MTAPIRES  PositionUpdate(IMTPosition* position)=0;
+   virtual MTAPIRES  PositionGetByGroup(LPCWSTR mask,IMTPositionArray* positions)=0;
+   //--- trade orders database
+   virtual IMTOrder* OrderCreate(void)=0;
+   virtual IMTOrderArray* OrderCreateArray(void)=0;
+   virtual MTAPIRES  OrderSubscribe(IMTOrderSink* sink)=0;
+   virtual MTAPIRES  OrderUnsubscribe(IMTOrderSink* sink)=0;
+   virtual MTAPIRES  OrderGet(const UINT64 ticket,IMTOrder* order)=0;
+   virtual MTAPIRES  OrderGetOpen(const UINT64 login,IMTOrderArray* orders)=0;
+   virtual MTAPIRES  OrderRequest(const UINT64 ticket,IMTOrder* order)=0;
+   virtual MTAPIRES  OrderRequestOpen(const UINT64 login,IMTOrderArray* orders)=0;
+   virtual MTAPIRES  HistoryRequest(const UINT64 login,const INT64 from,const INT64 to,IMTOrderArray* orders)=0;
+   virtual MTAPIRES  OrderDelete(const UINT64 ticket)=0;
+   virtual MTAPIRES  OrderUpdate(IMTOrder *order)=0;
+   virtual MTAPIRES  OrderGetByGroup(LPCWSTR mask,IMTOrderArray* orders)=0;
+   virtual MTAPIRES  OrderGetByLogins(const UINT64 *logins,const UINT logins_total,IMTOrderArray* orders)=0;
+   //--- ticks data
+   virtual MTAPIRES  TickSubscribe(IMTTickSink* sink)=0;
+   virtual MTAPIRES  TickUnsubscribe(IMTTickSink* sink)=0;
+   virtual MTAPIRES  TickAdd(LPCWSTR symbol,MTTick& tick)=0;
+   virtual MTAPIRES  TickAddStat(MTTick& tick,MTTickStat& stat)=0;
+   virtual MTAPIRES  TickLast(LPCWSTR symbol,MTTickShort& tick)=0;
+   virtual MTAPIRES  TickLast(UINT& id,MTTick*& ticks,UINT& ticks_total)=0;
+   virtual MTAPIRES  TickStat(LPCWSTR symbol,MTTickStat& stat)=0;
+   virtual MTAPIRES  TickHistoryRequest(LPCWSTR symbol,const INT64 from,const INT64 to,MTTickShort*& ticks,UINT& ticks_total)=0;
+   virtual MTAPIRES  TickLast(LPCWSTR symbol,LPCWSTR group,MTTickShort& tick)=0;
+   virtual MTAPIRES  TickLastRaw(LPCWSTR symbol,MTTickShort& tick)=0;
+   virtual MTAPIRES  TickReserved1(void)=0;
+   virtual MTAPIRES  TickReserved2(void)=0;
+   //--- books
+   virtual MTAPIRES  BookSubscribe(LPCWSTR symbol,IMTBookSink* sink)=0;
+   virtual MTAPIRES  BookUnsubscribe(LPCWSTR symbol,IMTBookSink* sink)=0;
+   virtual MTAPIRES  BookGet(LPCWSTR symbol,MTBook& book)=0;
+   virtual MTAPIRES  BookSubscribeBatch(LPWSTR* symbols,UINT symbols_total,IMTBookSink* sink)=0;
+   virtual MTAPIRES  BookUnsubscribeBatch(LPWSTR* symbols,UINT symbols_total,IMTBookSink* sink)=0;
+   virtual MTAPIRES  BookReserved3(void)=0;
+   virtual MTAPIRES  BookReserved4(void)=0;
+   //--- internal email
+   virtual IMTMail*  MailCreate(void)=0;
+   virtual MTAPIRES  MailSubscribe(IMTMailSink* sink)=0;
+   virtual MTAPIRES  MailUnsubscribe(IMTMailSink* sink)=0;
+   virtual UINT      MailTotal(void)=0;
+   virtual MTAPIRES  MailNext(const UINT pos,IMTMail* mail)=0;
+   virtual MTAPIRES  MailDelete(const UINT pos)=0;
+   virtual MTAPIRES  MailDeleteId(const UINT64 id)=0;
+   virtual MTAPIRES  MailSend(IMTMail* mail)=0;
+   virtual MTAPIRES  MailBodyRequest(const UINT64 id,IMTMail *mail)=0;
+   virtual MTAPIRES  MailReserved2(void)=0;
+   virtual MTAPIRES  MailReserved3(void)=0;
+   virtual MTAPIRES  MailReserved4(void)=0;
+   //--- internal news
+   virtual IMTNews*  NewsCreate(void)=0;
+   virtual MTAPIRES  NewsSubscribe(IMTNewsSink* sink)=0;
+   virtual MTAPIRES  NewsUnsubscribe(IMTNewsSink* sink)=0;
+   virtual UINT      NewsTotal(void)=0;
+   virtual MTAPIRES  NewsNext(const UINT pos,IMTNews* news)=0;
+   virtual MTAPIRES  NewsBodyRequest(const UINT64 id,IMTNews *news)=0;
+   virtual MTAPIRES  NewsSend(IMTNews* news)=0;
+   virtual MTAPIRES  NewsReserved1(void)=0;
+   virtual MTAPIRES  NewsReserved2(void)=0;
+   virtual MTAPIRES  NewsReserved3(void)=0;
+   virtual MTAPIRES  NewsReserved4(void)=0;
+   //--- requests
+   virtual IMTRequest* RequestCreate(void)=0;
+   virtual IMTRequestArray* RequestCreateArray(void)=0;
+   virtual MTAPIRES  RequestSubscribe(IMTRequestSink* sink)=0;
+   virtual MTAPIRES  RequestUnsubscribe(IMTRequestSink* sink)=0;
+   virtual UINT      RequestTotal(void)=0;
+   virtual MTAPIRES  RequestNext(const UINT pos,IMTRequest* request)=0;
+   virtual MTAPIRES  RequestGet(const UINT id,IMTRequest* request)=0;
+   virtual MTAPIRES  RequestGetAll(IMTRequestArray* requests)=0;
+   virtual MTAPIRES  RequestReserved1(void)=0;
+   virtual MTAPIRES  RequestReserved2(void)=0;
+   virtual MTAPIRES  RequestReserved3(void)=0;
+   virtual MTAPIRES  RequestReserved4(void)=0;
+   //--- dealing
+   virtual IMTConfirm* DealerConfirmCreate(void)=0;
+   virtual MTAPIRES  DealerUnsubscribe(IMTDealerSink* sink)=0;
+   virtual MTAPIRES  DealerStart(void)=0;
+   virtual MTAPIRES  DealerStop(void)=0;
+   virtual MTAPIRES  DealerGet(IMTRequest* request)=0;
+   virtual MTAPIRES  DealerLock(const UINT id,IMTRequest* request)=0;
+   virtual MTAPIRES  DealerAnswer(IMTConfirm* confirm)=0;
+   virtual MTAPIRES  DealerSend(IMTRequest* request,IMTDealerSink* sink,UINT& id)=0;
+   virtual MTAPIRES  DealerBalance(const UINT64 login,const double value,const UINT type,LPCWSTR comment,UINT64& deal_id)=0;
+   virtual MTAPIRES  DealerBalanceRaw(const UINT64 login,const double value,const UINT type,LPCWSTR comment,UINT64& deal_id)=0;
+   virtual MTAPIRES  DealerReserved1(void)=0;
+   virtual MTAPIRES  DealerReserved2(void)=0;
+   virtual MTAPIRES  DealerReserved3(void)=0;
+   //--- custom commands
+   virtual MTAPIRES  CustomCommand(LPCVOID indata,const UINT indata_len,LPVOID& outdata,UINT& outdata_len)=0;
+   virtual MTAPIRES  CustomCommand(IMTByteStream* indata,IMTByteStream* outdata)=0;
+   virtual IMTByteStream* CustomCreateStream(void)=0;
+   virtual MTAPIRES  CustomReserved3(void)=0;
+   virtual MTAPIRES  CustomReserved4(void)=0;
+   //--- trade summary
+   virtual IMTSummary* SummaryCreate(void)=0;
+   virtual IMTSummaryArray* SummaryCreateArray(void)=0;
+   virtual MTAPIRES  SummarySubscribe(IMTSummarySink* sink)=0;
+   virtual MTAPIRES  SummaryUnsubscribe(IMTSummarySink* sink)=0;
+   virtual LPCWSTR   SummaryCurrency(void)=0;
+   virtual MTAPIRES  SummaryCurrency(LPCWSTR currency)=0;
+   virtual UINT      SummaryTotal(void)=0;
+   virtual MTAPIRES  SummaryNext(const UINT pos,IMTSummary* summary)=0;
+   virtual MTAPIRES  SummaryGet(LPCWSTR symbol,IMTSummary* summary)=0;
+   virtual MTAPIRES  SummaryGetAll(IMTSummaryArray* summary)=0;
+   //--- exposure
+   virtual IMTExposure* ExposureCreate(void)=0;
+   virtual IMTExposureArray* ExposureCreateArray(void)=0;
+   virtual MTAPIRES  ExposureSubscribe(IMTExposureSink* sink)=0;
+   virtual MTAPIRES  ExposureUnsubscribe(IMTExposureSink* sink)=0;
+   virtual LPCWSTR   ExposureCurrency(void)=0;
+   virtual MTAPIRES  ExposureCurrency(LPCWSTR currency)=0;
+   virtual UINT      ExposureTotal(void)=0;
+   virtual MTAPIRES  ExposureNext(const UINT pos,IMTExposure* exposure)=0;
+   virtual MTAPIRES  ExposureGet(LPCWSTR symbol,IMTExposure* exposure)=0;
+   virtual MTAPIRES  ExposureGetAll(IMTExposureArray* exposure)=0;
+   //--- external accounts
+   virtual MTAPIRES  UserExternalGet(const UINT64 gateway_id,LPCWSTR account,IMTUser* user)=0;
+   virtual MTAPIRES  UserExternalGet(LPCWSTR account,IMTUser* user)=0;
+   virtual MTAPIRES  UserExternalRequest(const UINT64 gateway_id,LPCWSTR account,IMTUser* user)=0;
+   virtual MTAPIRES  UserExternalRequest(LPCWSTR account,IMTUser* user)=0;
+   //--- clients and trade accounts request
+   virtual IMTUserArray* UserCreateArray(void)=0;
+   virtual IMTAccountArray* UserCreateAccountArray(void)=0;
+   virtual MTAPIRES  UserRequestArray(LPCWSTR group,IMTUserArray* users)=0;
+   virtual MTAPIRES  UserAccountRequestArray(LPCWSTR group,IMTAccountArray *accounts)=0;
+   //--- self password management
+   virtual MTAPIRES  PasswordChange(const UINT type,LPCWSTR password)=0;
+   virtual MTAPIRES  PasswordReserved1(void)=0;
+   virtual MTAPIRES  PasswordReserved2(void)=0;
+   //--- daily reports database
+   virtual IMTDaily* DailyCreate(void)=0;
+   virtual IMTDailyArray* DailyCreateArray(void)=0;
+   virtual MTAPIRES  DailyRequest(const UINT64 login,const INT64 from,const INT64 to,IMTDailyArray* daily)=0;
+   virtual MTAPIRES  DailyRequestLight(const UINT64 login,const INT64 from,const INT64 to,IMTDailyArray* daily)=0;
+   virtual MTAPIRES  DailyReserved1(void)=0;
+   virtual MTAPIRES  DailyReserved2(void)=0;
+   virtual MTAPIRES  DailyReserved3(void)=0;
+   virtual MTAPIRES  DailyReserved4(void)=0;
+   //--- plug-ins configuration
+   virtual IMTConPlugin* PluginCreate(void)=0;
+   virtual IMTConPluginModule* PluginModuleCreate(void)=0;
+   virtual IMTConParam* PluginParamCreate(void)=0;
+   virtual MTAPIRES  PluginUpdate(IMTConPlugin* plugin)=0;
+   virtual UINT      PluginTotal(void)=0;
+   virtual MTAPIRES  PluginNext(const UINT pos,IMTConPlugin* plugin)=0;
+   virtual MTAPIRES  PluginGet(LPCWSTR name,IMTConPlugin* plugin)=0;
+   virtual MTAPIRES  PluginReserved1(void)=0;
+   virtual MTAPIRES  PluginReserved2(void)=0;
+   virtual MTAPIRES  PluginReserved3(void)=0;
+   virtual MTAPIRES  PluginReserved4(void)=0;
+   //--- spreads configuration
+   virtual IMTConSpread* SpreadCreate(void)=0;
+   virtual IMTConSpreadLeg* SpreadLegCreate(void)=0;
+   virtual MTAPIRES  SpreadSubscribe(IMTConSpreadSink* sink)=0;
+   virtual MTAPIRES  SpreadUnsubscribe(IMTConSpreadSink* sink)=0;
+   virtual UINT      SpreadTotal(void)=0;
+   virtual MTAPIRES  SpreadNext(const UINT pos,IMTConSpread* spread)=0;
+   virtual MTAPIRES  SpreadReserved1(void)=0;
+   virtual MTAPIRES  SpreadReserved2(void)=0;
+   virtual MTAPIRES  SpreadReserved3(void)=0;
+   virtual MTAPIRES  SpreadReserved4(void)=0;
+   //--- trade methods
+   virtual MTAPIRES  TradeProfit(LPCWSTR group,LPCWSTR symbol,const UINT type,const UINT64 volume,const double price_open,const double price_close,double& profit,double& profit_rate)=0;
+   virtual MTAPIRES  TradeRateBuy(LPCWSTR base,LPCWSTR currency,double& rate,LPCWSTR group=NULL,LPCWSTR symbol=NULL,const double price=0)=0;
+   virtual MTAPIRES  TradeRateSell(LPCWSTR base,LPCWSTR currency,double& rate,LPCWSTR group=NULL,LPCWSTR symbol=NULL,const double price=0)=0;
+   virtual MTAPIRES  TradeMarginCheck(const UINT64 login,LPCWSTR symbol,const UINT type,const UINT64 volume,const double price,IMTAccount* account_new=NULL,IMTAccount* account_current=NULL)=0;
+   virtual MTAPIRES  TradeMarginCheck(const IMTOrder* order,IMTAccount* account_new=NULL,IMTAccount* account_current=NULL)=0;
+   virtual MTAPIRES  TradeProfitExt(LPCWSTR group,LPCWSTR symbol,const UINT type,const UINT64 volume,const double price_open,const double price_close,double& profit,double& profit_rate)=0;
+   virtual MTAPIRES  TradeMarginCheckExt(const UINT64 login,LPCWSTR symbol,const UINT type,const UINT64 volume,const double price,IMTAccount* account_new=NULL,IMTAccount* account_current=NULL)=0;
+   virtual MTAPIRES  TradeReserved3(void)=0;
+   virtual MTAPIRES  TradeReserved4(void)=0;
+   //--- network connection
+   virtual MTAPIRES  NetworkRescan(const UINT flags,const UINT timeout)=0;
+   virtual UINT64    NetworkBytesSent(void)=0;
+   virtual UINT64    NetworkBytesRead(void)=0;
+   virtual MTAPIRES  NetworkServer(MTAPISTR& server)=0;
+   virtual MTAPIRES  NetworkAddress(MTAPISTR& address)=0;
+   virtual MTAPIRES  NetworkReserved1(void)=0;
+   virtual MTAPIRES  NetworkReserved2(void)=0;
+   virtual MTAPIRES  NetworkReserved3(void)=0;
+   virtual MTAPIRES  NetworkReserved4(void)=0;
+   //--- online connection data
+   virtual IMTOnline* OnlineCreate(void)=0;
+   virtual IMTOnlineArray* OnlineCreateArray(void)=0;
+   virtual UINT      OnlineTotal(void)=0;
+   virtual MTAPIRES  OnlineNext(const UINT pos,IMTOnline* online)=0;
+   virtual MTAPIRES  OnlineGet(const UINT64 login,IMTOnlineArray* online)=0;
+   virtual MTAPIRES  OnlineReserved1(void)=0;
+   virtual MTAPIRES  OnlineReserved2(void)=0;
+   virtual MTAPIRES  OnlineReserved3(void)=0;
+   virtual MTAPIRES  OnlineReserved4(void)=0;
+   //--- trading accounts control
+   virtual MTAPIRES  TradeAccountSet(const INT64 request_id,
+                                     const IMTUser *user,
+                                     const IMTAccount *account,
+                                     const IMTOrderArray *orders,
+                                     const IMTPositionArray *positions)=0;
+   virtual MTAPIRES  TradeAccountReserved1(void)=0;
+   virtual MTAPIRES  TradeAccountReserved2(void)=0;
+   virtual MTAPIRES  TradeAccountReserved3(void)=0;
+   virtual MTAPIRES  TradeAccountReserved4(void)=0;
+   //--- notifications
+   virtual MTAPIRES  NotificationsSend(LPWSTR metaquotes_ids,LPCWSTR message)=0;
+   virtual MTAPIRES  NotificationsSend(const UINT64* logins,const UINT logins_total,LPCWSTR message)=0;
+   virtual MTAPIRES  NotificationsReserved1(void)=0;
+   virtual MTAPIRES  NotificationsReserved2(void)=0;
+   virtual MTAPIRES  NotificationsReserved3(void)=0;
+   virtual MTAPIRES  NotificationsReserved4(void)=0;
+   //--- settings
+   virtual MTAPIRES  SettingGet(LPCWSTR section,LPCWSTR key,LPVOID& outdata,UINT& outdata_len)=0;
+   virtual MTAPIRES  SettingSet(LPCWSTR section,LPCWSTR key,const LPVOID indata,const UINT indata_len)=0;
+   virtual MTAPIRES  SettingDelete(LPCWSTR section,LPCWSTR key)=0;
+   virtual MTAPIRES  SettingReserved1(void)=0;
+   virtual MTAPIRES  SettingReserved2(void)=0;
+   virtual MTAPIRES  SettingReserved3(void)=0;
+   virtual MTAPIRES  SettingReserved4(void)=0;
+   //--- chart data
+   virtual MTAPIRES  ChartRequest(LPCWSTR symbol,const INT64 from,const INT64 to,MTChartBar*& bars,UINT& bars_total)=0;
+   virtual MTAPIRES  ChartDelete(LPCWSTR symbol,const INT64* bars_dates,const UINT bars_total)=0;
+   virtual MTAPIRES  ChartUpdate(LPCWSTR symbol,const MTChartBar* bars,const UINT bars_total)=0;
+   virtual MTAPIRES  ChartReplace(LPCWSTR symbol,const INT64 from,const INT64 to,const MTChartBar* bars,const UINT bars_total)=0;
+   virtual MTAPIRES  ChartSplit(LPCWSTR symbol,const UINT new_shares,const UINT old_shares,const UINT rounding_rule,const INT64 datetime_from,const INT64 datetime_to)=0;
+   virtual MTAPIRES  ChartReserved2(void)=0;
+   virtual MTAPIRES  ChartReserved3(void)=0;
+   //--- ticks data
+   virtual MTAPIRES  TickHistoryRequestRaw(LPCWSTR symbol,const INT64 from,const INT64 to,MTTickShort*& ticks,UINT& ticks_total)=0;
+   virtual MTAPIRES  TickHistoryAdd(LPCWSTR symbol,const MTTickShort* ticks,const UINT ticks_total)=0;
+   virtual MTAPIRES  TickHistoryReplace(LPCWSTR symbol,const INT64 from_msc,const INT64 to_msc,const MTTickShort* ticks,const UINT ticks_total)=0;
+   virtual MTAPIRES  TickHistoryReserved1(void)=0;
+   virtual MTAPIRES  TickHistoryReserved2(void)=0;
+   virtual MTAPIRES  TickHistoryReserved3(void)=0;
+   virtual MTAPIRES  TickHistoryReserved4(void)=0;
+   //--- deals database
+   virtual MTAPIRES  DealRequestByGroup(LPCWSTR group,const INT64 from,const INT64 to,IMTDealArray* deals)=0;
+   virtual MTAPIRES  DealRequestByLogins(const UINT64 *logins,const UINT logins_total,const INT64 from,const INT64 to,IMTDealArray* deals)=0;
+   virtual MTAPIRES  DealRequestByTickets(const UINT64 *tickets,const UINT tickets_total,IMTDealArray* deals)=0;
+   virtual MTAPIRES  DealUpdateBatch(IMTDealArray* deals,MTAPIRES* results)=0;
+   virtual MTAPIRES  DealUpdateBatchArray(IMTDeal** deals,const UINT deals_total,MTAPIRES* results)=0;
+   virtual MTAPIRES  DealDeleteBatch(const UINT64* tickets,const UINT tickets_total,MTAPIRES* results)=0;
+   virtual MTAPIRES  DealReserved1(void)=0;
+   virtual MTAPIRES  DealReserved2(void)=0;
+   virtual MTAPIRES  DealReserved3(void)=0;
+   virtual MTAPIRES  DealReserved4(void)=0;
+   //--- positions database
+   virtual MTAPIRES  PositionGetByLogins(const UINT64 *logins,const UINT logins_total,IMTPositionArray* positions)=0;
+   virtual MTAPIRES  PositionGetByTickets(const UINT64 *tickets,const UINT tickets_total,IMTPositionArray* positions)=0;
+   virtual MTAPIRES  PositionDeleteByTicket(const UINT64 ticket)=0;
+   virtual MTAPIRES  PositionRequestByGroup(LPCWSTR group,IMTPositionArray* positions)=0;
+   virtual MTAPIRES  PositionRequestByLogins(const UINT64 *logins,const UINT logins_total,IMTPositionArray* positions)=0;
+   virtual MTAPIRES  PositionRequestByTickets(const UINT64 *tickets,const UINT tickets_total,IMTPositionArray* positions)=0;
+   virtual MTAPIRES  PositionUpdateBatch(IMTPositionArray* positions,MTAPIRES* results)=0;
+   virtual MTAPIRES  PositionUpdateBatchArray(IMTPosition** positions,const UINT positions_total,MTAPIRES* results)=0;
+   virtual MTAPIRES  PositionDeleteBatch(const UINT64* tickets,const UINT tickets_total,MTAPIRES* results)=0;
+   virtual MTAPIRES  PositionReserved1(void)=0;
+   virtual MTAPIRES  PositionReserved2(void)=0;
+   virtual MTAPIRES  PositionReserved3(void)=0;
+   virtual MTAPIRES  PositionReserved4(void)=0;
+   //--- orders database
+   virtual MTAPIRES  OrderGetByTickets(const UINT64 *tickets,const UINT tickets_total,IMTOrderArray* orders)=0;
+   virtual MTAPIRES  OrderRequestByGroup(LPCWSTR group,IMTOrderArray* orders)=0;
+   virtual MTAPIRES  OrderRequestByLogins(const UINT64 *logins,const UINT logins_total,IMTOrderArray* orders)=0;
+   virtual MTAPIRES  OrderRequestByTickets(const UINT64 *tickets,const UINT tickets_total,IMTOrderArray* orders)=0;
+   virtual MTAPIRES  OrderUpdateBatch(IMTOrderArray* orders,MTAPIRES* results)=0;
+   virtual MTAPIRES  OrderUpdateBatchArray(IMTOrder** orders,const UINT orders_total,MTAPIRES* results)=0;
+   virtual MTAPIRES  OrderDeleteBatch(const UINT64* tickets,const UINT tickets_total,MTAPIRES* results)=0;
+   virtual MTAPIRES  OrderReserved1(void)=0;
+   virtual MTAPIRES  OrderReserved2(void)=0;
+   virtual MTAPIRES  OrderReserved3(void)=0;
+   virtual MTAPIRES  OrderReserved4(void)=0;
+   //--- orders history database
+   virtual MTAPIRES  HistoryRequestByGroup(LPCWSTR group,const INT64 from,const INT64 to,IMTOrderArray* orders)=0;
+   virtual MTAPIRES  HistoryRequestByLogins(const UINT64 *logins,const UINT logins_total,const INT64 from,const INT64 to,IMTOrderArray* orders)=0;
+   virtual MTAPIRES  HistoryRequestByTickets(const UINT64 *tickets,const UINT tickets_total,IMTOrderArray* orders)=0;
+   virtual MTAPIRES  HistoryReserved1(void)=0;
+   virtual MTAPIRES  HistoryReserved2(void)=0;
+   virtual MTAPIRES  HistoryReserved3(void)=0;
+   virtual MTAPIRES  HistoryReserved4(void)=0;
+   //--- email servers configuration
+   virtual MTAPIRES  EmailSend(LPCWSTR account,LPCWSTR to,LPCWSTR to_name,LPCWSTR subject,LPCWSTR body)=0;
+   virtual MTAPIRES  EmailReserved1(void)=0;
+   virtual MTAPIRES  EmailReserved2(void)=0;
+   virtual MTAPIRES  EmailReserved3(void)=0;
+   virtual MTAPIRES  EmailReserved4(void)=0;
+   //--- messengers configuration
+   virtual MTAPIRES  MessengerSend(LPCWSTR destination,LPCWSTR group,LPCWSTR sender,LPCWSTR text)=0;
+   virtual MTAPIRES  MessengerReserved1(void)=0;
+   virtual MTAPIRES  MessengerReserved2(void)=0;
+   virtual MTAPIRES  MessengerReserved3(void)=0;
+   virtual MTAPIRES  MessengerReserved4(void)=0;
+  };
+//+------------------------------------------------------------------+
+//| Administrator API interface                                      |
+//+------------------------------------------------------------------+
+class IMTAdminAPI
+  {
+public:
+   //--- pumping modes
+   enum EnPumpModes
+     {
+      PUMP_MODE_MAIL          =0x00000004,   // pump mails
+      PUMP_MODE_NEWS          =0x00000020,   // pump news
+      //--- enumeration ranges
+      PUMP_MODE_FULL          =0xffffffff    // full pumping
+     };
+   //--- external sync modes
+   enum EnExternalSyncModes
+     {
+      EXTERNAL_SYNC_ALL      =0,
+      EXTERNAL_SYNC_BALANCE  =1,
+      EXTERNAL_SYNC_POSITIONS=2,
+      EXTERNAL_SYNC_ORDERS   =3,
+      EXTERNAL_SYNC_LAST     =EXTERNAL_SYNC_ORDERS
+     };
+   //--- interface release
+   virtual void      Release(void)=0;
+   //--- Manager license check
+   virtual MTAPIRES  LicenseCheck(MTLicenseCheck& check)=0;
+   //--- memory management
+   virtual void*     Allocate(const UINT bytes)=0;
+   virtual void      Free(void* ptr)=0;
+   //--- proxy
+   virtual void      ProxySet(const MTProxyInfo &proxy)=0;
+   //--- connect/disconnect
+   virtual MTAPIRES  Connect(LPCWSTR server,UINT64 login,LPCWSTR password,LPCWSTR password_cert,UINT64 pump_mode,UINT timeout=INFINITE)=0;
+   virtual void      Disconnect(void)=0;
+   virtual MTAPIRES  Subscribe(IMTManagerSink* sink)=0;
+   virtual MTAPIRES  Unsubscribe(IMTManagerSink* sink)=0;
+   //--- server management
+   virtual MTAPIRES  ServerActivate(void)=0;
+   virtual MTAPIRES  ServerLiveUpdate(void)=0;
+   //--- API journal
+   virtual MTAPIRES  LoggerOut(const UINT code,LPCWSTR format,...)=0;
+   virtual void      LoggerFlush(void)=0;
+   virtual MTAPIRES  LoggerServerRequest(const UINT64 server_id,const UINT mode,const UINT type,
+                                         const INT64 from,const INT64 to,LPCWSTR filter,
+                                         MTLogRecord*& records,UINT& records_total)=0;
+   virtual MTAPIRES  LoggerGatewayRequest(const UINT gateway_pos,const INT64 from,const INT64 to,LPCWSTR filter,
+                                          MTLogRecord*& records,UINT& records_total)=0;
+   virtual MTAPIRES  LoggerFeederRequest(const UINT feeder_pos,const INT64 from,const INT64 to,LPCWSTR filter,
+                                         MTLogRecord*& records,UINT& records_total)=0;
+   virtual MTAPIRES  LoggerReserved1(void)=0;
+   virtual MTAPIRES  LoggerReserved2(void)=0;
+   virtual MTAPIRES  LoggerReserved3(void)=0;
+   virtual MTAPIRES  LoggerReserved4(void)=0;
+   //--- common configuration
+   virtual IMTConCommon* CommonCreate(void)=0;
+   virtual MTAPIRES  CommonSubscribe(IMTConCommonSink* sink)=0;
+   virtual MTAPIRES  CommonUnsubscribe(IMTConCommonSink* sink)=0;
+   virtual MTAPIRES  CommonGet(IMTConCommon* common)=0;
+   virtual MTAPIRES  CommonSet(IMTConCommon* common)=0;
+   virtual MTAPIRES  CommonReserved1(void)=0;
+   virtual MTAPIRES  CommonReserved2(void)=0;
+   virtual MTAPIRES  CommonReserved3(void)=0;
+   virtual MTAPIRES  CommonReserved4(void)=0;
+   //--- platform server configuration
+   virtual IMTConServer* NetServerCreate(void)=0;
+   virtual IMTConServerRange* NetServerRangeCreate(void)=0;
+   virtual MTAPIRES  NetServerSubscribe(IMTConServerSink* sink)=0;
+   virtual MTAPIRES  NetServerUnsubscribe(IMTConServerSink* sink)=0;
+   virtual MTAPIRES  NetServerRestart(const UINT64 id)=0;
+   virtual MTAPIRES  NetServerUpdate(IMTConServer* config)=0;
+   virtual MTAPIRES  NetServerDelete(const UINT pos)=0;
+   virtual MTAPIRES  NetServerShift(const UINT pos,const int shift)=0;
+   virtual UINT      NetServerTotal(void)=0;
+   virtual MTAPIRES  NetServerNext(const UINT pos,IMTConServer* config)=0;
+   virtual MTAPIRES  NetServerGet(const UINT64 id,IMTConServer* config)=0;
+   virtual MTAPIRES  NetServerUpdateBatch(IMTConServer** configs,const UINT config_total,MTAPIRES* results)=0;
+   virtual MTAPIRES  NetServerDeleteBatch(IMTConServer** configs,const UINT config_total,MTAPIRES* results)=0;
+   virtual IMTConAddressRange* NetServerAddressRangeCreate(void)=0;
+   virtual MTAPIRES  NetServerReserved4(void)=0;
+   //--- server firewall configuration
+   virtual IMTConFirewall* FirewallCreate()=0;
+   virtual MTAPIRES  FirewallSubscribe(IMTConFirewallSink* sink)=0;
+   virtual MTAPIRES  FirewallUnsubscribe(IMTConFirewallSink* sink)=0;
+   virtual MTAPIRES  FirewallUpdate(IMTConFirewall* config)=0;
+   virtual MTAPIRES  FirewallDelete(const UINT pos)=0;
+   virtual MTAPIRES  FirewallShift(const UINT pos,const int shift)=0;
+   virtual UINT      FirewallTotal(void)=0;
+   virtual MTAPIRES  FirewallNext(const UINT pos,IMTConFirewall* config)=0;
+   virtual MTAPIRES  FirewallUpdateBatch(IMTConFirewall** configs,const UINT config_total,MTAPIRES* results)=0;
+   virtual MTAPIRES  FirewallDeleteBatch(IMTConFirewall** configs,const UINT config_total,MTAPIRES* results)=0;
+   virtual MTAPIRES  FirewallReserved3(void)=0;
+   virtual MTAPIRES  FirewallReserved4(void)=0;
+   //--- time configuration
+   virtual IMTConTime* TimeCreate(void)=0;
+   virtual MTAPIRES  TimeSubscribe(IMTConTimeSink* sink)=0;
+   virtual MTAPIRES  TimeUnsubscribe(IMTConTimeSink* sink)=0;
+   virtual MTAPIRES  TimeGet(IMTConTime* config)=0;
+   virtual MTAPIRES  TimeSet(IMTConTime* config)=0;
+   virtual INT64     TimeServer(void)=0;
+   virtual MTAPIRES  TimeServerRequest(INT64& time_msc)=0;
+   virtual MTAPIRES  TimeReserved2(void)=0;
+   virtual MTAPIRES  TimeReserved3(void)=0;
+   virtual MTAPIRES  TimeReserved4(void)=0;
+   //--- holidays configuration
+   virtual IMTConHoliday* HolidayCreate()=0;
+   virtual MTAPIRES  HolidaySubscribe(IMTConHolidaySink* sink)=0;
+   virtual MTAPIRES  HolidayUnsubscribe(IMTConHolidaySink* sink)=0;
+   virtual MTAPIRES  HolidayUpdate(IMTConHoliday* config)=0;
+   virtual MTAPIRES  HolidayDelete(const UINT pos)=0;
+   virtual MTAPIRES  HolidayShift(const UINT pos,const int shift)=0;
+   virtual UINT      HolidayTotal(void)=0;
+   virtual MTAPIRES  HolidayNext(const UINT pos,IMTConHoliday* config)=0;
+   virtual MTAPIRES  HolidayUpdateBatch(IMTConHoliday** configs,const UINT config_total,MTAPIRES* results)=0;
+   virtual MTAPIRES  HolidayDeleteBatch(IMTConHoliday** configs,const UINT config_total,MTAPIRES* results)=0;
+   virtual MTAPIRES  HolidayReserved3(void)=0;
+   virtual MTAPIRES  HolidayReserved4(void)=0;
+   //--- clients group configuration
+   virtual IMTConGroup* GroupCreate(void)=0;
+   virtual IMTConGroupSymbol* GroupSymbolCreate(void)=0;
+   virtual IMTConCommission* GroupCommissionCreate(void)=0;
+   virtual IMTConCommTier* GroupTierCreate(void)=0;
+   virtual MTAPIRES  GroupSubscribe(IMTConGroupSink* sink)=0;
+   virtual MTAPIRES  GroupUnsubscribe(IMTConGroupSink* sink)=0;
+   virtual MTAPIRES  GroupUpdate(IMTConGroup* group)=0;
+   virtual MTAPIRES  GroupDelete(LPCWSTR name)=0;
+   virtual MTAPIRES  GroupDelete(const UINT pos)=0;
+   virtual MTAPIRES  GroupShift(const UINT pos,const int shift)=0;
+   virtual UINT      GroupTotal(void)=0;
+   virtual MTAPIRES  GroupNext(const UINT pos,IMTConGroup* group)=0;
+   virtual MTAPIRES  GroupGet(LPCWSTR name,IMTConGroup* group)=0;
+   virtual MTAPIRES  GroupUpdateBatch(IMTConGroup** configs,const UINT config_total,MTAPIRES* results)=0;
+   virtual MTAPIRES  GroupDeleteBatch(IMTConGroup** configs,const UINT config_total,MTAPIRES* results)=0;
+   virtual MTAPIRES  GroupReserved3(void)=0;
+   virtual MTAPIRES  GroupReserved4(void)=0;
+   //--- managers configuration
+   virtual IMTConManager* ManagerCreate(void)=0;
+   virtual IMTConManagerAccess* ManagerAccessCreate(void)=0;
+   virtual MTAPIRES  ManagerSubscribe(IMTConManagerSink* sink)=0;
+   virtual MTAPIRES  ManagerUnsubscribe(IMTConManagerSink* sink)=0;
+   virtual MTAPIRES  ManagerUpdate(IMTConManager* manager)=0;
+   virtual MTAPIRES  ManagerDelete(const UINT pos)=0;
+   virtual MTAPIRES  ManagerShift(const UINT pos,const int shift)=0;
+   virtual UINT      ManagerTotal(void)=0;
+   virtual MTAPIRES  ManagerNext(const UINT pos,IMTConManager* manager)=0;
+   virtual MTAPIRES  ManagerGet(const UINT64 login,IMTConManager* manager)=0;
+   virtual MTAPIRES  ManagerUpdateBatch(IMTConManager** configs,const UINT config_total,MTAPIRES* results)=0;
+   virtual MTAPIRES  ManagerDeleteBatch(IMTConManager** configs,const UINT config_total,MTAPIRES* results)=0;
+   virtual MTAPIRES  ManagerReserved3(void)=0;
+   virtual MTAPIRES  ManagerReserved4(void)=0;
+   //--- routing configuration
+   virtual IMTConRoute* RouteCreate(void)=0;
+   virtual IMTConCondition* RouteConditionCreate(void)=0;
+   virtual IMTConRouteDealer* RouteDealerCreate(void)=0;
+   virtual MTAPIRES  RouteSubscribe(IMTConRouteSink* sink)=0;
+   virtual MTAPIRES  RouteUnsubscribe(IMTConRouteSink* sink)=0;
+   virtual MTAPIRES  RouteUpdate(IMTConRoute* route)=0;
+   virtual MTAPIRES  RouteDelete(LPCWSTR name)=0;
+   virtual MTAPIRES  RouteDelete(const UINT pos)=0;
+   virtual MTAPIRES  RouteShift(const UINT pos,const int shift)=0;
+   virtual UINT      RouteTotal(void)=0;
+   virtual MTAPIRES  RouteNext(const UINT pos,IMTConRoute* route)=0;
+   virtual MTAPIRES  RouteGet(LPCWSTR name,IMTConRoute* route)=0;
+   virtual MTAPIRES  RouteUpdateBatch(IMTConRoute** configs,const UINT config_total,MTAPIRES* results)=0;
+   virtual MTAPIRES  RouteDeleteBatch(IMTConRoute** configs,const UINT config_total,MTAPIRES* results)=0;
+   virtual MTAPIRES  RouteReserved3(void)=0;
+   virtual MTAPIRES  RouteReserved4(void)=0;
+   //--- gateways configuration
+   virtual IMTConGateway* GatewayCreate(void)=0;
+   virtual IMTConGatewayModule* GatewayModuleCreate(void)=0;
+   virtual IMTConParam* GatewayParamCreate(void)=0;
+   virtual IMTConGatewayTranslate* GatewayTranslateCreate(void)=0;
+   virtual MTAPIRES  GatewaySubscribe(IMTConGatewaySink* sink)=0;
+   virtual MTAPIRES  GatewayUnsubscribe(IMTConGatewaySink* sink)=0;
+   virtual MTAPIRES  GatewayRestart(void)=0;
+   virtual MTAPIRES  GatewayUpdate(IMTConGateway* gateway)=0;
+   virtual MTAPIRES  GatewayDelete(LPCWSTR name)=0;
+   virtual MTAPIRES  GatewayDelete(const UINT pos)=0;
+   virtual MTAPIRES  GatewayShift(const UINT pos,const int shift)=0;
+   virtual UINT      GatewayTotal(void)=0;
+   virtual MTAPIRES  GatewayNext(const UINT pos,IMTConGateway* gateway)=0;
+   virtual MTAPIRES  GatewayGet(LPCWSTR name,IMTConGateway* gateway)=0;
+   virtual UINT      GatewayModuleTotal(void)=0;
+   virtual MTAPIRES  GatewayModuleNext(const UINT pos,IMTConGatewayModule* module)=0;
+   virtual MTAPIRES  GatewayModuleGet(LPCWSTR name,IMTConGatewayModule* module)=0;
+   virtual MTAPIRES  GatewayPositionRequest(UINT64 gateway_id,IMTPositionArray *positions,INT64 &positions_time)=0;
+   virtual MTAPIRES  GatewayUpdateBatch(IMTConGateway** configs,const UINT config_total,MTAPIRES* results)=0;
+   virtual MTAPIRES  GatewayDeleteBatch(IMTConGateway** configs,const UINT config_total,MTAPIRES* results)=0;
+   virtual MTAPIRES  GatewayReserved3(void)=0;
+   //--- plug-ins configuration
+   virtual IMTConPlugin* PluginCreate(void)=0;
+   virtual IMTConPluginModule* PluginModuleCreate(void)=0;
+   virtual IMTConParam* PluginParamCreate(void)=0;
+   virtual MTAPIRES  PluginSubscribe(IMTConPluginSink* sink)=0;
+   virtual MTAPIRES  PluginUnsubscribe(IMTConPluginSink* sink)=0;
+   virtual MTAPIRES  PluginUpdate(IMTConPlugin* plugin)=0;
+   virtual MTAPIRES  PluginDelete(const UINT64 server_id,LPCWSTR name)=0;
+   virtual MTAPIRES  PluginDelete(const UINT pos)=0;
+   virtual MTAPIRES  PluginShift(const UINT pos,const int shift)=0;
+   virtual UINT      PluginTotal(void)=0;
+   virtual MTAPIRES  PluginNext(const UINT pos,IMTConPlugin* plugin)=0;
+   virtual MTAPIRES  PluginGet(const UINT64 server_id,LPCWSTR name,IMTConPlugin* plugin)=0;
+   virtual UINT      PluginModuleTotal(void)=0;
+   virtual MTAPIRES  PluginModuleNext(const UINT pos,IMTConPluginModule* module)=0;
+   virtual MTAPIRES  PluginModuleGet(const UINT64 server_id,LPCWSTR name,IMTConPluginModule* module)=0;
+   virtual MTAPIRES  PluginUpdateBatch(IMTConPlugin** configs,const UINT config_total,MTAPIRES* results)=0;
+   virtual MTAPIRES  PluginDeleteBatch(IMTConPlugin** configs,const UINT config_total,MTAPIRES* results)=0;
+   virtual MTAPIRES  PluginReserved3(void)=0;
+   virtual MTAPIRES  PluginReserved4(void)=0;
+   //--- data feeds configuration
+   virtual IMTConFeeder* FeederCreate(void)=0;
+   virtual IMTConFeederModule* FeederModuleCreate(void)=0;
+   virtual IMTConParam* FeederParamCreate(void)=0;
+   virtual IMTConFeederTranslate* FeederTranslateCreate(void)=0;
+   virtual MTAPIRES  FeederSubscribe(IMTConFeederSink* sink)=0;
+   virtual MTAPIRES  FeederUnsubscribe(IMTConFeederSink* sink)=0;
+   virtual MTAPIRES  FeederRestart(void)=0;
+   virtual MTAPIRES  FeederUpdate(IMTConFeeder* feeder)=0;
+   virtual MTAPIRES  FeederDelete(LPCWSTR name)=0;
+   virtual MTAPIRES  FeederDelete(const UINT pos)=0;
+   virtual MTAPIRES  FeederShift(const UINT pos,const int shift)=0;
+   virtual UINT      FeederTotal(void)=0;
+   virtual MTAPIRES  FeederNext(const UINT pos,IMTConFeeder* feeder)=0;
+   virtual MTAPIRES  FeederGet(LPCWSTR name,IMTConFeeder* feeder)=0;
+   virtual UINT      FeederModuleTotal(void)=0;
+   virtual MTAPIRES  FeederModuleNext(const UINT pos,IMTConFeederModule* module)=0;
+   virtual MTAPIRES  FeederModuleGet(LPCWSTR name,IMTConFeederModule* module)=0;
+   virtual MTAPIRES  FeederUpdateBatch(IMTConFeeder** configs,const UINT config_total,MTAPIRES* results)=0;
+   virtual MTAPIRES  FeederDeleteBatch(IMTConFeeder** configs,const UINT config_total,MTAPIRES* results)=0;
+   virtual MTAPIRES  FeederReserved3(void)=0;
+   virtual MTAPIRES  FeederReserved4(void)=0;
+   //--- report configuration
+   virtual IMTConReport* ReportCreate(void)=0;
+   virtual IMTConReportModule* ReportModuleCreate(void)=0;
+   virtual IMTConParam* ReportParamCreate(void)=0;
+   virtual MTAPIRES  ReportSubscribe(IMTConReportSink* sink)=0;
+   virtual MTAPIRES  ReportUnsubscribe(IMTConReportSink* sink)=0;
+   virtual MTAPIRES  ReportUpdate(IMTConReport* report)=0;
+   virtual MTAPIRES  ReportDelete(const UINT64 server_id,LPCWSTR name)=0;
+   virtual MTAPIRES  ReportDelete(const UINT pos)=0;
+   virtual MTAPIRES  ReportShift(const UINT pos,const int shift)=0;
+   virtual UINT      ReportTotal(void)=0;
+   virtual MTAPIRES  ReportNext(const UINT pos,IMTConReport* report)=0;
+   virtual MTAPIRES  ReportGet(const UINT64 server_id,LPCWSTR name,IMTConReport* report)=0;
+   virtual UINT      ReportModuleTotal(void)=0;
+   virtual MTAPIRES  ReportModuleNext(const UINT pos,IMTConReportModule* module)=0;
+   virtual MTAPIRES  ReportModuleGet(const UINT64 server_id,LPCWSTR name,IMTConReportModule* module)=0;
+   virtual MTAPIRES  ReportUpdateBatch(IMTConReport** configs,const UINT config_total,MTAPIRES* results)=0;
+   virtual MTAPIRES  ReportDeleteBatch(IMTConReport** configs,const UINT config_total,MTAPIRES* results)=0;
+   virtual MTAPIRES  ReportReserved3(void)=0;
+   virtual MTAPIRES  ReportReserved4(void)=0;
+   //--- symbols configuration
+   virtual IMTConSymbol* SymbolCreate(void)=0;
+   virtual IMTConSymbolSession* SymbolSessionCreate(void)=0;
+   virtual MTAPIRES  SymbolSubscribe(IMTConSymbolSink* sink)=0;
+   virtual MTAPIRES  SymbolUnsubscribe(IMTConSymbolSink* sink)=0;
+   virtual MTAPIRES  SymbolUpdate(IMTConSymbol* symbol)=0;
+   virtual MTAPIRES  SymbolDelete(LPCWSTR name)=0;
+   virtual MTAPIRES  SymbolDelete(const UINT pos)=0;
+   virtual MTAPIRES  SymbolShift(const UINT pos,const int shift)=0;
+   virtual UINT      SymbolTotal(void)=0;
+   virtual MTAPIRES  SymbolNext(const UINT pos,IMTConSymbol* symbol)=0;
+   virtual MTAPIRES  SymbolGet(LPCWSTR name,IMTConSymbol* symbol)=0;
+   virtual MTAPIRES  SymbolExist(const IMTConSymbol* symbol,const IMTConGroup* group)=0;
+   virtual MTAPIRES  SymbolUpdateBatch(IMTConSymbol** configs,const UINT configs_total,MTAPIRES* results)=0;
+   virtual MTAPIRES  SymbolDeleteBatch(IMTConSymbol** configs,const UINT configs_total,MTAPIRES* results)=0;
+   virtual MTAPIRES  SymbolReserved3(void)=0;
+   virtual MTAPIRES  SymbolReserved4(void)=0;
+   //--- history synchronization configuration
+   virtual IMTConHistorySync* HistorySyncCreate(void)=0;
+   virtual MTAPIRES  HistorySyncSubscribe(IMTConHistorySyncSink* sink)=0;
+   virtual MTAPIRES  HistorySyncUnsubscribe(IMTConHistorySyncSink* sink)=0;
+   virtual MTAPIRES  HistorySyncStart(void)=0;
+   virtual MTAPIRES  HistorySyncUpdate(IMTConHistorySync* config)=0;
+   virtual MTAPIRES  HistorySyncDelete(const UINT pos)=0;
+   virtual MTAPIRES  HistorySyncShift(const UINT pos,const int shift)=0;
+   virtual UINT      HistorySyncTotal(void)=0;
+   virtual MTAPIRES  HistorySyncNext(const UINT pos,IMTConHistorySync* config)=0;
+   virtual MTAPIRES  HistorySyncUpdateBatch(IMTConHistorySync** configs,const UINT configs_total,MTAPIRES* results)=0;
+   virtual MTAPIRES  HistorySyncDeleteBatch(IMTConHistorySync** configs,const UINT configs_total,MTAPIRES* results)=0;
+   virtual MTAPIRES  HistorySyncReserved3(void)=0;
+   virtual MTAPIRES  HistorySyncReserved4(void)=0;
+   //--- clients database
+   virtual IMTUser*  UserCreate(void)=0;
+   virtual IMTUserArray* UserCreateArray(void)=0;
+   virtual MTAPIRES  UserAdd(IMTUser* user,LPCWSTR master_pass,LPCWSTR investor_pass)=0;
+   virtual MTAPIRES  UserDelete(const UINT64 login)=0;
+   virtual MTAPIRES  UserUpdate(IMTUser* user)=0;
+   virtual MTAPIRES  UserRequest(const UINT64 login,IMTUser *user)=0;
+   virtual MTAPIRES  UserPasswordCheck(const UINT type,const UINT64 login,LPCWSTR password)=0;
+   virtual MTAPIRES  UserPasswordChange(const UINT type,const UINT64 login,LPCWSTR password)=0;
+   virtual MTAPIRES  UserCertDelete(const UINT64 login)=0;
+   virtual MTAPIRES  UserCertConfirm(const UINT64 login)=0;
+   virtual MTAPIRES  UserExternalSync(const UINT64 login,const UINT64 gateway_id,LPCWSTR account_id,UINT sync_mode)=0;
+   virtual MTAPIRES  UserArchive(const UINT64 login)=0;
+   virtual MTAPIRES  UserArchiveRequest(const UINT64 login,IMTUser* user)=0;
+   virtual MTAPIRES  UserBackupRequest(const INT64 backup,const UINT64 login,IMTUser* user)=0;
+   virtual MTAPIRES  UserBackupList(const INT64 from,const INT64 to,INT64*& backups,UINT& backups_total)=0;
+   virtual MTAPIRES  UserRestore(IMTUser* user)=0;
+   virtual IMTCertificate *UserCertCreate(void)=0;
+   virtual MTAPIRES  UserCertUpdate(const UINT64 login,const IMTCertificate *certificate)=0;
+   virtual MTAPIRES  UserCertGet(const UINT64 login,IMTCertificate *certificate)=0;
+   virtual MTAPIRES  UserBalanceCheck(const UINT64 login,const UINT fixflag,double& balance_user,double& balance_history,double& credit_user,double& credit_history)=0;
+   //--- deals database
+   virtual IMTDeal*  DealCreate(void)=0;
+   virtual IMTDealArray* DealCreateArray(void)=0;
+   virtual MTAPIRES  DealRequest(const UINT64 ticket,IMTDeal* deal)=0;
+   virtual MTAPIRES  DealRequest(const UINT64 login,const INT64 from,const INT64 to,IMTDealArray* deals)=0;
+   virtual MTAPIRES  DealDelete(const UINT64 ticket)=0;
+   virtual MTAPIRES  DealUpdate(IMTDeal* deal)=0;
+   virtual MTAPIRES  DealBackupList(const INT64 from,const INT64 to,INT64*& backups,UINT& backups_total)=0;
+   virtual MTAPIRES  DealBackupRequest(const INT64 backup,const UINT64 ticket,IMTDeal* deal)=0;
+   virtual MTAPIRES  DealBackupRequest(const INT64 backup,const UINT64 login,const INT64 from,const INT64 to,IMTDealArray* deals)=0;
+   virtual MTAPIRES  DealBackupRestore(IMTDeal* deal)=0;
+   virtual MTAPIRES  DealBackupList(const UINT64 server,const INT64 from,const INT64 to,INT64*& backups,UINT& backups_total)=0;
+   virtual MTAPIRES  DealBackupRequest(const UINT64 server,const INT64 backup,const UINT64 ticket,IMTDeal* deal)=0;
+   virtual MTAPIRES  DealBackupRequest(const UINT64 server,const INT64 backup,const UINT64 login,const INT64 from,const INT64 to,IMTDealArray* deals)=0;
+   virtual MTAPIRES  DealRequestByGroup(LPCWSTR group,const INT64 from,const INT64 to,IMTDealArray* deals)=0;
+   //--- trade positions database
+   virtual IMTPosition* PositionCreate(void)=0;
+   virtual IMTPositionArray* PositionCreateArray(void)=0;
+   virtual MTAPIRES  PositionRequest(const UINT64 login,IMTPositionArray* positions)=0;
+   virtual MTAPIRES  PositionDelete(IMTPosition* position)=0;
+   virtual MTAPIRES  PositionUpdate(IMTPosition* position)=0;
+   virtual MTAPIRES  PositionBackupList(const INT64 from,const INT64 to,INT64*& backups,UINT& backups_total)=0;
+   virtual MTAPIRES  PositionBackupRequest(const INT64 backup,const UINT64 login,IMTPositionArray* positions)=0;
+   virtual MTAPIRES  PositionBackupRestore(IMTPosition* position)=0;
+   virtual MTAPIRES  PositionBackupList(const UINT64 server,const INT64 from,const INT64 to,INT64*& backups,UINT& backups_total)=0;
+   virtual MTAPIRES  PositionBackupRequest(const UINT64 server,const INT64 backup,const UINT64 login,IMTPositionArray* positions)=0;
+   virtual MTAPIRES  PositionCheck(const UINT64 login,IMTPositionArray* current,IMTPositionArray* invalid,IMTPositionArray* missed,IMTPositionArray* nonexist)=0;
+   virtual MTAPIRES  PositionFix(const UINT64 login,IMTPositionArray* current)=0;
+   //--- trade orders database
+   virtual IMTOrder* OrderCreate(void)=0;
+   virtual IMTOrderArray* OrderCreateArray(void)=0;
+   virtual MTAPIRES  OrderRequest(const UINT64 ticket,IMTOrder* order)=0;
+   virtual MTAPIRES  OrderRequestOpen(const UINT64 login,IMTOrderArray* orders)=0;
+   virtual MTAPIRES  HistoryRequest(const UINT64 login,const INT64 from,const INT64 to,IMTOrderArray* orders)=0;
+   virtual MTAPIRES  OrderDelete(const UINT64 ticket)=0;
+   virtual MTAPIRES  OrderUpdate(IMTOrder *order)=0;
+   virtual MTAPIRES  OrderBackupList(const INT64 from,const INT64 to,INT64*& backups,UINT& backups_total)=0;
+   virtual MTAPIRES  OrderBackupRequest(const INT64 backup,const UINT64 ticket,IMTOrder* order)=0;
+   virtual MTAPIRES  OrderBackupRequestOpen(const INT64 backup,const UINT64 login,IMTOrderArray* orders)=0;
+   virtual MTAPIRES  OrderBackupRequestHistory(const INT64 backup,const UINT64 login,const INT64 from,const INT64 to,IMTOrderArray* orders)=0;
+   virtual MTAPIRES  OrderBackupRestore(IMTOrder* order)=0;
+   virtual MTAPIRES  OrderBackupList(const UINT64 server,const INT64 from,const INT64 to,INT64*& backups,UINT& backups_total)=0;
+   virtual MTAPIRES  OrderBackupRequest(const UINT64 server,const INT64 backup,const UINT64 ticket,IMTOrder* order)=0;
+   virtual MTAPIRES  OrderBackupRequestOpen(const UINT64 server,const INT64 backup,const UINT64 login,IMTOrderArray* orders)=0;
+   virtual MTAPIRES  OrderBackupRequestHistory(const UINT64 server,const INT64 backup,const UINT64 login,const INT64 from,const INT64 to,IMTOrderArray* orders)=0;
+   //--- ticks data
+   virtual MTAPIRES  TickRequest(LPCWSTR symbol,const INT64 from,const INT64 to,MTTickShort*& ticks,UINT& ticks_total)=0;
+   virtual MTAPIRES  TickRequestRaw(LPCWSTR symbol,const INT64 from,const INT64 to,MTTickShort*& ticks,UINT& ticks_total)=0;
+   virtual MTAPIRES  TickAdd(LPCWSTR symbol,const MTTickShort* ticks,const UINT ticks_total)=0;
+   virtual MTAPIRES  TickReplace(LPCWSTR symbol,const INT64 from_msc,const INT64 to_msc,const MTTickShort* ticks,const UINT ticks_total)=0;
+   virtual MTAPIRES  TickReserved3(void)=0;
+   virtual MTAPIRES  TickReserved4(void)=0;
+   //--- chart data
+   virtual MTAPIRES  ChartRequest(LPCWSTR symbol,const INT64 from,const INT64 to,MTChartBar*& bars,UINT& bars_total)=0;
+   virtual MTAPIRES  ChartDelete(LPCWSTR symbol,const INT64* bars_dates,const UINT bars_total)=0;
+   virtual MTAPIRES  ChartUpdate(LPCWSTR symbol,const MTChartBar* bars,const UINT bars_total)=0;
+   virtual MTAPIRES  ChartReplace(LPCWSTR symbol,const INT64 from,const INT64 to,const MTChartBar* bars,const UINT bars_total)=0;
+   virtual MTAPIRES  ChartSplit(LPCWSTR symbol,const UINT new_shares,const UINT old_shares,const UINT rounding_rule,const INT64 datetime_from,const INT64 datetime_to)=0;
+   virtual MTAPIRES  ChartReserved2(void)=0;
+   virtual MTAPIRES  ChartReserved3(void)=0;
+   //--- internal email
+   virtual IMTMail*  MailCreate(void)=0;
+   virtual MTAPIRES  MailSubscribe(IMTMailSink* sink)=0;
+   virtual MTAPIRES  MailUnsubscribe(IMTMailSink* sink)=0;
+   virtual UINT      MailTotal(void)=0;
+   virtual MTAPIRES  MailNext(const UINT pos,IMTMail* mail)=0;
+   virtual MTAPIRES  MailDelete(const UINT pos)=0;
+   virtual MTAPIRES  MailDeleteId(const UINT64 id)=0;
+   virtual MTAPIRES  MailSend(IMTMail* mail)=0;
+   virtual MTAPIRES  MailBodyRequest(const UINT64 id,IMTMail *mail)=0;
+   virtual MTAPIRES  MailReserved2(void)=0;
+   virtual MTAPIRES  MailReserved3(void)=0;
+   virtual MTAPIRES  MailReserved4(void)=0;
+   //--- internal news
+   virtual IMTNews*  NewsCreate(void)=0;
+   virtual MTAPIRES  NewsSubscribe(IMTNewsSink* sink)=0;
+   virtual MTAPIRES  NewsUnsubscribe(IMTNewsSink* sink)=0;
+   virtual MTAPIRES  NewsSend(IMTNews* news)=0;
+   virtual UINT      NewsTotal(void)=0;
+   virtual MTAPIRES  NewsNext(const UINT pos,IMTNews* news)=0;
+   virtual MTAPIRES  NewsBodyRequest(const UINT64 id,IMTNews *news)=0;
+   virtual MTAPIRES  NewsReserved4(void)=0;
+   //--- external accounts
+   virtual MTAPIRES  UserExternalRequest(const UINT64 gateway_id,LPCWSTR account,IMTUser* user)=0;
+   virtual MTAPIRES  UserExternalRequest(LPCWSTR account,IMTUser* user)=0;
+   virtual MTAPIRES  UserBackupRequest(const UINT64 server,const INT64 backup,const UINT64 login,IMTUser* user)=0;
+   virtual MTAPIRES  UserBackupList(const UINT64 server,const INT64 from,const INT64 to,INT64*& backups,UINT& backups_total)=0;
+   virtual MTAPIRES  UserLogins(LPCWSTR group,UINT64*& logins,UINT& logins_total)=0;
+   virtual MTAPIRES  UserRequestArray(LPCWSTR group,IMTUserArray* users)=0;
+   //--- self password management
+   virtual MTAPIRES  PasswordChange(const UINT type,LPCWSTR password)=0;
+   virtual MTAPIRES  PasswordReserved1(void)=0;
+   virtual MTAPIRES  PasswordReserved2(void)=0;
+   //--- spreads configuration
+   virtual IMTConSpread* SpreadCreate(void)=0;
+   virtual IMTConSpreadLeg* SpreadLegCreate(void)=0;
+   virtual MTAPIRES  SpreadSubscribe(IMTConSpreadSink* sink)=0;
+   virtual MTAPIRES  SpreadUnsubscribe(IMTConSpreadSink* sink)=0;
+   virtual MTAPIRES  SpreadUpdate(IMTConSpread* spread)=0;
+   virtual MTAPIRES  SpreadDelete(const UINT pos)=0;
+   virtual MTAPIRES  SpreadShift(const UINT pos,const int shift)=0;
+   virtual UINT      SpreadTotal(void)=0;
+   virtual MTAPIRES  SpreadNext(const UINT pos,IMTConSpread* spread)=0;
+   virtual MTAPIRES  SpreadUpdateBatch(IMTConSpread** configs,const UINT configs_total,MTAPIRES* results)=0;
+   virtual MTAPIRES  SpreadDeleteBatch(IMTConSpread** configs,const UINT configs_total,MTAPIRES* results)=0;
+   virtual MTAPIRES  SpreadReserved3(void)=0;
+   virtual MTAPIRES  SpreadReserved4(void)=0;
+   //--- network connection
+   virtual MTAPIRES  NetworkRescan(const UINT flags,const UINT timeout)=0;
+   virtual UINT64    NetworkBytesSent(void)=0;
+   virtual UINT64    NetworkBytesRead(void)=0;
+   virtual MTAPIRES  NetworkServer(MTAPISTR& server)=0;
+   virtual MTAPIRES  NetworkAddress(MTAPISTR& address)=0;
+   virtual MTAPIRES  NetworkReserved1(void)=0;
+   virtual MTAPIRES  NetworkReserved2(void)=0;
+   virtual MTAPIRES  NetworkReserved3(void)=0;
+   virtual MTAPIRES  NetworkReserved4(void)=0;
+   //--- trade orders database
+   virtual MTAPIRES  OrderReopen(const UINT64 ticket)=0;
+   virtual MTAPIRES  OrderRequestByGroup(LPCWSTR group,IMTOrderArray* orders)=0;
+   virtual MTAPIRES  OrderRequestByLogins(const UINT64 *logins,const UINT logins_total,IMTOrderArray* orders)=0;
+   virtual MTAPIRES  OrderRequestByTickets(const UINT64 *tickets,const UINT tickets_total,IMTOrderArray* orders)=0;
+   virtual MTAPIRES  OrderUpdateBatch(IMTOrderArray* orders,MTAPIRES* results)=0;
+   //--- notifications
+   virtual MTAPIRES  NotificationsSend(LPWSTR metaquotes_ids,LPCWSTR message)=0;
+   virtual MTAPIRES  NotificationsSend(const UINT64* logins,const UINT logins_total,LPCWSTR message)=0;
+   virtual MTAPIRES  NotificationsReserved1(void)=0;
+   virtual MTAPIRES  NotificationsReserved2(void)=0;
+   virtual MTAPIRES  NotificationsReserved3(void)=0;
+   virtual MTAPIRES  NotificationsReserved4(void)=0;
+   //--- settings
+   virtual MTAPIRES  SettingGet(LPCWSTR section,LPCWSTR key,LPVOID& outdata,UINT& outdata_len)=0;
+   virtual MTAPIRES  SettingSet(LPCWSTR section,LPCWSTR key,const LPVOID indata,const UINT indata_len)=0;
+   virtual MTAPIRES  SettingDelete(LPCWSTR section,LPCWSTR key)=0;
+   virtual MTAPIRES  SettingReserved1(void)=0;
+   virtual MTAPIRES  SettingReserved2(void)=0;
+   virtual MTAPIRES  SettingReserved3(void)=0;
+   virtual MTAPIRES  SettingReserved4(void)=0;
+   //--- email servers configuration
+   virtual IMTConEmail* EmailCreate(void)=0;
+   virtual MTAPIRES  EmailSubscribe(IMTConEmailSink* sink)=0;
+   virtual MTAPIRES  EmailUnsubscribe(IMTConEmailSink* sink)=0;
+   virtual MTAPIRES  EmailUpdate(IMTConEmail* email)=0;
+   virtual MTAPIRES  EmailDelete(LPCWSTR name)=0;
+   virtual MTAPIRES  EmailDelete(const UINT pos)=0;
+   virtual MTAPIRES  EmailShift(const UINT pos,const int shift)=0;
+   virtual UINT      EmailTotal(void)=0;
+   virtual MTAPIRES  EmailNext(const UINT pos,IMTConEmail* email)=0;
+   virtual MTAPIRES  EmailGet(LPCWSTR name,IMTConEmail* email)=0;
+   virtual MTAPIRES  EmailUpdateBatch(IMTConEmail** configs,const UINT config_total,MTAPIRES* results)=0;
+   virtual MTAPIRES  EmailDeleteBatch(IMTConEmail** configs,const UINT config_total,MTAPIRES* results)=0;
+   virtual MTAPIRES  EmailSend(LPCWSTR account,LPCWSTR to,LPCWSTR to_name,LPCWSTR subject,LPCWSTR body)=0;
+   virtual MTAPIRES  EmailReserved2(void)=0;
+   virtual MTAPIRES  EmailReserved3(void)=0;
+   virtual MTAPIRES  EmailReserved4(void)=0;
+   //--- messengers configuration
+   virtual IMTConMessenger* MessengerCreate(void)=0;
+   virtual MTAPIRES  MessengerSubscribe(IMTConMessengerSink* sink)=0;
+   virtual MTAPIRES  MessengerUnsubscribe(IMTConMessengerSink* sink)=0;
+   virtual MTAPIRES  MessengerUpdate(IMTConMessenger* messenger)=0;
+   virtual MTAPIRES  MessengerDelete(LPCWSTR name)=0;
+   virtual MTAPIRES  MessengerDelete(const UINT pos)=0;
+   virtual MTAPIRES  MessengerShift(const UINT pos,const int shift)=0;
+   virtual UINT      MessengerTotal(void)=0;
+   virtual MTAPIRES  MessengerNext(const UINT pos,IMTConMessenger* messenger)=0;
+   virtual MTAPIRES  MessengerGet(LPCWSTR name,IMTConMessenger* messenger)=0;
+   virtual MTAPIRES  MessengerUpdateBatch(IMTConMessenger** configs,const UINT config_total,MTAPIRES* results)=0;
+   virtual MTAPIRES  MessengerDeleteBatch(IMTConMessenger** configs,const UINT config_total,MTAPIRES* results)=0;
+   virtual MTAPIRES  MessengerSend(LPCWSTR destination,LPCWSTR group,LPCWSTR sender,LPCWSTR text)=0;
+   virtual MTAPIRES  MessengerReserved2(void)=0;
+   virtual MTAPIRES  MessengerReserved3(void)=0;
+   virtual MTAPIRES  MessengerReserved4(void)=0;
+   //--- deals database
+   virtual MTAPIRES  DealRequestByLogins(const UINT64 *logins,const UINT logins_total,const INT64 from,const INT64 to,IMTDealArray* deals)=0;
+   virtual MTAPIRES  DealRequestByTickets(const UINT64 *tickets,const UINT tickets_total,IMTDealArray* deals)=0;
+   virtual MTAPIRES  DealUpdateBatch(IMTDealArray* deals,MTAPIRES* results)=0;
+   virtual MTAPIRES  DealUpdateBatchArray(IMTDeal** deals,const UINT deals_total,MTAPIRES* results)=0;
+   virtual MTAPIRES  DealDeleteBatch(const UINT64* tickets,const UINT tickets_total,MTAPIRES* results)=0;
+   virtual MTAPIRES  DealReserved1(void)=0;
+   virtual MTAPIRES  DealReserved2(void)=0;
+   virtual MTAPIRES  DealReserved3(void)=0;
+   virtual MTAPIRES  DealReserved4(void)=0;
+   //--- positions database
+   virtual MTAPIRES  PositionRequestByGroup(LPCWSTR group,IMTPositionArray* positions)=0;
+   virtual MTAPIRES  PositionRequestByLogins(const UINT64 *logins,const UINT logins_total,IMTPositionArray* positions)=0;
+   virtual MTAPIRES  PositionRequestByTickets(const UINT64 *tickets,const UINT tickets_total,IMTPositionArray* positions)=0;
+   virtual MTAPIRES  PositionUpdateBatch(IMTPositionArray* positions,MTAPIRES* results)=0;
+   virtual MTAPIRES  PositionUpdateBatchArray(IMTPosition** positions,const UINT positions_total,MTAPIRES* results)=0;
+   virtual MTAPIRES  PositionDeleteBatch(const UINT64* tickets,const UINT tickets_total,MTAPIRES* results)=0;
+   virtual MTAPIRES  PositionDeleteByTicket(const UINT64 ticket)=0;
+   virtual MTAPIRES  PositionReserved1(void)=0;
+   virtual MTAPIRES  PositionReserved2(void)=0;
+   virtual MTAPIRES  PositionReserved3(void)=0;
+   virtual MTAPIRES  PositionReserved4(void)=0;
+   //--- open orders database
+   virtual MTAPIRES  OrderUpdateBatchArray(IMTOrder** orders,const UINT orders_total,MTAPIRES* results)=0;
+   virtual MTAPIRES  OrderDeleteBatch(const UINT64* tickets,const UINT tickets_total,MTAPIRES* results)=0;
+   virtual MTAPIRES  OrderReserved1(void)=0;
+   virtual MTAPIRES  OrderReserved2(void)=0;
+   virtual MTAPIRES  OrderReserved3(void)=0;
+   virtual MTAPIRES  OrderReserved4(void)=0;
+   //--- orders history database
+   virtual MTAPIRES  HistoryRequestByGroup(LPCWSTR group,const INT64 from,const INT64 to,IMTOrderArray* orders)=0;
+   virtual MTAPIRES  HistoryRequestByLogins(const UINT64 *logins,const UINT logins_total,const INT64 from,const INT64 to,IMTOrderArray* orders)=0;
+   virtual MTAPIRES  HistoryRequestByTickets(const UINT64 *tickets,const UINT tickets_total,IMTOrderArray* orders)=0;
+   virtual MTAPIRES  HistoryReserved1(void)=0;
+   virtual MTAPIRES  HistoryReserved2(void)=0;
+   virtual MTAPIRES  HistoryReserved3(void)=0;
+   virtual MTAPIRES  HistoryReserved4(void)=0;
+   //--- TLS Certificates
+   virtual MTAPIRES  TLSCertificateUpdate(const void* pfx_certificate,const UINT pfx_certificate_size,LPCWSTR password)=0;
+   virtual MTAPIRES  TLSCertificateDelete(const UINT pos)=0;
+   virtual MTAPIRES  TLSCertificateShift(const UINT pos,const int shift)=0;
+   virtual UINT      TLSCertificateTotal(void)=0;
+   virtual MTAPIRES  TLSCertificateNext(const UINT pos,MTAPISTR& name,MTAPISTR& thumbprint)=0;
+   virtual MTAPIRES  TLSCertificateReserved1(void)=0;
+   virtual MTAPIRES  TLSCertificateReserved2(void)=0;
+   virtual MTAPIRES  TLSCertificateReserved3(void)=0;
+   virtual MTAPIRES  TLSCertificateReserved4(void)=0;
+  };
+//+------------------------------------------------------------------+
+//| Entry point functions declarations                               |
+//+------------------------------------------------------------------+
+typedef MTAPIRES(*MTManagerVersion_t)   (UINT &version);
+typedef MTAPIRES(*MTManagerCreate_t)    (UINT api_version,IMTManagerAPI **manager);
+typedef MTAPIRES(*MTAdminCreate_t)      (UINT api_version,IMTAdminAPI **admin);
+typedef MTAPIRES(*MTManagerCreateExt_t) (UINT api_version,LPCWSTR datapath,IMTManagerAPI **manager);
+typedef MTAPIRES(*MTAdminCreateExt_t)   (UINT api_version,LPCWSTR datapath,IMTAdminAPI **admin);
+//+------------------------------------------------------------------+
+//| Entry point functions names                                      |
+//+------------------------------------------------------------------+
+static const LPCSTR s_MTManagerVersion   ="MTManagerVersion";
+static const LPCSTR s_MTManagerCreate    ="MTManagerCreate";
+static const LPCSTR s_MTManagerCreateExt ="MTManagerCreateExt";
+static const LPCSTR s_MTAdminCreate      ="MTAdminCreate";
+static const LPCSTR s_MTAdminCreateExt   ="MTAdminCreateExt";
+//+------------------------------------------------------------------+
+//| Manager API factory                                              |
+//+------------------------------------------------------------------+
+class CMTManagerAPIFactory
+  {
+private:
+   HMODULE           m_hmodule;
+   MTManagerVersion_t m_mtversion;
+   MTManagerCreate_t m_mtmanager;
+   MTAdminCreate_t   m_mtadmin;
+   MTManagerCreateExt_t m_mtmanager_ext;
+   MTAdminCreateExt_t m_mtadmin_ext;
+
+public:
+                     CMTManagerAPIFactory(void) : m_hmodule(NULL),m_mtversion(NULL),m_mtmanager(NULL),m_mtadmin(NULL),m_mtmanager_ext(NULL),m_mtadmin_ext(NULL) {}
+                    ~CMTManagerAPIFactory(void) { Shutdown(); }
+   //--- initialize & shutdown
+   MTAPIRES          Initialize(LPCWSTR dll_path=NULL);
+   MTAPIRES          Shutdown(void);
+   //--- manager creation
+   MTAPIRES          CreateManager(UINT version,IMTManagerAPI **manager);
+   MTAPIRES          CreateAdmin(UINT version,IMTAdminAPI **admin);
+   //--- manager creation with path
+   MTAPIRES          CreateManager(UINT version,LPCWSTR datapath,IMTManagerAPI **manager);
+   MTAPIRES          CreateAdmin(UINT version,LPCWSTR datapath,IMTAdminAPI **admin);
+   //--- license check
+   static MTAPIRES   LicenseCheckManager(IMTManagerAPI *manager,LPCWSTR name);
+   static MTAPIRES   LicenseCheckAdmin(IMTAdminAPI *admin,LPCWSTR name);
+   //--- version info
+   MTAPIRES          Version(UINT &version);
+
+private:
+   bool              FindLibrary(LPCWSTR dll_path,wchar_t *path,const size_t path_maxlen);
+  };
+//+------------------------------------------------------------------+
+//| Library initialization                                           |
+//+------------------------------------------------------------------+
+inline MTAPIRES CMTManagerAPIFactory::Initialize(LPCWSTR dll_path/*=NULL*/)
+  {
+   wchar_t  path[MAX_PATH]={};
+//--- find the Gateway API DLL
+   if(!FindLibrary(dll_path,path,_countof(path)-1))
+      return(MT_RET_ERR_NOTFOUND);
+//--- load Manager API DLL
+   if((m_hmodule=::LoadLibraryW(path))!=NULL)
+     {
+      //--- find entry point addresses
+      m_mtversion=reinterpret_cast<MTManagerVersion_t>(::GetProcAddress(m_hmodule,s_MTManagerVersion));
+      //--- find for manager
+      if((m_mtmanager_ext=reinterpret_cast<MTManagerCreateExt_t>(::GetProcAddress(m_hmodule,s_MTManagerCreateExt)))==NULL)
+         m_mtmanager=reinterpret_cast<MTManagerCreate_t>(::GetProcAddress(m_hmodule,s_MTManagerCreate));
+      //--- find for admin
+      if((m_mtadmin_ext=reinterpret_cast<MTAdminCreateExt_t>(::GetProcAddress(m_hmodule,s_MTAdminCreateExt)))==NULL)
+         m_mtadmin=reinterpret_cast<MTAdminCreate_t>(::GetProcAddress(m_hmodule,s_MTAdminCreate));
+      //--- check results
+      if(!m_mtversion || !m_mtmanager_ext || !m_mtadmin_ext)
+        {
+         Shutdown();
+         //--- not found
+         return(MT_RET_ERR_NOTFOUND);
+        }
+     }
+//--- ok
+   return(MT_RET_OK);
+  }
+//+------------------------------------------------------------------+
+//| Library shutdown                                                 |
+//+------------------------------------------------------------------+
+inline MTAPIRES CMTManagerAPIFactory::Shutdown(void)
+  {
+//--- check & free
+   if(m_hmodule)
+     {
+      ::FreeLibrary((HMODULE)m_hmodule);
+      m_hmodule=NULL;
+     }
+//--- zero members
+   m_mtversion    =NULL;
+   m_mtmanager    =NULL;
+   m_mtadmin      =NULL;
+   m_mtmanager_ext=NULL;
+   m_mtadmin_ext  =NULL;
+//--- ok
+   return(MT_RET_OK);
+  }
+//+------------------------------------------------------------------+
+//| Find the library                                                 |
+//+------------------------------------------------------------------+
+inline bool CMTManagerAPIFactory::FindLibrary(LPCWSTR dll_path,wchar_t *path,const size_t path_maxlen)
+  {
+   wchar_t  folder[MAX_PATH]={};
+   wchar_t *ptr;
+//--- save paths
+   if(dll_path)
+     {
+      //--- add Manager API DLL name
+      if(sizeof(void*)==4)
+         swprintf_s(path,path_maxlen,L"%s\\MT5APIManager.dll",dll_path);
+      else
+         swprintf_s(path,path_maxlen,L"%s\\MT5APIManager64.dll",dll_path);
+      //--- check
+      if(GetFileAttributesW(path)!=INVALID_FILE_ATTRIBUTES)
+         return(true);
+     }
+//--- find the folder
+   ::GetModuleFileNameW(NULL,folder,_countof(folder)-1);
+//--- check for 5 levels
+   for(int i=0;i<5;i++)
+     {
+      //--- remove level
+      if((ptr=wcsrchr(folder,L'\\'))==NULL)
+         break;
+
+      *ptr=L'\0';
+      //--- check the file
+      if(sizeof(void*)==4)
+         swprintf_s(path,path_maxlen,L"%s\\MT5APIManager.dll",folder);
+      else
+         swprintf_s(path,path_maxlen,L"%s\\MT5APIManager64.dll",folder);
+
+      if(GetFileAttributesW(path)!=INVALID_FILE_ATTRIBUTES)
+         return(true);
+      //--- check /libs folder
+      if(sizeof(void*)==4)
+         swprintf_s(path,path_maxlen,L"%s\\libs\\MT5APIManager.dll",folder);
+      else
+         swprintf_s(path,path_maxlen,L"%s\\libs\\MT5APIManager64.dll",folder);
+
+      if(GetFileAttributesW(path)!=INVALID_FILE_ATTRIBUTES)
+         return(true);
+     }
+//---
+   return(false);
+  }
+//+------------------------------------------------------------------+
+//| Manager interface creation                                       |
+//+------------------------------------------------------------------+
+inline MTAPIRES CMTManagerAPIFactory::CreateManager(UINT version,IMTManagerAPI **manager)
+  {
+//--- check parameters
+   if(!manager)
+      return(MT_RET_ERR_PARAMS);
+//--- check members & parameters
+   if(!m_hmodule || (!m_mtmanager && !m_mtmanager_ext))
+      return(MT_RET_ERROR);
+//--- create manager
+   return(m_mtmanager_ext ? m_mtmanager_ext(version,NULL,manager) : m_mtmanager(version,manager));
+  }
+//+------------------------------------------------------------------+
+//| Administrator interface creation                                 |
+//+------------------------------------------------------------------+
+inline MTAPIRES CMTManagerAPIFactory::CreateAdmin(UINT version,IMTAdminAPI **admin)
+  {
+//--- check parameters
+   if(!admin)
+      return(MT_RET_ERR_PARAMS);
+//--- check members & parameters
+   if(!m_hmodule || (!m_mtadmin && !m_mtadmin_ext))
+      return(MT_RET_ERROR);
+//--- create manager
+   return(m_mtadmin_ext ? m_mtadmin_ext(version,NULL,admin) : m_mtadmin(version,admin));
+  }
+//+------------------------------------------------------------------+
+//| Manager interface creation                                       |
+//+------------------------------------------------------------------+
+inline MTAPIRES CMTManagerAPIFactory::CreateManager(UINT version,LPCWSTR datapath,IMTManagerAPI **manager)
+  {
+//--- check parameters
+   if(!manager)
+      return(MT_RET_ERR_PARAMS);
+//--- check members & parameters
+   if(!m_hmodule || !m_mtmanager_ext)
+      return(MT_RET_ERROR);
+//--- create manager
+   return(m_mtmanager_ext(version,datapath,manager));
+  }
+//+------------------------------------------------------------------+
+//| Administrator interface creation                                 |
+//+------------------------------------------------------------------+
+inline MTAPIRES CMTManagerAPIFactory::CreateAdmin(UINT version,LPCWSTR datapath,IMTAdminAPI **admin)
+  {
+//--- check parameters
+   if(!admin)
+      return(MT_RET_ERR_PARAMS);
+//--- check members & parameters
+   if(!m_hmodule || !m_mtadmin_ext)
+      return(MT_RET_ERROR);
+//--- create manager
+   return(m_mtadmin_ext(version,datapath,admin));
+  }
+//+------------------------------------------------------------------+
+//| Manager API license sign check                                   |
+//+------------------------------------------------------------------+
+inline MTAPIRES CMTManagerAPIFactory::LicenseCheckManager(IMTManagerAPI *manager,LPCWSTR name)
+  {
+   MTLicenseCheck license={};
+   HCRYPTPROV     prov=NULL;
+   HCRYPTHASH     hash=NULL;
+   HCRYPTKEY      key =NULL;
+   MTAPIRES       res=MT_RET_ERROR;
+//--- checking
+   if(!manager || !name || name[0]==L'\0')
+      return(MT_RET_ERROR);
+//--- fill license information, copy name
+   wcscpy_s(license.name,_countof(license.name),name);
+//--- initialize random generator
+   srand((unsigned int)GetTickCount());
+//--- generate sequence of random numbers
+   for(license.random_size=0;license.random_size<sizeof(license.random);license.random_size++)
+      license.random[license.random_size]=char(rand()&0xFF);
+//--- check license
+   manager->LicenseCheck(license);
+//--- check retcode
+   if(license.retcode!=MT_RET_OK)
+      return(license.retcode);
+//--- check license sign, initialize provider
+   if(CryptAcquireContext(&prov,NULL,MS_DEF_PROV,PROV_RSA_FULL,CRYPT_VERIFYCONTEXT)==FALSE)
+      return(MT_RET_ERROR);
+//--- import public key
+   if(CryptImportKey(prov,(const BYTE*)MT5APIPublicKey,sizeof(MT5APIPublicKey),0,0,&key)!=FALSE)
+     {
+      //--- initialize hash object
+      if(CryptCreateHash(prov,CALG_MD5,0,0,&hash)!=FALSE)
+        {
+         //--- set hash from data
+         if(CryptHashData(hash,(BYTE*)&license,(DWORD)offsetof(MTLicenseCheck,retcode),0)!=FALSE)
+           {
+            //--- verify hash sign, using public key
+            if(CryptVerifySignature(hash,(BYTE*)license.sign,(DWORD)license.sign_size,key,NULL,0)!=FALSE)
+               res=license.retcode;
+            else
+               res=MT_RET_ERR_DATA;
+           }
+        }
+     }
+//--- destroy hash
+   if(hash)
+      CryptDestroyHash(hash);
+//--- destroy key
+   if(key)
+      CryptDestroyKey(key);
+//--- release provider
+   if(prov)
+      CryptReleaseContext(prov,0);
+//--- return result
+   return(res);
+  }
+//+------------------------------------------------------------------+
+//| Manager API license sign check                                   |
+//+------------------------------------------------------------------+
+inline MTAPIRES CMTManagerAPIFactory::LicenseCheckAdmin(IMTAdminAPI *admin,LPCWSTR name)
+  {
+   MTLicenseCheck license={};
+   HCRYPTPROV     prov=NULL;
+   HCRYPTHASH     hash=NULL;
+   HCRYPTKEY      key =NULL;
+   MTAPIRES       res=MT_RET_ERROR;
+//--- checking
+   if(!admin || !name || name[0]==L'\0')
+      return(MT_RET_ERROR);
+//--- fill license information, copy name
+   wcscpy_s(license.name,_countof(license.name),name);
+//--- initialize random generator
+   srand((unsigned int)GetTickCount());
+//--- generate sequence of random numbers
+   for(license.random_size=0;license.random_size<sizeof(license.random);license.random_size++)
+      license.random[license.random_size]=char(rand()&0xFF);
+//--- check license
+   admin->LicenseCheck(license);
+//--- check retcode
+   if(license.retcode!=MT_RET_OK)
+      return(license.retcode);
+//--- check license sign, initialize provider
+   if(CryptAcquireContext(&prov,NULL,MS_DEF_PROV,PROV_RSA_FULL,CRYPT_VERIFYCONTEXT)==FALSE)
+      return(MT_RET_ERROR);
+//--- import public key
+   if(CryptImportKey(prov,(const BYTE*)MT5APIPublicKey,sizeof(MT5APIPublicKey),0,0,&key)!=FALSE)
+     {
+      //--- initialize hash object
+      if(CryptCreateHash(prov,CALG_MD5,0,0,&hash)!=FALSE)
+        {
+         //--- set hash from data
+         if(CryptHashData(hash,(BYTE*)&license,(DWORD)offsetof(MTLicenseCheck,retcode),0)!=FALSE)
+           {
+            //--- verify hash sign, using public key
+            if(CryptVerifySignature(hash,(BYTE*)license.sign,(DWORD)license.sign_size,key,NULL,0)!=FALSE)
+               res=license.retcode;
+            else
+               res=MT_RET_ERR_DATA;
+           }
+        }
+     }
+//--- destroy hash
+   if(hash)
+      CryptDestroyHash(hash);
+//--- destroy key
+   if(key)
+      CryptDestroyKey(key);
+//--- release provider
+   if(prov)
+      CryptReleaseContext(prov,0);
+//--- return result
+   return(res);
+  }
+//+------------------------------------------------------------------+
+//| Version                                                          |
+//+------------------------------------------------------------------+
+inline MTAPIRES CMTManagerAPIFactory::Version(UINT &version)
+  {
+//--- check members & parameters
+   if(!m_hmodule || !m_mtversion)
+      return(MT_RET_ERROR);
+//--- result
+   return(m_mtversion(version));
+  }
+//+------------------------------------------------------------------+

+ 31 - 0
MT5SDK/MT5APIPublicKey.h

@@ -0,0 +1,31 @@
+//+------------------------------------------------------------------+
+//|                                                 MetaTrader 5 API |
+//|                   Copyright 2000-2019, MetaQuotes Software Corp. |
+//|                                        http://www.metaquotes.net |
+//+------------------------------------------------------------------+
+#pragma once
+//+------------------------------------------------------------------+
+//| Public key for license sign check                                |
+//+------------------------------------------------------------------+
+__declspec(selectany) BYTE MT5APIPublicKey[]=
+  {
+   0x06,0x02,0x00,0x00,0x00,0x24,0x00,0x00,0x52,0x53,0x41,0x31,0x00,0x08,0x00,0x00,
+   0x01,0x00,0x01,0x00,0x09,0x38,0x01,0xE9,0x5E,0xDC,0xDB,0x7E,0x14,0x15,0xEC,0xF3,
+   0xF4,0x84,0xED,0x7D,0xBB,0xBF,0xA6,0xA0,0xA6,0xD1,0xAE,0x2E,0xC5,0x91,0x1D,0xC3,
+   0x72,0xC8,0xD1,0xBF,0x55,0xE4,0xFD,0xC1,0x57,0x97,0x9D,0x9E,0x8C,0xD8,0x12,0x64,
+   0x14,0xAB,0x29,0x82,0x64,0x06,0xAC,0x25,0xF3,0x7C,0x3E,0xDE,0x78,0xE6,0x60,0x7B,
+   0x37,0x80,0xFA,0x43,0x2B,0xD2,0xA8,0xA8,0x98,0x09,0xFF,0x42,0xD4,0x63,0xBE,0xF5,
+   0xB9,0x13,0x2E,0xB1,0x88,0x22,0xE7,0x1D,0xC8,0xC7,0x03,0x86,0xA0,0xB0,0x8E,0xF2,
+   0x5C,0x51,0x4C,0xF1,0x20,0x96,0x28,0x4A,0xDF,0x8D,0xE3,0x97,0xBB,0x2E,0x8A,0xCF,
+   0x1D,0x3C,0x86,0x2F,0x37,0xCA,0xBF,0xC5,0xED,0x61,0xA1,0xEE,0x14,0x41,0x34,0xC0,
+   0x97,0xAA,0x18,0x1D,0x2E,0x70,0x77,0x8D,0x18,0xA1,0xE1,0x5B,0x01,0x4F,0xCB,0xE6,
+   0x91,0x55,0x95,0x5C,0x5D,0x14,0x29,0xCF,0x05,0x47,0x49,0xAA,0x55,0xF0,0x1D,0xD4,
+   0x74,0x82,0x7B,0x13,0x3A,0xCF,0x98,0xCE,0x38,0x0A,0x1C,0xE6,0x4D,0xC0,0xB4,0xDE,
+   0xF7,0xE7,0xAC,0xF2,0xFB,0x2F,0x68,0xF3,0xDA,0x23,0xC8,0xE7,0xF8,0x76,0xD1,0x7C,
+   0x46,0x70,0x9F,0xE7,0xFD,0x69,0x78,0xB9,0x96,0xC3,0xD7,0x61,0x18,0x06,0x15,0xEE,
+   0xCB,0x19,0xE1,0x35,0xCA,0xAE,0x3C,0x46,0x6E,0x3E,0xD7,0xD9,0xF9,0x6F,0x7D,0x53,
+   0x3E,0x60,0x76,0xA8,0x0B,0x41,0x90,0x15,0x42,0x34,0x75,0x69,0x38,0x2E,0x4A,0xFF,
+   0xE1,0x2D,0x15,0x07,0x9A,0x46,0xEE,0x16,0x10,0x06,0xF9,0x70,0x0D,0xB7,0xBA,0x71,
+   0x60,0x6D,0x21,0xD7
+   };
+//+------------------------------------------------------------------+

+ 1002 - 0
MT5SDK/MT5APIReport.h

@@ -0,0 +1,1002 @@
+//+------------------------------------------------------------------+
+//|                                         MetaTrader 5 API Report  |
+//|                   Copyright 2000-2019, MetaQuotes Software Corp. |
+//|                                        http://www.metaquotes.net |
+//+------------------------------------------------------------------+
+#pragma once
+#include "MT5APIConstants.h"
+#include "MT5APILogger.h"
+#include "MT5APITools.h"
+#include "Config\MT5APIConfigReport.h"
+#include "Config\MT5APIConfigCommon.h"
+#include "Config\MT5APIConfigTime.h"
+#include "Config\MT5APIConfigHoliday.h"
+#include "Config\MT5APIConfigSymbol.h"
+#include "Config\MT5APIConfigGroup.h"
+#include "Config\MT5APIConfigManager.h"
+#include "Config\MT5APIConfigNetwork.h"
+#include "Config\MT5APIConfigPlugin.h"
+#include "Config\MT5APIConfigFeeder.h"
+#include "Config\MT5APIConfigGateway.h"
+#include "Config\MT5APIConfigFund.h"
+#include "Config\MT5APIConfigParam.h"
+#include "Bases\MT5APIUser.h"
+#include "Bases\MT5APIAccount.h"
+#include "Bases\MT5APIDeal.h"
+#include "Bases\MT5APIOrder.h"
+#include "Bases\MT5APIPosition.h"
+#include "Bases\MT5APIDaily.h"
+#include "Bases\MT5APITick.h"
+#include "Bases\MT5APIChart.h"
+#include "Bases\MT5APIDataset.h"
+#include "Bases\MT5APIClient.h"
+//+------------------------------------------------------------------+
+//| Report API version                                               |
+//+------------------------------------------------------------------+
+#define MTReportAPIVersion             2190
+#define MTReportAPIDate                L"18 Oct 2019"
+//+------------------------------------------------------------------+
+//| Report constants                                                 |
+//+------------------------------------------------------------------+
+//+------------------------------------------------------------------+
+//| Standard report parameter names                                  |
+//+------------------------------------------------------------------+
+#define MTAPI_PARAM_GROUPS              L"Groups"         // Groups list
+#define MTAPI_PARAM_SYMBOLS             L"Symbols"        // Symbols list
+#define MTAPI_PARAM_FROM                L"From"           // From
+#define MTAPI_PARAM_TO                  L"To"             // To
+#define MTAPI_PARAM_LEAD_SOURCE         L"Lead Source"    // Lead Source
+#define MTAPI_PARAM_LEAD_CAMPAIGN       L"Lead Campaign"  // Lead Campaign
+#define MTAPI_PARAM_IE_VERSION          L"IE_Version"     // IE version
+#define MTAPI_PARAM_SCR_WIDTH           L"Screen_Width"   // Screen width
+#define MTAPI_PARAM_SCR_HEIGHT          L"Screen_Height"  // Screen height
+//+------------------------------------------------------------------+
+//| Standard report colors of accounts                               |
+//+------------------------------------------------------------------+
+#define MTAPI_COLOR_ACOUNTS_REAL        0xCC4748          // Color of real accounts
+#define MTAPI_COLOR_ACOUNTS_PRELIMINARY 0x84B761          // Color of preliminary accounts
+#define MTAPI_COLOR_ACOUNTS_DEMO        0xB7B83F          // Color of demo accounts
+#define MTAPI_COLOR_ACOUNTS_CONTEST     0x67B7DC          // Color of contest accounts
+#define MTAPI_COLOR_ACOUNTS_COVERAGE    0xF9A825          // Color of coverage accounts
+#define MTAPI_COLOR_ACOUNTS_MANAGER     0xB9783F          // Color of manager accounts
+#define MTAPI_COLOR_ACOUNTS_OTHER       0x607D8B          // Color of other accounts
+//+------------------------------------------------------------------+
+//| Standard report colors of profit and loss                        |
+//+------------------------------------------------------------------+
+#define MTAPI_COLOR_PROFIT              0x84B761          // Color of profit
+#define MTAPI_COLOR_LOSS                0xCC4748          // Color of loss
+#define MTAPI_COLOR_NET_PROFIT          0x67B7DC          // Color of net profit
+//+------------------------------------------------------------------+
+//| Standard report colors of terminal types                         |
+//+------------------------------------------------------------------+
+#define MTAPI_COLOR_TERMINAL_CLIENT     0x67B7DC          // Color of Client terminal
+#define MTAPI_COLOR_TERMINAL_IPHONE     0x84B761          // Color of IPhone terminal
+#define MTAPI_COLOR_TERMINAL_ANDROID    0xFDD400          // Color of Android terminal
+//+------------------------------------------------------------------+
+//| Common colors to draw charts and graphs                          |
+//+------------------------------------------------------------------+
+static UINT ExtChartColors[]= {
+   0x2196F3,
+   0x2F4074,
+   0xFDD400,
+   0xCD82AD,
+   0xCC4748,
+   0x967BDC,
+   0xB7B83F,
+   0x67B7DC,
+   0x84B761,
+   0x607D8B,
+   0xF9A825
+   };
+//+------------------------------------------------------------------+
+//| Structures                                                       |
+//+------------------------------------------------------------------+
+//+------------------------------------------------------------------+
+//| Report parameter structure                                       |
+//+------------------------------------------------------------------+
+#pragma pack(push,1)
+struct MTReportParam
+  {
+   //--- parameter types
+   enum ParamType
+     {
+      TYPE_STRING    =0,                              // string
+      TYPE_INT       =1,                              // integer
+      TYPE_FLOAT     =2,                              // floating
+      TYPE_TIME      =3,                              // time only
+      TYPE_DATE      =4,                              // date only
+      TYPE_DATETIME  =5,                              // date & time
+      TYPE_GROUPS    =6,                              // groups list
+      TYPE_SYMBOLS   =7,                              // symbols list
+      //--- enumeration borders
+      TYPE_FIRST     =TYPE_STRING,
+      TYPE_LAST      =TYPE_SYMBOLS
+     };
+   //---
+   UINT              type;                            // type
+   wchar_t           name[64];                        // name
+   wchar_t           defvalue[256];                   // default value
+   UINT              reserved[16];                    // reserved
+  };
+#pragma pack(pop)
+//+------------------------------------------------------------------+
+//| Report about structure                                           |
+//+------------------------------------------------------------------+
+#pragma pack(push,1)
+struct MTReportInfo
+  {
+   //--- snapshot mode flags
+   enum EnSnapshots
+     {
+      SNAPSHOT_NONE          =0x0,                    // without snapshots
+      SNAPSHOT_USERS         =0x1,                    // users database snapshot for request
+      SNAPSHOT_USERS_FULL    =0x2,                    // full users database snapshot
+      SNAPSHOT_ACCOUNTS      =0x4,                    // trade account states snapshot
+      SNAPSHOT_ACCOUNTS_FULL =0x8,                    // trade account states snapshot for request
+      SNAPSHOT_ORDERS        =0x10,                   // orders database snapshot
+      SNAPSHOT_ORDERS_FULL   =0x20,                   // orders database snapshot for request
+      SNAPSHOT_POSITIONS     =0x40,                   // positions database snapshot
+      SNAPSHOT_POSITIONS_FULL=0x80,                   // positions database snapshot for request
+      //--- enumeration borders
+      SNAPSHOT_ALL           =SNAPSHOT_USERS|SNAPSHOT_ACCOUNTS|SNAPSHOT_ORDERS|SNAPSHOT_POSITIONS,
+      SNAPSHOT_ALL_FULL      =SNAPSHOT_USERS_FULL|SNAPSHOT_ACCOUNTS_FULL|SNAPSHOT_ORDERS_FULL|SNAPSHOT_POSITIONS_FULL,
+     };
+   //--- types reports
+   enum EnTypes
+     {
+      TYPE_NONE              =0x0,                    // no support
+      TYPE_HTML              =0x1,                    // hypertext
+      TYPE_TABLE             =0x2,                    // binary table
+      TYPE_DASHBOARD         =0x4,                    // dashboard
+      //--- enumeration borders
+      TYPE_ALL               =TYPE_HTML|TYPE_TABLE|TYPE_DASHBOARD
+     };
+   //--- minimal IE version
+   enum EnIEVersion
+     {
+      IE_VERSION_ANY         =0x0000,                 // any IE version
+      IE_VERSION_9           =0x0900,                 // IE 9 required
+      //--- enumeration borders
+      IE_VERSION_FIRST       =IE_VERSION_ANY,
+      IE_VERSION_LAST        =IE_VERSION_9,
+     };
+   //--- information
+   UINT              version;                         // report version
+   UINT              version_api;                     // report API version
+   UINT              version_ie;                      // minimal IE version
+   wchar_t           name[64];                        // report name
+   wchar_t           copyright[128];                  // copyright
+   wchar_t           description[256];                // description
+   UINT              snapshots;                       // snapshot modes
+   UINT              types;                           // report types
+   wchar_t           category[64];                    // report category
+   MTReportParam     params[64];                      // request parameters
+   UINT              params_total;                    // request parameters total
+   MTReportParam     config[64];                      // config parameters
+   UINT              config_total;                    // config parameters total
+   UINT              reserved[64];                    // reserved
+  };
+#pragma pack(pop)
+//+------------------------------------------------------------------+
+//| Server description structure                                     |
+//+------------------------------------------------------------------+
+#pragma pack(push,1)
+struct MTReportServerInfo
+  {
+   wchar_t           platform_name[64];               // platform name
+   wchar_t           platform_owner[128];             // platform owner
+   UINT              server_version;                  // server version
+   UINT              server_build;                    // server build
+   UINT              server_type;                     // server type
+   UINT64            server_id;                       // server id
+   UINT              reserved[32];                    // reserved
+  };
+#pragma pack(pop)
+//+------------------------------------------------------------------+
+//| Report chart series interface                                    |
+//+------------------------------------------------------------------+
+class IMTReportSeries
+  {
+public:
+   //--- series type
+   enum EnSeriesType
+     {
+      TYPE_TITLE              =0,                     // title
+      //---
+      TYPE_LINE               =100,                   // line
+      TYPE_HISTOGRAM          =101,                   // histogram
+      TYPE_BAR                =102,                   // bar
+      TYPE_AREA               =103,                   // area
+      TYPE_PIECE              =104,                   // piece for pie
+      //--- enumeration borders
+      TYPE_FIRST              =TYPE_TITLE,
+      TYPE_LAST               =TYPE_PIECE
+     };
+   //--- flags
+   enum EnSeriesFlags
+     {
+      FLAG_NONE               =0x0000000,
+      FLAG_SHOW_VALUES        =0x0000001,                     // show series values on chart
+      //--- enumeration borders
+      FLAG_ALL                =FLAG_SHOW_VALUES
+     };
+
+public:
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTReportSeries *series)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- title
+   virtual LPCWSTR   Title(void) const=0;
+   virtual MTAPIRES  Title(LPCWSTR title)=0;
+   //--- type
+   virtual UINT      Type(void) const=0;
+   virtual MTAPIRES  Type(const UINT type)=0;
+   //--- flags IMTReportSeries::EnSeriesFlags
+   virtual UINT64    Flags(void) const=0;
+   virtual MTAPIRES  Flags(const UINT64 flags)=0;
+   //--- color
+   virtual UINT      Color(void) const=0;
+   virtual MTAPIRES  Color(const UINT color)=0;
+   //--- tooltip format
+   virtual LPCWSTR   Tooltip(void) const=0;
+   virtual MTAPIRES  Tooltip(LPCWSTR tooltip)=0;
+   //--- values management
+   virtual MTAPIRES  ValueClear(void)=0;
+   virtual UINT      ValueTotal(void) const=0;
+   virtual MTAPIRES  ValueAdd(LPCWSTR value)=0;
+   virtual MTAPIRES  ValueAddInt(const INT64 value)=0;
+   virtual MTAPIRES  ValueAddDouble(const double value)=0;
+   virtual MTAPIRES  ValueUpdate(const UINT pos,LPCWSTR value)=0;
+   virtual MTAPIRES  ValueUpdateInt(const UINT pos,const INT64 value)=0;
+   virtual MTAPIRES  ValueUpdateDouble(const UINT pos,const double value)=0;
+   virtual LPCWSTR   ValueNext(const UINT pos) const=0;
+   virtual MTAPIRES  ValueNextInt(const UINT pos,INT64& value) const=0;
+   virtual MTAPIRES  ValueNextDouble(const UINT pos,double& value) const=0;
+   virtual MTAPIRES  ValueShift(const UINT pos,const int shift)=0;
+   virtual MTAPIRES  ValueDelete(const UINT pos)=0;
+   virtual MTAPIRES  ValueDescription(const UINT pos,LPCWSTR descr)=0;
+   virtual LPCWSTR   ValueDescription(const UINT pos) const=0;
+  };
+//+------------------------------------------------------------------+
+//| Report chart interface                                           |
+//+------------------------------------------------------------------+
+class IMTReportChart
+  {
+public:
+   //--- chart type
+   enum EnChartType
+     {
+      TYPE_GRAPH              =0,                     // classical chart
+      TYPE_GRAPH_ACCUMULATION =1,                     // classical chart with accumulation
+      TYPE_GRAPH_NORMALIZED   =2,                     // classical chart with normalization
+      TYPE_GRAPH_STACKED      =3,                     // classical chart with stack
+      //---
+      TYPE_BAR                =100,                   // line bar chart
+      TYPE_BAR_ACCUMULATION   =101,                   // line bar chart with accumulation
+      TYPE_BAR_NORMALIZED     =102,                   // line bar chart with normalization
+      TYPE_BAR_STACKED        =103,                   // line bar chart with stack
+      //---
+      TYPE_PIE                =200,                   // pie chart
+      //--- enumeration borders
+      TYPE_FIRST              =TYPE_GRAPH,
+      TYPE_LAST               =TYPE_PIE
+     };
+   //--- flags
+   enum EnChartFlags
+     {
+      FLAG_NONE               =0x00000000,
+      FLAG_ACCUMULATED_VALUES =0x00000001,             // show accumulated values
+      FLAG_SHOW_TABLE         =0x00000002,             // show value table
+      //--- enumeration borders
+      FLAG_ALL                =FLAG_ACCUMULATED_VALUES|FLAG_SHOW_TABLE
+     };
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTReportChart *chart)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- title
+   virtual LPCWSTR   Title(void) const=0;
+   virtual MTAPIRES  Title(LPCWSTR title)=0;
+   //--- type
+   virtual UINT      Type(void) const=0;
+   virtual MTAPIRES  Type(const UINT type)=0;
+   //--- digits
+   virtual UINT      Digits(void) const=0;
+   virtual MTAPIRES  Digits(const UINT digits)=0;
+   //--- flags
+   virtual UINT64    Flags(void) const=0;
+   virtual MTAPIRES  Flags(const UINT64 flags)=0;
+   //--- bar height
+   virtual UINT      BarHeight(void) const=0;
+   virtual MTAPIRES  BarHeight(const UINT height)=0;
+   //--- piece tooltip format
+   virtual LPCWSTR   PieceTooltip(void)=0;
+   virtual MTAPIRES  PieceTooltip(LPCWSTR tooltip)=0;
+   //--- piece description format
+   virtual LPCWSTR   PieceDescription(void)=0;
+   virtual MTAPIRES  PieceDescription(LPCWSTR description)=0;
+   //--- series management
+   virtual MTAPIRES  SeriesClear(void)=0;
+   virtual MTAPIRES  SeriesAdd(IMTReportSeries *series)=0;
+   virtual MTAPIRES  SeriesAddCopy(const IMTReportSeries *series)=0;
+   virtual MTAPIRES  SeriesDelete(const UINT pos)=0;
+   virtual IMTReportSeries* SeriesDetach(const UINT pos)=0;
+   virtual MTAPIRES  SeriesUpdate(const UINT pos,IMTReportSeries* series)=0;
+   virtual MTAPIRES  SeriesShift(const UINT pos,const int shift)=0;
+   virtual UINT      SeriesTotal(void) const=0;
+   virtual IMTReportSeries* SeriesNext(const UINT pos)=0;
+  };
+//+------------------------------------------------------------------+
+//| Report HTML interface                                            |
+//+------------------------------------------------------------------+
+class IMTReportDashboardHtml
+  {
+public:
+   //--- common methods
+   virtual MTAPIRES  Assign(const IMTReportDashboardHtml *html)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- HTML management
+   virtual MTAPIRES  Write(LPCWSTR format,...)=0;
+   virtual MTAPIRES  WriteSafe(LPCWSTR html,const UINT flags)=0;
+   virtual MTAPIRES  WriteChart(const IMTReportChart *chart)=0;
+   virtual MTAPIRES  WriteReserved1(void)=0;
+   virtual MTAPIRES  WriteReserved2(void)=0;
+   //--- html template processing
+   virtual MTAPIRES  TplLoad(LPCWSTR templstr)=0;
+   virtual MTAPIRES  TplLoadFile(LPCWSTR templname)=0;
+   virtual MTAPIRES  TplLoadResource(const UINT resid,LPCWSTR restype)=0;
+   virtual MTAPIRES  TplNext(MTAPISTR& tag,UINT *counter)=0;
+   virtual MTAPIRES  TplProcess(const UINT flags)=0;
+   virtual MTAPIRES  TplReserved1(void)=0;
+   virtual MTAPIRES  TplReserved2(void)=0;
+  };
+//+------------------------------------------------------------------+
+//| Report widget interface                                          |
+//+------------------------------------------------------------------+
+class IMTReportDashboardWidget
+  {
+public:
+   //--- chart type
+   enum EnWidgetType
+     {
+      //--- charts
+      WIDGET_TYPE_CHART_BAR   =0,                   // bar chart
+      WIDGET_TYPE_CHART_LINE  =1,                   // line chart
+      WIDGET_TYPE_CHART_AREA  =2,                   // area chart
+      WIDGET_TYPE_CHART_PIE   =3,                   // pie chart
+      WIDGET_TYPE_CHART_SPLINE=4,                   // spline chart
+      WIDGET_TYPE_CHART_AREA_SPLINE=5,              // area spline chart
+      //--- 
+      WIDGET_TYPE_VALUE       =100,                 // single value
+      WIDGET_TYPE_TABLE       =101,                 // table
+      WIDGET_TYPE_HTML        =102,                 // HTML
+      //--- enumeration borders
+      WIDGET_TYPE_FIRST       =WIDGET_TYPE_CHART_BAR,
+      WIDGET_TYPE_LAST        =WIDGET_TYPE_HTML
+     };
+   //--- chart stack type
+   enum EnChartStackType
+     {
+      CHART_STACK_NONE        =0,                     // no stack chart
+      CHART_STACK_SIMPLE      =1,                     // simple stack chart
+      CHART_STACK_ACCUMULATION=2,                     // accumulation stack chart
+      CHART_STACK_NORMALIZED  =3,                     // normalized stack chart
+      //--- enumeration borders
+      CHART_STACK_FIRST       =CHART_STACK_NONE,
+      CHART_STACK_LAST        =CHART_STACK_NORMALIZED
+     };
+   //--- chart value axis type
+   enum EnChartValueAxis
+     {
+      CHART_VALUE_AXIS_ABSOLUTE=0,                    // absolute value axis
+      CHART_VALUE_AXIS_RELATIVE=1,                    // relative value axis
+      //--- enumeration borders
+      CHART_VALUE_AXIS_FIRST  =CHART_VALUE_AXIS_ABSOLUTE,
+      CHART_VALUE_AXIS_LAST   =CHART_VALUE_AXIS_RELATIVE
+     };
+   //--- flags
+   enum EnWidgetFlags
+     {
+      WIDGET_FLAG_NONE        =0x00000000,            // no flags
+      WIDGET_FLAG_AUTO_WIDTH  =0x00000001,            // auto width
+      WIDGET_FLAG_AUTO_HEIGHT =0x00000002,            // auto height
+      WIDGET_FLAG_AUTO_TOP    =0x00000004,            // auto top
+      WIDGET_FLAG_AUTO_LEFT   =0x00000008,            // auto left
+      //--- enumeration borders
+      WIDGET_FLAG_DEFAULT     =WIDGET_FLAG_AUTO_WIDTH|WIDGET_FLAG_AUTO_HEIGHT|WIDGET_FLAG_AUTO_TOP|WIDGET_FLAG_AUTO_LEFT,
+      WIDGET_FLAG_ALL         =WIDGET_FLAG_AUTO_WIDTH|WIDGET_FLAG_AUTO_HEIGHT|WIDGET_FLAG_AUTO_TOP|WIDGET_FLAG_AUTO_LEFT
+     };
+   //--- common methods
+   virtual MTAPIRES  Assign(const IMTReportDashboardWidget *widget)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- title
+   virtual LPCWSTR   Title(void) const=0;
+   virtual MTAPIRES  Title(LPCWSTR title)=0;
+   //--- type
+   virtual UINT      Type(void) const=0;
+   virtual MTAPIRES  Type(const UINT type)=0;
+   //--- chart stack type
+   virtual UINT      ChartStackType(void) const=0;
+   virtual MTAPIRES  ChartStackType(const UINT stack_type)=0;
+   //--- flags
+   virtual UINT64    Flags(void) const=0;
+   virtual MTAPIRES  Flags(const UINT64 flags)=0;
+   //--- widget width
+   virtual UINT      Width(void) const=0;
+   virtual MTAPIRES  Width(const UINT width)=0;
+   //--- widget height
+   virtual UINT      Height(void) const=0;
+   virtual MTAPIRES  Height(const UINT height)=0;
+   //--- widget left edge position
+   virtual UINT      Left(void) const=0;
+   virtual MTAPIRES  Left(const UINT left)=0;
+   //--- widget top edge position
+   virtual UINT      Top(void) const=0;
+   virtual MTAPIRES  Top(const UINT top)=0;
+   //--- description
+   virtual LPCWSTR   Description(void) const=0;
+   virtual MTAPIRES  Description(LPCWSTR description)=0;
+   //--- chart value axis
+   virtual UINT      ChartValueAxis(void) const=0;
+   virtual MTAPIRES  ChartValueAxis(const UINT value_axis)=0;
+   //--- HTML
+   virtual IMTReportDashboardHtml* Html(void)=0;
+   virtual MTAPIRES  Html(IMTReportDashboardHtml *html)=0;
+   //--- dataset
+   virtual IMTDataset* Data(void)=0;
+   virtual MTAPIRES  Data(IMTDataset *data_set)=0;
+   //--- title column
+   virtual UINT      DataColumnTitle(void) const=0;
+   virtual MTAPIRES  DataColumnTitle(const UINT column_id)=0;
+   //--- data set column management
+   virtual MTAPIRES  DataColumnClear(void)=0;
+   virtual MTAPIRES  DataColumnAdd(const UINT column_id)=0;
+   virtual MTAPIRES  DataColumnDelete(const UINT pos)=0;
+   virtual MTAPIRES  DataColumnShift(const UINT pos,const int shift)=0;
+   virtual UINT      DataColumnTotal(void) const=0;
+   virtual const UINT* DataColumnNext(const UINT pos) const=0;
+  };
+//+------------------------------------------------------------------+
+//| Report cache key set interface                                   |
+//+------------------------------------------------------------------+
+class IMTReportCacheKeySet
+  {
+public:
+   //--- common methods
+   virtual void      Release(void)=0;
+   virtual MTAPIRES  Assign(const IMTReportCacheKeySet *keyset)=0;
+   virtual MTAPIRES  Clear(void)=0;
+   //--- swap with keyset
+   virtual MTAPIRES  Swap(IMTReportCacheKeySet *keyset)=0;
+   //--- total keys in set
+   virtual UINT      Total(void) const=0;
+   //--- pointer to keys sorted array
+   virtual const UINT64* Array(void) const=0;
+   //--- iterate sorted keys in array
+   virtual const UINT64* Next(const UINT64 *key) const=0;
+   //--- search key
+   virtual const UINT64* Search(const UINT64 key) const=0;
+   //--- check all keys from passed set present
+   virtual MTAPIRES  ContainsSet(const IMTReportCacheKeySet *keyset) const=0;
+   //--- reserve memory for keys
+   virtual MTAPIRES  Reserve(const UINT total)=0;
+   //--- insert keys
+   virtual MTAPIRES  Insert(const UINT64 key)=0;
+   virtual MTAPIRES  InsertArray(const UINT64 *keys,const UINT total)=0;
+   virtual MTAPIRES  InsertSet(const IMTReportCacheKeySet *keyset)=0;
+   //--- remove keys
+   virtual MTAPIRES  Remove(const UINT64 key)=0;
+   virtual MTAPIRES  RemoveArray(const UINT64 *keys,const UINT total)=0;
+   virtual MTAPIRES  RemoveSet(const IMTReportCacheKeySet *keyset)=0;
+  };
+//+------------------------------------------------------------------+
+//| Report cache value interface                                     |
+//| Contains valid key and data until next calls:                    |
+//| IMTReportCache::Release()                                        |
+//| IMTReportCache::ReadEnd()                                        |
+//| IMTReportCache::WriteEnd()                                       |
+//+------------------------------------------------------------------+
+class IMTReportCacheValue
+  {
+public:
+   //--- release interface
+   virtual void      Release(void)=0;
+   //--- key
+   virtual UINT64    Key(void) const=0;
+   //--- data
+   virtual const void* Data(void) const=0;
+   virtual UINT      Size(void) const=0;
+   //--- iterate to next value
+   virtual MTAPIRES  Next(void)=0;
+  };
+//+------------------------------------------------------------------+
+//| Report cache interface                                           |
+//+------------------------------------------------------------------+
+class IMTReportCache
+  {
+public:
+   //--- release interface
+   virtual void      Release(void)=0;
+   //--- name
+   virtual LPCWSTR   Name(void) const=0;
+   //--- last generation time
+   virtual INT64     TimeLastWrite(void) const=0;
+   //--- create value object
+   virtual IMTReportCacheValue* ValueCreate(void) const=0;
+   //--- read begin/end
+   virtual MTAPIRES  ReadBegin(void)=0;
+   virtual MTAPIRES  ReadEnd(void)=0;
+   //--- read parameters
+   virtual INT64     ReadParamFrom(void) const=0;
+   virtual INT64     ReadParamTo(void) const=0;
+   virtual LPCWSTR   ReadParamString(void) const=0;
+   virtual const void* ReadParamData(UINT &size) const=0;
+   virtual MTAPIRES  ReadParamKeySet(IMTReportCacheKeySet *keys) const=0;
+   //--- read value by key
+   virtual MTAPIRES  ReadValue(const UINT64 key,IMTReportCacheValue *value) const=0;
+   //--- read multiple values by key set
+   virtual MTAPIRES  ReadValues(const IMTReportCacheKeySet *keys,IMTReportCacheValue *value) const=0;
+   //--- get keys from set that missing in cache
+   virtual MTAPIRES  ReadMissingKeys(const IMTReportCacheKeySet *keys,IMTReportCacheKeySet *missing_keys) const=0;
+   //--- get string position in dictionary
+   virtual MTAPIRES  ReadDictionaryPos(const UINT dictionary_id,LPCWSTR string,UINT &pos) const=0;
+   //--- get string from dictionary by position
+   virtual MTAPIRES  ReadDictionaryString(const UINT dictionary_id,const UINT pos,LPCWSTR &string) const=0;
+   //--- write begin/end
+   virtual MTAPIRES  WriteBegin(void)=0;
+   virtual MTAPIRES  WriteEnd(bool apply)=0;
+   //--- write parameters
+   virtual MTAPIRES  WriteParamFrom(const INT64 from)=0;
+   virtual MTAPIRES  WriteParamTo(const INT64 to)=0;
+   virtual MTAPIRES  WriteParamString(LPCWSTR param)=0;
+   virtual MTAPIRES  WriteParamData(const void *data,const UINT size)=0;
+   virtual MTAPIRES  WriteParamKeySet(const IMTReportCacheKeySet *keys,const bool merge)=0;
+   //--- write value by key
+   virtual MTAPIRES  WriteValue(const UINT64 key,const void *value,const UINT size)=0;
+   //--- write empty value for keys from set that missing in cache
+   virtual MTAPIRES  WriteMissingKeys(const IMTReportCacheKeySet *keys)=0;
+   //--- write new string to dictionary or get existing string position
+   virtual MTAPIRES  WriteDictionaryString(const UINT dictionary_id,LPCWSTR string,UINT &pos)=0;
+  };
+//+------------------------------------------------------------------+
+//| Report API interface                                             |
+//+------------------------------------------------------------------+
+class IMTReportAPI
+  {
+public:
+   //--- HtmlWriteSafe flags
+   enum EnHtmlSafeFlags
+     {
+      HTML_SAFE_NONE          =0x0,    // no flags
+      HTML_SAFE_USENOBSP      =0x1,    // replace blank to &nbsp;
+     };
+   //--- HtmlTplProcess flags
+   enum EnTplProcessFlags
+     {
+      TPL_PROCESS_NONE        =0x0,    // no flags
+     };
+   //--- Dashboard flags
+   enum EnDashboardFlags
+     {
+      DASHBOARD_FLAG_NONE     =0x0,    // no flags
+     };
+
+public:
+   //--- server description
+   virtual MTAPIRES  About(MTReportServerInfo& info)=0;
+   //--- license check
+   virtual MTAPIRES  LicenseCheck(LPCWSTR license_name)=0;
+   //--- memory management
+   virtual void*     Allocate(const UINT size)=0;
+   virtual void      Free(void* ptr)=0;
+   //--- clear result
+   virtual MTAPIRES  Clear(void)=0;
+   virtual MTAPIRES  FunctionReserved1(void)=0;
+   virtual MTAPIRES  FunctionReserved2(void)=0;
+   virtual MTAPIRES  FunctionReserved3(void)=0;
+   virtual MTAPIRES  FunctionReserved4(void)=0;
+   virtual MTAPIRES  FunctionReserved5(void)=0;
+   virtual MTAPIRES  FunctionReserved6(void)=0;
+   //--- common flags functions
+   virtual MTAPIRES  IsStopped(void)=0;
+   virtual MTAPIRES  IsReserved1(void)=0;
+   virtual MTAPIRES  IsReserved2(void)=0;
+   virtual MTAPIRES  IsReserved3(void)=0;
+   virtual MTAPIRES  IsReserved4(void)=0;
+   virtual MTAPIRES  IsReserved5(void)=0;
+   virtual MTAPIRES  IsReserved6(void)=0;
+   //--- server log functions
+   virtual MTAPIRES  LoggerOut(const UINT code,LPCWSTR msg,...)=0;
+   virtual MTAPIRES  LoggerRequest(const UINT mode,const UINT type,const INT64 from,const INT64 to,LPCWSTR filter,MTLogRecord*& records,UINT& records_total)=0;
+   virtual void      LoggerFlush(void)=0;
+   virtual MTAPIRES  LoggerReserved1(void)=0;
+   virtual MTAPIRES  LoggerReserved2(void)=0;
+   virtual MTAPIRES  LoggerReserved3(void)=0;
+   virtual MTAPIRES  LoggerReserved4(void)=0;
+   //--- report parameters
+   virtual IMTConParam* ParamCreate(void)=0;
+   virtual UINT      ParamTotal(void)=0;
+   virtual MTAPIRES  ParamGet(LPCWSTR name,IMTConParam *param)=0;
+   virtual MTAPIRES  ParamNext(const UINT pos,IMTConParam *param)=0;
+   virtual MTAPIRES  ParamReserved1(void)=0;
+   virtual MTAPIRES  ParamReserved2(void)=0;
+   virtual MTAPIRES  ParamReserved3(void)=0;
+   virtual MTAPIRES  ParamReserved4(void)=0;
+   //--- report parameters helpers
+   virtual MTAPIRES  ParamLogins(UINT64*& logins,UINT& total)=0;
+   virtual INT64     ParamFrom(void)=0;
+   virtual INT64     ParamTo(void)=0;
+   virtual LPCWSTR   ParamGroups(void)=0;
+   virtual LPCWSTR   ParamSymbols(void)=0;
+   virtual UINT      ParamIEVersion(void)=0;
+   virtual UINT      ParamScreenWidth(void)=0;
+   virtual UINT      ParamScreenHeight(void)=0;
+   virtual MTAPIRES  ParamHelperReserved1(void)=0;
+   virtual MTAPIRES  ParamHelperReserved2(void)=0;
+   virtual MTAPIRES  ParamHelperReserved3(void)=0;
+   virtual MTAPIRES  ParamHelperReserved4(void)=0;
+   //--- HTML management
+   virtual MTAPIRES  HtmlWrite(LPCWSTR format,...)=0;
+   virtual MTAPIRES  HtmlWriteSafe(LPCWSTR html,const UINT flags)=0;
+   virtual MTAPIRES  HtmlWriteReserved1(void)=0;
+   virtual MTAPIRES  HtmlWriteReserved2(void)=0;
+   virtual MTAPIRES  HtmlTplLoad(LPCWSTR templstr)=0;
+   virtual MTAPIRES  HtmlTplLoadFile(LPCWSTR templname)=0;
+   virtual MTAPIRES  HtmlTplLoadResource(const UINT resid,LPCWSTR restype)=0;
+   virtual MTAPIRES  HtmlTplNext(MTAPISTR& tag,UINT *counter)=0;
+   virtual MTAPIRES  HtmlTplProcess(const UINT flags)=0;
+   virtual MTAPIRES  HtmlTplReserved1(void)=0;
+   virtual MTAPIRES  HtmlTplReserved2(void)=0;
+   virtual MTAPIRES  HtmlReserved1(void)=0;
+   virtual MTAPIRES  HtmlReserved2(void)=0;
+   virtual MTAPIRES  HtmlReserved3(void)=0;
+   virtual MTAPIRES  HtmlReserved4(void)=0;
+   //--- table column management
+   virtual IMTDatasetColumn* TableColumnCreate(void)=0;
+   virtual MTAPIRES  TableColumnClear(void)=0;
+   virtual MTAPIRES  TableColumnAdd(const IMTDatasetColumn *column)=0;
+   virtual MTAPIRES  TableColumnDelete(const UINT pos)=0;
+   virtual UINT      TableColumnTotal(void)=0;
+   virtual UINT      TableColumnSize(void)=0;
+   virtual MTAPIRES  TableColumnNext(const UINT pos,IMTDatasetColumn *column)=0;
+   virtual MTAPIRES  TableColumnReserved1(void)=0;
+   virtual MTAPIRES  TableColumnReserved2(void)=0;
+   //--- table row management
+   virtual MTAPIRES  TableRowClear(void)=0;
+   virtual MTAPIRES  TableRowWrite(const void *data,const UINT size)=0;
+   virtual UINT      TableRowTotal(void)=0;
+   virtual MTAPIRES  TableRowReserved1(void)=0;
+   virtual MTAPIRES  TableRowReserved2(void)=0;
+   //--- table summary management
+   virtual IMTDatasetSummary* TableSummaryCreate(void)=0;
+   virtual MTAPIRES  TableSummaryClear(void)=0;
+   virtual MTAPIRES  TableSummaryAdd(const IMTDatasetSummary *summary)=0;
+   virtual MTAPIRES  TableSummaryDelete(const UINT pos)=0;
+   virtual MTAPIRES  TableSummaryNext(const UINT pos,IMTDatasetSummary *summary)=0;
+   virtual UINT      TableSummaryTotal(void)=0;
+   virtual MTAPIRES  TableSummaryReserved1(void)=0;
+   virtual MTAPIRES  TableSummaryReserved2(void)=0;
+   virtual MTAPIRES  TableSummaryReserved3(void)=0;
+   //--- table reserved functions
+   virtual MTAPIRES  TableReserved1(void)=0;
+   virtual MTAPIRES  TableReserved2(void)=0;
+   virtual MTAPIRES  TableReserved3(void)=0;
+   virtual MTAPIRES  TableReserved4(void)=0;
+   virtual MTAPIRES  TableReserved5(void)=0;
+   virtual MTAPIRES  TableReserved6(void)=0;
+   //--- chart management
+   virtual IMTReportChart* ChartCreate(void)=0;
+   virtual IMTReportSeries* ChartCreateSeries(void)=0;
+   virtual MTAPIRES  ChartWriteHtml(const IMTReportChart *chart)=0;
+   virtual MTAPIRES  ChartReserved1(void)=0;
+   virtual MTAPIRES  ChartReserved2(void)=0;
+   virtual MTAPIRES  ChartReserved3(void)=0;
+   virtual MTAPIRES  ChartReserved4(void)=0;
+   //--- report configuration
+   virtual IMTConReport* ReportCreate(void)=0;
+   virtual MTAPIRES  ReportCurrent(IMTConReport *report)=0;
+   virtual MTAPIRES  ReportReserved1(void)=0;
+   virtual MTAPIRES  ReportReserved2(void)=0;
+   virtual MTAPIRES  ReportReserved3(void)=0;
+   virtual MTAPIRES  ReportReserved4(void)=0;
+   //--- common configuration 
+   virtual IMTConCommon* CommonCreate(void)=0;
+   virtual MTAPIRES  CommonGet(IMTConCommon* common)=0;
+   virtual MTAPIRES  CommonReserved1(void)=0;
+   virtual MTAPIRES  CommonReserved2(void)=0;
+   virtual MTAPIRES  CommonReserved3(void)=0;
+   virtual MTAPIRES  CommonReserved4(void)=0;
+   //--- network configuration
+   virtual IMTConServer* NetServerCreate(void)=0;
+   virtual IMTConServerRange* NetServerRangeCreate(void)=0;
+   virtual UINT      NetServerTotal(void)=0;
+   virtual MTAPIRES  NetServerNext(const UINT pos,IMTConServer *server)=0;
+   virtual MTAPIRES  NetServerGet(const UINT64 id,IMTConServer *server)=0;
+   virtual MTAPIRES  NetServerReserved1(void)=0;
+   virtual MTAPIRES  NetServerReserved2(void)=0;
+   virtual MTAPIRES  NetServerReserved3(void)=0;
+   virtual MTAPIRES  NetServerReserved4(void)=0;
+   //--- time configuration
+   virtual IMTConTime* TimeCreate(void)=0;
+   virtual INT64     TimeCurrent(void)=0;
+   virtual INT64     TimeGeneration(void)=0;
+   virtual MTAPIRES  TimeGet(IMTConTime *time)=0;
+   virtual MTAPIRES  TimeReserved1(void)=0;
+   virtual MTAPIRES  TimeReserved2(void)=0;
+   virtual MTAPIRES  TimeReserved3(void)=0;
+   virtual MTAPIRES  TimeReserved4(void)=0;
+   //--- holiday configuration
+   virtual IMTConHoliday* HolidayCreate()=0;
+   virtual UINT      HolidayTotal(void)=0;
+   virtual MTAPIRES  HolidayNext(const UINT pos,IMTConHoliday *holiday)=0;
+   virtual MTAPIRES  HolidayReserved1(void)=0;
+   virtual MTAPIRES  HolidayReserved2(void)=0;
+   virtual MTAPIRES  HolidayReserved3(void)=0;
+   virtual MTAPIRES  HolidayReserved4(void)=0;
+   //--- clients group configuration
+   virtual IMTConGroup* GroupCreate(void)=0;
+   virtual IMTConGroupSymbol* GroupSymbolCreate(void)=0;
+   virtual IMTConCommission* GroupCommissionCreate(void)=0;
+   virtual IMTConCommTier* GroupTierCreate(void)=0;
+   virtual UINT      GroupTotal(void)=0;
+   virtual MTAPIRES  GroupNext(const UINT pos,IMTConGroup *group)=0;
+   virtual MTAPIRES  GroupGet(LPCWSTR name,IMTConGroup *group)=0;
+   virtual MTAPIRES  GroupGetLight(LPCWSTR name,IMTConGroup *group)=0;
+   virtual MTAPIRES  GroupReserved1(void)=0;
+   virtual MTAPIRES  GroupReserved2(void)=0;
+   virtual MTAPIRES  GroupReserved3(void)=0;
+   virtual MTAPIRES  GroupReserved4(void)=0;
+   //--- symbols configuration
+   virtual IMTConSymbol* SymbolCreate(void)=0;
+   virtual IMTConSymbolSession* SymbolSessionCreate(void)=0;
+   virtual UINT      SymbolTotal(void)=0;
+   virtual MTAPIRES  SymbolNext(const UINT pos,IMTConSymbol *symbol)=0;
+   virtual MTAPIRES  SymbolGet(LPCWSTR name,IMTConSymbol *symbol)=0;
+   virtual MTAPIRES  SymbolGetLight(LPCWSTR name,IMTConSymbol *symbol)=0;
+   virtual MTAPIRES  SymbolGet(LPCWSTR name,const IMTConGroup *group,IMTConSymbol *symbol)=0;
+   virtual MTAPIRES  SymbolExist(const IMTConSymbol* symbol,const IMTConGroup* group)=0;
+   virtual MTAPIRES  SymbolReserved1(void)=0;
+   virtual MTAPIRES  SymbolReserved2(void)=0;
+   virtual MTAPIRES  SymbolReserved3(void)=0;
+   virtual MTAPIRES  SymbolReserved4(void)=0;
+   //--- managers configuration
+   virtual IMTConManager* ManagerCreate(void)=0;
+   virtual IMTConManagerAccess* ManagerAccessCreate(void)=0;
+   virtual MTAPIRES  ManagerCurrent(IMTConManager *manager)=0;
+   virtual UINT      ManagerTotal(void)=0;
+   virtual MTAPIRES  ManagerNext(const UINT pos,IMTConManager *manager)=0;
+   virtual MTAPIRES  ManagerGet(const UINT64 login,IMTConManager *manager)=0;
+   virtual MTAPIRES  ManagerReserved1(void)=0;
+   virtual MTAPIRES  ManagerReserved2(void)=0;
+   virtual MTAPIRES  ManagerReserved3(void)=0;
+   virtual MTAPIRES  ManagerReserved4(void)=0;
+   //--- clients database
+   virtual IMTUser*  UserCreate(void)=0;
+   virtual IMTAccount* UserCreateAccount(void)=0;
+   virtual MTAPIRES  UserGet(const UINT64 login,IMTUser *user)=0;
+   virtual MTAPIRES  UserGetLight(const UINT64 login,IMTUser *user)=0;
+   virtual MTAPIRES  UserLogins(LPCWSTR group,UINT64*& logins,UINT &total)=0;
+   virtual MTAPIRES  UserAccountGet(const UINT64 login,IMTAccount *account)=0;
+   virtual MTAPIRES  UserSelect(const IMTDatasetRequest *request,IMTDataset *dataset)=0;
+   virtual MTAPIRES  UserReserved2(void)=0;
+   virtual MTAPIRES  UserReserved3(void)=0;
+   virtual MTAPIRES  UserReserved4(void)=0;
+   //--- trade orders database
+   virtual IMTOrder* OrderCreate(void)=0;
+   virtual IMTOrderArray* OrderCreateArray(void)=0;
+   virtual MTAPIRES  OrderGet(const UINT64 ticket,IMTOrder *order)=0;
+   virtual MTAPIRES  OrderGet(const UINT64 login,IMTOrderArray *orders)=0;
+   virtual MTAPIRES  OrderSelect(const IMTDatasetRequest *request,IMTDataset *dataset)=0;
+   virtual MTAPIRES  OrderReserved2(void)=0;
+   virtual MTAPIRES  OrderReserved3(void)=0;
+   virtual MTAPIRES  OrderReserved4(void)=0;
+   //--- trade history orders databases
+   virtual MTAPIRES  HistoryGet(const UINT64 ticket,IMTOrder *order)=0;
+   virtual MTAPIRES  HistoryGet(const UINT64 login,const INT64 from,const INT64 to,IMTOrderArray *orders)=0;
+   virtual MTAPIRES  HistorySelect(const IMTDatasetRequest *request,IMTDataset *dataset)=0;
+   virtual MTAPIRES  HistoryReserved2(void)=0;
+   virtual MTAPIRES  HistoryReserved3(void)=0;
+   virtual MTAPIRES  HistoryReserved4(void)=0;
+   //--- trade deals database
+   virtual IMTDeal*  DealCreate(void)=0;
+   virtual IMTDealArray* DealCreateArray(void)=0;
+   virtual MTAPIRES  DealGet(const UINT64 ticket,IMTDeal *deal)=0;
+   virtual MTAPIRES  DealGet(const UINT64 login,const INT64 from,const INT64 to,IMTDealArray *deals)=0;
+   virtual MTAPIRES  DealSelect(const IMTDatasetRequest *request,IMTDataset *dataset)=0;
+   virtual MTAPIRES  DealReserved2(void)=0;
+   virtual MTAPIRES  DealReserved3(void)=0;
+   virtual MTAPIRES  DealReserved4(void)=0;
+   //--- trade positions database
+   virtual IMTPosition* PositionCreate(void)=0;
+   virtual IMTPositionArray* PositionCreateArray(void)=0;
+   virtual MTAPIRES  PositionGet(const UINT64 login,LPCWSTR symbol,IMTPosition *position)=0;
+   virtual MTAPIRES  PositionGet(const UINT64 login,IMTPositionArray *positions)=0;
+   virtual MTAPIRES  PositionGetByTicket(const UINT64 ticket,IMTPosition *position)=0;
+   virtual MTAPIRES  PositionSelect(const IMTDatasetRequest *request,IMTDataset *dataset)=0;
+   virtual MTAPIRES  PositionReserved2(void)=0;
+   virtual MTAPIRES  PositionReserved3(void)=0;
+   //--- trade daily database
+   virtual IMTDaily* DailyCreate(void)=0;
+   virtual IMTDailyArray* DailyCreateArray(void)=0;
+   virtual MTAPIRES  DailyGet(const UINT64 login,const INT64 datetime,IMTDaily *daily)=0;
+   virtual MTAPIRES  DailyGetLight(const UINT64 login,const INT64 datetime,IMTDaily *daily)=0;
+   virtual MTAPIRES  DailyGet(const UINT64 login,const INT64 from,const INT64 to,IMTDailyArray *daily)=0;
+   virtual MTAPIRES  DailyGetLight(const UINT64 login,const INT64 from,const INT64 to,IMTDailyArray *daily)=0;
+   virtual MTAPIRES  DailySelect(const IMTDatasetRequest *request,IMTDataset *dataset)=0;
+   virtual MTAPIRES  DailyReserved2(void)=0;
+   virtual MTAPIRES  DailyReserved3(void)=0;
+   virtual MTAPIRES  DailyReserved4(void)=0;
+   //--- trade methods
+   virtual MTAPIRES  TradeProfit(LPCWSTR group,LPCWSTR symbol,const UINT type,const UINT64 volume,const double price_open,const double price_close,double& profit,double& profit_rate)=0;
+   virtual MTAPIRES  TradeRateBuy(LPCWSTR base,LPCWSTR currency,double& rate,LPCWSTR group=NULL,LPCWSTR symbol=NULL,const double price=0)=0;
+   virtual MTAPIRES  TradeRateSell(LPCWSTR base,LPCWSTR currency,double& rate,LPCWSTR group=NULL,LPCWSTR symbol=NULL,const double price=0)=0;
+   virtual MTAPIRES  TradeProfitExt(LPCWSTR group,LPCWSTR symbol,const UINT type,const UINT64 volume,const double price_open,const double price_close,double& profit,double& profit_rate)=0;
+   virtual MTAPIRES  TradeReserved2(void)=0;
+   virtual MTAPIRES  TradeReserved3(void)=0;
+   virtual MTAPIRES  TradeReserved4(void)=0;
+   //--- plugins configuration
+   virtual IMTConPlugin* PluginCreate(void)=0;
+   virtual IMTConPluginModule* PluginModuleCreate(void)=0;
+   virtual IMTConParam* PluginParamCreate(void)=0;
+   virtual UINT      PluginTotal(void)=0;
+   virtual MTAPIRES  PluginNext(const UINT pos,IMTConPlugin *plugin)=0;
+   virtual MTAPIRES  PluginGet(const UINT64 server,LPCWSTR name,IMTConPlugin *plugin)=0;
+   virtual UINT      PluginModuleTotal(void)=0;
+   virtual MTAPIRES  PluginModuleNext(const UINT pos,IMTConPluginModule *module)=0;
+   virtual MTAPIRES  PluginModuleGet(const UINT64 server,LPCWSTR name,IMTConPluginModule *module)=0;
+   virtual MTAPIRES  PluginReserved1(void)=0;
+   virtual MTAPIRES  PluginReserved2(void)=0;
+   virtual MTAPIRES  PluginReserved3(void)=0;
+   virtual MTAPIRES  PluginReserved4(void)=0;
+   //--- datafeeds configuration
+   virtual IMTConFeeder* FeederCreate(void)=0;
+   virtual IMTConFeederModule* FeederModuleCreate(void)=0;
+   virtual IMTConParam* FeederParamCreate(void)=0;
+   virtual IMTConFeederTranslate* FeederTranslateCreate(void)=0;
+   virtual UINT      FeederTotal(void)=0;
+   virtual MTAPIRES  FeederNext(const UINT pos,IMTConFeeder *feeder)=0;
+   virtual MTAPIRES  FeederGet(LPCWSTR name,IMTConFeeder *feeder)=0;
+   virtual UINT      FeederModuleTotal(void)=0;
+   virtual MTAPIRES  FeederModuleNext(const UINT pos,IMTConFeederModule *module)=0;
+   virtual MTAPIRES  FeederModuleGet(LPCWSTR name,IMTConFeederModule *module)=0;
+   virtual MTAPIRES  FeederReserved1(void)=0;
+   virtual MTAPIRES  FeederReserved2(void)=0;
+   virtual MTAPIRES  FeederReserved3(void)=0;
+   virtual MTAPIRES  FeederReserved4(void)=0;
+   //--- gateways configuration
+   virtual IMTConGateway* GatewayCreate(void)=0;
+   virtual IMTConGatewayModule* GatewayModuleCreate(void)=0;
+   virtual IMTConParam* GatewayParamCreate(void)=0;
+   virtual IMTConGatewayTranslate* GatewayTranslateCreate(void)=0;
+   virtual UINT      GatewayTotal(void)=0;
+   virtual MTAPIRES  GatewayNext(const UINT pos,IMTConGateway *gateway)=0;
+   virtual MTAPIRES  GatewayGet(LPCWSTR name,IMTConGateway *gateway)=0;
+   virtual UINT      GatewayModuleTotal(void)=0;
+   virtual MTAPIRES  GatewayModuleNext(const UINT pos,IMTConGatewayModule *module)=0;
+   virtual MTAPIRES  GatewayModuleGet(LPCWSTR name,IMTConGatewayModule *module)=0;
+   virtual MTAPIRES  GatewayReserved1(void)=0;
+   virtual MTAPIRES  GatewayReserved2(void)=0;
+   virtual MTAPIRES  GatewayReserved3(void)=0;
+   virtual MTAPIRES  GatewayReserved4(void)=0;
+   //--- ticks
+   virtual MTAPIRES  TickHistoryGet(LPCWSTR symbol,const INT64 from,const INT64 to,MTTickShort*& ticks,UINT& ticks_total)=0;
+   virtual MTAPIRES  TickHistoryGetRaw(LPCWSTR symbol,const INT64 from,const INT64 to,MTTickShort*& ticks,UINT& ticks_total)=0;
+   virtual MTAPIRES  TickLast(LPCWSTR symbol,MTTickShort& tick)=0;
+   virtual MTAPIRES  TickLast(const IMTConSymbol* symbol,MTTickShort& tick)=0;
+   virtual MTAPIRES  TickStat(LPCWSTR symbol,MTTickStat& stat)=0;
+   virtual MTAPIRES  TickReserved4(void)=0;
+   //--- chart methods
+   virtual MTAPIRES  ChartHistoryGet(LPCWSTR symbol,const INT64 from,const INT64 to,MTChartBar*& bars,UINT& bars_total)=0;
+   virtual MTAPIRES  ChartHistoryReserved1(void)=0;
+   virtual MTAPIRES  ChartHistoryReserved2(void)=0;
+   virtual MTAPIRES  ChartHistoryReserved3(void)=0;
+   virtual MTAPIRES  ChartHistoryReserved4(void)=0;
+   //--- dashboard width
+   virtual UINT      DashboardWidth(void)=0;
+   virtual MTAPIRES  DashboardWidth(const UINT width)=0;
+   //--- dashboard height
+   virtual UINT      DashboardHeight(void)=0;
+   virtual MTAPIRES  DashboardHeight(const UINT height)=0;
+   //--- dashboard title
+   virtual LPCWSTR   DashboardTitle(void)=0;
+   virtual MTAPIRES  DashboardTitle(LPCWSTR title)=0;
+   //--- dashboard flags
+   virtual UINT64    DashboardFlags(void)=0;
+   virtual MTAPIRES  DashboardFlags(const UINT64 flags)=0;
+   //--- reserved dashboard properties
+   virtual MTAPIRES  DashboardReserved1(void)=0;
+   virtual MTAPIRES  DashboardReserved2(void)=0;
+   virtual MTAPIRES  DashboardReserved3(void)=0;
+   virtual MTAPIRES  DashboardReserved4(void)=0;
+   //--- dataset management
+   virtual IMTDataset* DatasetAppend(void)=0;
+   virtual MTAPIRES  DatasetClear(void)=0;
+   virtual MTAPIRES  DatasetDelete(const UINT pos)=0;
+   virtual UINT      DatasetTotal(void) const=0;
+   virtual IMTDataset* DatasetNext(const UINT pos)=0;
+   virtual IMTDatasetRequest* DatasetRequestCreate(void)=0;
+   virtual MTAPIRES  DatasetReserved2(void)=0;
+   virtual MTAPIRES  DatasetReserved3(void)=0;
+   virtual MTAPIRES  DatasetReserved4(void)=0;
+   //--- dashboard HTML management
+   virtual IMTReportDashboardHtml* DashboardHtmlAppend(void)=0;
+   virtual MTAPIRES  DashboardHtmlClear(void)=0;
+   virtual MTAPIRES  DashboardHtmlDelete(const UINT pos)=0;
+   virtual UINT      DashboardHtmlTotal(void) const=0;
+   virtual IMTReportDashboardHtml* DashboardHtmlNext(const UINT pos)=0;
+   virtual MTAPIRES  DashboardHtmlReserved1(void)=0;
+   virtual MTAPIRES  DashboardHtmlReserved2(void)=0;
+   virtual MTAPIRES  DashboardHtmlReserved3(void)=0;
+   virtual MTAPIRES  DashboardHtmlReserved4(void)=0;
+   //--- dashboard widget management
+   virtual IMTReportDashboardWidget* DashboardWidgetAppend(void)=0;
+   virtual MTAPIRES  DashboardWidgetClear(void)=0;
+   virtual MTAPIRES  DashboardWidgetDelete(const UINT pos)=0;
+   virtual UINT      DashboardWidgetTotal(void) const=0;
+   virtual IMTReportDashboardWidget* DashboardWidgetNext(const UINT pos)=0;
+   virtual MTAPIRES  DashboardWidgetReserved1(void)=0;
+   virtual MTAPIRES  DashboardWidgetReserved2(void)=0;
+   virtual MTAPIRES  DashboardWidgetReserved3(void)=0;
+   virtual MTAPIRES  DashboardWidgetReserved4(void)=0;
+   //--- key set management
+   virtual IMTReportCacheKeySet* KeySetCreate(void) const=0;
+   virtual MTAPIRES  KeySetParamLogins(IMTReportCacheKeySet *keyset) const=0;
+   virtual MTAPIRES  KeySetReserved1(void)=0;
+   virtual MTAPIRES  KeySetReserved2(void)=0;
+   virtual MTAPIRES  KeySetReserved3(void)=0;
+   virtual MTAPIRES  KeySetReserved4(void)=0;
+   //--- report cache management
+   virtual IMTReportCache* ReportCacheCreate(void) const=0;
+   virtual MTAPIRES  ReportCacheGet(LPCWSTR name,const UINT version,IMTReportCache *report_cache)=0;
+   virtual MTAPIRES  ReportCacheGetTemporary(LPCWSTR name,const UINT version,const UINT64 key_time_to_live,IMTReportCache *report_cache)=0;
+   virtual MTAPIRES  ReportCacheReserved1(void)=0;
+   virtual MTAPIRES  ReportCacheReserved2(void)=0;
+   virtual MTAPIRES  ReportCacheReserved3(void)=0;
+   virtual MTAPIRES  ReportCacheReserved4(void)=0;
+   //--- clients database
+   virtual MTAPIRES  ClientSelect(const IMTDatasetRequest *request,IMTDataset *dataset)=0;
+   virtual IMTClient *ClientCreate(void)=0;
+   virtual IMTClientArray *ClientCreateArray(void)=0;
+   virtual MTAPIRES  ClientGet(const UINT64 client_id,IMTClient *client)=0;
+   virtual MTAPIRES  ClientGetHistory(const UINT64 client_id,const UINT64 author,const INT64 from,const INT64 to,IMTClientArray *history)=0;
+   virtual MTAPIRES  ClientIdsAll(UINT64*& ids,UINT& ids_total)=0;
+   virtual MTAPIRES  ClientIdsByGroup(const LPCWSTR groups,UINT64*& ids,UINT& ids_total)=0;
+   virtual MTAPIRES  ClientUserLogins(const UINT64 client_id,UINT64*& logins,UINT& logins_total)=0;
+   virtual MTAPIRES  ClientReserved8(void)=0;
+   virtual MTAPIRES  ClientReserved9(void)=0;
+   //--- funds configuration
+   virtual IMTConFund* FundCreate(void)=0;
+   virtual IMTConFundAccount* FundAccountCreate(void)=0;
+   virtual IMTConFundInvestor* FundInvestorCreate(void)=0;
+   virtual UINT      FundTotal(void)=0;
+   virtual MTAPIRES  FundNext(const UINT pos,IMTConFund *fund)=0;
+   virtual MTAPIRES  FundGet(LPCWSTR name,IMTConFund *fund)=0;
+   virtual MTAPIRES  FundReserved1(void)=0;
+   virtual MTAPIRES  FundReserved2(void)=0;
+   virtual MTAPIRES  FundReserved3(void)=0;
+   virtual MTAPIRES  FundReserved4(void)=0;
+   //--- ticks
+   virtual MTAPIRES  TickGet(LPCWSTR symbol,const INT64 from,const INT64 to,MTTickShort*& ticks,UINT& ticks_total)=0;
+   virtual MTAPIRES  TickGet(const IMTConSymbol* symbol,const INT64 from,const INT64 to,MTTickShort*& ticks,UINT& ticks_total)=0;
+   virtual MTAPIRES  TickReserved5(void)=0;
+   virtual MTAPIRES  TickReserved6(void)=0;
+   virtual MTAPIRES  TickReserved7(void)=0;
+   virtual MTAPIRES  TickReserved8(void)=0;
+  };
+//+------------------------------------------------------------------+
+//| Report context interface                                         |
+//+------------------------------------------------------------------+
+class IMTReportContext
+  {
+public:
+   virtual void      Release(void)=0;
+   //--- report generation method
+   virtual MTAPIRES  Generate(const UINT type,IMTReportAPI *api)=0;
+  };
+//+------------------------------------------------------------------+
+//| Report DLL entry points                                          |
+//+------------------------------------------------------------------+
+MTAPIENTRY MTAPIRES  MTReportAbout(const UINT index,MTReportInfo& info);
+MTAPIENTRY MTAPIRES  MTReportCreate(const UINT index,const UINT apiversion,IMTReportContext **context);
+//+------------------------------------------------------------------+

+ 980 - 0
MT5SDK/MT5APIServer.h

@@ -0,0 +1,980 @@
+//+------------------------------------------------------------------+
+//|                                                 MetaTrader 5 API |
+//|                   Copyright 2000-2019, MetaQuotes Software Corp. |
+//|                                        http://www.metaquotes.net |
+//+------------------------------------------------------------------+
+#pragma once
+#include "MT5APIConstants.h"
+#include "MT5APILogger.h"
+#include "MT5APITools.h"
+#include "Config\MT5APIConfigPlugin.h"
+#include "Config\MT5APIConfigCommon.h"
+#include "Config\MT5APIConfigTime.h"
+#include "Config\MT5APIConfigFirewall.h"
+#include "Config\MT5APIConfigSymbol.h"
+#include "Config\MT5APIConfigSpread.h"
+#include "Config\MT5APIConfigGroup.h"
+#include "Config\MT5APIConfigHoliday.h"
+#include "Config\MT5APIConfigFeeder.h"
+#include "Config\MT5APIConfigGateway.h"
+#include "Config\MT5APIConfigReport.h"
+#include "Config\MT5APIConfigManager.h"
+#include "Config\MT5APIConfigHistory.h"
+#include "Config\MT5APIConfigNetwork.h"
+#include "Config\MT5APIConfigRoute.h"
+#include "Config\MT5APIConfigEmail.h"
+#include "Config\MT5APIConfigMessenger.h"
+#include "Bases\MT5APIUser.h"
+#include "Bases\MT5APIAccount.h"
+#include "Bases\MT5APIBook.h"
+#include "Bases\MT5APIChart.h"
+#include "Bases\MT5APIDeal.h"
+#include "Bases\MT5APIOrder.h"
+#include "Bases\MT5APIPosition.h"
+#include "Bases\MT5APITick.h"
+#include "Bases\MT5APIMail.h"
+#include "Bases\MT5APINews.h"
+#include "Bases\MT5APIDaily.h"
+#include "Bases\MT5APIRequest.h"
+#include "Bases\MT5APIConfirm.h"
+#include "Bases\MT5APIByteStream.h"
+#include "Bases\MT5APICertificate.h"
+#include "Bases\MT5APIExecution.h"
+#include "Bases\MT5APIOnline.h"
+#include "Bases\MT5APIDataset.h"
+#include "Bases\MT5APIClient.h"
+#include "Bases\MT5APIDocument.h"
+#include "Bases\MT5APIComment.h"
+#include "Bases\MT5APIAttachment.h"
+//+------------------------------------------------------------------+
+//| Server API version                                               |
+//+------------------------------------------------------------------+
+#define MTServerAPIVersion             2190
+#define MTServerAPIDate                L"18 Oct 2019"
+//+------------------------------------------------------------------+
+//| Structures                                                       |
+//+------------------------------------------------------------------+
+//+------------------------------------------------------------------+
+//| Plugin parameter structure                                       |
+//+------------------------------------------------------------------+
+#pragma pack(push,1)
+struct MTPluginParam
+  {
+   //--- parameter types
+   enum EnParamType
+     {
+      TYPE_STRING    =0,   // string
+      TYPE_INT       =1,   // integer
+      TYPE_FLOAT     =2,   // floating
+      TYPE_TIME      =3,   // time only
+      TYPE_DATE      =4,   // date only
+      TYPE_DATETIME  =5,   // date & time
+      TYPE_GROUPS    =6,   // groups list
+      TYPE_SYMBOLS   =7,   // symbols list
+      //---
+      TYPE_FIRST     =TYPE_STRING,
+      TYPE_LAST      =TYPE_SYMBOLS
+     };
+   //---
+   UINT              type;                                 // parameter type (EnParamType)
+   wchar_t           name[64];                             // parameter name
+   wchar_t           value[256];                           // parameter value
+   UINT              reserved[16];                         // reserved
+  };
+#pragma pack(pop)
+//+------------------------------------------------------------------+
+//| Plugin about structure                                           |
+//+------------------------------------------------------------------+
+#pragma pack(push,1)
+struct MTPluginInfo
+  {
+   UINT              version;                               // plugin version
+   UINT              version_api;                           // server API version
+   wchar_t           name[64];                              // plugin Name
+   wchar_t           copyright[128];                        // copyright
+   wchar_t           description[256];                      // description
+   MTPluginParam     defaults[128];                         // default parameters
+   UINT              defaults_total;                        // default parameters total
+   UINT              reserved[128];                         // reserved
+  };
+#pragma pack(pop)
+//+------------------------------------------------------------------+
+//| Server description structure                                     |
+//+------------------------------------------------------------------+
+#pragma pack(push,1)
+struct MTServerInfo
+  {
+   wchar_t           platform_name[64];                     // platform name
+   wchar_t           platform_owner[128];                   // platform owner
+   UINT              server_version;                        // server version
+   UINT              server_build;                          // server build
+   UINT              server_type;                           // server type
+   UINT64            server_id;                             // server id
+   UINT              reserved[32];                          // reserved
+  };
+#pragma pack(pop)
+//+------------------------------------------------------------------+
+//| Custom commands notification interface                           |
+//+------------------------------------------------------------------+
+class IMTCustomSink
+  {
+public:
+   //--- manager API command
+   virtual MTAPIRES  HookManagerCommand(LPCWSTR              /*ip*/,
+                                        const IMTConManager* /*manager*/,
+                                        LPCVOID              /*indata*/,
+                                        const UINT           /*indata_len*/,
+                                        LPVOID&              /*outdata*/,
+                                        UINT&                /*outdata_len*/) { return(MT_RET_OK_NONE); }
+   //--- manager API command
+   virtual MTAPIRES  HookManagerCommand(const UINT64         /*session*/,
+                                        LPCWSTR              /*ip*/,
+                                        const IMTConManager* /*manager*/,
+                                        IMTByteStream*       /*indata*/,
+                                        IMTByteStream*       /*outdata*/)     { return(MT_RET_OK_NONE); }
+   //--- Web API command
+   virtual MTAPIRES  HookWebAPICommand(const UINT64          /*session*/,
+                                       LPCWSTR               /*ip*/,
+                                       const IMTConManager*  /*manager*/,
+                                       LPCWSTR               /*command*/,
+                                       IMTByteStream*        /*indata*/,
+                                       IMTByteStream*        /*outdata*/)     { return(MT_RET_OK_NONE); }
+  };
+//+------------------------------------------------------------------+
+//| Trades notification interface                                    |
+//+------------------------------------------------------------------+
+class IMTTradeSink
+  {
+public:
+   //--- trade request event
+   virtual void      OnTradeRequestAdd(const IMTRequest*   /*request*/,
+                                       const IMTConGroup*  /*group*/,
+                                       const IMTConSymbol* /*symbol*/,
+                                       const IMTPosition*  /*position*/,
+                                       const IMTOrder*     /*order*/)    {  }
+   //--- trade request process event
+   virtual void      OnTradeRequestUpdate(const IMTRequest* /*request*/) {  }
+   //--- trade request process event
+   virtual void      OnTradeRequestDelete(const IMTRequest* /*request*/) {  }
+   //--- trade request process event
+   virtual void      OnTradeRequestProcess(const IMTRequest*   /*request*/,
+                                           const IMTConfirm*   /*confirm*/,
+                                           const IMTConGroup*  /*group*/,
+                                           const IMTConSymbol* /*symbol*/,
+                                           const IMTPosition*  /*position*/,
+                                           const IMTOrder*     /*order*/,
+                                           const IMTDeal*      /*deal*/) {   }
+   //--- trade request add hook
+   virtual MTAPIRES  HookTradeRequestAdd(IMTRequest*         /*request*/,
+                                         const IMTConGroup*  /*group*/,
+                                         const IMTConSymbol* /*symbol*/,
+                                         const IMTPosition*  /*position*/,
+                                         const IMTOrder*     /*order*/,
+                                         IMTOrder*           /*order_new*/) { return(MT_RET_OK); }
+   //--- trade request route hook
+   virtual MTAPIRES  HookTradeRequestRoute(IMTRequest*         /*request*/,
+                                           IMTConfirm*         /*confirm*/,
+                                           const IMTConGroup*  /*group*/,
+                                           const IMTConSymbol* /*symbol*/,
+                                           const IMTPosition*  /*position*/,
+                                           const IMTOrder*     /*order*/)   { return(MT_RET_OK); }
+   //--- trade request deal hook
+   virtual MTAPIRES  HookTradeRequestProcess(const IMTRequest*   /*request*/,
+                                             const IMTConfirm*   /*confirm*/,
+                                             const IMTConGroup*  /*group*/,
+                                             const IMTConSymbol* /*symbol*/,
+                                             IMTPosition*        /*position*/,
+                                             IMTOrder*           /*order*/,
+                                             IMTDeal*            /*deal*/)  { return(MT_RET_OK); }
+   //--- rollover calculation hook
+   virtual MTAPIRES HookTradeRollover(const INT64         /*datetime*/,
+                                      const IMTConGroup*  /*group*/,
+                                      const IMTConSymbol* /*symbol*/,
+                                      const IMTPosition*  /*position*/,
+                                      const double        /*original_value*/,
+                                      double&             /*new_value*/)    { return(MT_RET_OK); }
+   //--- interest calculation hook
+   virtual MTAPIRES HookTradeInterest(const INT64         /*datetime*/,
+                                      const IMTConGroup*  /*group*/,
+                                      const IMTAccount*   /*account*/,
+                                      const double        /*original_value*/,
+                                      double&             /*new_value*/)    { return(MT_RET_OK); }
+   //--- interest charge hook
+   virtual MTAPIRES HookTradeInterestCharge(const INT64         /*datetime*/,
+                                            const IMTConGroup*  /*group*/,
+                                            const IMTUser*      /*user*/,
+                                            const double        /*original_value*/,
+                                            double&             /*new_value*/)    { return(MT_RET_OK); }
+   //--- order commission calculation
+   virtual MTAPIRES HookTradeCommissionOrder(const IMTConCommission*  /*commission*/,
+                                             const IMTConGroup*       /*group*/,
+                                             const IMTConSymbol*      /*symbol*/,
+                                             const IMTOrder*          /*order*/,
+                                             const double             /*original_value*/,
+                                             double&                  /*new_value*/)  { return(MT_RET_OK); }
+   //--- final commission calculation
+   virtual MTAPIRES HookTradeCommissionCharge(const INT64             /*period_start*/,
+                                              const INT64             /*period_end*/,
+                                              const IMTConCommission* /*commission*/,
+                                              const IMTConGroup*      /*group*/,
+                                              const IMTUser*          /*user*/,
+                                              const double            /*original_value*/,
+                                              double&                 /*new_value*/)  { return(MT_RET_OK); }
+   //--- order commission calculation
+   virtual MTAPIRES HookTradeCommissionDeal(const IMTConCommission*   /*commission*/,
+                                             const IMTConGroup*       /*group*/,
+                                             const IMTConSymbol*      /*symbol*/,
+                                             const IMTDeal*           /*deal*/,
+                                             const double             /*original_value*/,
+                                             double&                  /*new_value*/)  { return(MT_RET_OK); }
+   //--- trade execution event
+   virtual void      OnTradeExecution(const IMTConGateway* /*gateway*/,
+                                      const IMTExecution*  /*execution*/,
+                                      const IMTConGroup*   /*group*/,
+                                      const IMTConSymbol*  /*symbol*/,
+                                      const IMTPosition*   /*position*/,
+                                      const IMTOrder*      /*order*/,
+                                      const IMTDeal*       /*deal*/) {   }
+   //--- trade execution hook
+   virtual MTAPIRES  HookTradeExecution(const IMTConGateway* /*gateway*/,
+                                        const IMTExecution*  /*execution*/,
+                                        const IMTConGroup*   /*group*/,
+                                        const IMTConSymbol*  /*symbol*/,
+                                        IMTPosition*         /*position*/,
+                                        IMTOrder*            /*order*/,
+                                        IMTDeal*             /*deal*/)  { return(MT_RET_OK); }
+   //--- trade request refused on pre-trade control event
+   virtual void      OnTradeRequestRefuse(const IMTRequest* /*request*/) {  }
+   //--- trade request process event
+   virtual void      OnTradeRequestProcessCloseBy(const IMTRequest*   /*request*/,
+                                           const IMTConfirm*   /*confirm*/,
+                                           const IMTConGroup*  /*group*/,
+                                           const IMTConSymbol* /*symbol*/,
+                                           const IMTPosition*  /*position*/,
+                                           const IMTOrder*     /*order*/,
+                                           const IMTDeal*      /*deal*/,
+                                           const IMTDeal*      /*deal_by*/) {   }
+   //--- trade request deal hook
+   virtual MTAPIRES  HookTradeRequestProcessCloseBy(const IMTRequest*   /*request*/,
+                                                    const IMTConfirm*   /*confirm*/,
+                                                    const IMTConGroup*  /*group*/,
+                                                    const IMTConSymbol* /*symbol*/,
+                                                    IMTPosition*        /*position*/,
+                                                    IMTOrder*           /*order*/,
+                                                    IMTDeal*            /*deal*/,
+                                                    IMTDeal*            /*deal_by*/) { return(MT_RET_OK); }
+   //--- interest charge hook
+   virtual MTAPIRES HookTradeInterestChargeDeal(const INT64         /*datetime*/,
+                                                const IMTConGroup*  /*group*/,
+                                                const IMTUser*      /*user*/,
+                                                IMTDeal*            /*deal*/)    { return(MT_RET_OK); }
+   //--- trade request route hook
+   virtual MTAPIRES  HookTradeRequestRuleFilter(IMTRequest*         /*request*/,
+                                                IMTConRoute*        /*rule*/,
+                                                const IMTConGroup*  /*group*/)   { return(MT_RET_OK_NONE); }
+   //--- trade request route hook
+   virtual MTAPIRES  HookTradeRequestRuleApply(IMTRequest*         /*request*/,
+                                               IMTConRoute*        /*rule*/,
+                                               const IMTConGroup*  /*group*/)    { return(MT_RET_OK_NONE); }
+
+   //--- trade execution event for close by
+   virtual void      OnTradeExecutionCloseBy(const IMTExecution* /*execution*/,
+                                             const IMTConGroup*  /*group*/,
+                                             const IMTConSymbol* /*symbol*/,
+                                             const IMTPosition*  /*position*/,
+                                             const IMTOrder*     /*order*/,
+                                             const IMTDeal*      /*deal*/,
+                                             const IMTDeal*      /*deal_by*/) {   }
+   //--- trade execution hook for close by
+   virtual MTAPIRES  HookTradeExecutionCloseBy(const IMTExecution* /*execution*/,
+                                               const IMTConGroup*  /*group*/,
+                                               const IMTConSymbol* /*symbol*/,
+                                               IMTPosition*        /*position*/,
+                                               IMTOrder*           /*order*/,
+                                               IMTDeal*            /*deal*/,
+                                               IMTDeal*            /*deal_by*/)      { return(MT_RET_OK); }
+  };
+//+------------------------------------------------------------------+
+//| End of day notification interface                                |
+//+------------------------------------------------------------------+
+class IMTEndOfDaySink
+  {
+public:
+   //--- end of day events
+   virtual void      OnEODStart(const INT64 /*datetime*/,const INT64 /*prev_datetime*/)                                        { }
+   virtual void      OnEODGroupStart(const INT64 /*datetime*/,const INT64 /*prev_datetime*/,const IMTConGroup* /*group*/)      { }
+   virtual void      OnEODGroupCommissions(const INT64 /*datetime*/,const INT64 /*prev_datetime*/,const IMTConGroup* /*group*/){ }
+   virtual void      OnEODGroupInterest(const INT64 /*datetime*/,const INT64 /*prev_datetime*/,const IMTConGroup* /*group*/)   { }
+   virtual void      OnEODGroupStatements(const INT64 /*datetime*/,const INT64 /*prev_datetime*/,const IMTConGroup* /*group*/) { }
+   virtual void      OnEODGroupRollovers(const INT64 /*datetime*/,const INT64 /*prev_datetime*/,const IMTConGroup* /*group*/)  { }
+   virtual void      OnEODGroupFinish(const INT64 /*datetime*/,const INT64 /*prev_datetime*/,const IMTConGroup* /*group*/)     { }
+   virtual void      OnEODFinish(const INT64 /*datetime*/,const INT64 /*prev_datetime*/)                                       { }
+   //--- end of month events
+   virtual void      OnEOMStart(const INT64 /*datetime*/,const INT64 /*prev_datetime*/)                                        { }
+   virtual void      OnEOMGroupStart(const INT64 /*datetime*/,const INT64 /*prev_datetime*/,const IMTConGroup* /*group*/)      { }
+   virtual void      OnEOMGroupCommissions(const INT64 /*datetime*/,const INT64 /*prev_datetime*/,const IMTConGroup* /*group*/){ }
+   virtual void      OnEOMGroupInterest(const INT64 /*datetime*/,const INT64 /*prev_datetime*/,const IMTConGroup* /*group*/)   { }
+   virtual void      OnEOMGroupStatements(const INT64 /*datetime*/,const INT64 /*prev_datetime*/,const IMTConGroup* /*group*/) { }
+   virtual void      OnEOMGroupFinish(const INT64 /*datetime*/,const INT64 /*prev_datetime*/,const IMTConGroup* /*group*/)     { }
+   virtual void      OnEOMFinish(const INT64 /*datetime*/,const INT64 /*prev_datetime*/)                                       { }
+  };
+//+------------------------------------------------------------------+
+//| Server events notification interface                             |
+//+------------------------------------------------------------------+
+class IMTServerSink
+  {
+public:
+   virtual void      OnServerLog(const INT /*code*/,const UINT /*type*/,const INT64 /*datetime_msc*/,LPCWSTR /*source*/,LPCWSTR /*message*/){}
+  };
+//+------------------------------------------------------------------+
+//| Server API interface                                             |
+//+------------------------------------------------------------------+
+class IMTServerAPI
+  {
+public:
+   //--- server description
+   virtual MTAPIRES  About(MTServerInfo& info)=0;
+   //--- license check
+   virtual MTAPIRES  LicenseCheck(LPCWSTR license_name)=0;
+   //--- memory management
+   virtual void*     Allocate(const UINT bytes)=0;
+   virtual void      Free(void* ptr)=0;
+   //--- server management functions
+   virtual MTAPIRES  ServerRestart(void)=0;
+   virtual MTAPIRES  ServerSubscribe(IMTServerSink* sink)=0;
+   virtual MTAPIRES  ServerUnsubscribe(IMTServerSink* sink)=0;
+   virtual MTAPIRES  ServerReserved3(void)=0;
+   virtual MTAPIRES  ServerReserved4(void)=0;
+   //--- server log functions
+   virtual MTAPIRES  LoggerOut(const UINT code,LPCWSTR msg,...)=0;
+   virtual MTAPIRES  LoggerRequest(const UINT mode,const UINT type,const INT64 from,const INT64 to,LPCWSTR filter,MTLogRecord*& records,UINT& records_total)=0;
+   virtual void      LoggerFlush(void)=0;
+   virtual MTAPIRES  LoggerReserved1(void)=0;
+   virtual MTAPIRES  LoggerReserved2(void)=0;
+   virtual MTAPIRES  LoggerReserved3(void)=0;
+   virtual MTAPIRES  LoggerReserved4(void)=0;
+   //--- plugins configs
+   virtual IMTConPlugin* PluginCreate(void)=0;
+   virtual IMTConPluginModule* PluginModuleCreate(void)=0;
+   virtual IMTConParam* PluginParamCreate(void)=0;
+   virtual MTAPIRES  PluginSubscribe(IMTConPluginSink* sink)=0;
+   virtual MTAPIRES  PluginUnsubscribe(IMTConPluginSink* sink)=0;
+   virtual MTAPIRES  PluginCurrent(IMTConPlugin* plugin)=0;
+   virtual MTAPIRES  PluginAdd(IMTConPlugin* plugin)=0;
+   virtual MTAPIRES  PluginDelete(LPCWSTR name)=0;
+   virtual MTAPIRES  PluginDelete(const UINT pos)=0;
+   virtual MTAPIRES  PluginShift(const UINT pos,const int shift)=0;
+   virtual UINT      PluginTotal(void)=0;
+   virtual MTAPIRES  PluginNext(const UINT pos,IMTConPlugin* plugin)=0;
+   virtual MTAPIRES  PluginGet(LPCWSTR name,IMTConPlugin* plugin)=0;
+   virtual UINT      PluginModuleTotal(void)=0;
+   virtual MTAPIRES  PluginModuleNext(const UINT pos,IMTConPluginModule* module)=0;
+   virtual MTAPIRES  PluginModuleGet(LPCWSTR name,IMTConPluginModule* module)=0;
+   virtual MTAPIRES  PluginDelete(const UINT64 server,LPCWSTR name)=0;
+   virtual MTAPIRES  PluginGet(const UINT64 server,LPCWSTR name,IMTConPlugin* plugin)=0;
+   virtual MTAPIRES  PluginModuleGet(const UINT64 server,LPCWSTR name,IMTConPluginModule* module)=0;
+   virtual MTAPIRES  PluginReserved4(void)=0;
+   //--- common config 
+   virtual IMTConCommon* CommonCreate(void)=0;
+   virtual MTAPIRES  CommonSubscribe(IMTConCommonSink* sink)=0;
+   virtual MTAPIRES  CommonUnsubscribe(IMTConCommonSink* sink)=0;
+   virtual MTAPIRES  CommonGet(IMTConCommon* common)=0;
+   virtual MTAPIRES  CommonSet(const IMTConCommon* common)=0;
+   virtual MTAPIRES  CommonReserved1(void)=0;
+   virtual MTAPIRES  CommonReserved2(void)=0;
+   virtual MTAPIRES  CommonReserved3(void)=0;
+   virtual MTAPIRES  CommonReserved4(void)=0;
+   //--- platform server config
+   virtual IMTConServer* NetServerCreate(void)=0;
+   virtual IMTConServerRange* NetServerRangeCreate(void)=0;
+   virtual MTAPIRES  NetServerSubscribe(IMTConServerSink* sink)=0;
+   virtual MTAPIRES  NetServerUnsubscribe(IMTConServerSink* sink)=0;
+   virtual MTAPIRES  NetServerAdd(IMTConServer* config)=0;
+   virtual MTAPIRES  NetServerDelete(const UINT pos)=0;
+   virtual MTAPIRES  NetServerShift(const UINT pos,const int shift)=0;
+   virtual UINT      NetServerTotal(void)=0;
+   virtual MTAPIRES  NetServerNext(const UINT pos,IMTConServer* config)=0;
+   virtual MTAPIRES  NetServerGet(const UINT64 id,IMTConServer* config)=0;
+   virtual IMTConAddressRange* NetServerAddressRangeCreate(void)=0;
+   virtual IMTConClusterState* NetServerClusterStateCreate(void)=0;
+   virtual MTAPIRES  NetServerReserved3(void)=0;
+   virtual MTAPIRES  NetServerReserved4(void)=0;
+   //--- time config
+   virtual IMTConTime* TimeCreate(void)=0;
+   virtual MTAPIRES  TimeSubscribe(IMTConTimeSink* sink)=0;
+   virtual MTAPIRES  TimeUnsubscribe(IMTConTimeSink* sink)=0;
+   virtual INT64     TimeCurrent(void)=0;
+   virtual MTAPIRES  TimeGet(IMTConTime* common)=0;
+   virtual MTAPIRES  TimeSet(const IMTConTime* time)=0;
+   virtual INT64     TimeCurrentMsc(void)=0;
+   virtual MTAPIRES  TimeReserved2(void)=0;
+   virtual MTAPIRES  TimeReserved3(void)=0;
+   virtual MTAPIRES  TimeReserved4(void)=0;
+   //--- holidays configuration
+   virtual IMTConHoliday* HolidayCreate()=0;
+   virtual MTAPIRES  HolidaySubscribe(IMTConHolidaySink* sink)=0;
+   virtual MTAPIRES  HolidayUnsubscribe(IMTConHolidaySink* sink)=0;
+   virtual MTAPIRES  HolidayAdd(IMTConHoliday* config)=0;
+   virtual MTAPIRES  HolidayDelete(const UINT pos)=0;
+   virtual MTAPIRES  HolidayShift(const UINT pos,const int shift)=0;
+   virtual UINT      HolidayTotal(void)=0;
+   virtual MTAPIRES  HolidayNext(const UINT pos,IMTConHoliday* config)=0;
+   virtual MTAPIRES  HolidayReserved1(void)=0;
+   virtual MTAPIRES  HolidayReserved2(void)=0;
+   virtual MTAPIRES  HolidayReserved3(void)=0;
+   virtual MTAPIRES  HolidayReserved4(void)=0;
+   //--- server firewall configuration
+   virtual IMTConFirewall* FirewallCreate()=0;
+   virtual MTAPIRES  FirewallSubscribe(IMTConFirewallSink* sink)=0;
+   virtual MTAPIRES  FirewallUnsubscribe(IMTConFirewallSink* sink)=0;
+   virtual MTAPIRES  FirewallAdd(IMTConFirewall* config)=0;
+   virtual MTAPIRES  FirewallDelete(const UINT pos)=0;
+   virtual MTAPIRES  FirewallShift(const UINT pos,const int shift)=0;
+   virtual UINT      FirewallTotal(void)=0;
+   virtual MTAPIRES  FirewallNext(const UINT pos,IMTConFirewall* config)=0;
+   virtual MTAPIRES  FirewallReserved1(void)=0;
+   virtual MTAPIRES  FirewallReserved2(void)=0;
+   virtual MTAPIRES  FirewallReserved3(void)=0;
+   virtual MTAPIRES  FirewallReserved4(void)=0;
+   //--- symbols configuration
+   virtual IMTConSymbol* SymbolCreate(void)=0;
+   virtual IMTConSymbolSession* SymbolSessionCreate(void)=0;
+   virtual MTAPIRES  SymbolSubscribe(IMTConSymbolSink* sink)=0;
+   virtual MTAPIRES  SymbolUnsubscribe(IMTConSymbolSink* sink)=0;
+   virtual MTAPIRES  SymbolAdd(IMTConSymbol* symbol)=0;
+   virtual MTAPIRES  SymbolDelete(LPCWSTR name)=0;
+   virtual MTAPIRES  SymbolDelete(const UINT pos)=0;
+   virtual MTAPIRES  SymbolShift(const UINT pos,const int shift)=0;
+   virtual UINT      SymbolTotal(void)=0;
+   virtual MTAPIRES  SymbolNext(const UINT pos,IMTConSymbol* symbol)=0;
+   virtual MTAPIRES  SymbolGet(LPCWSTR name,IMTConSymbol* symbol)=0;
+   virtual MTAPIRES  SymbolGet(LPCWSTR name,const IMTConGroup* group,IMTConSymbol* symbol)=0;
+   virtual MTAPIRES  SymbolExist(const IMTConSymbol* symbol,const IMTConGroup* group)=0;
+   virtual MTAPIRES  SymbolReserved1(void)=0;
+   virtual MTAPIRES  SymbolReserved2(void)=0;
+   virtual MTAPIRES  SymbolReserved3(void)=0;
+   virtual MTAPIRES  SymbolReserved4(void)=0;
+   //--- clients group configuration
+   virtual IMTConGroup* GroupCreate(void)=0;
+   virtual IMTConGroupSymbol* GroupSymbolCreate(void)=0;
+   virtual IMTConCommission* GroupCommissionCreate(void)=0;
+   virtual IMTConCommTier* GroupTierCreate(void)=0;
+   virtual MTAPIRES  GroupSubscribe(IMTConGroupSink* sink)=0;
+   virtual MTAPIRES  GroupUnsubscribe(IMTConGroupSink* sink)=0;
+   virtual MTAPIRES  GroupAdd(IMTConGroup* group)=0;
+   virtual MTAPIRES  GroupDelete(LPCWSTR name)=0;
+   virtual MTAPIRES  GroupDelete(const UINT pos)=0;
+   virtual MTAPIRES  GroupShift(const UINT pos,const int shift)=0;
+   virtual UINT      GroupTotal(void)=0;
+   virtual MTAPIRES  GroupNext(const UINT pos,IMTConGroup* group)=0;
+   virtual MTAPIRES  GroupGet(LPCWSTR name,IMTConGroup* group)=0;
+   virtual MTAPIRES  GroupReserved1(void)=0;
+   virtual MTAPIRES  GroupReserved2(void)=0;
+   virtual MTAPIRES  GroupReserved3(void)=0;
+   virtual MTAPIRES  GroupReserved4(void)=0;
+   //--- managers configuration
+   virtual IMTConManager* ManagerCreate(void)=0;
+   virtual IMTConManagerAccess* ManagerAccessCreate(void)=0;
+   virtual MTAPIRES  ManagerSubscribe(IMTConManagerSink* sink)=0;
+   virtual MTAPIRES  ManagerUnsubscribe(IMTConManagerSink* sink)=0;
+   virtual MTAPIRES  ManagerAdd(IMTConManager* manager)=0;
+   virtual MTAPIRES  ManagerDelete(const UINT pos)=0;
+   virtual MTAPIRES  ManagerShift(const UINT pos,const int shift)=0;
+   virtual UINT      ManagerTotal(void)=0;
+   virtual MTAPIRES  ManagerNext(const UINT pos,IMTConManager* manager)=0;
+   virtual MTAPIRES  ManagerGet(const UINT64 login,IMTConManager* manager)=0;
+   virtual MTAPIRES  ManagerReserved1(void)=0;
+   virtual MTAPIRES  ManagerReserved2(void)=0;
+   virtual MTAPIRES  ManagerReserved3(void)=0;
+   virtual MTAPIRES  ManagerReserved4(void)=0;
+   //--- history synchronization configuration
+   virtual IMTConHistorySync* HistorySyncCreate(void)=0;
+   virtual MTAPIRES  HistorySyncSubscribe(IMTConHistorySyncSink* sink)=0;
+   virtual MTAPIRES  HistorySyncUnsubscribe(IMTConHistorySyncSink* sink)=0;
+   virtual MTAPIRES  HistorySyncAdd(IMTConHistorySync* config)=0;
+   virtual MTAPIRES  HistorySyncDelete(const UINT pos)=0;
+   virtual MTAPIRES  HistorySyncShift(const UINT pos,const int shift)=0;
+   virtual UINT      HistorySyncTotal(void)=0;
+   virtual MTAPIRES  HistorySyncNext(const UINT pos,IMTConHistorySync* config)=0;
+   virtual MTAPIRES  HistorySyncReserved1(void)=0;
+   virtual MTAPIRES  HistorySyncReserved2(void)=0;
+   virtual MTAPIRES  HistorySyncReserved3(void)=0;
+   virtual MTAPIRES  HistorySyncReserved4(void)=0;
+   //--- datafeeds configuration
+   virtual IMTConFeeder* FeederCreate(void)=0;
+   virtual IMTConFeederModule* FeederModuleCreate(void)=0;
+   virtual IMTConParam* FeederParamCreate(void)=0;
+   virtual IMTConFeederTranslate* FeederTranslateCreate(void)=0;
+   virtual MTAPIRES  FeederSubscribe(IMTConFeederSink* sink)=0;
+   virtual MTAPIRES  FeederUnsubscribe(IMTConFeederSink* sink)=0;
+   virtual MTAPIRES  FeederAdd(IMTConFeeder* feeder)=0;
+   virtual MTAPIRES  FeederDelete(LPCWSTR name)=0;
+   virtual MTAPIRES  FeederDelete(const UINT pos)=0;
+   virtual MTAPIRES  FeederShift(const UINT pos,const int shift)=0;
+   virtual UINT      FeederTotal(void)=0;
+   virtual MTAPIRES  FeederNext(const UINT pos,IMTConFeeder* feeder)=0;
+   virtual MTAPIRES  FeederGet(LPCWSTR name,IMTConFeeder* feeder)=0;
+   virtual UINT      FeederModuleTotal(void)=0;
+   virtual MTAPIRES  FeederModuleNext(const UINT pos,IMTConFeederModule* module)=0;
+   virtual MTAPIRES  FeederModuleGet(LPCWSTR name,IMTConFeederModule* module)=0;
+   virtual MTAPIRES  FeederReserved1(void)=0;
+   virtual MTAPIRES  FeederReserved2(void)=0;
+   virtual MTAPIRES  FeederReserved3(void)=0;
+   virtual MTAPIRES  FeederReserved4(void)=0;
+   //--- gateways configuration
+   virtual IMTConGateway* GatewayCreate(void)=0;
+   virtual IMTConGatewayModule* GatewayModuleCreate(void)=0;
+   virtual IMTConParam* GatewayParamCreate(void)=0;
+   virtual IMTConGatewayTranslate* GatewayTranslateCreate(void)=0;
+   virtual MTAPIRES  GatewaySubscribe(IMTConGatewaySink* sink)=0;
+   virtual MTAPIRES  GatewayUnsubscribe(IMTConGatewaySink* sink)=0;
+   virtual MTAPIRES  GatewayAdd(IMTConGateway* gateway)=0;
+   virtual MTAPIRES  GatewayDelete(LPCWSTR name)=0;
+   virtual MTAPIRES  GatewayDelete(const UINT pos)=0;
+   virtual MTAPIRES  GatewayShift(const UINT pos,const int shift)=0;
+   virtual UINT      GatewayTotal(void)=0;
+   virtual MTAPIRES  GatewayNext(const UINT pos,IMTConGateway* gateway)=0;
+   virtual MTAPIRES  GatewayGet(LPCWSTR name,IMTConGateway* gateway)=0;
+   virtual UINT      GatewayModuleTotal(void)=0;
+   virtual MTAPIRES  GatewayModuleNext(const UINT pos,IMTConGatewayModule* module)=0;
+   virtual MTAPIRES  GatewayModuleGet(LPCWSTR name,IMTConGatewayModule* module)=0;
+   virtual MTAPIRES  GatewayReserved1(void)=0;
+   virtual MTAPIRES  GatewayReserved2(void)=0;
+   virtual MTAPIRES  GatewayReserved3(void)=0;
+   virtual MTAPIRES  GatewayReserved4(void)=0;
+   //--- report configuration
+   virtual IMTConReport* ReportCreate(void)=0;
+   virtual IMTConReportModule* ReportModuleCreate(void)=0;
+   virtual IMTConParam* ReportParamCreate(void)=0;
+   virtual MTAPIRES  ReportSubscribe(IMTConReportSink* sink)=0;
+   virtual MTAPIRES  ReportUnsubscribe(IMTConReportSink* sink)=0;
+   virtual MTAPIRES  ReportAdd(IMTConReport* report)=0;
+   virtual MTAPIRES  ReportDelete(LPCWSTR name)=0;
+   virtual MTAPIRES  ReportDelete(const UINT pos)=0;
+   virtual MTAPIRES  ReportShift(const UINT pos,const int shift)=0;
+   virtual UINT      ReportTotal(void)=0;
+   virtual MTAPIRES  ReportNext(const UINT pos,IMTConReport* report)=0;
+   virtual MTAPIRES  ReportGet(LPCWSTR name,IMTConReport* report)=0;
+   virtual UINT      ReportModuleTotal(void)=0;
+   virtual MTAPIRES  ReportModuleNext(const UINT pos,IMTConReportModule* module)=0;
+   virtual MTAPIRES  ReportModuleGet(LPCWSTR name,IMTConReportModule* module)=0;
+   virtual MTAPIRES  ReportDelete(const UINT64 server,LPCWSTR name)=0;
+   virtual MTAPIRES  ReportGet(const UINT64 server,LPCWSTR name,IMTConReport* report)=0;
+   virtual MTAPIRES  ReportModuleGet(const UINT64 server,LPCWSTR name,IMTConReportModule* module)=0;
+   virtual MTAPIRES  ReportReserved4(void)=0;
+   //--- routing configuration
+   virtual IMTConRoute* RouteCreate(void)=0;
+   virtual IMTConCondition* RouteConditionCreate(void)=0;
+   virtual IMTConRouteDealer* RouteDealerCreate(void)=0;
+   virtual MTAPIRES  RouteSubscribe(IMTConRouteSink* sink)=0;
+   virtual MTAPIRES  RouteUnsubscribe(IMTConRouteSink* sink)=0;
+   virtual MTAPIRES  RouteAdd(IMTConRoute* route)=0;
+   virtual MTAPIRES  RouteDelete(LPCWSTR name)=0;
+   virtual MTAPIRES  RouteDelete(const UINT pos)=0;
+   virtual MTAPIRES  RouteShift(const UINT pos,const int shift)=0;
+   virtual UINT      RouteTotal(void)=0;
+   virtual MTAPIRES  RouteNext(const UINT pos,IMTConRoute* route)=0;
+   virtual MTAPIRES  RouteGet(LPCWSTR name,IMTConRoute* route)=0;
+   virtual MTAPIRES  RouteReserved1(void)=0;
+   virtual MTAPIRES  RouteReserved2(void)=0;
+   virtual MTAPIRES  RouteReserved3(void)=0;
+   virtual MTAPIRES  RouteReserved4(void)=0;
+   //--- clients database
+   virtual IMTUser*  UserCreate(void)=0;
+   virtual IMTAccount* UserCreateAccount(void)=0;
+   virtual MTAPIRES  UserSubscribe(IMTUserSink* sink)=0;
+   virtual MTAPIRES  UserUnsubscribe(IMTUserSink* sink)=0;
+   virtual MTAPIRES  UserAdd(IMTUser* user,LPCWSTR master_pass,LPCWSTR investor_pass)=0;
+   virtual MTAPIRES  UserDelete(const UINT64 login)=0;
+   virtual MTAPIRES  UserUpdate(IMTUser* user)=0;
+   virtual UINT      UserTotal(void)=0;
+   virtual MTAPIRES  UserGet(const UINT64 login,IMTUser* user)=0;
+   virtual MTAPIRES  UserGroup(const UINT64 login,MTAPISTR& group)=0;
+   virtual MTAPIRES  UserLogins(LPCWSTR group,UINT64*& logins,UINT& logins_total)=0;
+   virtual MTAPIRES  UserPasswordCheck(const UINT type,const UINT64 login,LPCWSTR password)=0;
+   virtual MTAPIRES  UserPasswordChange(const UINT type,const UINT64 login,LPCWSTR password)=0;
+   virtual MTAPIRES  UserCertDelete(const UINT64 login)=0;
+   virtual MTAPIRES  UserCertConfirm(const UINT64 login)=0;
+   virtual MTAPIRES  UserDepositChangeRaw(const UINT64 login,const double value,const UINT type,LPCWSTR comment,UINT64& deal_id)=0;
+   virtual MTAPIRES  UserDepositChange(const UINT64 login,const double value,const UINT action,LPCWSTR comment,UINT64& deal_id)=0;
+   virtual MTAPIRES  UserAccountGet(const UINT64 login,IMTAccount* account)=0;
+   virtual MTAPIRES  UserArchive(const UINT64 login)=0;
+   virtual MTAPIRES  UserArchiveGet(const UINT64 login,IMTUser* user)=0;
+   virtual MTAPIRES  UserRestore(IMTUser* user)=0;
+   virtual MTAPIRES  UserArchiveLogins(LPCWSTR group,UINT64*& logins,UINT& logins_total)=0;
+   //--- deals database
+   virtual IMTDeal*  DealCreate(void)=0;
+   virtual IMTDealArray* DealCreateArray(void)=0;
+   virtual MTAPIRES  DealSubscribe(IMTDealSink* sink)=0;
+   virtual MTAPIRES  DealUnsubscribe(IMTDealSink* sink)=0;
+   virtual MTAPIRES  DealDelete(const UINT64 ticket)=0;
+   virtual MTAPIRES  DealUpdate(IMTDeal* deal)=0;
+   virtual MTAPIRES  DealGet(const UINT64 ticket,IMTDeal* deal)=0;
+   virtual MTAPIRES  DealGet(const INT64 from,const INT64 to,const UINT64 login,IMTDealArray* deals)=0;
+   virtual MTAPIRES  DealAdd(IMTDeal* deal)=0;
+   virtual MTAPIRES  DealPerform(IMTDeal* deal)=0;
+   virtual MTAPIRES  DealPerformCloseBy(IMTDeal* deal,IMTDeal* dealby)=0;
+   virtual MTAPIRES  DealDeleteBatch(const UINT64* tickets,const UINT tickets_total,MTAPIRES* results)=0;
+   //--- trade positions database
+   virtual IMTPosition* PositionCreate(void)=0;
+   virtual IMTPositionArray* PositionCreateArray(void)=0;
+   virtual MTAPIRES  PositionSubscribe(IMTPositionSink* sink)=0;
+   virtual MTAPIRES  PositionUnsubscribe(IMTPositionSink* sink)=0;
+   virtual MTAPIRES  PositionDelete(const UINT64 login,LPCWSTR symbol)=0;
+   virtual MTAPIRES  PositionUpdate(IMTPosition* position)=0;
+   virtual MTAPIRES  PositionGet(const UINT64 login,LPCWSTR symbol,IMTPosition* position)=0;
+   virtual MTAPIRES  PositionGet(const UINT64 login,IMTPositionArray* position)=0;
+   virtual MTAPIRES  PositionDeleteByTicket(const UINT64 ticket)=0;
+   virtual MTAPIRES  PositionGetByTicket(const UINT64 ticket,IMTPosition* position)=0;
+   virtual MTAPIRES  PositionCheck(const UINT64 login,IMTPositionArray* current,IMTPositionArray* invalid,IMTPositionArray* missed,IMTPositionArray* nonexist)=0;
+   virtual MTAPIRES  PositionFix(const UINT64 login,IMTPositionArray* current)=0;
+   //--- open orders database
+   virtual IMTOrder* OrderCreate(void)=0;
+   virtual IMTOrderArray* OrderCreateArray(void)=0;
+   virtual MTAPIRES  OrderSubscribe(IMTOrderSink* sink)=0;
+   virtual MTAPIRES  OrderUnsubscribe(IMTOrderSink* sink)=0;
+   virtual MTAPIRES  OrderDelete(const UINT64 ticket)=0;
+   virtual MTAPIRES  OrderUpdate(IMTOrder* order)=0;
+   virtual MTAPIRES  OrderGet(const UINT64 ticket,IMTOrder* order)=0;
+   virtual MTAPIRES  OrderGet(const UINT64 login,IMTOrderArray* orders)=0;
+   virtual MTAPIRES  OrderAdd(IMTOrder* order)=0;
+   virtual MTAPIRES  OrderDeleteBatch(const UINT64* tickets,const UINT tickets_total,MTAPIRES* results)=0;
+   virtual MTAPIRES  OrderUpdateBatch(IMTOrderArray* orders,MTAPIRES* results)=0;
+   virtual MTAPIRES  OrderUpdateBatchArray(IMTOrder** orders,const UINT orders_total,MTAPIRES* results)=0;
+   //--- orders history database
+   virtual MTAPIRES  HistorySubscribe(IMTHistorySink* sink)=0;
+   virtual MTAPIRES  HistoryUnsubscribe(IMTHistorySink* sink)=0;
+   virtual MTAPIRES  HistoryDelete(const UINT64 ticket)=0;
+   virtual MTAPIRES  HistoryUpdate(IMTOrder* order)=0;
+   virtual MTAPIRES  HistoryGet(const UINT64 ticket,IMTOrder* order)=0;
+   virtual MTAPIRES  HistoryGet(const INT64 from,const INT64 to,const UINT64 login,IMTOrderArray* orders)=0;
+   virtual MTAPIRES  HistoryReopen(const UINT64 ticket)=0;
+   virtual MTAPIRES  HistoryAdd(IMTOrder* order)=0;
+   virtual MTAPIRES  HistoryDeleteBatch(const UINT64* tickets,const UINT tickets_total,MTAPIRES* results)=0;
+   virtual MTAPIRES  HistoryUpdateBatch(IMTOrderArray* orders,MTAPIRES* results)=0;
+   //--- daily reports database
+   virtual IMTDaily* DailyCreate(void)=0;
+   virtual IMTDailyArray* DailyCreateArray(void)=0;
+   virtual MTAPIRES  DailySubscribe(IMTDailySink* sink)=0;
+   virtual MTAPIRES  DailyUnsubscribe(IMTDailySink* sink)=0;
+   virtual MTAPIRES  DailyGet(const INT64 from,const INT64 to,const UINT64 login,IMTDailyArray* daily)=0;
+   virtual MTAPIRES  DailyGetLight(const INT64 from,const INT64 to,const UINT64 login,IMTDailyArray* daily)=0;
+   virtual MTAPIRES  DailySelectByGroup(LPCWSTR group,INT64 from,INT64 to,const IMTDatasetRequest *request,IMTDataset *dataset)=0;
+   virtual MTAPIRES  DailySelectByLogins(const UINT64 *logins,UINT logins_total,INT64 from,INT64 to,const IMTDatasetRequest *request,IMTDataset *dataset)=0;
+   virtual MTAPIRES  DailyReserved4(void)=0;
+   //--- ticks data
+   virtual MTAPIRES  TickSubscribe(IMTTickSink* sink)=0;
+   virtual MTAPIRES  TickUnsubscribe(IMTTickSink* sink)=0;
+   virtual MTAPIRES  TickAdd(MTTick& tick)=0;
+   virtual MTAPIRES  TickAddStat(MTTick& tick,MTTickStat& stat)=0;
+   virtual MTAPIRES  TickLast(LPCWSTR symbol,MTTickShort& tick)=0;
+   virtual MTAPIRES  TickLast(const IMTConSymbol* symbol,MTTickShort& tick)=0;
+   virtual MTAPIRES  TickStat(LPCWSTR symbol,MTTickStat& stat)=0;
+   virtual MTAPIRES  TickGet(LPCWSTR symbol,const INT64 from,const INT64 to,MTTickShort*& ticks,UINT& ticks_total)=0;
+   virtual MTAPIRES  TickGet(const IMTConSymbol* symbol,const INT64 from,const INT64 to,MTTickShort*& ticks,UINT& ticks_total)=0;
+   virtual MTAPIRES  TickHistoryGetRaw(LPCWSTR symbol,const INT64 from,const INT64 to,MTTickShort*& ticks,UINT& ticks_total)=0;
+   virtual MTAPIRES  TickHistoryGet(LPCWSTR symbol,const INT64 from,const INT64 to,MTTickShort*& ticks,UINT& ticks_total)=0;
+   virtual MTAPIRES  TickReserved2(void)=0;
+   virtual MTAPIRES  TickReserved3(void)=0;
+   virtual MTAPIRES  TickReserved4(void)=0;
+   //--- internal mail
+   virtual IMTMail*  MailCreate(void)=0;
+   virtual MTAPIRES  MailSubscribe(IMTMailSink* sink)=0;
+   virtual MTAPIRES  MailUnsubscribe(IMTMailSink* sink)=0;
+   virtual MTAPIRES  MailSend(IMTMail* mail)=0;
+   virtual MTAPIRES  MailReserved1(void)=0;
+   virtual MTAPIRES  MailReserved2(void)=0;
+   virtual MTAPIRES  MailReserved3(void)=0;
+   virtual MTAPIRES  MailReserved4(void)=0;
+   //--- internal news
+   virtual IMTNews*  NewsCreate(void)=0;
+   virtual MTAPIRES  NewsSubscribe(IMTNewsSink* sink)=0;
+   virtual MTAPIRES  NewsUnsubscribe(IMTNewsSink* sink)=0;
+   virtual MTAPIRES  NewsSend(IMTNews* news)=0;
+   virtual MTAPIRES  NewsReserved1(void)=0;
+   virtual MTAPIRES  NewsReserved2(void)=0;
+   virtual MTAPIRES  NewsReserved3(void)=0;
+   virtual MTAPIRES  NewsReserved4(void)=0;
+   //--- custom commands processing
+   virtual MTAPIRES  CustomSubscribe(IMTCustomSink* sink)=0;
+   virtual MTAPIRES  CustomUnsubscribe(IMTCustomSink* sink)=0;
+   virtual IMTByteStream* CustomCreateStream(void)=0;
+   virtual MTAPIRES  CustomReserved2(void)=0;
+   virtual MTAPIRES  CustomReserved3(void)=0;
+   virtual MTAPIRES  CustomReserved4(void)=0;
+   //--- trade methods
+   virtual IMTRequest* TradeRequestCreate(void)=0;
+   virtual MTAPIRES  TradeSubscribe(IMTTradeSink* sink)=0;
+   virtual MTAPIRES  TradeUnsubscribe(IMTTradeSink* sink)=0;
+   virtual MTAPIRES  TradeRequest(IMTRequest* request)=0;
+   virtual MTAPIRES  TradeProfit(LPCWSTR group,LPCWSTR symbol,const UINT type,const UINT64 volume,const double price_open,const double price_close,double& profit,double& profit_rate)=0;
+   virtual MTAPIRES  TradeRateBuy(LPCWSTR base,LPCWSTR currency,double& rate,LPCWSTR group=NULL,LPCWSTR symbol=NULL,const double price=0)=0;
+   virtual MTAPIRES  TradeRateSell(LPCWSTR base,LPCWSTR currency,double& rate,LPCWSTR group=NULL,LPCWSTR symbol=NULL,const double price=0)=0;
+   virtual MTAPIRES  TradeMarginCheck(const UINT64 login,LPCWSTR symbol,const UINT type,const UINT64 volume,const double price,IMTAccount* account_new=NULL,IMTAccount* account_current=NULL)=0;
+   virtual MTAPIRES  TradeMarginCheck(const IMTOrder* order,IMTAccount* account_new=NULL,IMTAccount* account_current=NULL)=0;
+   virtual MTAPIRES  TradeBalanceCheckObsolete(const UINT64 login,const UINT fixflag,double& balance_user,double& balance_history)=0;
+   virtual MTAPIRES  TradeSubscribeEOD(IMTEndOfDaySink* sink)=0;
+   virtual MTAPIRES  TradeUnsubscribeEOD(IMTEndOfDaySink* sink)=0;
+   virtual MTAPIRES  TradeBalanceCheck(const UINT64 login,const UINT fixflag,double& balance_user,double& balance_history,double& credit_user,double& credit_history)=0;
+   virtual MTAPIRES  TradeAccountSet(const IMTUser *user,const IMTAccount *account,const IMTOrderArray *orders,const IMTPositionArray *positions)=0;
+   virtual IMTConfirm* TradeConfirmCreate(void)=0;
+   virtual IMTExecution* TradeExecutionCreate(void)=0;
+   virtual IMTRequestArray* TradeRequestCreateArray(void)=0;
+   virtual MTAPIRES  TradeProfitExt(LPCWSTR group,LPCWSTR symbol,const UINT type,const UINT64 volume,const double price_open,const double price_close,double& profit,double& profit_rate)=0;
+   //--- books access
+   virtual MTAPIRES  BookSubscribe(IMTBookSink* sink)=0;
+   virtual MTAPIRES  BookUnsubscribe(IMTBookSink* sink)=0;
+   virtual MTAPIRES  BookGet(LPCWSTR symbol,MTBook& book)=0;
+   virtual MTAPIRES  BookReserved1(void)=0;
+   virtual MTAPIRES  BookReserved2(void)=0;
+   virtual MTAPIRES  BookReserved3(void)=0;
+   virtual MTAPIRES  BookReserved4(void)=0;
+   //--- chart methods
+   virtual MTAPIRES  ChartGet(LPCWSTR symbol,const INT64 from,const INT64 to,MTChartBar*& bars,UINT& bars_total)=0;
+   virtual MTAPIRES  ChartDelete(LPCWSTR symbol,const INT64* bars_dates,const UINT bars_dates_total)=0;
+   virtual MTAPIRES  ChartUpdate(LPCWSTR symbol,const MTChartBar* bars,const UINT bars_total)=0;
+   virtual MTAPIRES  ChartSplit(LPCWSTR symbol,const UINT new_shares,const UINT old_shares,const UINT rounding_rule,const INT64 datetime_from,const INT64 datetime_to)=0;
+   virtual MTAPIRES  ChartReserved2(void)=0;
+   virtual MTAPIRES  ChartReserved3(void)=0;
+   virtual MTAPIRES  ChartReserved4(void)=0;
+   //--- clients database
+   virtual IMTCertificate *UserCertCreate(void)=0;
+   virtual MTAPIRES  UserCertUpdate(const UINT64 login,const IMTCertificate *certificate)=0;
+   virtual MTAPIRES  UserCertGet(const UINT64 login,IMTCertificate *certificate)=0;
+   virtual MTAPIRES  UserCertReserved1(void)=0;
+   virtual MTAPIRES  UserCertReserved2(void)=0;
+   virtual MTAPIRES  UserCertReserved3(void)=0;
+   virtual MTAPIRES  UserCertReserved4(void)=0;
+   //--- spreads configuration
+   virtual IMTConSpread* SpreadCreate(void)=0;
+   virtual IMTConSpreadLeg* SpreadLegCreate(void)=0;
+   virtual MTAPIRES  SpreadSubscribe(IMTConSpreadSink* sink)=0;
+   virtual MTAPIRES  SpreadUnsubscribe(IMTConSpreadSink* sink)=0;
+   virtual MTAPIRES  SpreadAdd(IMTConSpread* spread)=0;
+   virtual MTAPIRES  SpreadDelete(const UINT pos)=0;
+   virtual MTAPIRES  SpreadShift(const UINT pos,const int shift)=0;
+   virtual UINT      SpreadTotal(void)=0;
+   virtual MTAPIRES  SpreadNext(const UINT pos,IMTConSpread* spread)=0;
+   virtual MTAPIRES  SpreadGet(const UINT id,IMTConSpread* spread)=0;
+   virtual MTAPIRES  SpreadReserved1(void)=0;
+   virtual MTAPIRES  SpreadReserved2(void)=0;
+   virtual MTAPIRES  SpreadReserved3(void)=0;
+   virtual MTAPIRES  SpreadReserved4(void)=0;
+   //--- online connection data
+   virtual IMTOnline* OnlineCreate(void)=0;
+   virtual IMTOnlineArray* OnlineCreateArray(void)=0;
+   virtual UINT      OnlineTotal(void)=0;
+   virtual MTAPIRES  OnlineNext(const UINT pos,IMTOnline* online)=0;
+   virtual MTAPIRES  OnlineGet(const UINT64 login,IMTOnlineArray* online)=0;
+   virtual MTAPIRES  OnlineReserved1(void)=0;
+   virtual MTAPIRES  OnlineReserved2(void)=0;
+   virtual MTAPIRES  OnlineReserved3(void)=0;
+   virtual MTAPIRES  OnlineReserved4(void)=0;
+   //--- notifications
+   virtual MTAPIRES  NotificationsSend(LPCWSTR metaquotes_ids,LPCWSTR message)=0;
+   virtual MTAPIRES  NotificationsSend(const UINT64* logins,const UINT logins_total,LPCWSTR message)=0;
+   virtual MTAPIRES  NotificationsReserved1(void)=0;
+   virtual MTAPIRES  NotificationsReserved2(void)=0;
+   virtual MTAPIRES  NotificationsReserved3(void)=0;
+   virtual MTAPIRES  NotificationsReserved4(void)=0;
+   //--- deals
+   virtual MTAPIRES  DealUpdateBatch(IMTDealArray* deals,MTAPIRES* results)=0;
+   virtual MTAPIRES  DealUpdateBatchArray(IMTDeal** deals,const UINT deals_total,MTAPIRES* results)=0;
+   virtual MTAPIRES  DealAddBatch(IMTDealArray* deals,MTAPIRES* results)=0;
+   virtual MTAPIRES  DealAddBatchArray(IMTDeal** deals,const UINT deals_total,MTAPIRES* results)=0;
+   virtual MTAPIRES  DealPerformBatch(IMTDealArray* deals,MTAPIRES* results)=0;
+   virtual MTAPIRES  DealPerformBatchArray(IMTDeal** deals,const UINT deals_total,MTAPIRES* results)=0;
+   virtual MTAPIRES  DealSelectByGroup(LPCWSTR group,INT64 from,INT64 to,const IMTDatasetRequest *request,IMTDataset *dataset)=0;
+   virtual MTAPIRES  DealSelectByLogins(const UINT64 *logins,UINT logins_total,INT64 from,INT64 to,const IMTDatasetRequest *request,IMTDataset *dataset)=0;
+   virtual MTAPIRES  DealGetByGroup(LPCWSTR group,INT64 from,INT64 to,IMTDealArray *deals)=0;
+   virtual MTAPIRES  DealGetByLogins(const UINT64 *logins,UINT logins_total,INT64 from,INT64 to,IMTDealArray *deals)=0;
+   //--- orders
+   virtual MTAPIRES  OrderAddBatch(IMTOrderArray* orders,MTAPIRES* results)=0;
+   virtual MTAPIRES  OrderAddBatchArray(IMTOrder** orders,const UINT orders_total,MTAPIRES* results)=0;
+   virtual MTAPIRES  OrderSelectByGroup(LPCWSTR group,const IMTDatasetRequest *request,IMTDataset *dataset)=0;
+   virtual MTAPIRES  OrderSelectByLogins(const UINT64 *logins,UINT logins_total,const IMTDatasetRequest *request,IMTDataset *dataset)=0;
+   virtual MTAPIRES  OrderGetByGroup(LPCWSTR group,IMTOrderArray *orders)=0;
+   virtual MTAPIRES  OrderGetByLogins(const UINT64 *logins,UINT logins_total,IMTOrderArray *orders)=0;
+   //--- history
+   virtual MTAPIRES  HistoryUpdateBatchArray(IMTOrder** orders,const UINT orders_total,MTAPIRES* results)=0;
+   virtual MTAPIRES  HistoryAddBatch(IMTOrderArray* orders,MTAPIRES* results)=0;
+   virtual MTAPIRES  HistoryAddBatchArray(IMTOrder** orders,const UINT orders_total,MTAPIRES* results)=0;
+   virtual MTAPIRES  HistorySelectByGroup(LPCWSTR group,INT64 from,INT64 to,const IMTDatasetRequest *request,IMTDataset *dataset)=0;
+   virtual MTAPIRES  HistorySelectByLogins(const UINT64 *logins,UINT logins_total,INT64 from,INT64 to,const IMTDatasetRequest *request,IMTDataset *dataset)=0;
+   virtual MTAPIRES  HistoryGetByGroup(LPCWSTR group,INT64 from,INT64 to,IMTOrderArray *orders)=0;
+   virtual MTAPIRES  HistoryGetByLogins(const UINT64 *logins,UINT logins_total,INT64 from,INT64 to,IMTOrderArray *orders)=0;
+   //--- dealing
+   virtual MTAPIRES  DealerStart(const UINT64 dealer,IMTRequestSink* sink)=0;
+   virtual MTAPIRES  DealerStop(const UINT64 dealer,IMTRequestSink* sink)=0;
+   virtual MTAPIRES  DealerGet(const UINT64 dealer,IMTRequest* request)=0;
+   virtual MTAPIRES  DealerLock(const UINT64 dealer,const UINT id,IMTRequest* request)=0;
+   virtual MTAPIRES  DealerAnswer(const UINT64 dealer,IMTConfirm* confirm)=0;
+   virtual UINT      DealerRequestTotal(const UINT64 dealer)=0;
+   virtual MTAPIRES  DealerRequestNext(const UINT64 dealer,const UINT pos,IMTRequest* request)=0;
+   virtual MTAPIRES  DealerRequestGet(const UINT64 dealer,const UINT id,IMTRequest* request)=0;
+   virtual MTAPIRES  DealerRequestGetAll(const UINT64 dealer,IMTRequestArray* requests)=0;
+   virtual MTAPIRES  DealerReserved1(void)=0;
+   virtual MTAPIRES  DealerReserved2(void)=0;
+   virtual MTAPIRES  DealerReserved3(void)=0;
+   virtual MTAPIRES  DealerReserved4(void)=0;
+   //--- trade methods
+   virtual MTAPIRES  TradeMarginCheckExt(const UINT64 login,LPCWSTR symbol,const UINT type,const UINT64 volume,const double price,IMTAccount* account_new=NULL,IMTAccount* account_current=NULL)=0;
+   virtual MTAPIRES  TradeReserved1(void)=0;
+   virtual MTAPIRES  TradeReserved2(void)=0;
+   virtual MTAPIRES  TradeReserved3(void)=0;
+   virtual MTAPIRES  TradeReserved4(void)=0;
+   virtual MTAPIRES  TradeReserved5(void)=0;
+   virtual MTAPIRES  TradeReserved6(void)=0;
+   //--- email servers configuration
+   virtual IMTConEmail* EmailCreate()=0;
+   virtual MTAPIRES  EmailSubscribe(IMTConEmailSink* sink)=0;
+   virtual MTAPIRES  EmailUnsubscribe(IMTConEmailSink* sink)=0;
+   virtual MTAPIRES  EmailAdd(IMTConEmail* config)=0;
+   virtual MTAPIRES  EmailDelete(LPCWSTR name)=0;
+   virtual MTAPIRES  EmailDelete(const UINT pos)=0;
+   virtual MTAPIRES  EmailShift(const UINT pos,const int shift)=0;
+   virtual UINT      EmailTotal(void)=0;
+   virtual MTAPIRES  EmailNext(const UINT pos,IMTConEmail* email)=0;
+   virtual MTAPIRES  EmailGet(LPCWSTR name,IMTConEmail* email)=0;
+   virtual MTAPIRES  EmailSend(LPCWSTR account,LPCWSTR to,LPCWSTR to_name,LPCWSTR subject,LPCWSTR body)=0;
+   virtual MTAPIRES  EmailReserved2(void)=0;
+   virtual MTAPIRES  EmailReserved3(void)=0;
+   virtual MTAPIRES  EmailReserved4(void)=0;
+   //--- messengers configuration
+   virtual IMTConMessenger* MessengerCreate()=0;
+   virtual MTAPIRES  MessengerSubscribe(IMTConMessengerSink* sink)=0;
+   virtual MTAPIRES  MessengerUnsubscribe(IMTConMessengerSink* sink)=0;
+   virtual MTAPIRES  MessengerAdd(IMTConMessenger* config)=0;
+   virtual MTAPIRES  MessengerDelete(LPCWSTR name)=0;
+   virtual MTAPIRES  MessengerDelete(const UINT pos)=0;
+   virtual MTAPIRES  MessengerShift(const UINT pos,const int shift)=0;
+   virtual UINT      MessengerTotal(void)=0;
+   virtual MTAPIRES  MessengerNext(const UINT pos,IMTConMessenger* messenger)=0;
+   virtual MTAPIRES  MessengerGet(LPCWSTR name,IMTConMessenger* messenger)=0;
+   virtual MTAPIRES  MessengerSend(LPCWSTR destination,LPCWSTR group,LPCWSTR sender,LPCWSTR text)=0;
+   virtual MTAPIRES  MessengerReserved2(void)=0;
+   virtual MTAPIRES  MessengerReserved3(void)=0;
+   virtual MTAPIRES  MessengerReserved4(void)=0;
+   //--- trade positions database
+   virtual MTAPIRES  PositionSelectByGroup(LPCWSTR group,INT64 from,INT64 to,const IMTDatasetRequest *request,IMTDataset *dataset)=0;
+   virtual MTAPIRES  PositionSelectByLogins(const UINT64 *logins,UINT logins_total,INT64 from,INT64 to,const IMTDatasetRequest *request,IMTDataset *dataset)=0;
+   virtual MTAPIRES  PositionGetByGroup(LPCWSTR group,IMTPositionArray *positions)=0;
+   virtual MTAPIRES  PositionGetByLogins(const UINT64 *logins,UINT logins_total,IMTPositionArray *positions)=0;
+   virtual MTAPIRES  PositionGetByTickets(const UINT64 *tickets,UINT tickets_total,IMTPositionArray *positions)=0;
+   virtual MTAPIRES  PositionReserved1(void)=0;
+   virtual MTAPIRES  PositionReserved2(void)=0;
+   virtual MTAPIRES  PositionReserved3(void)=0;
+   virtual MTAPIRES  PositionReserved4(void)=0;
+   //--- dataset management
+   virtual IMTDatasetRequest* DatasetRequestCreate(void)=0;
+   virtual IMTDataset* DatasetCreate(void)=0;
+   virtual MTAPIRES  DatasetReserved1(void)=0;
+   virtual MTAPIRES  DatasetReserved2(void)=0;
+   virtual MTAPIRES  DatasetReserved3(void)=0;
+   virtual MTAPIRES  DatasetReserved4(void)=0;
+   //--- orders
+   virtual MTAPIRES  OrderGetByTickets(const UINT64 *tickets,UINT tickets_total,IMTOrderArray *orders)=0;
+   virtual MTAPIRES  OrderReserved1(void)=0;
+   virtual MTAPIRES  OrderReserved2(void)=0;
+   virtual MTAPIRES  OrderReserved3(void)=0;
+   virtual MTAPIRES  OrderReserved4(void)=0;
+   //--- history
+   virtual MTAPIRES  HistoryGetByTickets(const UINT64 *tickets,UINT tickets_total,IMTOrderArray *orders)=0;
+   virtual MTAPIRES  HistoryReserved1(void)=0;
+   virtual MTAPIRES  HistoryReserved2(void)=0;
+   virtual MTAPIRES  HistoryReserved3(void)=0;
+   virtual MTAPIRES  HistoryReserved4(void)=0;
+   //--- dealing
+   virtual MTAPIRES  DealGetByTickets(const UINT64 *tickets,UINT tickets_total,IMTDealArray *deals)=0;
+   virtual MTAPIRES  DealReserved1(void)=0;
+   virtual MTAPIRES  DealReserved2(void)=0;
+   virtual MTAPIRES  DealReserved3(void)=0;
+   virtual MTAPIRES  DealReserved4(void)=0;
+   //--- client management
+   virtual IMTClient *ClientCreate(void)=0;
+   virtual IMTClientArray *ClientCreateArray(void)=0;
+   virtual MTAPIRES  ClientSubscribe(IMTClientSink* sink)=0;
+   virtual MTAPIRES  ClientUnsubscribe(IMTClientSink* sink)=0;
+   virtual MTAPIRES  ClientAdd(IMTClient *client,const UINT64 author)=0;
+   virtual MTAPIRES  ClientUpdate(IMTClient *client,const UINT64 author)=0;
+   virtual MTAPIRES  ClientDelete(const UINT64 client_id,const UINT64 author)=0;
+   virtual MTAPIRES  ClientGet(const UINT64 client_id,IMTClient *client)=0;
+   virtual MTAPIRES  ClientGetHistory(const UINT64 client_id,const UINT64 author,const INT64 from,const INT64 to,IMTClientArray *history)=0;
+   virtual MTAPIRES  ClientIdsAll(UINT64*& ids,UINT& ids_total)=0;
+   virtual MTAPIRES  ClientIdsByGroup(const LPCWSTR groups,UINT64*& ids,UINT& ids_total)=0;
+   virtual MTAPIRES  ClientIdsByManager(const UINT64 manager,UINT64*& ids,UINT& ids_total)=0;
+   virtual MTAPIRES  ClientUserAdd(const UINT64 client_id,const UINT64 login)=0;
+   virtual MTAPIRES  ClientUserDelete(const UINT64 client_id,const UINT64 login)=0;
+   virtual MTAPIRES  ClientUserLogins(const UINT64 client_id,UINT64*& logins,UINT& logins_total)=0;
+   virtual MTAPIRES  ClientReserved1(void)=0;
+   virtual MTAPIRES  ClientReserved2(void)=0;
+   virtual MTAPIRES  ClientReserved3(void)=0;
+   virtual MTAPIRES  ClientReserved4(void)=0;
+   //--- document management
+   virtual IMTDocument *DocumentCreate(void)=0;
+   virtual IMTDocumentArray *DocumentCreateArray(void)=0;
+   virtual MTAPIRES  DocumentSubscribe(IMTDocumentSink* sink)=0;
+   virtual MTAPIRES  DocumentUnsubscribe(IMTDocumentSink* sink)=0;
+   virtual MTAPIRES  DocumentAdd(IMTDocument *document,const UINT64 author)=0;
+   virtual MTAPIRES  DocumentUpdate(IMTDocument *document,const UINT64 author)=0;
+   virtual MTAPIRES  DocumentDelete(const UINT64 document_id,const UINT64 author)=0;
+   virtual MTAPIRES  DocumentGet(const UINT64 document_id,IMTDocument *document)=0;
+   virtual MTAPIRES  DocumentGetByClient(const UINT64 client_id,const UINT position,const UINT total,IMTDocumentArray *documents)=0;
+   virtual MTAPIRES  DocumentGetHistory(const UINT64 document_id,const UINT64 author,const INT64 from,const INT64 to,IMTDocumentArray *history)=0;
+   virtual MTAPIRES  DocumentReserved1(void)=0;
+   virtual MTAPIRES  DocumentReserved2(void)=0;
+   virtual MTAPIRES  DocumentReserved3(void)=0;
+   virtual MTAPIRES  DocumentReserved4(void)=0;
+   //--- comment management
+   virtual IMTComment *CommentCreate(void)=0;
+   virtual IMTCommentArray *CommentCreateArray(void)=0;
+   virtual MTAPIRES  CommentSubscribe(IMTCommentSink* sink)=0;
+   virtual MTAPIRES  CommentUnsubscribe(IMTCommentSink* sink)=0;
+   virtual MTAPIRES  CommentAdd(IMTComment *comment,const UINT64 author)=0;
+   virtual MTAPIRES  CommentUpdate(IMTComment *comment,const UINT64 author)=0;
+   virtual MTAPIRES  CommentDelete(const UINT64 comment_id,const UINT64 author)=0;
+   virtual MTAPIRES  CommentGet(const UINT64 comment_id,IMTComment *comment)=0;
+   virtual MTAPIRES  CommentGetByClient(const UINT64 client_id,const UINT position,const UINT total,IMTCommentArray *comments)=0;
+   virtual MTAPIRES  CommentGetByDocument(const UINT64 document_id,const UINT position,const UINT total,IMTCommentArray *comments)=0;
+   virtual MTAPIRES  CommentReserved1(void)=0;
+   virtual MTAPIRES  CommentReserved2(void)=0;
+   virtual MTAPIRES  CommentReserved3(void)=0;
+   virtual MTAPIRES  CommentReserved4(void)=0;
+   //--- attachment management
+   virtual IMTAttachment* AttachmentCreate(void)=0;
+   virtual MTAPIRES  AttachmentAdd(IMTAttachment *attachment,const UINT64 author)=0;
+   virtual MTAPIRES  AttachmentGet(const UINT64 attachment_id,IMTAttachment *attachment)=0;
+   virtual MTAPIRES  AttachmentReserved1(void)=0;
+   virtual MTAPIRES  AttachmentReserved2(void)=0;
+   virtual MTAPIRES  AttachmentReserved3(void)=0;
+   virtual MTAPIRES  AttachmentReserved4(void)=0;
+   //--- TLS Certificates
+   virtual MTAPIRES  TLSCertificateUpdate(const void* pfx_certificate,const UINT pfx_certificate_size,LPCWSTR password)=0;
+   virtual MTAPIRES  TLSCertificateDelete(const UINT pos)=0;
+   virtual MTAPIRES  TLSCertificateShift(const UINT pos,const int shift)=0;
+   virtual UINT      TLSCertificateTotal(void)=0;
+   virtual MTAPIRES  TLSCertificateNext(const UINT pos,MTAPISTR& name,MTAPISTR& thumbprint)=0;
+   virtual void*     TLSCertificatePfx(const UINT pos,UINT& pfx_certificate_size)=0;
+   virtual MTAPIRES  TLSCertificateReserved1(void)=0;
+   virtual MTAPIRES  TLSCertificateReserved2(void)=0;
+   virtual MTAPIRES  TLSCertificateReserved3(void)=0;
+   virtual MTAPIRES  TLSCertificateReserved4(void)=0;
+  };
+//+------------------------------------------------------------------+
+//| Server plugin interface                                          |
+//+------------------------------------------------------------------+
+class IMTServerPlugin
+  {
+public:
+   virtual void      Release(void)=0;
+   //--- plugin start & stop notification
+   virtual MTAPIRES  Start(IMTServerAPI* server)=0;
+   virtual MTAPIRES  Stop(void)=0;
+  };
+//+------------------------------------------------------------------+
+//| Plugin DLL entry points                                          |
+//+------------------------------------------------------------------+
+MTAPIENTRY MTAPIRES  MTServerAbout(MTPluginInfo& info);
+MTAPIENTRY MTAPIRES  MTServerCreate(UINT apiversion,IMTServerPlugin** plugin);
+//+------------------------------------------------------------------+
+

+ 17 - 0
MT5SDK/MT5APITools.h

@@ -0,0 +1,17 @@
+//+------------------------------------------------------------------+
+//|                                                 MetaTrader 5 API |
+//|                   Copyright 2000-2019, MetaQuotes Software Corp. |
+//|                                        http://www.metaquotes.net |
+//+------------------------------------------------------------------+
+#pragma once
+#include "Classes\MT5APIStr.h"
+#include "Classes\MT5APIMath.h"
+#include "Classes\MT5APIFormat.h"
+#include "Classes\MT5APITime.h"
+#include "Classes\MT5APIStorage.h"
+#include "Classes\MT5APISync.h"
+#include "Classes\MT5APIThread.h"
+#include "Classes\MT5APIProcess.h"
+#include "Classes\MT5APIFile.h"
+#include "Classes\MT5APIMemPack.h"
+//+------------------------------------------------------------------+

+ 44 - 0
MT5SDK/MT5APITypes.h

@@ -0,0 +1,44 @@
+//+------------------------------------------------------------------+
+//|                                                 MetaTrader 5 API |
+//|                   Copyright 2000-2019, MetaQuotes Software Corp. |
+//|                                        http://www.metaquotes.net |
+//+------------------------------------------------------------------+
+#pragma once
+//+------------------------------------------------------------------+
+//| API DLL entry point specification                                |
+//+------------------------------------------------------------------+
+#define MTAPIENTRY extern "C" __declspec(dllexport)
+//+------------------------------------------------------------------+
+//| MetaTrader 5 API return type                                     |
+//+------------------------------------------------------------------+
+typedef UINT MTAPIRES;
+//+------------------------------------------------------------------+
+//| MetaTrader 5 API string type                                     |
+//+------------------------------------------------------------------+
+typedef wchar_t MTAPISTR[260];
+//+------------------------------------------------------------------+
+//| MetaTrader 5 API sort function pointer type                      |
+//+------------------------------------------------------------------+
+typedef int (__cdecl *MTSortFunctionPtr)(const void *left, const void *right);
+//+------------------------------------------------------------------+
+//| License check block                                              |
+//+------------------------------------------------------------------+
+#pragma pack(push,1)
+struct MTLicenseCheck
+  {
+   //--- license data - filled by API client before LicenseCheck call
+   wchar_t           name[128];            // license name
+   int               data_reserved[128];   // additional license data
+   //--- random sequence - filled by API client before LicenseCheck call
+   char              random[256];          // random sequence for sign verification
+   UINT              random_size;          // random sequence size
+   //--- check result - filled API client after LicenseCheck call
+   MTAPIRES          retcode;              // license check result
+   int               result_reserved[128]; // license check additional info
+   //--- license block sign - filled API client after LicenseCheck call
+   char              sign[1024];           // license check sign
+   UINT              sign_size;            // license check sign size
+   int               sign_reserved[64];    // reserved
+  };
+#pragma pack(pop)
+//+------------------------------------------------------------------+