diff --git a/MtApi/MtApiClient.cs b/MtApi/MtApiClient.cs index d9f086aa..9860701a 100755 --- a/MtApi/MtApiClient.cs +++ b/MtApi/MtApiClient.cs @@ -1757,13 +1757,15 @@ namespace MtApi public bool ObjectCreate(long chartId, string objectName, EnumObject objectType, int subWindow, DateTime? time1, double price1, DateTime? time2 = null, double? price2 = null, DateTime? time3 = null, double? price3 = null) { - var namedParams = new Dictionary(); - namedParams.Add(nameof(chartId), chartId); - namedParams.Add(nameof(objectName), objectName); - namedParams.Add(nameof(objectType), (int)objectType); - namedParams.Add(nameof(subWindow), subWindow); - namedParams.Add(nameof(time1), MtApiTimeConverter.ConvertToMtTime(time1.Value)); - namedParams.Add(nameof(price1), price1); + var namedParams = new Dictionary + { + {nameof(chartId), chartId}, + {nameof(objectName), objectName}, + {nameof(objectType), (int) objectType}, + {nameof(subWindow), subWindow}, + {nameof(time1), MtApiTimeConverter.ConvertToMtTime(time1)}, + {nameof(price1), price1} + }; if (time2 != null) namedParams.Add(nameof(time2), MtApiTimeConverter.ConvertToMtTime(time2.Value)); @@ -1780,13 +1782,16 @@ namespace MtApi /// ///The function returns the name of the corresponding object by its index in the objects list. /// + ///Chart identifier. 0 means the current chart. ///Object index. This value must be greater or equal to 0 and less than ObjectsTotal(). + ///Number of the chart window. Must be greater or equal to -1 (-1 mean all subwindows, 0 means the main chart window) and less than WindowsTotal(). + ///Type of the object. The value can be one of the values of the EnumObject enumeration. EMPTY (-1) means all types. /// ///Name of the object is returned in case of success. /// - public string ObjectName(int objectIndex) + public string ObjectName(long chartId, int objectIndex, int subWindow = EMPTY, int objectType = EMPTY) { - var commandParameters = new ArrayList { objectIndex }; + var commandParameters = new ArrayList { chartId, objectIndex, subWindow, objectType }; return SendCommand(MtCommandType.ObjectName, commandParameters); } @@ -1976,8 +1981,7 @@ namespace MtApi public bool ObjectSetDouble(long chartId, string objectName, EnumObjectPropertyDouble propId, int propModifier, double propValue) { var commandParameters = new ArrayList { chartId, objectName, (int)propId, propValue }; - var namedParams = new Dictionary(); - namedParams.Add(nameof(propModifier), propModifier); + var namedParams = new Dictionary {{nameof(propModifier), propModifier}}; return SendCommand(MtCommandType.ObjectSetDouble, commandParameters, namedParams); } @@ -2011,8 +2015,7 @@ namespace MtApi public bool ObjectSetInteger(long chartId, string objectName, EnumObjectPropertyInteger propId, int propModifier, long propValue) { var commandParameters = new ArrayList { chartId, objectName, (int)propId, propValue }; - var namedParams = new Dictionary(); - namedParams.Add(nameof(propModifier), propModifier); + var namedParams = new Dictionary {{nameof(propModifier), propModifier}}; return SendCommand(MtCommandType.ObjectSetInteger, commandParameters, namedParams); } @@ -2046,8 +2049,7 @@ namespace MtApi public bool ObjectSetString(long chartId, string objectName, EnumObjectPropertyString propId, int propModifier, string propValue) { var commandParameters = new ArrayList { chartId, objectName, (int)propId, propValue }; - var namedParams = new Dictionary(); - namedParams.Add(nameof(propModifier), propModifier); + var namedParams = new Dictionary {{nameof(propModifier), propModifier}}; return SendCommand(MtCommandType.ObjectSetString, commandParameters, namedParams); } @@ -2137,6 +2139,51 @@ namespace MtApi return SendCommand(MtCommandType.ObjectSet, commandParameters); } + /// + ///The function sets a new description to a level of a Fibonacci object. + /// + ///Object name. + ///Index of the Fibonacci level (0-31). + ///New description of the level. + /// + ///The function returns true if successful, otherwise false. + /// + public bool ObjectSetFiboDescription(string objectName, int index, string text) + { + var commandParameters = new ArrayList { objectName, index, text }; + return SendCommand(MtCommandType.ObjectSetFiboDescription, commandParameters); + } + + /// + ///The function changes the object description. + /// + ///Object name. + ///A text describing the object. + ///Font size in points. + ///Font name. + ///Font color. + /// + ///Changes the object description. If the function succeeds, the returned value will be true, otherwise false. + /// + public bool ObjectSetText(string objectName, string text, int fontSize = 0, string fontName = null, Color? textColor = null) + { + var commandParameters = new ArrayList { objectName, text, fontSize, fontName, MtApiColorConverter.ConvertToMtColor(textColor) }; + return SendCommand(MtCommandType.ObjectSetText, commandParameters); + } + + /// + ///The function returns the object type value. + /// + ///Object name. + /// + ///The function returns the object type value. + /// + public EnumObject ObjectType(string objectName) + { + var commandParameters = new ArrayList { objectName }; + return (EnumObject)SendCommand(MtCommandType.ObjectType, commandParameters); + } + #endregion #region Private Methods diff --git a/MtApi/MtApiColorConverter.cs b/MtApi/MtApiColorConverter.cs index ff3b544f..9ae859f8 100755 --- a/MtApi/MtApiColorConverter.cs +++ b/MtApi/MtApiColorConverter.cs @@ -13,9 +13,9 @@ namespace MtApi return Color.FromArgb((byte)(color), (byte)(color >> 8), (byte)(color >> 16)); } - public static int ConvertToMtColor(Color color) + public static int ConvertToMtColor(Color? color) { - return color == Color.Empty ? 0xffffff : (Color.FromArgb(color.B, color.G, color.R).ToArgb() & 0xffffff); + return color == null || color == Color.Empty ? 0xffffff : (Color.FromArgb(color.Value.B, color.Value.G, color.Value.R).ToArgb() & 0xffffff); } } } diff --git a/mq4/MtApi.ex4 b/mq4/MtApi.ex4 index 4ae51c9e..2eeac926 100755 Binary files a/mq4/MtApi.ex4 and b/mq4/MtApi.ex4 differ diff --git a/mq4/MtApi.mq4 b/mq4/MtApi.mq4 index 03d52d3e..beaa9bd6 100755 Binary files a/mq4/MtApi.mq4 and b/mq4/MtApi.mq4 differ