mirror of
https://github.com/vdemydiuk/mtapi.git
synced 2026-07-28 11:07:48 +00:00
Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b838084ba2 | |||
| cd24891022 | |||
| add69a4c03 | |||
| 5a3407e47c | |||
| ce8cfbbb70 | |||
| 8470bbd5cc | |||
| 5c7ae748a5 | |||
| 7abb4d3b5e | |||
| 486c42685a | |||
| f41ab37b6f | |||
| 9e129fb6e2 | |||
| f7b00a8d88 | |||
| a7cb14de25 | |||
| f50925c8d3 | |||
| e29a11de68 | |||
| 12141775f3 | |||
| b6d24b8aa9 |
@@ -51,9 +51,15 @@ public struct CMqlBookInfo
|
||||
|
||||
void convertSystemString(wchar_t* dest, String^ src)
|
||||
{
|
||||
pin_ptr<const wchar_t> wch = PtrToStringChars(src);
|
||||
memcpy(dest, wch, wcslen(wch) * sizeof(wchar_t));
|
||||
dest[wcslen(wch)] = '\0';
|
||||
if (src != nullptr) {
|
||||
pin_ptr<const wchar_t> wch = PtrToStringChars(src);
|
||||
memcpy(dest, wch, wcsnlen(wch, 1000) * sizeof(wchar_t));
|
||||
dest[wcsnlen(wch, 1000)] = L'\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
dest[0] = L'\0';
|
||||
}
|
||||
}
|
||||
|
||||
#define _DLLAPI extern "C" __declspec(dllexport)
|
||||
@@ -278,7 +284,7 @@ _DLLAPI int _stdcall getStringValue(int expertHandle, int paramIndex, wchar_t* r
|
||||
_DLLAPI int _stdcall getULongValue(int expertHandle, int paramIndex, unsigned __int64* res, wchar_t* err)
|
||||
{
|
||||
return Execute<int>([&expertHandle, ¶mIndex, res]() {
|
||||
*res = (unsigned long)MtAdapter::GetInstance()->GetCommandParameter(expertHandle, paramIndex);
|
||||
*res = (unsigned __int64)MtAdapter::GetInstance()->GetCommandParameter(expertHandle, paramIndex);
|
||||
return 1;
|
||||
}, err, 0);
|
||||
}
|
||||
@@ -286,7 +292,7 @@ _DLLAPI int _stdcall getULongValue(int expertHandle, int paramIndex, unsigned __
|
||||
_DLLAPI int _stdcall getLongValue(int expertHandle, int paramIndex, __int64* res, wchar_t* err)
|
||||
{
|
||||
return Execute<int>([&expertHandle, ¶mIndex, res]() {
|
||||
*res = (long)MtAdapter::GetInstance()->GetCommandParameter(expertHandle, paramIndex);
|
||||
*res = (__int64)MtAdapter::GetInstance()->GetCommandParameter(expertHandle, paramIndex);
|
||||
return 1;
|
||||
}, err, 0);
|
||||
}
|
||||
@@ -306,4 +312,4 @@ _DLLAPI int _stdcall getUIntValue(int expertHandle, int paramIndex, unsigned int
|
||||
*res = (unsigned int)MtAdapter::GetInstance()->GetCommandParameter(expertHandle, paramIndex);
|
||||
return 1;
|
||||
}, err, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,9 +9,9 @@ namespace MTApiService
|
||||
[DataMember]
|
||||
public int Action { get; set; }
|
||||
[DataMember]
|
||||
public uint Magic { get; set; }
|
||||
public ulong Magic { get; set; }
|
||||
[DataMember]
|
||||
public uint Order { get; set; }
|
||||
public ulong Order { get; set; }
|
||||
[DataMember]
|
||||
public string Symbol { get; set; }
|
||||
[DataMember]
|
||||
@@ -25,7 +25,7 @@ namespace MTApiService
|
||||
[DataMember]
|
||||
public double Tp { get; set; }
|
||||
[DataMember]
|
||||
public uint Deviation { get; set; }
|
||||
public ulong Deviation { get; set; }
|
||||
[DataMember]
|
||||
public int Type { get; set; }
|
||||
[DataMember]
|
||||
@@ -36,5 +36,9 @@ namespace MTApiService
|
||||
public DateTime Expiration { get; set; }
|
||||
[DataMember]
|
||||
public string Comment { get; set; }
|
||||
[DataMember]
|
||||
public ulong Position { get; set; }
|
||||
[DataMember]
|
||||
public ulong PositionBy { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace MtApi5
|
||||
namespace MtApi5
|
||||
{
|
||||
public class MqlTradeCheckResult
|
||||
{
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace MtApi5
|
||||
namespace MtApi5
|
||||
{
|
||||
public class MqlTradeResult
|
||||
{
|
||||
@@ -27,6 +23,11 @@ namespace MtApi5
|
||||
public double Bid { get; private set; } // Current Bid price
|
||||
public double Ask { get; private set; } // Current Ask price
|
||||
public string Comment { get; private set; } // Broker comment to operation (by default it is filled by the operation description)
|
||||
public uint Request_id { get; private set; } // Request ID set by the terminal during the dispatch
|
||||
public uint Request_id { get; private set; } // Request ID set by the terminal during the dispatch
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"Retcode={Retcode}; Deal={Deal}; Order={Order}; Volume={Volume}; Price={Price}; Bid={Bid}; Ask={Ask}; Comment={Comment}; Request_id={Request_id}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace MtApi5
|
||||
namespace MtApi5
|
||||
{
|
||||
internal enum Mt5CommandType
|
||||
{
|
||||
@@ -105,6 +100,7 @@ namespace MtApi5
|
||||
//CTrade
|
||||
PositionClose = 64,
|
||||
PositionOpen = 65,
|
||||
PositionOpenWithResult = 1065,
|
||||
|
||||
//Backtesting
|
||||
BacktestingReady = 66,
|
||||
@@ -115,6 +111,25 @@ namespace MtApi5
|
||||
//Requests
|
||||
MtRequest = 155,
|
||||
|
||||
PositionSelectByTicket = 69
|
||||
PositionSelectByTicket = 69,
|
||||
|
||||
ObjectCreate = 70,
|
||||
ObjectName = 71,
|
||||
ObjectDelete = 72,
|
||||
ObjectsDeleteAll = 73,
|
||||
ObjectFind = 74,
|
||||
ObjectGetTimeByValue = 75,
|
||||
ObjectGetValueByTime = 76,
|
||||
ObjectMove = 77,
|
||||
ObjectsTotal = 78,
|
||||
ObjectGetDouble = 79,
|
||||
ObjectGetInteger = 80,
|
||||
ObjectGetString = 81,
|
||||
ObjectSetDouble = 82,
|
||||
ObjectSetInteger = 83,
|
||||
ObjectSetString = 84,
|
||||
//TextSetFont = 85,
|
||||
//TextOut = 86,
|
||||
//TextGetSize = 87
|
||||
}
|
||||
}
|
||||
|
||||
@@ -606,4 +606,141 @@
|
||||
|
||||
#endregion //Trade Orders in Depth Of Market
|
||||
|
||||
#region Object Types
|
||||
|
||||
public enum ENUM_OBJECT
|
||||
{
|
||||
OBJ_VLINE = 0, // Vertical Line
|
||||
OBJ_HLINE = 1, // Horizontal Line
|
||||
OBJ_TREND = 2, // Trend Line
|
||||
OBJ_TRENDBYANGLE = 3, // Trend Line By Angle
|
||||
OBJ_CYCLES = 4, // Cycle Lines
|
||||
OBJ_ARROWED_LINE = 108, // Arrowed Line
|
||||
OBJ_CHANNEL = 5, // Equidistant Channel
|
||||
OBJ_STDDEVCHANNEL = 6, // Standard Deviation Channel
|
||||
OBJ_REGRESSION = 7, // Linear Regression Channel
|
||||
OBJ_PITCHFORK = 8, // Andrews Pitchfork
|
||||
OBJ_GANNLINE = 9, // Gann Line
|
||||
OBJ_GANNFAN = 10, // Gann Fan
|
||||
OBJ_GANNGRID = 11, // Gann Grid
|
||||
OBJ_FIBO = 12, // Fibonacci Retracement
|
||||
OBJ_FIBOTIMES = 13, // Fibonacci Time Zones
|
||||
OBJ_FIBOFAN = 14, // Fibonacci Fan
|
||||
OBJ_FIBOARC = 15, // Fibonacci Arcs
|
||||
OBJ_FIBOCHANNEL = 16, // Fibonacci Channel
|
||||
OBJ_EXPANSION = 17, // Fibonacci Expansion
|
||||
OBJ_ELLIOTWAVE5 = 18, // Elliott Motive Wave
|
||||
OBJ_ELLIOTWAVE3 = 19, // Elliott Correction Wave
|
||||
OBJ_RECTANGLE = 20, // Rectangle
|
||||
OBJ_TRIANGLE = 21, // Triangle
|
||||
OBJ_ELLIPSE = 22, // Ellipse
|
||||
OBJ_ARROW_THUMB_UP = 23, // Thumbs Up
|
||||
OBJ_ARROW_THUMB_DOWN = 24, // Thumbs Down
|
||||
OBJ_ARROW_UP = 25, // Arrow Up
|
||||
OBJ_ARROW_DOWN = 26, // Arrow Down
|
||||
OBJ_ARROW_STOP = 27, // Stop Sign
|
||||
OBJ_ARROW_CHECK = 28, // Check Sign
|
||||
OBJ_ARROW_LEFT_PRICE = 29, // Left Price Label
|
||||
OBJ_ARROW_RIGHT_PRICE = 30, // Right Price Label
|
||||
OBJ_ARROW_BUY = 31, // Buy Sign
|
||||
OBJ_ARROW_SELL = 32, // Sell Sign
|
||||
OBJ_ARROW = 100, // Arrow
|
||||
OBJ_TEXT = 101, // Text
|
||||
OBJ_LABEL = 102, // Label
|
||||
OBJ_BUTTON = 103, // Button
|
||||
OBJ_CHART = 104, // Chart
|
||||
OBJ_BITMAP = 105, // Bitmap
|
||||
OBJ_BITMAP_LABEL = 106, // Bitmap Label
|
||||
OBJ_EDIT = 107, // Edit
|
||||
OBJ_EVENT = 109, // The "Event" object corresponding to an event in the economic calendar
|
||||
OBJ_RECTANGLE_LABEL = 110 // The "Rectangle label" object for creating and designing the custom graphical interface.
|
||||
}
|
||||
|
||||
#endregion // Object Types
|
||||
|
||||
#region Object Properties
|
||||
|
||||
public enum ENUM_OBJECT_PROPERTY_DOUBLE
|
||||
{
|
||||
OBJPROP_PRICE = 9, // Price coordinate
|
||||
OBJPROP_LEVELVALUE = 204, // Level value
|
||||
OBJPROP_SCALE = 1006, // Scale (properties of Gann objects and Fibonacci Arcs)
|
||||
OBJPROP_ANGLE = 1007, // Angle. For the objects with no angle specified, created from a program, the value is equal to EMPTY_VALUE
|
||||
OBJPROP_DEVIATION = 1010 // Deviation for the Standard Deviation Channel
|
||||
}
|
||||
|
||||
public enum ENUM_OBJECT_PROPERTY_INTEGER
|
||||
{
|
||||
OBJPROP_COLOR = 0, // Color
|
||||
OBJPROP_STYLE = 1, // Style
|
||||
OBJPROP_WIDTH = 2, // Line thickness
|
||||
OBJPROP_BACK = 3, // Object in the background
|
||||
OBJPROP_ZORDER = 207, // Priority of a graphical object for receiving events of clicking on a chart (CHARTEVENT_CLICK). The default zero value is set when creating an object; the priority can be increased if necessary. When objects are placed one atop another, only one of them with the highest priority will receive the CHARTEVENT_CLICK event.
|
||||
OBJPROP_FILL = 1031, // Fill an object with color (for OBJ_RECTANGLE, OBJ_TRIANGLE, OBJ_ELLIPSE, OBJ_CHANNEL, OBJ_STDDEVCHANNEL, OBJ_REGRESSION)
|
||||
OBJPROP_HIDDEN = 208, // Prohibit showing of the name of a graphical object in the list of objects from the terminal menu "Charts" - "Objects" - "List of objects". The true value allows to hide an object from the list. By default, true is set to the objects that display calendar events, trading history and to the objects created from MQL5 programs. To see such graphical objects and access their properties, click on the "All" button in the "List of objects" window.
|
||||
OBJPROP_SELECTED = 4, // Object is selected
|
||||
OBJPROP_READONLY = 1028, // Ability to edit text in the Edit object
|
||||
OBJPROP_TYPE = 7, // Object type
|
||||
OBJPROP_TIME = 8, // Time coordinate
|
||||
OBJPROP_SELECTABLE = 10, // Object availability
|
||||
OBJPROP_CREATETIME = 11, // Time of object creation
|
||||
OBJPROP_LEVELS = 200, // Number of levels
|
||||
OBJPROP_LEVELCOLOR = 201, // Color of the line-level
|
||||
OBJPROP_LEVELSTYLE = 202, // Style of the line-level
|
||||
OBJPROP_LEVELWIDTH = 203, // Thickness of the line-level
|
||||
OBJPROP_ALIGN = 1036, // Horizontal text alignment in the "Edit" object (OBJ_EDIT)
|
||||
OBJPROP_FONTSIZE = 1002, // Font size
|
||||
OBJPROP_RAY_LEFT = 1003, // Ray goes to the left
|
||||
OBJPROP_RAY_RIGHT = 1004, // Ray goes to the right
|
||||
OBJPROP_RAY = 1032, // A vertical line goes through all the windows of a chart
|
||||
OBJPROP_ELLIPSE = 1005, // Showing the full ellipse of the Fibonacci Arc object (OBJ_FIBOARC)
|
||||
OBJPROP_ARROWCODE = 1008, // Arrow code for the Arrow object
|
||||
OBJPROP_TIMEFRAMES = 12, // Visibility of an object at timeframes
|
||||
OBJPROP_ANCHOR = 1011, // Location of the anchor point of a graphical object
|
||||
OBJPROP_XDISTANCE = 1012, // The distance in pixels along the X axis from the binding corner
|
||||
OBJPROP_YDISTANCE = 1013, // The distance in pixels along the Y axis from the binding corner
|
||||
OBJPROP_DIRECTION = 1014, // Trend of the Gann object
|
||||
OBJPROP_DEGREE = 1015, // Level of the Elliott Wave Marking
|
||||
OBJPROP_DRAWLINES = 1016, // Displaying lines for marking the Elliott Wave
|
||||
OBJPROP_STATE = 1018, // Button state (pressed / depressed)
|
||||
OBJPROP_CHART_ID = 1030, // ID of the "Chart" object (OBJ_CHART). It allows working with the properties of this object like with a normal chart using the functions described in Chart Operations, but there some exceptions.
|
||||
OBJPROP_XSIZE = 1019, // The object's width along the X axis in pixels. Specified for OBJ_LABEL (read only), OBJ_BUTTON, OBJ_CHART, OBJ_BITMAP, OBJ_BITMAP_LABEL, OBJ_EDIT, OBJ_RECTANGLE_LABEL objects.
|
||||
OBJPROP_YSIZE = 1020, // The object's height along the Y axis in pixels. Specified for OBJ_LABEL (read only), OBJ_BUTTON, OBJ_CHART, OBJ_BITMAP, OBJ_BITMAP_LABEL, OBJ_EDIT, OBJ_RECTANGLE_LABEL objects.
|
||||
OBJPROP_XOFFSET = 1033, // The X coordinate of the upper left corner of the rectangular visible area in the graphical objects "Bitmap Label" and "Bitmap" (OBJ_BITMAP_LABEL and OBJ_BITMAP). The value is set in pixels relative to the upper left corner of the original image.
|
||||
OBJPROP_YOFFSET = 1034, // The Y coordinate of the upper left corner of the rectangular visible area in the graphical objects "Bitmap Label" and "Bitmap" (OBJ_BITMAP_LABEL and OBJ_BITMAP). The value is set in pixels relative to the upper left corner of the original image.
|
||||
OBJPROP_PERIOD = 1022, // Timeframe for the Chart object
|
||||
OBJPROP_DATE_SCALE = 1023, // Displaying the time scale for the Chart object
|
||||
OBJPROP_PRICE_SCALE = 1024, // Displaying the price scale for the Chart object
|
||||
OBJPROP_CHART_SCALE = 1027, // The scale for the Chart object
|
||||
OBJPROP_BGCOLOR = 1025, // The background color for OBJ_EDIT, OBJ_BUTTON, OBJ_RECTANGLE_LABEL
|
||||
OBJPROP_CORNER = 1026, // The corner of the chart to link a graphical object
|
||||
OBJPROP_BORDER_TYPE = 1029, // Border type for the "Rectangle label" object
|
||||
OBJPROP_BORDER_COLOR = 1035 // Border color for the OBJ_EDIT and OBJ_BUTTON objects
|
||||
}
|
||||
|
||||
public enum ENUM_OBJECT_PROPERTY_STRING
|
||||
{
|
||||
OBJPROP_NAME = 5, // Object name
|
||||
OBJPROP_TEXT = 6, // Description of the object (the text contained in the object)
|
||||
OBJPROP_TOOLTIP = 206, // The text of a tooltip. If the property is not set, then the tooltip generated automatically by the terminal is shown. A tooltip can be disabled by setting the "\n" (line feed) value to it
|
||||
OBJPROP_LEVELTEXT = 205, // Level description
|
||||
OBJPROP_FONT = 1001, // Font
|
||||
OBJPROP_BMPFILE = 1017, // The name of BMP-file for Bitmap Label.
|
||||
OBJPROP_SYMBOL = 1021 // Symbol for the Chart object
|
||||
}
|
||||
|
||||
public enum ENUM_BORDER_TYPE
|
||||
{
|
||||
BORDER_FLAT = 0, // Flat form
|
||||
BORDER_RAISED = 1, // Prominent form
|
||||
BORDER_SUNKEN = 2 // Concave form
|
||||
}
|
||||
|
||||
public enum ENUM_ALIGN_MODE
|
||||
{
|
||||
ALIGN_LEFT = 1, // Left alignment
|
||||
ALIGN_CENTER = 2, // Centered (only for the Edit object)
|
||||
ALIGN_RIGHT = 0, // Right alignment
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
+219
-2
@@ -522,6 +522,25 @@ namespace MtApi5
|
||||
|
||||
return SendCommand<bool>(Mt5CommandType.PositionOpen, commandParameters);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Opens a position with the specified parameters.
|
||||
/// </summary>
|
||||
/// <param name="symbol">symbol</param>
|
||||
/// <param name="orderType">order type to open position </param>
|
||||
/// <param name="volume">position volume</param>
|
||||
/// <param name="price">execution price</param>
|
||||
/// <param name="sl">Stop Loss price</param>
|
||||
/// <param name="tp">Take Profit price</param>
|
||||
/// <param name="comment">comment</param>
|
||||
/// <returns>true - successful check of the basic structures, otherwise - false.</returns>
|
||||
public bool PositionOpen(string symbol, ENUM_ORDER_TYPE orderType, double volume, double price, double sl, double tp, string comment , out MqlTradeResult result)
|
||||
{
|
||||
var commandParameters = new ArrayList { symbol, (int)orderType, volume, price, sl, tp, comment };
|
||||
|
||||
var strResult = SendCommand<string>(Mt5CommandType.PositionOpenWithResult, commandParameters);
|
||||
return strResult.ParseResult(ParamSeparator, out result);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Account Information functions
|
||||
@@ -1419,9 +1438,207 @@ namespace MtApi5
|
||||
|
||||
return SendCommand<bool>(Mt5CommandType.Print, commandParameters);
|
||||
}
|
||||
#endregion
|
||||
#endregion // Common Functions
|
||||
|
||||
#endregion
|
||||
#region Object Functions
|
||||
|
||||
///<summary>
|
||||
///The function creates an object with the specified name, type, and the initial coordinates in the specified chart subwindow.
|
||||
///</summary>
|
||||
///<param name="chartId">Chart identifier. 0 means the current chart.</param>
|
||||
///<param name="name">Name of the object. The name must be unique within a chart, including its subwindows.</param>
|
||||
///<param name="type">Object type. The value can be one of the values of the ENUM_OBJECT enumeration.</param>
|
||||
///<param name="nwin">Number of the chart subwindow. 0 means the main chart window. The specified subwindow must exist, otherwise the function returns false.</param>
|
||||
///<param name="time">The time coordinate of the first anchor.</param>
|
||||
///<param name="price">The price coordinate of the first anchor point.</param>
|
||||
public bool ObjectCreate(long chartId, string name, ENUM_OBJECT type, int nwin, DateTime time, double price)
|
||||
{
|
||||
var commandParameters = new ArrayList { chartId, name, (int)type, nwin, Mt5TimeConverter.ConvertToMtTime(time), price };
|
||||
return SendCommand<bool>(Mt5CommandType.ObjectCreate, commandParameters);
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///The function returns the name of the corresponding object in the specified chart, in the specified subwindow, of the specified type.
|
||||
///</summary>
|
||||
///<param name="chartId">Chart identifier. 0 means the current chart.</param>
|
||||
///<param name="pos">Ordinal number of the object according to the specified filter by the number and type of the subwindow.</param>
|
||||
///<param name="subWindow">umber of the chart subwindow. 0 means the main chart window, -1 means all the subwindows of the chart, including the main window.</param>
|
||||
///<param name="type">Type of the object. The value can be one of the values of the ENUM_OBJECT enumeration. -1 means all types.</param>
|
||||
public string ObjectName(long chartId, int pos, int subWindow = -1, int type = -1)
|
||||
{
|
||||
var commandParameters = new ArrayList { chartId, pos, subWindow, type };
|
||||
return SendCommand<string>(Mt5CommandType.ObjectName, commandParameters);
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///The function removes the object with the specified name from the specified chart.
|
||||
///</summary>
|
||||
///<param name="chartId">Chart identifier. 0 means the current chart.</param>
|
||||
///<param name="name">Name of object to be deleted.</param>
|
||||
public bool ObjectDelete(long chartId, string name)
|
||||
{
|
||||
var commandParameters = new ArrayList { chartId, name };
|
||||
return SendCommand<bool>(Mt5CommandType.ObjectDelete, commandParameters);
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///The function removes the object with the specified name from the specified chart.
|
||||
///</summary>
|
||||
///<param name="chartId">Chart identifier. 0 means the current chart.</param>
|
||||
///<param name="subWindow">Number of the chart subwindow. 0 means the main chart window, -1 means all the subwindows of the chart, including the main window.</param>
|
||||
///<param name="type">Type of the object. The value can be one of the values of the ENUM_OBJECT enumeration. -1 means all types.</param>
|
||||
public int ObjectsDeleteAll(long chartId, int subWindow = -1, int type = -1)
|
||||
{
|
||||
var commandParameters = new ArrayList { chartId, subWindow, type };
|
||||
return SendCommand<int>(Mt5CommandType.ObjectsDeleteAll, commandParameters);
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///The function searches for an object with the specified name in the chart with the specified ID.
|
||||
///</summary>
|
||||
///<param name="chartId">Chart identifier. 0 means the current chart.</param>
|
||||
///<param name="name">The name of the searched object.</param>
|
||||
public int ObjectFind(long chartId, string name)
|
||||
{
|
||||
var commandParameters = new ArrayList { chartId, name };
|
||||
return SendCommand<int>(Mt5CommandType.ObjectFind, commandParameters);
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///The function returns the time value for the specified price value of the specified object.
|
||||
///</summary>
|
||||
///<param name="chartId">Chart identifier. 0 means the current chart.</param>
|
||||
///<param name="name">Name of the object.</param>
|
||||
///<param name="value">Price value.</param>
|
||||
///<param name="lineId">Line identifier.</param>
|
||||
public DateTime ObjectGetTimeByValue(long chartId, string name, double value, int lineId)
|
||||
{
|
||||
var commandParameters = new ArrayList { chartId, name, value, lineId };
|
||||
var res = SendCommand<int>(Mt5CommandType.ObjectGetTimeByValue, commandParameters);
|
||||
return Mt5TimeConverter.ConvertFromMtTime(res);
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///The function returns the price value for the specified time value of the specified object.
|
||||
///</summary>
|
||||
///<param name="chartId">Chart identifier. 0 means the current chart.</param>
|
||||
///<param name="name">Name of the object.</param>
|
||||
///<param name="time">Time value.</param>
|
||||
///<param name="lineId">Line identifier.</param>
|
||||
public double ObjectGetValueByTime(long chartId, string name, DateTime time, int lineId)
|
||||
{
|
||||
var commandParameters = new ArrayList { chartId, name, Mt5TimeConverter.ConvertToMtTime(time), lineId };
|
||||
return SendCommand<double>(Mt5CommandType.ObjectGetValueByTime, commandParameters);
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///The function changes coordinates of the specified anchor point of the object.
|
||||
///</summary>
|
||||
///<param name="chartId">Chart identifier. 0 means the current chart.</param>
|
||||
///<param name="name">Name of the object.</param>
|
||||
///<param name="pointIndex">Index of the anchor point. The number of anchor points depends on the type of object.</param>
|
||||
///<param name="time">Time coordinate of the selected anchor point.</param>
|
||||
///<param name="price">Price coordinate of the selected anchor point.</param>
|
||||
public bool ObjectMove(long chartId, string name, int pointIndex, DateTime time, double price)
|
||||
{
|
||||
var commandParameters = new ArrayList { chartId, name, pointIndex, Mt5TimeConverter.ConvertToMtTime(time), price };
|
||||
return SendCommand<bool>(Mt5CommandType.ObjectMove, commandParameters);
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///The function returns the number of objects in the specified chart, specified subwindow, of the specified type.
|
||||
///</summary>
|
||||
///<param name="chartId">Chart identifier. 0 means the current chart.</param>
|
||||
///<param name="subWindow">Number of the chart subwindow. 0 means the main chart window, -1 means all the subwindows of the chart, including the main window.</param>
|
||||
///<param name="type">Type of the object. The value can be one of the values of the ENUM_OBJECT enumeration. -1 means all types.</param>
|
||||
public int ObjectsTotal(long chartId, int subWindow = -1, int type = -1)
|
||||
|
||||
{
|
||||
var commandParameters = new ArrayList { chartId, subWindow, type };
|
||||
return SendCommand<int>(Mt5CommandType.ObjectsTotal, commandParameters);
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///The function sets the value of the corresponding object property. The object property must be of the double type.
|
||||
///</summary>
|
||||
///<param name="chartId">Chart identifier. 0 means the current chart.</param>
|
||||
///<param name="name">Name of the object.</param>
|
||||
///<param name="propId">ID of the object property. The value can be one of the values of the ENUM_OBJECT_PROPERTY_DOUBLE enumeration.</param>
|
||||
///<param name="propValue">The value of the property.</param>
|
||||
public bool ObjectSetDouble(long chartId, string name, ENUM_OBJECT_PROPERTY_DOUBLE propId, double propValue)
|
||||
|
||||
{
|
||||
var commandParameters = new ArrayList { chartId, name, (int)propId, propValue };
|
||||
return SendCommand<bool>(Mt5CommandType.ObjectSetDouble, commandParameters);
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///The function sets the value of the corresponding object property. The object property must be of the datetime, int, color, bool or char type.
|
||||
///</summary>
|
||||
///<param name="chartId">Chart identifier. 0 means the current chart.</param>
|
||||
///<param name="name">Name of the object.</param>
|
||||
///<param name="propId">ID of the object property. The value can be one of the values of the ENUM_OBJECT_PROPERTY_INTEGER enumeration.</param>
|
||||
///<param name="propValue">The value of the property.</param>
|
||||
public bool ObjectSetInteger(long chartId, string name, ENUM_OBJECT_PROPERTY_INTEGER propId, long propValue)
|
||||
|
||||
{
|
||||
var commandParameters = new ArrayList { chartId, name, (int)propId, propValue };
|
||||
return SendCommand<bool>(Mt5CommandType.ObjectSetInteger, commandParameters);
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///The function sets the value of the corresponding object property. The object property must be of the string type.
|
||||
///</summary>
|
||||
///<param name="chartId">Chart identifier. 0 means the current chart.</param>
|
||||
///<param name="name">Name of the object.</param>
|
||||
///<param name="propId">ID of the object property. The value can be one of the values of the ENUM_OBJECT_PROPERTY_STRING enumeration.</param>
|
||||
///<param name="propValue">The value of the property.</param>
|
||||
public bool ObjectSetString(long chartId, string name, ENUM_OBJECT_PROPERTY_STRING propId, string propValue)
|
||||
|
||||
{
|
||||
var commandParameters = new ArrayList { chartId, name, (int)propId, propValue };
|
||||
return SendCommand<bool>(Mt5CommandType.ObjectSetString, commandParameters);
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///The function returns the value of the corresponding object property. The object property must be of the double type.
|
||||
///</summary>
|
||||
///<param name="chartId">Chart identifier. 0 means the current chart.</param>
|
||||
///<param name="name">Name of the object.</param>
|
||||
///<param name="propId">ID of the object property. The value can be one of the values of the ENUM_OBJECT_PROPERTY_DOUBLE enumeration.</param>
|
||||
public double ObjectGetDouble(long chartId, string name, ENUM_OBJECT_PROPERTY_DOUBLE propId)
|
||||
{
|
||||
var commandParameters = new ArrayList { chartId, name, (int)propId };
|
||||
return SendCommand<double>(Mt5CommandType.ObjectGetDouble, commandParameters);
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///he function returns the value of the corresponding object property. The object property must be of the datetime, int, color, bool or char type.
|
||||
///</summary>
|
||||
///<param name="chartId">Chart identifier. 0 means the current chart.</param>
|
||||
///<param name="name">Name of the object.</param>
|
||||
///<param name="propId">ID of the object property. The value can be one of the values of the ENUM_OBJECT_PROPERTY_INTEGER enumeration.</param>
|
||||
public long ObjectGetInteger(long chartId, string name, ENUM_OBJECT_PROPERTY_INTEGER propId)
|
||||
{
|
||||
var commandParameters = new ArrayList { chartId, name, (int)propId };
|
||||
return SendCommand<long>(Mt5CommandType.ObjectGetInteger, commandParameters);
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///The function returns the value of the corresponding object property. The object property must be of the string type.
|
||||
///</summary>
|
||||
///<param name="chartId">Chart identifier. 0 means the current chart.</param>
|
||||
///<param name="name">Name of the object.</param>
|
||||
///<param name="propId">ID of the object property. The value can be one of the values of the ENUM_OBJECT_PROPERTY_STRING enumeration.</param>
|
||||
public string ObjectGetString(long chartId, string name, ENUM_OBJECT_PROPERTY_STRING propId)
|
||||
{
|
||||
var commandParameters = new ArrayList { chartId, name, (int)propId };
|
||||
return SendCommand<string>(Mt5CommandType.ObjectGetString, commandParameters);
|
||||
}
|
||||
|
||||
#endregion //Object Functions
|
||||
|
||||
#endregion // Public Methods
|
||||
|
||||
#region Properties
|
||||
///<summary>
|
||||
|
||||
@@ -149,7 +149,7 @@ namespace MtApi5
|
||||
|
||||
return new ArrayList { (int)request.Action, request.Magic, request.Order, request.Symbol, request.Volume
|
||||
, request.Price, request.Stoplimit, request.Sl, request.Tp, request.Deviation, (int)request.Type
|
||||
, (int)request.Type_filling, (int)request.Type_time, exp, request.Comment };
|
||||
, (int)request.Type_filling, (int)request.Type_time, exp, request.Comment, request.Position, request.PositionBy };
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -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.12")]
|
||||
[assembly: AssemblyFileVersion("1.0.12")]
|
||||
[assembly: AssemblyVersion("1.0.13")]
|
||||
[assembly: AssemblyFileVersion("1.0.13")]
|
||||
|
||||
@@ -745,13 +745,14 @@ namespace MtApi5TestClient
|
||||
const string symbol = "EURUSD";
|
||||
const ENUM_ORDER_TYPE orderType = ENUM_ORDER_TYPE.ORDER_TYPE_BUY;
|
||||
const double volume = 0.1;
|
||||
const double price = 1.013;
|
||||
const double sl = 1.00;
|
||||
const double tp = 1.020;
|
||||
const double price = 1.18129;
|
||||
const double sl = 1.1811;
|
||||
const double tp = 1.1814;
|
||||
const string comment = "Test PositionOpen";
|
||||
MqlTradeResult tradeResult = null;
|
||||
|
||||
var retVal = await Execute (() => _mtApiClient.PositionOpen(symbol, orderType, volume, price, sl, tp, comment));
|
||||
AddLog($"PositionOpen: symbol EURUSD result = {retVal}");
|
||||
var retVal = await Execute (() => _mtApiClient.PositionOpen(symbol, orderType, volume, price, sl, tp, comment, out tradeResult));
|
||||
AddLog($"PositionOpen: symbol EURUSD retVal = {retVal}, result = {tradeResult}");
|
||||
}
|
||||
|
||||
private async void ExecutePrint(object obj)
|
||||
|
||||
Binary file not shown.
+3295
-1441
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user