Compare commits

...

11 Commits

12 changed files with 210 additions and 95 deletions
+24 -24
View File
@@ -107,7 +107,7 @@ int _stdcall initExpert(int expertHandle, int port, wchar_t* symbol, double bid,
try
{
MT5Handler^ mtHander = gcnew MT5Handler();
MtServerInstance::GetInstance()->InitExpert(expertHandle, port, gcnew String(symbol), bid, ask, mtHander);
MtAdapter::GetInstance()->InitExpert(expertHandle, port, gcnew String(symbol), bid, ask, mtHander);
}
catch (Exception^ e)
{
@@ -123,7 +123,7 @@ int _stdcall deinitExpert(int expertHandle, wchar_t* err)
{
try
{
MtServerInstance::GetInstance()->DeinitExpert(expertHandle);
MtAdapter::GetInstance()->DeinitExpert(expertHandle);
}
catch (Exception^ e)
{
@@ -139,7 +139,7 @@ int _stdcall updateQuote(int expertHandle, wchar_t* symbol, double bid, double a
{
try
{
MtServerInstance::GetInstance()->SendQuote(expertHandle, gcnew String(symbol), bid, ask);
MtAdapter::GetInstance()->SendQuote(expertHandle, gcnew String(symbol), bid, ask);
}
catch (Exception^ e)
{
@@ -155,7 +155,7 @@ int _stdcall sendIntResponse(int expertHandle, int response)
{
try
{
MtServerInstance::GetInstance()->SendResponse(expertHandle, gcnew MtResponseInt(response));
MtAdapter::GetInstance()->SendResponse(expertHandle, gcnew MtResponseInt(response));
}
catch (Exception^ e)
{
@@ -169,7 +169,7 @@ int _stdcall sendLongResponse(int expertHandle, __int64 response)
{
try
{
MtServerInstance::GetInstance()->SendResponse(expertHandle, gcnew MtResponseLong(response));
MtAdapter::GetInstance()->SendResponse(expertHandle, gcnew MtResponseLong(response));
}
catch (Exception^ e)
{
@@ -183,7 +183,7 @@ int _stdcall sendULongResponse(int expertHandle, unsigned __int64 response)
{
try
{
MtServerInstance::GetInstance()->SendResponse(expertHandle, gcnew MtResponseULong(response));
MtAdapter::GetInstance()->SendResponse(expertHandle, gcnew MtResponseULong(response));
}
catch (Exception^ e)
{
@@ -199,7 +199,7 @@ int _stdcall sendBooleanResponse(int expertHandle, int response)
{
bool value = (response != 0) ? true : false;
MtServerInstance::GetInstance()->SendResponse(expertHandle, gcnew MtResponseBool(value));
MtAdapter::GetInstance()->SendResponse(expertHandle, gcnew MtResponseBool(value));
}
catch (Exception^ e)
{
@@ -213,7 +213,7 @@ int _stdcall sendDoubleResponse(int expertHandle, double response)
{
try
{
MtServerInstance::GetInstance()->SendResponse(expertHandle, gcnew MtResponseDouble(response));
MtAdapter::GetInstance()->SendResponse(expertHandle, gcnew MtResponseDouble(response));
}
catch (Exception^ e)
{
@@ -227,7 +227,7 @@ int _stdcall sendStringResponse(int expertHandle, wchar_t* response)
{
try
{
MtServerInstance::GetInstance()->SendResponse(expertHandle, gcnew MtResponseString(gcnew String(response)));
MtAdapter::GetInstance()->SendResponse(expertHandle, gcnew MtResponseString(gcnew String(response)));
}
catch (Exception^ e)
{
@@ -241,7 +241,7 @@ int _stdcall sendVoidResponse(int expertHandle)
{
try
{
MtServerInstance::GetInstance()->SendResponse(expertHandle, nullptr);
MtAdapter::GetInstance()->SendResponse(expertHandle, nullptr);
}
catch (Exception^ e)
{
@@ -262,7 +262,7 @@ int _stdcall sendDoubleArrayResponse(int expertHandle, double* values, int size)
list[i] = values[i];
}
MtServerInstance::GetInstance()->SendResponse(expertHandle, gcnew MtResponseDoubleArray(list));
MtAdapter::GetInstance()->SendResponse(expertHandle, gcnew MtResponseDoubleArray(list));
}
catch (Exception^ e)
{
@@ -283,7 +283,7 @@ int _stdcall sendIntArrayResponse(int expertHandle, int* values, int size)
list[i] = values[i];
}
MtServerInstance::GetInstance()->SendResponse(expertHandle, gcnew MtResponseIntArray(list));
MtAdapter::GetInstance()->SendResponse(expertHandle, gcnew MtResponseIntArray(list));
}
catch (Exception^ e)
{
@@ -304,7 +304,7 @@ int _stdcall sendLongArrayResponse(int expertHandle, __int64* values, int size)
list[i] = values[i];
}
MtServerInstance::GetInstance()->SendResponse(expertHandle, gcnew MtResponseLongArray(list));
MtAdapter::GetInstance()->SendResponse(expertHandle, gcnew MtResponseLongArray(list));
}
catch (Exception^ e)
{
@@ -335,7 +335,7 @@ int _stdcall sendMqlRatesArrayResponse(int expertHandle, CMqlRates values[], int
list[i] = rates;
}
MtServerInstance::GetInstance()->SendResponse(expertHandle, gcnew MtResponseMqlRatesArray(list));
MtAdapter::GetInstance()->SendResponse(expertHandle, gcnew MtResponseMqlRatesArray(list));
}
catch (Exception^ e)
{
@@ -357,7 +357,7 @@ int _stdcall sendMqlTickResponse(int expertHandle, CMqlTick* response, int size)
mtResponse->last = response->last;
mtResponse->volume = response->volume;
MtServerInstance::GetInstance()->SendResponse(expertHandle, gcnew MtResponseMqlTick(mtResponse));
MtAdapter::GetInstance()->SendResponse(expertHandle, gcnew MtResponseMqlTick(mtResponse));
}
catch (Exception^ e)
{
@@ -384,7 +384,7 @@ int _stdcall sendMqlBookInfoArrayResponse(int expertHandle, CMqlBookInfo values[
list[i] = info;
}
MtServerInstance::GetInstance()->SendResponse(expertHandle, gcnew MtResponseMqlBookInfoArray(list));
MtAdapter::GetInstance()->SendResponse(expertHandle, gcnew MtResponseMqlBookInfoArray(list));
}
catch (Exception^ e)
{
@@ -400,7 +400,7 @@ int _stdcall getCommandType(int expertHandle, int* res)
{
try
{
*res = MtServerInstance::GetInstance()->GetCommandType(expertHandle);
*res = MtAdapter::GetInstance()->GetCommandType(expertHandle);
}
catch (Exception^ e)
{
@@ -414,7 +414,7 @@ int _stdcall getIntValue(int expertHandle, int paramIndex, int* res)
{
try
{
*res = (int)MtServerInstance::GetInstance()->GetCommandParameter(expertHandle, paramIndex);
*res = (int)MtAdapter::GetInstance()->GetCommandParameter(expertHandle, paramIndex);
}
catch (Exception^ e)
{
@@ -428,7 +428,7 @@ int _stdcall getDoubleValue(int expertHandle, int paramIndex, double* res)
{
try
{
*res = (double)MtServerInstance::GetInstance()->GetCommandParameter(expertHandle, paramIndex);
*res = (double)MtAdapter::GetInstance()->GetCommandParameter(expertHandle, paramIndex);
}
catch (Exception^ e)
{
@@ -442,7 +442,7 @@ int _stdcall getStringValue(int expertHandle, int paramIndex, wchar_t* res)
{
try
{
convertSystemString(res, (String^)MtServerInstance::GetInstance()->GetCommandParameter(expertHandle, paramIndex));
convertSystemString(res, (String^)MtAdapter::GetInstance()->GetCommandParameter(expertHandle, paramIndex));
}
catch (Exception^ e)
{
@@ -456,7 +456,7 @@ int _stdcall getULongValue(int expertHandle, int paramIndex, unsigned __int64* r
{
try
{
*res = (unsigned long)MtServerInstance::GetInstance()->GetCommandParameter(expertHandle, paramIndex);
*res = (unsigned long)MtAdapter::GetInstance()->GetCommandParameter(expertHandle, paramIndex);
}
catch (Exception^ e)
{
@@ -470,7 +470,7 @@ int _stdcall getLongValue(int expertHandle, int paramIndex, __int64* res)
{
try
{
*res = (long)MtServerInstance::GetInstance()->GetCommandParameter(expertHandle, paramIndex);
*res = (long)MtAdapter::GetInstance()->GetCommandParameter(expertHandle, paramIndex);
}
catch (Exception^ e)
{
@@ -484,7 +484,7 @@ int _stdcall getBooleanValue(int expertHandle, int paramIndex, int* res)
{
try
{
bool val = (bool)MtServerInstance::GetInstance()->GetCommandParameter(expertHandle, paramIndex);
bool val = (bool)MtAdapter::GetInstance()->GetCommandParameter(expertHandle, paramIndex);
*res = val == true ? 1 : 0;
}
catch (Exception^ e)
@@ -499,7 +499,7 @@ int _stdcall getUIntValue(int expertHandle, int paramIndex, unsigned int* res)
{
try
{
*res = (unsigned int)MtServerInstance::GetInstance()->GetCommandParameter(expertHandle, paramIndex);
*res = (unsigned int)MtAdapter::GetInstance()->GetCommandParameter(expertHandle, paramIndex);
}
catch (Exception^ e)
{
+1 -1
View File
@@ -29,7 +29,7 @@ namespace MTApiService
var roller = new RollingFileAppender
{
AppendToFile = false,
AppendToFile = true,
File = $@"{System.IO.Path.GetTempPath()}{profileName}\Logs\{filename}",
Layout = patternLayout,
PreserveLogFileNameExtension = true,
+11 -3
View File
@@ -62,13 +62,21 @@ namespace MTApiService
}
//init local pipe host
var localUrl = CreateConnectionAddress(null, port, true);
var localServiceHost = CreateServiceHost(localUrl, true);
var localPipeUrl = CreateConnectionAddress(null, port, true);
var localPipeServiceHost = CreateServiceHost(localPipeUrl, true);
if (localPipeServiceHost != null)
{
_hosts.Add(localPipeServiceHost);
}
//init localhost
var localUrl = CreateConnectionAddress("localhost", port, false);
var localServiceHost = CreateServiceHost(localUrl, false);
if (localServiceHost != null)
{
_hosts.Add(localServiceHost);
}
//init network hosts
var dnsHostName = Dns.GetHostName();
var ips = Dns.GetHostEntry(dnsHostName);
+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.25.0")]
[assembly: AssemblyFileVersion("1.0.25.0")]
[assembly: AssemblyVersion("1.0.27.0")]
[assembly: AssemblyFileVersion("1.0.27.0")]
+60 -5
View File
@@ -271,31 +271,77 @@ namespace MtApi
public int OrderSend(string symbol, TradeOperation cmd, double volume, double price, int slippage, double stoploss, double takeprofit
, string comment, int magic, DateTime expiration)
{
return OrderSend(symbol, cmd, volume, price, slippage, stoploss, takeprofit, comment, magic, expiration, Color.Empty);
var response = SendRequest<OrderSendResponse>(new OrderSendRequest
{
Symbol = symbol,
Cmd = (int)cmd,
Volume = volume,
Price = price,
Slippage = slippage,
Stoploss = stoploss,
Takeprofit = takeprofit,
Comment = comment,
Magic = magic,
Expiration = MtApiTimeConverter.ConvertToMtTime(expiration)
});
return response?.Ticket ?? -1;
}
public int OrderSend(string symbol, TradeOperation cmd, double volume, double price, int slippage, double stoploss, double takeprofit
, string comment, int magic)
{
return OrderSend(symbol, cmd, volume, price, slippage, stoploss, takeprofit, comment, magic, DateTime.MinValue, Color.Empty);
var response = SendRequest<OrderSendResponse>(new OrderSendRequest
{
Symbol = symbol,
Cmd = (int)cmd,
Volume = volume,
Price = price,
Slippage = slippage,
Stoploss = stoploss,
Takeprofit = takeprofit,
Comment = comment,
Magic = magic
});
return response?.Ticket ?? -1;
}
public int OrderSend(string symbol, TradeOperation cmd, double volume, double price, int slippage, double stoploss, double takeprofit
, string comment)
{
return OrderSend(symbol, cmd, volume, price, slippage, stoploss, takeprofit, comment, 0, DateTime.MinValue, Color.Empty);
var response = SendRequest<OrderSendResponse>(new OrderSendRequest
{
Symbol = symbol,
Cmd = (int)cmd,
Volume = volume,
Price = price,
Slippage = slippage,
Stoploss = stoploss,
Takeprofit = takeprofit,
Comment = comment
});
return response?.Ticket ?? -1;
}
public int OrderSend(string symbol, TradeOperation cmd, double volume, double price, int slippage, double stoploss, double takeprofit)
{
return OrderSend(symbol, cmd, volume, price, slippage, stoploss, takeprofit, null, 0, DateTime.MinValue, Color.Empty);
var response = SendRequest<OrderSendResponse>(new OrderSendRequest
{
Symbol = symbol,
Cmd = (int)cmd,
Volume = volume,
Price = price,
Slippage = slippage,
Stoploss = stoploss,
Takeprofit = takeprofit,
});
return response?.Ticket ?? -1;
}
public int OrderSend(string symbol, TradeOperation cmd, double volume, string price, int slippage, double stoploss, double takeprofit)
{
double dPrice;
return double.TryParse(price, out dPrice) ?
OrderSend(symbol, cmd, volume, dPrice, slippage, stoploss, takeprofit, null, 0, DateTime.MinValue, Color.Empty) : 0;
OrderSend(symbol, cmd, volume, dPrice, slippage, stoploss, takeprofit) : 0;
}
public int OrderSendBuy(string symbol, double volume, int slippage)
@@ -2186,6 +2232,15 @@ namespace MtApi
#endregion
#region Backtesting functions
public void UnlockTicks()
{
SendCommand<object>(MtCommandType.UnlockTicks, null);
}
#endregion
#region Private Methods
private MtClient Client
{
+3 -1
View File
@@ -227,6 +227,8 @@
ObjectSet = 231,
ObjectSetFiboDescription = 232,
ObjectSetText = 233,
ObjectType = 234
ObjectType = 234,
UnlockTicks = 235
}
}
+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.33.0")]
[assembly: AssemblyFileVersion("1.0.33.0")]
[assembly: AssemblyVersion("1.0.36.0")]
[assembly: AssemblyFileVersion("1.0.36.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.11.1")]
[assembly: AssemblyFileVersion("1.0.11.1")]
[assembly: AssemblyVersion("1.0.12")]
[assembly: AssemblyFileVersion("1.0.12")]
+62 -34
View File
@@ -197,9 +197,11 @@
this.button38 = new System.Windows.Forms.Button();
this.button37 = new System.Windows.Forms.Button();
this.tabPage10 = new System.Windows.Forms.TabPage();
this.button68 = new System.Windows.Forms.Button();
this.comboBox11 = new System.Windows.Forms.ComboBox();
this.button4 = new System.Windows.Forms.Button();
this.button68 = new System.Windows.Forms.Button();
this.tabPage11 = new System.Windows.Forms.TabPage();
this.button69 = new System.Windows.Forms.Button();
this.groupBox1.SuspendLayout();
this.statusStrip1.SuspendLayout();
this.groupBox2.SuspendLayout();
@@ -218,6 +220,7 @@
this.tabPage8.SuspendLayout();
this.tabPage9.SuspendLayout();
this.tabPage10.SuspendLayout();
this.tabPage11.SuspendLayout();
this.SuspendLayout();
//
// textBoxServerName
@@ -240,7 +243,7 @@
this.buttonConnect.Location = new System.Drawing.Point(17, 73);
this.buttonConnect.Name = "buttonConnect";
this.buttonConnect.Size = new System.Drawing.Size(75, 23);
this.buttonConnect.TabIndex = 4;
this.buttonConnect.TabIndex = 2;
this.buttonConnect.Text = "Connect";
this.buttonConnect.UseVisualStyleBackColor = true;
this.buttonConnect.Click += new System.EventHandler(this.buttonConnect_Click);
@@ -322,7 +325,7 @@
this.checkBox2.Location = new System.Drawing.Point(6, 296);
this.checkBox2.Name = "checkBox2";
this.checkBox2.Size = new System.Drawing.Size(281, 17);
this.checkBox2.TabIndex = 16;
this.checkBox2.TabIndex = 5;
this.checkBox2.Text = "Use selected ExpertHandle (chart) as default executor";
this.checkBox2.UseVisualStyleBackColor = true;
this.checkBox2.CheckedChanged += new System.EventHandler(this.checkBox2_CheckedChanged);
@@ -343,7 +346,7 @@
this.listViewQuotes.MultiSelect = false;
this.listViewQuotes.Name = "listViewQuotes";
this.listViewQuotes.Size = new System.Drawing.Size(292, 271);
this.listViewQuotes.TabIndex = 15;
this.listViewQuotes.TabIndex = 4;
this.listViewQuotes.UseCompatibleStateImageBehavior = false;
this.listViewQuotes.View = System.Windows.Forms.View.Details;
this.listViewQuotes.SelectedIndexChanged += new System.EventHandler(this.listViewQuotes_SelectedIndexChanged);
@@ -400,6 +403,7 @@
this.tabControl1.Controls.Add(this.tabPage8);
this.tabControl1.Controls.Add(this.tabPage9);
this.tabControl1.Controls.Add(this.tabPage10);
this.tabControl1.Controls.Add(this.tabPage11);
this.tabControl1.Location = new System.Drawing.Point(324, 12);
this.tabControl1.Multiline = true;
this.tabControl1.Name = "tabControl1";
@@ -442,7 +446,7 @@
this.button22.Location = new System.Drawing.Point(216, 293);
this.button22.Name = "button22";
this.button22.Size = new System.Drawing.Size(75, 23);
this.button22.TabIndex = 19;
this.button22.TabIndex = 31;
this.button22.Text = "OrderModify";
this.button22.UseVisualStyleBackColor = true;
this.button22.Click += new System.EventHandler(this.button22_Click);
@@ -452,7 +456,7 @@
this.button21.Location = new System.Drawing.Point(216, 264);
this.button21.Name = "button21";
this.button21.Size = new System.Drawing.Size(75, 23);
this.button21.TabIndex = 18;
this.button21.TabIndex = 30;
this.button21.Text = "OrderDelete";
this.button21.UseVisualStyleBackColor = true;
this.button21.Click += new System.EventHandler(this.button21_Click);
@@ -471,7 +475,7 @@
this.textBoxOppositeTicket.Location = new System.Drawing.Point(303, 239);
this.textBoxOppositeTicket.Name = "textBoxOppositeTicket";
this.textBoxOppositeTicket.Size = new System.Drawing.Size(100, 20);
this.textBoxOppositeTicket.TabIndex = 16;
this.textBoxOppositeTicket.TabIndex = 28;
this.textBoxOppositeTicket.Text = "0";
//
// button15
@@ -479,7 +483,7 @@
this.button15.Location = new System.Drawing.Point(410, 237);
this.button15.Name = "button15";
this.button15.Size = new System.Drawing.Size(92, 23);
this.button15.TabIndex = 15;
this.button15.TabIndex = 29;
this.button15.Text = "OrderCloseBy";
this.button15.UseVisualStyleBackColor = true;
this.button15.Click += new System.EventHandler(this.button15_Click);
@@ -490,7 +494,7 @@
this.checkBox1.Location = new System.Drawing.Point(297, 208);
this.checkBox1.Name = "checkBox1";
this.checkBox1.Size = new System.Drawing.Size(205, 17);
this.checkBox1.TabIndex = 14;
this.checkBox1.TabIndex = 27;
this.checkBox1.Text = "Close order by current price on market";
this.checkBox1.UseVisualStyleBackColor = true;
//
@@ -499,7 +503,7 @@
this.button20.Location = new System.Drawing.Point(216, 202);
this.button20.Name = "button20";
this.button20.Size = new System.Drawing.Size(75, 23);
this.button20.TabIndex = 13;
this.button20.TabIndex = 26;
this.button20.Text = "OrderClose";
this.button20.UseVisualStyleBackColor = true;
this.button20.Click += new System.EventHandler(this.button20_Click);
@@ -509,7 +513,7 @@
this.button17.Location = new System.Drawing.Point(558, 158);
this.button17.Name = "button17";
this.button17.Size = new System.Drawing.Size(75, 23);
this.button17.TabIndex = 12;
this.button17.TabIndex = 25;
this.button17.Text = "GetOrders";
this.button17.UseVisualStyleBackColor = true;
this.button17.Click += new System.EventHandler(this.button17_Click);
@@ -524,7 +528,7 @@
this.comboBox2.Location = new System.Drawing.Point(341, 158);
this.comboBox2.Name = "comboBox2";
this.comboBox2.Size = new System.Drawing.Size(114, 21);
this.comboBox2.TabIndex = 11;
this.comboBox2.TabIndex = 23;
//
// comboBox1
//
@@ -536,14 +540,14 @@
this.comboBox1.Location = new System.Drawing.Point(216, 158);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(119, 21);
this.comboBox1.TabIndex = 10;
this.comboBox1.TabIndex = 22;
//
// button16
//
this.button16.Location = new System.Drawing.Point(461, 158);
this.button16.Name = "button16";
this.button16.Size = new System.Drawing.Size(75, 23);
this.button16.TabIndex = 9;
this.button16.TabIndex = 24;
this.button16.Text = "GetOrder";
this.button16.UseVisualStyleBackColor = true;
this.button16.Click += new System.EventHandler(this.button16_Click);
@@ -562,7 +566,7 @@
this.textBoxIndexTicket.Location = new System.Drawing.Point(290, 132);
this.textBoxIndexTicket.Name = "textBoxIndexTicket";
this.textBoxIndexTicket.Size = new System.Drawing.Size(109, 20);
this.textBoxIndexTicket.TabIndex = 7;
this.textBoxIndexTicket.TabIndex = 21;
this.textBoxIndexTicket.Text = "0";
//
// comboBoxSelectedCommand
@@ -596,7 +600,7 @@
this.comboBoxSelectedCommand.Location = new System.Drawing.Point(213, 344);
this.comboBoxSelectedCommand.Name = "comboBoxSelectedCommand";
this.comboBoxSelectedCommand.Size = new System.Drawing.Size(121, 21);
this.comboBoxSelectedCommand.TabIndex = 6;
this.comboBoxSelectedCommand.TabIndex = 32;
//
// label15
//
@@ -624,14 +628,14 @@
this.listBoxClosedOrders.Location = new System.Drawing.Point(213, 85);
this.listBoxClosedOrders.Name = "listBoxClosedOrders";
this.listBoxClosedOrders.Size = new System.Drawing.Size(419, 43);
this.listBoxClosedOrders.TabIndex = 5;
this.listBoxClosedOrders.TabIndex = 20;
//
// button2
//
this.button2.Location = new System.Drawing.Point(356, 342);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(87, 23);
this.button2.TabIndex = 2;
this.button2.TabIndex = 33;
this.button2.Text = "Execute";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
@@ -675,7 +679,7 @@
this.button19.Location = new System.Drawing.Point(87, 336);
this.button19.Name = "button19";
this.button19.Size = new System.Drawing.Size(75, 23);
this.button19.TabIndex = 15;
this.button19.TabIndex = 18;
this.button19.Text = "Sell";
this.button19.UseVisualStyleBackColor = true;
this.button19.Click += new System.EventHandler(this.button19_Click);
@@ -685,7 +689,7 @@
this.button18.Location = new System.Drawing.Point(6, 336);
this.button18.Name = "button18";
this.button18.Size = new System.Drawing.Size(75, 23);
this.button18.TabIndex = 14;
this.button18.TabIndex = 17;
this.button18.Text = "Buy";
this.button18.UseVisualStyleBackColor = true;
this.button18.Click += new System.EventHandler(this.button18_Click);
@@ -700,28 +704,28 @@
this.comboBoxOrderColor.Location = new System.Drawing.Point(69, 281);
this.comboBoxOrderColor.Name = "comboBoxOrderColor";
this.comboBoxOrderColor.Size = new System.Drawing.Size(121, 21);
this.comboBoxOrderColor.TabIndex = 13;
this.comboBoxOrderColor.TabIndex = 15;
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(70, 255);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(120, 20);
this.textBox2.TabIndex = 11;
this.textBox2.TabIndex = 14;
//
// textBoxOrderMagic
//
this.textBoxOrderMagic.Location = new System.Drawing.Point(70, 229);
this.textBoxOrderMagic.Name = "textBoxOrderMagic";
this.textBoxOrderMagic.Size = new System.Drawing.Size(120, 20);
this.textBoxOrderMagic.TabIndex = 11;
this.textBoxOrderMagic.TabIndex = 13;
//
// textBoxOrderComment
//
this.textBoxOrderComment.Location = new System.Drawing.Point(70, 203);
this.textBoxOrderComment.Name = "textBoxOrderComment";
this.textBoxOrderComment.Size = new System.Drawing.Size(120, 20);
this.textBoxOrderComment.TabIndex = 11;
this.textBoxOrderComment.TabIndex = 12;
//
// textBoxOrderProffit
//
@@ -878,7 +882,7 @@
this.button1.Location = new System.Drawing.Point(120, 307);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 12;
this.button1.TabIndex = 16;
this.button1.Text = "Send";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
@@ -909,7 +913,7 @@
this.listBoxSendedOrders.Name = "listBoxSendedOrders";
this.listBoxSendedOrders.SelectionMode = System.Windows.Forms.SelectionMode.MultiSimple;
this.listBoxSendedOrders.Size = new System.Drawing.Size(419, 43);
this.listBoxSendedOrders.TabIndex = 1;
this.listBoxSendedOrders.TabIndex = 19;
//
// tabPage1
//
@@ -2008,6 +2012,16 @@
this.tabPage10.Text = "Object Functions";
this.tabPage10.UseVisualStyleBackColor = true;
//
// button68
//
this.button68.Location = new System.Drawing.Point(6, 39);
this.button68.Name = "button68";
this.button68.Size = new System.Drawing.Size(75, 23);
this.button68.TabIndex = 2;
this.button68.Text = "ObjectName";
this.button68.UseVisualStyleBackColor = true;
this.button68.Click += new System.EventHandler(this.button68_Click);
//
// comboBox11
//
this.comboBox11.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
@@ -2027,15 +2041,26 @@
this.button4.UseVisualStyleBackColor = true;
this.button4.Click += new System.EventHandler(this.button4_Click);
//
// button68
// tabPage11
//
this.button68.Location = new System.Drawing.Point(6, 39);
this.button68.Name = "button68";
this.button68.Size = new System.Drawing.Size(75, 23);
this.button68.TabIndex = 2;
this.button68.Text = "ObjectName";
this.button68.UseVisualStyleBackColor = true;
this.button68.Click += new System.EventHandler(this.button68_Click);
this.tabPage11.Controls.Add(this.button69);
this.tabPage11.Location = new System.Drawing.Point(4, 40);
this.tabPage11.Name = "tabPage11";
this.tabPage11.Padding = new System.Windows.Forms.Padding(3);
this.tabPage11.Size = new System.Drawing.Size(638, 383);
this.tabPage11.TabIndex = 11;
this.tabPage11.Text = "Backtesting";
this.tabPage11.UseVisualStyleBackColor = true;
//
// button69
//
this.button69.Location = new System.Drawing.Point(6, 6);
this.button69.Name = "button69";
this.button69.Size = new System.Drawing.Size(75, 23);
this.button69.TabIndex = 4;
this.button69.Text = "UnlockTicks";
this.button69.UseVisualStyleBackColor = true;
this.button69.Click += new System.EventHandler(this.button69_Click);
//
// Form1
//
@@ -2081,6 +2106,7 @@
this.tabPage9.ResumeLayout(false);
this.tabPage9.PerformLayout();
this.tabPage10.ResumeLayout(false);
this.tabPage11.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
@@ -2259,6 +2285,8 @@
private System.Windows.Forms.ComboBox comboBox11;
private System.Windows.Forms.TextBox textBoxChartId;
private System.Windows.Forms.Button button68;
private System.Windows.Forms.TabPage tabPage11;
private System.Windows.Forms.Button button69;
}
}
+43 -21
View File
@@ -141,7 +141,7 @@ namespace TestApiClientUI
private void apiClient_QuoteUpdated(object sender, string symbol, double bid, double ask)
{
Console.WriteLine(@"Quote: Symbol = {0}, Bid = {1}, Ask = {2}", symbol, bid, ask);
Console.WriteLine(@"Quote: Symbol = {0}, Bid = {1}, Ask = {2}", symbol, bid, ask);
}
private void _apiClient_QuoteUpdate(object sender, MtQuoteEventArgs e)
@@ -673,6 +673,8 @@ namespace TestApiClientUI
//OrderSend
private async void button1_Click(object sender, EventArgs e)
{
var ticket = -1;
var symbol = textBoxOrderSymbol.Text;
var cmd = (TradeOperation) comboBoxOrderCommand.SelectedIndex;
@@ -693,28 +695,43 @@ namespace TestApiClientUI
var comment = textBoxOrderComment.Text;
int magic;
int.TryParse(textBoxOrderMagic.Text, out magic);
var expiration = DateTime.Now;
Color arrowColor;
switch (comboBoxOrderColor.SelectedIndex)
if (string.IsNullOrEmpty(comment))
{
case 0:
arrowColor = Color.Green;
break;
case 1:
arrowColor = Color.Blue;
break;
case 2:
arrowColor = Color.Red;
break;
default:
return;
ticket = await Execute(() => _apiClient.OrderSend(symbol, cmd, volume, price, slippage, stoploss, takeprofit));
}
else
{
int magic;
if (!int.TryParse(textBoxOrderMagic.Text, out magic))
{
ticket = await Execute(() => _apiClient.OrderSend(symbol, cmd, volume, price, slippage, stoploss, takeprofit, comment));
}
else
{
if (comboBoxOrderColor.SelectedIndex < 0 || comboBoxOrderColor.SelectedIndex > 2)
{
ticket = await Execute(() => _apiClient.OrderSend(symbol, cmd, volume, price, slippage, stoploss, takeprofit, comment, magic));
}
else
{
var expiration = DateTime.Now.AddDays(1);
Color arrowColor = Color.White;
switch (comboBoxOrderColor.SelectedIndex)
{
case 0:
arrowColor = Color.Green;
break;
case 1:
arrowColor = Color.Blue;
break;
case 2:
arrowColor = Color.Red;
break;
}
ticket = await Execute(() => _apiClient.OrderSend(symbol, cmd, volume, price, slippage, stoploss, takeprofit, comment, magic, expiration, arrowColor));
}
}
}
var ticket = await Execute(() => _apiClient.OrderSend(symbol, cmd, volume, price, slippage, stoploss, takeprofit, comment, magic, expiration, arrowColor));
PrintLog($"Sended order result: ticket = {ticket}");
}
@@ -1402,5 +1419,10 @@ namespace TestApiClientUI
var result = await Execute(() => _apiClient.ObjectName(chartId, objectIndex));
PrintLog($"ObjectName result: {result}");
}
private void button69_Click(object sender, EventArgs e)
{
_apiClient.UnlockTicks();
}
}
}
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.