Skip to content

Commit ffb42a7

Browse files
committed
init
0 parents  commit ffb42a7

13 files changed

+330
-0
lines changed

.gitignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Temp/
2+
Bin/
3+
.vs
4+
*.suo
5+
*.user
6+
*.userosscache
7+
ipch/
8+
*.aps
9+
*.ncb
10+
*.opendb
11+
*.opensdf
12+
*.sdf
13+
*.cachefile
14+
*.VC.db

MQL4/Experts/websockets.mq4

1.97 KB
Binary file not shown.

MQL4/Libraries/zlib1.dll

71.5 KB
Binary file not shown.

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Turns Metatrader4 into REST API server.
2+
3+
Note: make sure you have VSredist: https://www.microsoft.com/en-ie/download/details.aspx?id=48145
4+
5+
Copy MQL4 folder to Data folder of mt5 (how to get where is Data folder is localted, open mt5, click File->Open Data Folder or just click Ctrl+Shft+D).
6+
In MT4 Navigator (to show Naavigator click Ctrl+N) select Expert Advisors->Advisors. Right click on RestApi, select Modify. Editor will be opened, press F7 to compile. Done.

mt4-websockets.sln

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 15
4+
VisualStudioVersion = 15.0.27130.0
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mt4-websockets", "mt4-websockets\mt4-websockets.vcxproj", "{7359E8DF-CF85-409D-833B-3B66F8DAC462}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|x64 = Debug|x64
11+
Debug|x86 = Debug|x86
12+
Release|x64 = Release|x64
13+
Release|x86 = Release|x86
14+
EndGlobalSection
15+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
16+
{7359E8DF-CF85-409D-833B-3B66F8DAC462}.Debug|x64.ActiveCfg = Debug|x64
17+
{7359E8DF-CF85-409D-833B-3B66F8DAC462}.Debug|x64.Build.0 = Debug|x64
18+
{7359E8DF-CF85-409D-833B-3B66F8DAC462}.Debug|x86.ActiveCfg = Debug|Win32
19+
{7359E8DF-CF85-409D-833B-3B66F8DAC462}.Debug|x86.Build.0 = Debug|Win32
20+
{7359E8DF-CF85-409D-833B-3B66F8DAC462}.Release|x64.ActiveCfg = Release|x64
21+
{7359E8DF-CF85-409D-833B-3B66F8DAC462}.Release|x64.Build.0 = Release|x64
22+
{7359E8DF-CF85-409D-833B-3B66F8DAC462}.Release|x86.ActiveCfg = Release|Win32
23+
{7359E8DF-CF85-409D-833B-3B66F8DAC462}.Release|x86.Build.0 = Release|Win32
24+
EndGlobalSection
25+
GlobalSection(SolutionProperties) = preSolution
26+
HideSolutionNode = FALSE
27+
EndGlobalSection
28+
GlobalSection(ExtensibilityGlobals) = postSolution
29+
SolutionGuid = {08964258-A61B-48D7-9E07-0818CDD29B8B}
30+
EndGlobalSection
31+
EndGlobal

mt4-websockets/main.cpp

4.64 KB
Binary file not shown.

mt4-websockets/mt4-websockets.def

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
LIBRARY "mt4-rest.dll"
2+
EXPORTS
3+
Init
4+
Deinit

mt4-websockets/mt4-websockets.vcxproj

Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup Label="ProjectConfigurations">
4+
<ProjectConfiguration Include="Debug|Win32">
5+
<Configuration>Debug</Configuration>
6+
<Platform>Win32</Platform>
7+
</ProjectConfiguration>
8+
<ProjectConfiguration Include="Release|Win32">
9+
<Configuration>Release</Configuration>
10+
<Platform>Win32</Platform>
11+
</ProjectConfiguration>
12+
<ProjectConfiguration Include="Debug|x64">
13+
<Configuration>Debug</Configuration>
14+
<Platform>x64</Platform>
15+
</ProjectConfiguration>
16+
<ProjectConfiguration Include="Release|x64">
17+
<Configuration>Release</Configuration>
18+
<Platform>x64</Platform>
19+
</ProjectConfiguration>
20+
</ItemGroup>
21+
<PropertyGroup Label="Globals">
22+
<VCProjectVersion>15.0</VCProjectVersion>
23+
<ProjectGuid>{7359E8DF-CF85-409D-833B-3B66F8DAC462}</ProjectGuid>
24+
<Keyword>Win32Proj</Keyword>
25+
<RootNamespace>microservicetutorial</RootNamespace>
26+
<WindowsTargetPlatformVersion>10.0.17763.0</WindowsTargetPlatformVersion>
27+
<ProjectName>mt4-websockets</ProjectName>
28+
</PropertyGroup>
29+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
30+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
31+
<ConfigurationType>Application</ConfigurationType>
32+
<UseDebugLibraries>true</UseDebugLibraries>
33+
<PlatformToolset>v141</PlatformToolset>
34+
<CharacterSet>Unicode</CharacterSet>
35+
</PropertyGroup>
36+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
37+
<ConfigurationType>DynamicLibrary</ConfigurationType>
38+
<UseDebugLibraries>false</UseDebugLibraries>
39+
<PlatformToolset>v141</PlatformToolset>
40+
<WholeProgramOptimization>true</WholeProgramOptimization>
41+
<CharacterSet>Unicode</CharacterSet>
42+
</PropertyGroup>
43+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
44+
<ConfigurationType>Application</ConfigurationType>
45+
<UseDebugLibraries>true</UseDebugLibraries>
46+
<PlatformToolset>v141</PlatformToolset>
47+
<CharacterSet>Unicode</CharacterSet>
48+
</PropertyGroup>
49+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
50+
<ConfigurationType>DynamicLibrary</ConfigurationType>
51+
<UseDebugLibraries>false</UseDebugLibraries>
52+
<PlatformToolset>v141</PlatformToolset>
53+
<WholeProgramOptimization>true</WholeProgramOptimization>
54+
<CharacterSet>Unicode</CharacterSet>
55+
</PropertyGroup>
56+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
57+
<ImportGroup Label="ExtensionSettings">
58+
</ImportGroup>
59+
<ImportGroup Label="Shared">
60+
</ImportGroup>
61+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
62+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
63+
</ImportGroup>
64+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
65+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
66+
</ImportGroup>
67+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
68+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
69+
</ImportGroup>
70+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
71+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
72+
</ImportGroup>
73+
<PropertyGroup Label="UserMacros" />
74+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
75+
<LinkIncremental>true</LinkIncremental>
76+
</PropertyGroup>
77+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
78+
<LinkIncremental>true</LinkIncremental>
79+
</PropertyGroup>
80+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
81+
<LinkIncremental>false</LinkIncremental>
82+
<OutDir>$(SolutionDir)Bin\$(Platform)\$(Configuration)\</OutDir>
83+
<IntDir>$(SolutionDir)Temp\$(Platform)\$(Configuration)\</IntDir>
84+
</PropertyGroup>
85+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
86+
<LinkIncremental>false</LinkIncremental>
87+
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
88+
</PropertyGroup>
89+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
90+
<ClCompile>
91+
<PrecompiledHeader>Use</PrecompiledHeader>
92+
<WarningLevel>Level3</WarningLevel>
93+
<Optimization>Disabled</Optimization>
94+
<SDLCheck>true</SDLCheck>
95+
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
96+
<ConformanceMode>false</ConformanceMode>
97+
<LanguageStandard>
98+
</LanguageStandard>
99+
</ClCompile>
100+
<Link>
101+
<SubSystem>Console</SubSystem>
102+
<GenerateDebugInformation>true</GenerateDebugInformation>
103+
</Link>
104+
</ItemDefinitionGroup>
105+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
106+
<ClCompile>
107+
<PrecompiledHeader>Use</PrecompiledHeader>
108+
<WarningLevel>Level3</WarningLevel>
109+
<Optimization>Disabled</Optimization>
110+
<SDLCheck>true</SDLCheck>
111+
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
112+
<ConformanceMode>false</ConformanceMode>
113+
</ClCompile>
114+
<Link>
115+
<SubSystem>Console</SubSystem>
116+
<GenerateDebugInformation>true</GenerateDebugInformation>
117+
</Link>
118+
</ItemDefinitionGroup>
119+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
120+
<ClCompile>
121+
<PrecompiledHeader>Use</PrecompiledHeader>
122+
<WarningLevel>Level3</WarningLevel>
123+
<Optimization>MaxSpeed</Optimization>
124+
<FunctionLevelLinking>true</FunctionLevelLinking>
125+
<IntrinsicFunctions>true</IntrinsicFunctions>
126+
<SDLCheck>true</SDLCheck>
127+
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
128+
<ConformanceMode>true</ConformanceMode>
129+
<AdditionalIncludeDirectories>F:\vcpkg\installed\x86-windows\include;%(AdditionalIncludeDirectories);</AdditionalIncludeDirectories>
130+
</ClCompile>
131+
<Link>
132+
<SubSystem>Console</SubSystem>
133+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
134+
<OptimizeReferences>true</OptimizeReferences>
135+
<GenerateDebugInformation>true</GenerateDebugInformation>
136+
<AdditionalLibraryDirectories>F:\vcpkg\installed\x86-windows\lib\;$(SolutionDir)$(Platform)\$(Configuration);</AdditionalLibraryDirectories>
137+
<AdditionalDependencies>zlib.lib;mbedcrypto.lib;mbedx509.lib;mbedtls.lib;ixwebsocket.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
138+
<ModuleDefinitionFile>mt4-websockets.def</ModuleDefinitionFile>
139+
</Link>
140+
</ItemDefinitionGroup>
141+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
142+
<ClCompile>
143+
<PrecompiledHeader>Use</PrecompiledHeader>
144+
<WarningLevel>Level3</WarningLevel>
145+
<Optimization>MaxSpeed</Optimization>
146+
<FunctionLevelLinking>true</FunctionLevelLinking>
147+
<IntrinsicFunctions>true</IntrinsicFunctions>
148+
<SDLCheck>true</SDLCheck>
149+
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
150+
<ConformanceMode>true</ConformanceMode>
151+
<AdditionalIncludeDirectories>..\packages\x64-windows\include;..\..\boost_1_69_0;%(AdditionalIncludeDirectories);</AdditionalIncludeDirectories>
152+
<ExceptionHandling>Sync</ExceptionHandling>
153+
</ClCompile>
154+
<Link>
155+
<SubSystem>Console</SubSystem>
156+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
157+
<OptimizeReferences>true</OptimizeReferences>
158+
<GenerateDebugInformation>true</GenerateDebugInformation>
159+
<AdditionalLibraryDirectories>..\packages\x64-windows\lib\;..\..\boost_1_69_0\lib64-msvc-14.1;$(SolutionDir)$(Platform)\$(Configuration);</AdditionalLibraryDirectories>
160+
<AdditionalDependencies>cpprest_2_10.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
161+
<ModuleDefinitionFile>mt4-websockets.def</ModuleDefinitionFile>
162+
</Link>
163+
<PreBuildEvent>
164+
<Command>taskkill /IM ServiceHub.DataWarehouseHost.exe /F 2&gt;nul 1&gt;nul
165+
Exit 0</Command>
166+
</PreBuildEvent>
167+
</ItemDefinitionGroup>
168+
<ItemGroup>
169+
<ClInclude Include="safe_vector.hpp" />
170+
<ClInclude Include="stdafx.h" />
171+
<ClInclude Include="targetver.h" />
172+
</ItemGroup>
173+
<ItemGroup>
174+
<ClCompile Include="main.cpp" />
175+
<ClCompile Include="safe_vector.cpp" />
176+
<ClCompile Include="stdafx.cpp">
177+
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
178+
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
179+
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
180+
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
181+
</ClCompile>
182+
</ItemGroup>
183+
<ItemGroup>
184+
<None Include="mt4-websockets.def" />
185+
</ItemGroup>
186+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
187+
<ImportGroup Label="ExtensionTargets">
188+
</ImportGroup>
189+
</Project>

mt4-websockets/safe_vector.cpp

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#include "stdafx.h"
2+
#include <string>
3+
#include <utility>
4+
#include "safe_vector.hpp"
5+
6+
void SafeVector::insert(string in, const int index)
7+
{
8+
lock_guard<mutex> lock(mut);
9+
vec[index] = move(in);
10+
cond.notify_one();
11+
}
12+
13+
void SafeVector::push_back(string in)
14+
{
15+
lock_guard<mutex> lock(mut);
16+
vec.push_back(move(in));
17+
cond.notify_one();
18+
}
19+
20+
void SafeVector::pop_back()
21+
{
22+
lock_guard<mutex> lock(mut);
23+
vec.pop_back();
24+
cond.notify_one();
25+
}
26+
27+
string& SafeVector::back()
28+
{
29+
return vec.back();
30+
}
31+
32+
size_t SafeVector::size() {
33+
return vec.size();
34+
}
35+
36+
string& SafeVector::operator[](const int index)
37+
{
38+
return vec[index];
39+
}
40+
41+
vector<string>::iterator SafeVector::begin()
42+
{
43+
return vec.begin();
44+
}
45+
46+
vector<string>::iterator SafeVector::end()
47+
{
48+
return vec.end();
49+
}
50+
51+
vector<string> SafeVector::toVector()
52+
{
53+
return vec;
54+
}

mt4-websockets/safe_vector.hpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#ifndef SAFEVECTOR_HPP
2+
#define SAFEVECTOR_HPP
3+
4+
#include <vector>
5+
#include <mutex>
6+
#include <condition_variable>
7+
#include <string>
8+
using namespace std;
9+
10+
class SafeVector {
11+
public:
12+
SafeVector() : vec(), mut(), cond() {}
13+
SafeVector(const SafeVector& orig) : vec(orig.vec), mut(), cond() {}
14+
~SafeVector() {}
15+
16+
void insert(string in, const int index);
17+
void push_back(string in);
18+
void pop_back();
19+
size_t size();
20+
string& operator[](const int index);
21+
string& back();
22+
vector<string>::iterator begin();
23+
vector<string>::iterator end();
24+
vector<string> toVector();
25+
26+
private:
27+
vector<string> vec;
28+
mutex mut;
29+
condition_variable cond;
30+
};
31+
32+
#endif /* SAFEVECTOR_HPP */

mt4-websockets/stdafx.cpp

620 Bytes
Binary file not shown.

mt4-websockets/stdafx.h

574 Bytes
Binary file not shown.

mt4-websockets/targetver.h

630 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)