Compare commits

..

5 Commits

10 changed files with 146 additions and 71 deletions
+2 -2
View File
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.38.0")]
[assembly: AssemblyFileVersion("1.0.38.0")]
[assembly: AssemblyVersion("1.0.39.0")]
[assembly: AssemblyFileVersion("1.0.39.0")]
+2 -2
View File
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.14")]
[assembly: AssemblyFileVersion("1.0.14")]
[assembly: AssemblyVersion("1.0.15")]
[assembly: AssemblyFileVersion("1.0.15")]
@@ -259,6 +259,8 @@
<Button Content="HistoryDealGetDouble" Command="{Binding HistoryDealGetDoubleCommand}" Height="25" HorizontalAlignment="Left" Margin="4"/>
<Button Content="HistoryDealGetInteger" Command="{Binding HistoryDealGetIntegerCommand}" Height="25" HorizontalAlignment="Left" Margin="4"/>
<Button Content="HistoryDealGetString" Command="{Binding HistoryDealGetStringCommand}" Height="25" HorizontalAlignment="Left" Margin="4"/>
<Button Content="HistoryOrderGetInteger" Command="{Binding HistoryOrderGetIntegerCommand}" Height="25" HorizontalAlignment="Left" Margin="4"/>
<Button Content="HistoryDealMethods" Command="{Binding HistoryDealMethodsCommand}" Height="25" HorizontalAlignment="Left" Margin="4"/>
</StackPanel>
</Grid>
+34
View File
@@ -16,9 +16,11 @@ namespace MtApi5TestClient
public DelegateCommand DisconnectCommand { get; private set; }
public DelegateCommand OrderSendCommand { get; private set; }
public DelegateCommand HistoryOrderGetIntegerCommand { get; private set; }
public DelegateCommand HistoryDealGetDoubleCommand { get; private set; }
public DelegateCommand HistoryDealGetIntegerCommand { get; private set; }
public DelegateCommand HistoryDealGetStringCommand { get; private set; }
public DelegateCommand HistoryDealMethodsCommand { get; private set; }
public DelegateCommand AccountInfoDoubleCommand { get; private set; }
public DelegateCommand AccountInfoIntegerCommand { get; private set; }
@@ -196,9 +198,11 @@ namespace MtApi5TestClient
DisconnectCommand = new DelegateCommand(ExecuteDisconnect, CanExecuteDisconnect);
OrderSendCommand = new DelegateCommand(ExecuteOrderSend);
HistoryOrderGetIntegerCommand = new DelegateCommand(ExecuteHistoryOrderGetInteger);
HistoryDealGetDoubleCommand = new DelegateCommand(ExecuteHistoryDealGetDouble);
HistoryDealGetIntegerCommand = new DelegateCommand(ExecuteHistoryDealGetInteger);
HistoryDealGetStringCommand = new DelegateCommand(ExecuteHistoryDealGetString);
HistoryDealMethodsCommand = new DelegateCommand(ExecuteHistoryDealMethods);
AccountInfoDoubleCommand = new DelegateCommand(ExecuteAccountInfoDouble);
AccountInfoIntegerCommand = new DelegateCommand(ExecuteAccountInfoInteger);
@@ -277,6 +281,16 @@ namespace MtApi5TestClient
AddLog(message);
}
private async void ExecuteHistoryOrderGetInteger(object o)
{
const ulong ticket = 12345;
const ENUM_ORDER_PROPERTY_INTEGER propertyId = ENUM_ORDER_PROPERTY_INTEGER.ORDER_POSITION_ID;
var retVal = await Execute(() => _mtApiClient.HistoryOrderGetInteger(ticket, propertyId));
AddLog($"HistoryOrderGetInteger: {retVal}");
}
private async void ExecuteHistoryDealGetDouble(object o)
{
const ulong ticket = 12345;
@@ -307,6 +321,26 @@ namespace MtApi5TestClient
AddLog($"HistoryDealGetString: {retVal}");
}
private async void ExecuteHistoryDealMethods(object o)
{
try
{
var posId = await Execute(() => _mtApiClient.PositionGetInteger(ENUM_POSITION_PROPERTY_INTEGER.POSITION_IDENTIFIER)); // posId = 7247951
var history = await Execute(() => _mtApiClient.HistorySelectByPosition(posId)); // history = true
var historyDealsTotal = await Execute(() => _mtApiClient.HistoryDealsTotal()); // historyDealsCount = 4
var histDealTicket = await Execute(() => _mtApiClient.HistoryDealGetTicket(0)); // histDealTicket = 6632442
var histDealPrice = await Execute(() => _mtApiClient.HistoryDealGetDouble(histDealTicket, ENUM_DEAL_PROPERTY_DOUBLE.DEAL_PRICE)); // Exception
}
catch (Exception ex)
{
// ex.Messsage = "Service connection failed! Ошибка сериализации параметра http://tempuri.org/:command. Сообщение InnerException было \"Тип \"MtApi5.ENUM_DEAL_PROPERTY_DOUBLE\" с именем контракта данных \"ENUM_DEAL_PROPERTY_DOUBLE:http://schemas.datacontract.org/2004/07/MtApi5\" не ожидается. Попробуйте использовать DataContractResolver, если вы используете DataContractSerializer, или добавьте любые статически неизвестные типы в список известных типов - например, используя атрибут KnownTypeAttribute или путем их добавления в список известных типов, передаваемый в сериализатор.\". Подробнее см. InnerException."
AddLog(ex.Message);
return;
}
AddLog("ExecuteHistoryDealMethods: success.");
}
private async void ExecuteAccountInfoDouble(object o)
{
var result = await Execute(() => _mtApiClient.AccountInfoDouble(AccountInfoDoublePropertyId));
+78 -65
View File
@@ -113,6 +113,13 @@
this.label22 = new System.Windows.Forms.Label();
this.textBoxErrorCode = new System.Windows.Forms.TextBox();
this.tabPage3 = new System.Windows.Forms.TabPage();
this.button70 = new System.Windows.Forms.Button();
this.label33 = new System.Windows.Forms.Label();
this.label32 = new System.Windows.Forms.Label();
this.label31 = new System.Windows.Forms.Label();
this.textBoxAccountHost = new System.Windows.Forms.TextBox();
this.textBoxAccountPassword = new System.Windows.Forms.TextBox();
this.textBoxAccountLogin = new System.Windows.Forms.TextBox();
this.button67 = new System.Windows.Forms.Button();
this.button66 = new System.Windows.Forms.Button();
this.button65 = new System.Windows.Forms.Button();
@@ -182,6 +189,7 @@
this.button14 = new System.Windows.Forms.Button();
this.button13 = new System.Windows.Forms.Button();
this.tabPage7 = new System.Windows.Forms.TabPage();
this.button71 = new System.Windows.Forms.Button();
this.button23 = new System.Windows.Forms.Button();
this.iCustomBtn = new System.Windows.Forms.Button();
this.tabPage8 = new System.Windows.Forms.TabPage();
@@ -202,13 +210,6 @@
this.button4 = new System.Windows.Forms.Button();
this.tabPage11 = new System.Windows.Forms.TabPage();
this.button69 = new System.Windows.Forms.Button();
this.textBoxAccountLogin = new System.Windows.Forms.TextBox();
this.textBoxAccountPassword = new System.Windows.Forms.TextBox();
this.label31 = new System.Windows.Forms.Label();
this.label32 = new System.Windows.Forms.Label();
this.textBoxAccountHost = new System.Windows.Forms.TextBox();
this.label33 = new System.Windows.Forms.Label();
this.button70 = new System.Windows.Forms.Button();
this.groupBox1.SuspendLayout();
this.statusStrip1.SuspendLayout();
this.groupBox2.SuspendLayout();
@@ -1154,6 +1155,64 @@
this.tabPage3.Text = "Account Information";
this.tabPage3.UseVisualStyleBackColor = true;
//
// button70
//
this.button70.Location = new System.Drawing.Point(371, 292);
this.button70.Name = "button70";
this.button70.Size = new System.Drawing.Size(97, 23);
this.button70.TabIndex = 18;
this.button70.Text = "ChangeAccount";
this.button70.UseVisualStyleBackColor = true;
this.button70.Click += new System.EventHandler(this.button70_Click);
//
// label33
//
this.label33.AutoSize = true;
this.label33.Location = new System.Drawing.Point(168, 269);
this.label33.Name = "label33";
this.label33.Size = new System.Drawing.Size(66, 13);
this.label33.TabIndex = 17;
this.label33.Text = "MT4 Server:";
//
// label32
//
this.label32.AutoSize = true;
this.label32.Location = new System.Drawing.Point(168, 241);
this.label32.Name = "label32";
this.label32.Size = new System.Drawing.Size(56, 13);
this.label32.TabIndex = 17;
this.label32.Text = "Password:";
//
// label31
//
this.label31.AutoSize = true;
this.label31.Location = new System.Drawing.Point(168, 214);
this.label31.Name = "label31";
this.label31.Size = new System.Drawing.Size(36, 13);
this.label31.TabIndex = 17;
this.label31.Text = "Login:";
//
// textBoxAccountHost
//
this.textBoxAccountHost.Location = new System.Drawing.Point(234, 266);
this.textBoxAccountHost.Name = "textBoxAccountHost";
this.textBoxAccountHost.Size = new System.Drawing.Size(238, 20);
this.textBoxAccountHost.TabIndex = 17;
//
// textBoxAccountPassword
//
this.textBoxAccountPassword.Location = new System.Drawing.Point(234, 238);
this.textBoxAccountPassword.Name = "textBoxAccountPassword";
this.textBoxAccountPassword.Size = new System.Drawing.Size(238, 20);
this.textBoxAccountPassword.TabIndex = 16;
//
// textBoxAccountLogin
//
this.textBoxAccountLogin.Location = new System.Drawing.Point(232, 212);
this.textBoxAccountLogin.Name = "textBoxAccountLogin";
this.textBoxAccountLogin.Size = new System.Drawing.Size(238, 20);
this.textBoxAccountLogin.TabIndex = 15;
//
// button67
//
this.button67.Location = new System.Drawing.Point(157, 33);
@@ -1836,6 +1895,7 @@
//
// tabPage7
//
this.tabPage7.Controls.Add(this.button71);
this.tabPage7.Controls.Add(this.button23);
this.tabPage7.Controls.Add(this.iCustomBtn);
this.tabPage7.Location = new System.Drawing.Point(4, 40);
@@ -1846,6 +1906,16 @@
this.tabPage7.Text = "Technical Indicators";
this.tabPage7.UseVisualStyleBackColor = true;
//
// button71
//
this.button71.Location = new System.Drawing.Point(6, 64);
this.button71.Name = "button71";
this.button71.Size = new System.Drawing.Size(107, 23);
this.button71.TabIndex = 17;
this.button71.Text = "iBarShift";
this.button71.UseVisualStyleBackColor = true;
this.button71.Click += new System.EventHandler(this.button71_Click);
//
// button23
//
this.button23.Location = new System.Drawing.Point(6, 35);
@@ -2076,64 +2146,6 @@
this.button69.UseVisualStyleBackColor = true;
this.button69.Click += new System.EventHandler(this.button69_Click);
//
// textBoxAccountLogin
//
this.textBoxAccountLogin.Location = new System.Drawing.Point(232, 212);
this.textBoxAccountLogin.Name = "textBoxAccountLogin";
this.textBoxAccountLogin.Size = new System.Drawing.Size(238, 20);
this.textBoxAccountLogin.TabIndex = 15;
//
// textBoxAccountPassword
//
this.textBoxAccountPassword.Location = new System.Drawing.Point(234, 238);
this.textBoxAccountPassword.Name = "textBoxAccountPassword";
this.textBoxAccountPassword.Size = new System.Drawing.Size(238, 20);
this.textBoxAccountPassword.TabIndex = 16;
//
// label31
//
this.label31.AutoSize = true;
this.label31.Location = new System.Drawing.Point(168, 214);
this.label31.Name = "label31";
this.label31.Size = new System.Drawing.Size(36, 13);
this.label31.TabIndex = 17;
this.label31.Text = "Login:";
//
// label32
//
this.label32.AutoSize = true;
this.label32.Location = new System.Drawing.Point(168, 241);
this.label32.Name = "label32";
this.label32.Size = new System.Drawing.Size(56, 13);
this.label32.TabIndex = 17;
this.label32.Text = "Password:";
//
// textBoxAccountHost
//
this.textBoxAccountHost.Location = new System.Drawing.Point(234, 266);
this.textBoxAccountHost.Name = "textBoxAccountHost";
this.textBoxAccountHost.Size = new System.Drawing.Size(238, 20);
this.textBoxAccountHost.TabIndex = 17;
//
// label33
//
this.label33.AutoSize = true;
this.label33.Location = new System.Drawing.Point(168, 269);
this.label33.Name = "label33";
this.label33.Size = new System.Drawing.Size(66, 13);
this.label33.TabIndex = 17;
this.label33.Text = "MT4 Server:";
//
// button70
//
this.button70.Location = new System.Drawing.Point(371, 292);
this.button70.Name = "button70";
this.button70.Size = new System.Drawing.Size(97, 23);
this.button70.TabIndex = 18;
this.button70.Text = "ChangeAccount";
this.button70.UseVisualStyleBackColor = true;
this.button70.Click += new System.EventHandler(this.button70_Click);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@@ -2366,6 +2378,7 @@
private System.Windows.Forms.TextBox textBoxAccountPassword;
private System.Windows.Forms.TextBox textBoxAccountLogin;
private System.Windows.Forms.Button button70;
private System.Windows.Forms.Button button71;
}
}
+16
View File
@@ -1462,5 +1462,21 @@ namespace TestApiClientUI
var result = await Execute(() => _apiClient.ChangeAccount(login, password, host));
PrintLog($"ChangeAccount result: {result}");
}
//iBarShift
private async void button71_Click(object sender, EventArgs e)
{
const string symbol = "EURUSD";
const ChartPeriod timeframe = ChartPeriod.PERIOD_D1;
var time1 = _apiClient.TimeCurrent();
var time2 = _apiClient.iTime(symbol, timeframe, 5);
var result1 = await Execute(() => _apiClient.iBarShift(symbol, timeframe, time1, true));
var result2 = await Execute(() => _apiClient.iBarShift(symbol, timeframe, time2, true));
PrintLog($"iBarShift result1 = {result1}, time = {time1}");
PrintLog($"iBarShift result2 = {result2}, time = {time2}");
}
}
}
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
+12 -2
View File
@@ -1,7 +1,7 @@
#property copyright "Vyacheslav Demidyuk"
#property link ""
#property version "1.3"
#property version "1.4"
#property description "MtApi (MT5) connection expert"
#include <json.mqh>
@@ -39,6 +39,8 @@
bool getBooleanValue(int expertHandle, int paramIndex, bool& res, string& err);
#import
//#define __DEBUG_LOG__
input int Port = 8228;
int ExpertHandle;
@@ -92,7 +94,9 @@ bool IsDemo()
bool IsTesting()
{
bool isTesting = MQLInfoInteger(MQL_TESTER);
#ifdef __DEBUG_LOG__
PrintFormat("IsTesting: %s", isTesting ? "true" : "false");
#endif
return isTesting;
}
@@ -141,7 +145,9 @@ int init()
return (1);
}
#ifdef __DEBUG_LOG__
PrintFormat("Expert Handle = %d", ExpertHandle);
#endif
//--- Backtesting mode
if (IsTesting())
@@ -219,10 +225,12 @@ int executeCommand()
return (0);
}
#ifdef __DEBUG_LOG__
if (commandType > 0)
{
Print("executeCommand: commnad type = ", commandType);
}
#endif
switch (commandType)
{
@@ -681,7 +689,9 @@ void Execute_Request()
string response = "";
if (request != "")
{
#ifdef __DEBUG_LOG__
Print("Execute_Request: incoming request = ", request);
#endif
response = OnRequest(request);
}
@@ -1151,7 +1161,7 @@ void Execute_HistoryOrderGetInteger()
return;
}
if (!sendULongResponse(ExpertHandle, HistoryOrderGetInteger(ticket_number, (ENUM_ORDER_PROPERTY_INTEGER)property_id), _response_error))
if (!sendLongResponse(ExpertHandle, HistoryOrderGetInteger(ticket_number, (ENUM_ORDER_PROPERTY_INTEGER)property_id), _response_error))
{
PrintResponseError("HistoryOrderGetInteger", _response_error);
}