From 8470bbd5cc812b3be40268a304e18a86d9c0db66 Mon Sep 17 00:00:00 2001 From: DW Date: Wed, 27 Sep 2017 18:36:26 +0300 Subject: [PATCH] Issue #41: Complete object functions in client side (MT5) --- MtApi5/Mt5CommandType.cs | 6 ++-- MtApi5/Mt5Enums.cs | 1 - MtApi5/MtApi5Client.cs | 70 ++++++++++++++++++++++++++++++++++++++-- 3 files changed, 71 insertions(+), 6 deletions(-) diff --git a/MtApi5/Mt5CommandType.cs b/MtApi5/Mt5CommandType.cs index 957720e7..dcff8beb 100755 --- a/MtApi5/Mt5CommandType.cs +++ b/MtApi5/Mt5CommandType.cs @@ -127,8 +127,8 @@ ObjectSetDouble = 82, ObjectSetInteger = 83, ObjectSetString = 84, - TextSetFont = 85, - TextOut = 86, - TextGetSize = 87 + //TextSetFont = 85, + //TextOut = 86, + //TextGetSize = 87 } } diff --git a/MtApi5/Mt5Enums.cs b/MtApi5/Mt5Enums.cs index 3d24d5a6..781f60a6 100755 --- a/MtApi5/Mt5Enums.cs +++ b/MtApi5/Mt5Enums.cs @@ -742,6 +742,5 @@ ALIGN_CENTER = 2, // Centered (only for the Edit object) ALIGN_RIGHT = 0, // Right alignment } - #endregion } diff --git a/MtApi5/MtApi5Client.cs b/MtApi5/MtApi5Client.cs index 29525ae6..8d7a6e6d 100755 --- a/MtApi5/MtApi5Client.cs +++ b/MtApi5/MtApi5Client.cs @@ -1540,7 +1540,7 @@ namespace MtApi5 } /// - ///The function returns the number of objects in the specified chart, specified subwindow, of the specified type. + ///The function sets the value of the corresponding object property. The object property must be of the double type. /// ///Chart identifier. 0 means the current chart. ///Name of the object. @@ -1550,11 +1550,77 @@ namespace MtApi5 { var commandParameters = new ArrayList { chartId, name, (int)propId, propValue }; - return SendCommand(Mt5CommandType.ObjectsTotal, commandParameters); + return SendCommand(Mt5CommandType.ObjectSetDouble, commandParameters); + } + + /// + ///The function sets the value of the corresponding object property. The object property must be of the datetime, int, color, bool or char type. + /// + ///Chart identifier. 0 means the current chart. + ///Name of the object. + ///ID of the object property. The value can be one of the values of the ENUM_OBJECT_PROPERTY_INTEGER enumeration. + ///The value of the property. + 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(Mt5CommandType.ObjectSetInteger, commandParameters); + } + + /// + ///The function sets the value of the corresponding object property. The object property must be of the string type. + /// + ///Chart identifier. 0 means the current chart. + ///Name of the object. + ///ID of the object property. The value can be one of the values of the ENUM_OBJECT_PROPERTY_STRING enumeration. + ///The value of the property. + 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(Mt5CommandType.ObjectSetString, commandParameters); + } + + /// + ///The function returns the value of the corresponding object property. The object property must be of the double type. + /// + ///Chart identifier. 0 means the current chart. + ///Name of the object. + ///ID of the object property. The value can be one of the values of the ENUM_OBJECT_PROPERTY_DOUBLE enumeration. + public double ObjectGetDouble(long chartId, string name, ENUM_OBJECT_PROPERTY_DOUBLE propId) + { + var commandParameters = new ArrayList { chartId, name, (int)propId }; + return SendCommand(Mt5CommandType.ObjectGetDouble, commandParameters); + } + + /// + ///he function returns the value of the corresponding object property. The object property must be of the datetime, int, color, bool or char type. + /// + ///Chart identifier. 0 means the current chart. + ///Name of the object. + ///ID of the object property. The value can be one of the values of the ENUM_OBJECT_PROPERTY_INTEGER enumeration. + public long ObjectGetInteger(long chartId, string name, ENUM_OBJECT_PROPERTY_INTEGER propId) + { + var commandParameters = new ArrayList { chartId, name, (int)propId }; + return SendCommand(Mt5CommandType.ObjectGetInteger, commandParameters); + } + + /// + ///The function returns the value of the corresponding object property. The object property must be of the string type. + /// + ///Chart identifier. 0 means the current chart. + ///Name of the object. + ///ID of the object property. The value can be one of the values of the ENUM_OBJECT_PROPERTY_STRING enumeration. + public string ObjectGetString(long chartId, string name, ENUM_OBJECT_PROPERTY_STRING propId) + { + var commandParameters = new ArrayList { chartId, name, (int)propId }; + return SendCommand(Mt5CommandType.ObjectGetString, commandParameters); } #endregion //Object Functions + #endregion // Public Methods + #region Properties /// ///Connection status of MetaTrader API.