mirror of
https://github.com/vdemydiuk/mtapi.git
synced 2026-07-28 19:17:48 +00:00
Added OrderSendRequest/OrderSendResponse. Changed functions OrderSend to use request pattern
This commit is contained in:
Generated
+51
-15
@@ -45,6 +45,7 @@
|
||||
this.colAsk = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.colFeedCount = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
this.listBoxEventLog = new System.Windows.Forms.ListBox();
|
||||
this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||
this.tabControl1 = new System.Windows.Forms.TabControl();
|
||||
this.tabPage2 = new System.Windows.Forms.TabPage();
|
||||
this.button17 = new System.Windows.Forms.Button();
|
||||
@@ -120,7 +121,8 @@
|
||||
this.button15 = new System.Windows.Forms.Button();
|
||||
this.button14 = new System.Windows.Forms.Button();
|
||||
this.button13 = new System.Windows.Forms.Button();
|
||||
this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||
this.button18 = new System.Windows.Forms.Button();
|
||||
this.button19 = new System.Windows.Forms.Button();
|
||||
this.groupBox1.SuspendLayout();
|
||||
this.statusStrip1.SuspendLayout();
|
||||
this.groupBox2.SuspendLayout();
|
||||
@@ -207,7 +209,7 @@
|
||||
//
|
||||
this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.toolStripStatusConnection});
|
||||
this.statusStrip1.Location = new System.Drawing.Point(0, 637);
|
||||
this.statusStrip1.Location = new System.Drawing.Point(0, 668);
|
||||
this.statusStrip1.Name = "statusStrip1";
|
||||
this.statusStrip1.Size = new System.Drawing.Size(713, 22);
|
||||
this.statusStrip1.TabIndex = 11;
|
||||
@@ -271,12 +273,18 @@
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.listBoxEventLog.ContextMenuStrip = this.contextMenuStrip1;
|
||||
this.listBoxEventLog.FormattingEnabled = true;
|
||||
this.listBoxEventLog.Location = new System.Drawing.Point(12, 543);
|
||||
this.listBoxEventLog.Location = new System.Drawing.Point(12, 556);
|
||||
this.listBoxEventLog.Name = "listBoxEventLog";
|
||||
this.listBoxEventLog.Size = new System.Drawing.Size(690, 82);
|
||||
this.listBoxEventLog.Size = new System.Drawing.Size(690, 95);
|
||||
this.listBoxEventLog.TabIndex = 14;
|
||||
this.listBoxEventLog.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.listBoxEventLog_MouseDoubleClick);
|
||||
//
|
||||
// contextMenuStrip1
|
||||
//
|
||||
this.contextMenuStrip1.Name = "contextMenuStrip1";
|
||||
this.contextMenuStrip1.Size = new System.Drawing.Size(61, 4);
|
||||
this.contextMenuStrip1.Text = "Clear";
|
||||
//
|
||||
// tabControl1
|
||||
//
|
||||
this.tabControl1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
@@ -290,7 +298,7 @@
|
||||
this.tabControl1.Location = new System.Drawing.Point(12, 147);
|
||||
this.tabControl1.Name = "tabControl1";
|
||||
this.tabControl1.SelectedIndex = 0;
|
||||
this.tabControl1.Size = new System.Drawing.Size(690, 388);
|
||||
this.tabControl1.Size = new System.Drawing.Size(690, 403);
|
||||
this.tabControl1.TabIndex = 15;
|
||||
//
|
||||
// tabPage2
|
||||
@@ -311,7 +319,7 @@
|
||||
this.tabPage2.Location = new System.Drawing.Point(4, 22);
|
||||
this.tabPage2.Name = "tabPage2";
|
||||
this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.tabPage2.Size = new System.Drawing.Size(682, 362);
|
||||
this.tabPage2.Size = new System.Drawing.Size(682, 377);
|
||||
this.tabPage2.TabIndex = 1;
|
||||
this.tabPage2.Text = "Trade Operations";
|
||||
this.tabPage2.UseVisualStyleBackColor = true;
|
||||
@@ -405,7 +413,7 @@
|
||||
"OrderTakeProfit",
|
||||
"OrderTicket",
|
||||
"OrderType"});
|
||||
this.comboBoxSelectedCommand.Location = new System.Drawing.Point(216, 313);
|
||||
this.comboBoxSelectedCommand.Location = new System.Drawing.Point(216, 292);
|
||||
this.comboBoxSelectedCommand.Name = "comboBoxSelectedCommand";
|
||||
this.comboBoxSelectedCommand.Size = new System.Drawing.Size(121, 21);
|
||||
this.comboBoxSelectedCommand.TabIndex = 6;
|
||||
@@ -440,7 +448,7 @@
|
||||
//
|
||||
// button2
|
||||
//
|
||||
this.button2.Location = new System.Drawing.Point(343, 313);
|
||||
this.button2.Location = new System.Drawing.Point(343, 292);
|
||||
this.button2.Name = "button2";
|
||||
this.button2.Size = new System.Drawing.Size(87, 23);
|
||||
this.button2.TabIndex = 2;
|
||||
@@ -450,6 +458,8 @@
|
||||
//
|
||||
// groupBox3
|
||||
//
|
||||
this.groupBox3.Controls.Add(this.button19);
|
||||
this.groupBox3.Controls.Add(this.button18);
|
||||
this.groupBox3.Controls.Add(this.comboBoxOrderColor);
|
||||
this.groupBox3.Controls.Add(this.textBox2);
|
||||
this.groupBox3.Controls.Add(this.textBoxOrderMagic);
|
||||
@@ -475,7 +485,7 @@
|
||||
this.groupBox3.Controls.Add(this.label9);
|
||||
this.groupBox3.Location = new System.Drawing.Point(6, 6);
|
||||
this.groupBox3.Name = "groupBox3";
|
||||
this.groupBox3.Size = new System.Drawing.Size(201, 335);
|
||||
this.groupBox3.Size = new System.Drawing.Size(201, 365);
|
||||
this.groupBox3.TabIndex = 5;
|
||||
this.groupBox3.TabStop = false;
|
||||
this.groupBox3.Text = "Send Order";
|
||||
@@ -546,9 +556,19 @@
|
||||
// numericOrderSlippage
|
||||
//
|
||||
this.numericOrderSlippage.Location = new System.Drawing.Point(70, 122);
|
||||
this.numericOrderSlippage.Minimum = new decimal(new int[] {
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.numericOrderSlippage.Name = "numericOrderSlippage";
|
||||
this.numericOrderSlippage.Size = new System.Drawing.Size(120, 20);
|
||||
this.numericOrderSlippage.TabIndex = 9;
|
||||
this.numericOrderSlippage.Value = new decimal(new int[] {
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
//
|
||||
// label19
|
||||
//
|
||||
@@ -688,7 +708,7 @@
|
||||
this.listBoxSendedOrders.Location = new System.Drawing.Point(213, 23);
|
||||
this.listBoxSendedOrders.Name = "listBoxSendedOrders";
|
||||
this.listBoxSendedOrders.SelectionMode = System.Windows.Forms.SelectionMode.MultiSimple;
|
||||
this.listBoxSendedOrders.Size = new System.Drawing.Size(463, 108);
|
||||
this.listBoxSendedOrders.Size = new System.Drawing.Size(463, 121);
|
||||
this.listBoxSendedOrders.TabIndex = 1;
|
||||
//
|
||||
// tabPage1
|
||||
@@ -1131,17 +1151,31 @@
|
||||
this.button13.UseVisualStyleBackColor = true;
|
||||
this.button13.Click += new System.EventHandler(this.button13_Click);
|
||||
//
|
||||
// contextMenuStrip1
|
||||
// button18
|
||||
//
|
||||
this.contextMenuStrip1.Name = "contextMenuStrip1";
|
||||
this.contextMenuStrip1.Size = new System.Drawing.Size(61, 4);
|
||||
this.contextMenuStrip1.Text = "Clear";
|
||||
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.Text = "Buy";
|
||||
this.button18.UseVisualStyleBackColor = true;
|
||||
this.button18.Click += new System.EventHandler(this.button18_Click);
|
||||
//
|
||||
// button19
|
||||
//
|
||||
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.Text = "Sell";
|
||||
this.button19.UseVisualStyleBackColor = true;
|
||||
this.button19.Click += new System.EventHandler(this.button19_Click);
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(713, 659);
|
||||
this.ClientSize = new System.Drawing.Size(713, 690);
|
||||
this.ContextMenuStrip = this.contextMenuStrip1;
|
||||
this.Controls.Add(this.listBoxEventLog);
|
||||
this.Controls.Add(this.tabControl1);
|
||||
@@ -1270,6 +1304,8 @@
|
||||
private System.Windows.Forms.ComboBox comboBox2;
|
||||
private System.Windows.Forms.Button button17;
|
||||
private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
|
||||
private System.Windows.Forms.Button button19;
|
||||
private System.Windows.Forms.Button button18;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -219,17 +219,25 @@ namespace TestApiClientUI
|
||||
private void sendOrder(string symbol, TradeOperation command, double volume, double price, int slippage, double stoploss, double takeprofit
|
||||
, string comment, int magic, DateTime expiration, Color arrow_color)
|
||||
{
|
||||
int orderId = apiClient.OrderSend(symbol, command, volume, price, slippage, stoploss, takeprofit, comment, magic, expiration, arrow_color);
|
||||
|
||||
RunOnUiThread(() =>
|
||||
{
|
||||
if (orderId >= 0)
|
||||
{
|
||||
listBoxSendedOrders.Items.Add(orderId);
|
||||
}
|
||||
int ticket = 0;
|
||||
try
|
||||
{
|
||||
ticket = apiClient.OrderSend(symbol, command, volume, price, slippage, stoploss, takeprofit, comment, magic, expiration, arrow_color);
|
||||
}
|
||||
catch (MtConnectionException ex)
|
||||
{
|
||||
addToLog("MtExecutionException: " + ex.Message);
|
||||
return;
|
||||
}
|
||||
catch (MtExecutionException ex)
|
||||
{
|
||||
addToLog("MtExecutionException: " + ex.Message + "; ErrorCode = " + ex.ErrorCode);
|
||||
return;
|
||||
}
|
||||
|
||||
addToLog(string.Format("Sended order result: ticketId = {0}, volume - {1}", orderId, volume, slippage));
|
||||
});
|
||||
addToLog(string.Format("Sended order result: ticketId = {0}, symbol = {1}, volume = {2}, slippage = {3}",
|
||||
ticket, symbol, volume, slippage));
|
||||
}
|
||||
|
||||
private void button1_Click(object sender, EventArgs e)
|
||||
@@ -981,5 +989,63 @@ namespace TestApiClientUI
|
||||
{
|
||||
listBoxEventLog.Items.Clear();
|
||||
}
|
||||
|
||||
private void button18_Click(object sender, EventArgs e)
|
||||
{
|
||||
var symbol = textBoxOrderSymbol.Text;
|
||||
|
||||
double volume;
|
||||
double.TryParse(textBoxOrderVolume.Text, out volume);
|
||||
|
||||
var slippage = (int)numericOrderSlippage.Value;
|
||||
|
||||
int ticket = 0;
|
||||
try
|
||||
{
|
||||
ticket = apiClient.OrderSendBuy(symbol, volume, slippage);
|
||||
}
|
||||
catch (MtConnectionException ex)
|
||||
{
|
||||
addToLog("MtExecutionException: " + ex.Message);
|
||||
return;
|
||||
}
|
||||
catch (MtExecutionException ex)
|
||||
{
|
||||
addToLog("MtExecutionException: " + ex.Message + "; ErrorCode = " + ex.ErrorCode);
|
||||
return;
|
||||
}
|
||||
|
||||
addToLog(string.Format("Sended order result: ticketId = {0}, symbol = {1}, volume = {2}, slippage = {3}",
|
||||
ticket, symbol, volume, slippage));
|
||||
}
|
||||
|
||||
private void button19_Click(object sender, EventArgs e)
|
||||
{
|
||||
var symbol = textBoxOrderSymbol.Text;
|
||||
|
||||
double volume;
|
||||
double.TryParse(textBoxOrderVolume.Text, out volume);
|
||||
|
||||
var slippage = (int)numericOrderSlippage.Value;
|
||||
|
||||
int ticket = 0;
|
||||
try
|
||||
{
|
||||
ticket = apiClient.OrderSendSell(symbol, volume, slippage);
|
||||
}
|
||||
catch (MtConnectionException ex)
|
||||
{
|
||||
addToLog("MtExecutionException: " + ex.Message);
|
||||
return;
|
||||
}
|
||||
catch (MtExecutionException ex)
|
||||
{
|
||||
addToLog("MtExecutionException: " + ex.Message + "; ErrorCode = " + ex.ErrorCode);
|
||||
return;
|
||||
}
|
||||
|
||||
addToLog(string.Format("Sended order result: ticketId = {0}, symbol = {1}, volume = {2}, slippage = {3}",
|
||||
ticket, symbol, volume, slippage));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user