diff --git a/MtApi5/Mt5CommandType.cs b/MtApi5/Mt5CommandType.cs index 07aa0851..62f3dd5f 100755 --- a/MtApi5/Mt5CommandType.cs +++ b/MtApi5/Mt5CommandType.cs @@ -179,11 +179,68 @@ namespace MtApi5 IndicatorRelease = 131, + + + //Chart Operations + ChartId = 206, + ChartRedraw = 207, + ChartApplyTemplate = 236, + ChartSaveTemplate = 237, + ChartWindowFind = 238, + ChartTimePriceToXY = 239, + ChartXYToTimePrice = 240, + ChartOpen = 241, + ChartFirst = 242, + ChartNext = 243, + ChartClose = 244, + ChartSymbol = 245, + ChartPeriod = 246, + ChartSetDouble = 247, + ChartSetInteger = 248, + ChartSetString = 249, + ChartGetDouble = 250, + ChartGetInteger = 251, + ChartGetString = 252, + ChartNavigate = 253, + ChartIndicatorDelete = 254, + ChartIndicatorName = 255, + ChartIndicatorsTotal = 256, + ChartWindowOnDropped = 257, + ChartPriceOnDropped = 258, + ChartTimeOnDropped = 259, + ChartXOnDropped = 260, + ChartYOnDropped = 261, + ChartSetSymbolPeriod = 262, + ChartScreenShot = 263, + + // Windows Operations + WindowBarsPerChart = 264, + WindowExpertName = 265, + WindowFind = 266, + WindowFirstVisibleBar = 267, + WindowHandle = 268, + WindowIsVisible = 269, + WindowOnDropped = 270, + WindowPriceMax = 271, + WindowPriceMin = 272, + WindowPriceOnDropped = 273, + WindowRedraw = 274, + WindowScreenShot = 275, + WindowTimeOnDropped = 276, + WindowsTotal = 277, + WindowXOnDropped = 278, + WindowYOnDropped = 279, + + // Terminal Operations + TerminalCompany = 68, + TerminalName = 69, + TerminalPath = 70, + //Checkup GetLastError = 132, - TerminalInfoInteger = 133, //TODO - TerminalInfoDouble = 134, //TODO - TerminalInfoString = 135, //TODO + TerminalInfoString = 153, //TODO + TerminalInfoInteger = 204, //TODO + TerminalInfoDouble = 205, //TODO //Common Functions Alert = 136, //TODO diff --git a/MtApi5/Mt5Enums.cs b/MtApi5/Mt5Enums.cs index ac93de8c..edb532b9 100755 --- a/MtApi5/Mt5Enums.cs +++ b/MtApi5/Mt5Enums.cs @@ -36,6 +36,90 @@ namespace MtApi5 #endregion //Chart Timeframes + #region Charts Properties + + public enum ENUM_CHART_PROPERTY_DOUBLE + { + CHART_SHIFT_SIZE = 3, + CHART_FIXED_POSITION = 41, + CHART_FIXED_MAX = 8, + CHART_FIXED_MIN = 9, + CHART_POINTS_PER_BAR = 11, + CHART_PRICE_MIN = 108, + CHART_PRICE_MAX = 109 + } + + public enum ENUM_CHART_PROPERTY_INTEGER + { + CHART_SHOW = 46, + CHART_IS_OBJECT = 111, + CHART_BRING_TO_TOP = 35, + CHART_CONTEXT_MENU = 50, + CHART_CROSSHAIR_TOOL = 49, + CHART_MOUSE_SCROLL = 42, + CHART_EVENT_MOUSE_WHEEL = 48, + CHART_EVENT_MOUSE_MOVE = 40, + CHART_EVENT_OBJECT_CREATE = 38, + CHART_EVENT_OBJECT_DELETE = 39, + CHART_MODE = 0, + CHART_FOREGROUND = 1, + CHART_SHIFT = 2, + CHART_AUTOSCROLL = 4, + CHART_KEYBOARD_CONTROL = 47, + CHART_QUICK_NAVIGATION = 45, + CHART_SCALE = 5, + CHART_SCALEFIX = 6, + CHART_SCALEFIX_11 = 7, + CHART_SCALE_PT_PER_BAR = 10, + CHART_SHOW_OHLC = 12, + CHART_SHOW_BID_LINE = 13, + CHART_SHOW_ASK_LINE = 14, + CHART_SHOW_LAST_LINE = 15, + CHART_SHOW_PERIOD_SEP = 16, + CHART_SHOW_GRID = 17, + CHART_SHOW_VOLUMES = 18, + CHART_SHOW_OBJECT_DESCR = 19, + CHART_VISIBLE_BARS = 100, + CHART_WINDOWS_TOTAL = 101, + CHART_WINDOW_IS_VISIBLE = 102, + CHART_WINDOW_HANDLE = 103, + CHART_WINDOW_YDISTANCE = 110, + CHART_FIRST_VISIBLE_BAR = 104, + CHART_WIDTH_IN_BARS = 105, + CHART_WIDTH_IN_PIXELS = 106, + CHART_HEIGHT_IN_PIXELS = 107, + CHART_COLOR_BACKGROUND = 21, + CHART_COLOR_FOREGROUND = 22, + CHART_COLOR_GRID = 23, + CHART_COLOR_VOLUME = 24, + CHART_COLOR_CHART_UP = 25, + CHART_COLOR_CHART_DOWN = 26, + CHART_COLOR_CHART_LINE = 27, + CHART_COLOR_CANDLE_BULL = 28, + CHART_COLOR_CANDLE_BEAR = 29, + CHART_COLOR_BID = 30, + CHART_COLOR_ASK = 31, + CHART_COLOR_LAST = 32, + CHART_COLOR_STOP_LEVEL = 33, + CHART_SHOW_TRADE_LEVELS = 34, + CHART_DRAG_TRADE_LEVELS = 43, + CHART_SHOW_DATE_SCALE = 36, + CHART_SHOW_PRICE_SCALE = 37, + CHART_SHOW_ONE_CLICK = 44, + CHART_IS_MAXIMIZED = 115, + CHART_IS_MINIMIZED = 116 + } + + public enum ENUM_CHART_PROPERTY_STRING + { + CHART_COMMENT = 20, + CHART_EXPERT_NAME = 113, + CHART_SCRIPT_NAME = 114 + } + + + #endregion + // Environment State: #region Client Terminal Properties diff --git a/MtApi5/MtApi5Client.cs b/MtApi5/MtApi5Client.cs index 295db5d2..c49ac754 100755 --- a/MtApi5/MtApi5Client.cs +++ b/MtApi5/MtApi5Client.cs @@ -581,11 +581,11 @@ namespace MtApi5 #region Account Information functions - /// - ///Returns the value of the corresponding account property. - /// - ///Identifier of the property. - public double AccountInfoDouble(ENUM_ACCOUNT_INFO_DOUBLE propertyId) + /// + ///Returns the value of the corresponding account property. + /// + ///Identifier of the property. + public double AccountInfoDouble(ENUM_ACCOUNT_INFO_DOUBLE propertyId) { var commandParameters = new ArrayList { (int)propertyId }; @@ -1483,6 +1483,671 @@ namespace MtApi5 #endregion + #region Chart Operations + + /// + ///Returns the ID of the current chart. + /// + /// + /// Value of long type. + /// + public long ChartId() + { + return SendCommand(Mt5CommandType.ChartId, null); + } + + /// + ///This function calls a forced redrawing of a specified chart. + /// + public void ChartRedraw(long chartId = 0) + { + var commandParameters = new ArrayList { chartId }; + SendCommand(Mt5CommandType.ChartRedraw, commandParameters); + } + + /// + ///Applies a specific template from a specified file to the chart. + /// + ///Chart ID. + ///The name of the file containing the template. + /// + ///Returns true if the command has been added to chart queue, otherwise false. + /// + public bool ChartApplyTemplate(long chartId, string filename) + { + var commandParameters = new ArrayList { chartId, filename }; + return SendCommand(Mt5CommandType.ChartApplyTemplate, commandParameters); + } + + /// + ///Saves current chart settings in a template with a specified name. + /// + ///Chart ID. + ///The filename to save the template. The ".tpl" extension will be added to the filename automatically; there is no need to specify it. The template is saved in data_folder\templates\ and can be used for manual application in the terminal. If a template with the same filename already exists, the contents of this file will be overwritten. + /// + ///Returns true if the command has been added to chart queue, otherwise false. + /// + public bool ChartSaveTemplate(long chartId, string filename) + { + var commandParameters = new ArrayList { chartId, filename }; + return SendCommand(Mt5CommandType.ChartSaveTemplate, commandParameters); + } + + /// + ///The function returns the number of a subwindow where an indicator is drawn. + /// + ///Chart ID. + ///Short name of the indicator. + /// + ///Subwindow number in case of success. In case of failure the function returns -1. + /// + public int ChartWindowFind(long chartId, string indicatorShortname) + { + var commandParameters = new ArrayList { chartId, indicatorShortname }; + return SendCommand(Mt5CommandType.ChartWindowFind, commandParameters); + } + + /// + ///The function returns the number of a subwindow where an indicator is drawn. + /// + ///Chart ID. + ///The number of the chart subwindow. 0 means the main chart window. + ///The time value on the chart, for which the value in pixels along the X axis will be received. + ///The price value on the chart, for which the value in pixels along the Y axis will be received. + ///The variable, into which the conversion of time to X will be received. The origin is in the upper left corner of the main chart window. + ///The variable, into which the conversion of price to Y will be received. The origin is in the upper left corner of the main chart window. + /// + ///Subwindow number in case of success. In case of failure the function returns -1. + /// + public bool ChartTimePriceToXY(long chartId, int subWindow, DateTime? time, double price, out int x, out int y) + { + var commandParameters = new ArrayList { chartId, subWindow, Mt5TimeConverter.ConvertToMtTime((DateTime)time), price }; + var str = SendCommand(Mt5CommandType.ChartTimePriceToXY, commandParameters); + var res = false; + x = 0; + y = 0; + if (!string.IsNullOrEmpty(str) && str.Contains(";")) + { + var values = str.Split(';'); + if (values.Length > 1) + { + int.TryParse(values[0], out x); + int.TryParse(values[1], out y); + res = true; + } + } + return res; + } + + /// + ///The function returns the number of a subwindow where an indicator is drawn. + /// + ///Chart ID. + ///The variable, into which the conversion of time to X will be received. The origin is in the upper left corner of the main chart window. + ///The variable, into which the conversion of price to Y will be received. The origin is in the upper left corner of the main chart window. + ///The number of the chart subwindow. 0 means the main chart window. + ///The time value on the chart, for which the value in pixels along the X axis will be received. + ///The price value on the chart, for which the value in pixels along the Y axis will be received. + /// + ///Subwindow number in case of success. In case of failure the function returns -1. + /// + public bool ChartXYToTimePrice(long chartId, int x, int y, out int subWindow, out DateTime? time, out double price) + { + var commandParameters = new ArrayList { chartId, x, y }; + var str = SendCommand(Mt5CommandType.ChartXYToTimePrice, commandParameters); + var res = false; + subWindow = 0; + time = null; + price = double.NaN; + if (!string.IsNullOrEmpty(str) && str.Contains(";")) + { + var values = str.Split(';'); + if (values.Length > 2) + { + int.TryParse(values[0], out subWindow); + int mt4Time; + int.TryParse(values[1], out mt4Time); + time = Mt5TimeConverter.ConvertFromMtTime(mt4Time); + double.TryParse(values[2], out price); + res = true; + } + } + return res; + } + + /// + ///Opens a new chart with the specified symbol and period. + /// + ///Chart symbol. NULL means the symbol of the current chart (the Expert Advisor is attached to). + /// Chart period (timeframe). Can be one of the ENUM_TIMEFRAMES values. 0 means the current chart period. + /// + ///If successful, it returns the opened chart ID. Otherwise returns 0. + /// + public long ChartOpen(string symbol, ENUM_TIMEFRAMES period) + { + var commandParameters = new ArrayList { symbol, (int)period }; + return SendCommand(Mt5CommandType.ChartOpen, commandParameters); + } + + /// + ///Returns the ID of the first chart of the client terminal. + /// + public long ChartFirst() + { + return SendCommand(Mt5CommandType.ChartFirst, null); + } + + /// + ///Returns the chart ID of the chart next to the specified one. + /// + ///Chart ID. 0 does not mean the current chart. 0 means "return the first chart ID". + /// + ///Chart ID. If this is the end of the chart list, it returns -1. + /// + public long ChartNext(long chartId) + { + var commandParameters = new ArrayList { chartId }; + return SendCommand(Mt5CommandType.ChartNext, commandParameters); + } + + /// + ///Closes the specified chart. + /// + ///Chart ID. 0 means the current chart. + /// + ///If successful, returns true, otherwise false. + /// + public bool ChartClose(long chartId) + { + var commandParameters = new ArrayList { chartId }; + return SendCommand(Mt5CommandType.ChartClose, commandParameters); + } + + /// + ///Returns the symbol name for the specified chart. + /// + ///Chart ID. 0 means the current chart. + /// + ///If chart does not exist, the result will be an empty string. + /// + public string ChartSymbol(long chartId) + { + var commandParameters = new ArrayList { chartId }; + return SendCommand(Mt5CommandType.ChartSymbol, commandParameters); + } + + /// + ///Returns the timeframe period of specified chart. + /// + ///Chart ID. 0 means the current chart. + /// + ///The function returns one of the ENUM_TIMEFRAMES values. If chart does not exist, it returns 0. + /// + public ENUM_TIMEFRAMES ChartPeriod(long chartId) + { + var commandParameters = new ArrayList { chartId }; + return (ENUM_TIMEFRAMES)SendCommand(Mt5CommandType.ChartPeriod, commandParameters); + } + + /// + ///Sets a value for a corresponding property of the specified chart. Chart property should be of a double type. + /// + ///Chart ID. 0 means the current chart. + ///Chart property ID. Can be one of the ENUM_CHART_PROPERTY_DOUBLE values (except the read-only properties). + ///Property value. + /// + ///Returns true if the command has been added to chart queue, otherwise false. + /// + public bool ChartSetDouble(long chartId, ENUM_CHART_PROPERTY_DOUBLE propId, double value) + { + var commandParameters = new ArrayList { chartId, (int)propId, value }; + return SendCommand(Mt5CommandType.ChartSetDouble, commandParameters); + } + + /// + ///Sets a value for a corresponding property of the specified chart. Chart property must be datetime, int, color, bool or char. + /// + ///Chart ID. 0 means the current chart. + ///Chart property ID. It can be one of the ENUM_CHART_PROPERTY_INTEGER value (except the read-only properties). + ///Property value. + /// + ///Returns true if the command has been added to chart queue, otherwise false. + /// + public bool ChartSetInteger(long chartId, ENUM_CHART_PROPERTY_INTEGER propId, long value) + { + var commandParameters = new ArrayList { chartId, (int)propId, value }; + return SendCommand(Mt5CommandType.ChartSetInteger, commandParameters); + } + + /// + ///Sets a value for a corresponding property of the specified chart. Chart property must be of the string type. + /// + ///Chart ID. 0 means the current chart. + ///Chart property ID. Its value can be one of the ENUM_CHART_PROPERTY_STRING values (except the read-only properties). + ///Property value string. String length cannot exceed 2045 characters (extra characters will be truncated). + /// + ///Returns true if the command has been added to chart queue, otherwise false. + /// + public bool ChartSetString(long chartId, ENUM_CHART_PROPERTY_STRING propId, string value) + { + var commandParameters = new ArrayList { chartId, (int)propId, value }; + return SendCommand(Mt5CommandType.ChartSetString, commandParameters); + } + + /// + ///Sets a value for a corresponding property of the specified chart. Chart property must be of the string type. + /// + ///Chart ID. 0 means the current chart. + ///Chart property ID. This value can be one of the ENUM_CHART_PROPERTY_DOUBLE values. + ///Number of the chart subwindow. For the first case, the default value is 0 (main chart window). The most of the properties do not require a subwindow number. + /// + ///The value of double type. + /// + public double ChartGetDouble(long chartId, ENUM_CHART_PROPERTY_DOUBLE propId, int subWindow = 0) + { + var commandParameters = new ArrayList { chartId, (int)propId, subWindow }; + return SendCommand(Mt5CommandType.ChartGetDouble, commandParameters); + } + + /// + ///Returns the value of a corresponding property of the specified chart. Chart property must be of datetime, int or bool type. + /// + ///Chart ID. 0 means the current chart. + ///Chart property ID. This value can be one of the ENUM_CHART_PROPERTY_INTEGER values. + ///Number of the chart subwindow. For the first case, the default value is 0 (main chart window). The most of the properties do not require a subwindow number. + /// + ///The value of long type. + /// + public long ChartGetInteger(long chartId, ENUM_CHART_PROPERTY_INTEGER propId, int subWindow = 0) + { + var commandParameters = new ArrayList { chartId, (int)propId, subWindow }; + return SendCommand(Mt5CommandType.ChartGetInteger, commandParameters); + } + + /// + ///Returns the value of a corresponding property of the specified chart. Chart property must be of string type. + /// + ///Chart ID. 0 means the current chart. + ///Chart property ID. This value can be one of the ENUM_CHART_PROPERTY_STRING values. + /// + ///The value of string type. + /// + public string ChartGetString(long chartId, ENUM_CHART_PROPERTY_STRING propId) + { + var commandParameters = new ArrayList { chartId, (int)propId }; + return SendCommand(Mt5CommandType.ChartGetString, commandParameters); + } + + /// + ///Performs shift of the specified chart by the specified number of bars relative to the specified position in the chart. + /// + ///Chart ID. 0 means the current chart. + ///Chart position to perform a shift. Can be one of the ENUM_CHART_POSITION values. + ///Number of bars to shift the chart. Positive value means the right shift (to the end of chart), negative value means the left shift (to the beginning of chart). The zero shift can be used to navigate to the beginning or end of chart. + /// + ///Returns true if successful, otherwise returns false. + /// + public bool ChartNavigate(long chartId, int position, int shift = 0) + { + var commandParameters = new ArrayList { chartId, position, shift }; + return SendCommand(Mt5CommandType.ChartNavigate, commandParameters); + } + + /// + ///Performs shift of the specified chart by the specified number of bars relative to the specified position in the chart. + /// + ///Chart ID. 0 means the current chart. + ///Number of the chart subwindow. 0 denotes the main chart subwindow. + ///The short name of the indicator which is set in the INDICATOR_SHORTNAME property with the IndicatorSetString() function. To get the short name of an indicator use the ChartIndicatorName() function. + /// + ///Returns true if the command has been added to chart queue, otherwise false. + /// + public bool ChartIndicatorDelete(long chartId, int subWindow, string indicatorShortname) + { + var commandParameters = new ArrayList { chartId, subWindow, indicatorShortname }; + return SendCommand(Mt5CommandType.ChartIndicatorDelete, commandParameters); + } + + /// + ///Returns the short name of the indicator by the number in the indicators list on the specified chart window. + /// + ///Chart ID. 0 means the current chart. + ///Number of the chart subwindow. 0 denotes the main chart subwindow. + ///the index of the indicator in the list of indicators. The numeration of indicators start with zero, i.e. the first indicator in the list has the 0 index. To obtain the number of indicators in the list use the ChartIndicatorsTotal() function. + /// + ///The short name of the indicator which is set in the INDICATOR_SHORTNAME property with the IndicatorSetString() function. + /// + public string ChartIndicatorName(long chartId, int subWindow, int index) + { + var commandParameters = new ArrayList { chartId, subWindow, index }; + return SendCommand(Mt5CommandType.ChartIndicatorName, commandParameters); + } + + /// + ///Returns the number of all indicators applied to the specified chart window. + /// + ///Chart ID. 0 means the current chart. + ///Number of the chart subwindow. 0 denotes the main chart subwindow. + /// + ///The number of indicators in the specified chart window. + /// + public int ChartIndicatorsTotal(long chartId, int subWindow) + { + var commandParameters = new ArrayList { chartId, subWindow }; + return SendCommand(Mt5CommandType.ChartIndicatorsTotal, commandParameters); + } + + /// + ///Returns the number (index) of the chart subwindow the Expert Advisor or script has been dropped to. 0 means the main chart window. + /// + public int ChartWindowOnDropped() + { + return SendCommand(Mt5CommandType.ChartWindowOnDropped, null); + } + + /// + ///Returns the price coordinate corresponding to the chart point the Expert Advisor or script has been dropped to. + /// + public double ChartPriceOnDropped() + { + return SendCommand(Mt5CommandType.ChartPriceOnDropped, null); + } + + /// + ///Returns the time coordinate corresponding to the chart point the Expert Advisor or script has been dropped to. + /// + public DateTime ChartTimeOnDropped() + { + var res = SendCommand(Mt5CommandType.ChartTimeOnDropped, null); + return Mt5TimeConverter.ConvertFromMtTime(res); + } + + /// + ///Returns the X coordinate of the chart point the Expert Advisor or script has been dropped to. + /// + public int ChartXOnDropped() + { + return SendCommand(Mt5CommandType.ChartXOnDropped, null); + } + + /// + ///Returns the Y coordinateof the chart point the Expert Advisor or script has been dropped to. + /// + public int ChartYOnDropped() + { + return SendCommand(Mt5CommandType.ChartYOnDropped, null); + } + + /// + ///Changes the symbol and period of the specified chart. The function is asynchronous, i.e. it sends the command and does not wait for its execution completion. + /// + ///Chart ID. 0 means the current chart. + ///Chart symbol. NULL value means the current chart symbol (Expert Advisor is attached to) + ///Chart period (timeframe). Can be one of the ENUM_TIMEFRAMES values. 0 means the current chart period. + /// + ///Returns true if the command has been added to chart queue, otherwise false. + /// + public bool ChartSetSymbolPeriod(long chartId, string symbol, ENUM_TIMEFRAMES period) + { + var commandParameters = new ArrayList { chartId, symbol, (int)period }; + return SendCommand(Mt5CommandType.ChartSetSymbolPeriod, commandParameters); + } + + /// + ///Saves current chart screen shot as a GIF, PNG or BMP file depending on specified extension. + /// + ///Chart ID. 0 means the current chart. + ///Screenshot file name. Cannot exceed 63 characters. Screenshot files are placed in the \Files directory. + ///Screenshot width in pixels. + ///Screenshot height in pixels. + ///Output mode of a narrow screenshot. + /// + ///Returns true if the command has been added to chart queue, otherwise false. + /// + public bool ChartScreenShot(long chartId, string filename, int width, int height, ENUM_ALIGN_MODE alignMode = ENUM_ALIGN_MODE.ALIGN_RIGHT) + { + var commandParameters = new ArrayList { chartId, filename, width, height, (int)alignMode }; + return SendCommand(Mt5CommandType.ChartScreenShot, commandParameters); + } + + /// + ///Returns the amount of bars visible on the chart. + /// + /// + ///The amount of bars visible on the chart. + /// + public int WindowBarsPerChart() + { + return SendCommand(Mt5CommandType.WindowBarsPerChart, null); + } + + /// + ///Returns the name of the executed Expert Advisor, script, custom indicator, or library. + /// + /// + ///The name of the executed Expert Advisor, script, custom indicator, or library, depending on the MQL4 program, from which this function has been called. + /// + public string WindowExpertName() + { + return SendCommand(Mt5CommandType.WindowExpertName, null); + } + + /// + ///Returns the window index containing this specified indicator. + /// + ///Indicator short name. + /// + ///If indicator with name was found, the function returns the window index containing this specified indicator, otherwise it returns -1. + /// + public int WindowFind(string name) + { + var commandParameters = new ArrayList { name }; + return SendCommand(Mt5CommandType.WindowFind, commandParameters); + } + + /// + ///Returns index of the first visible bar in the current chart window. + /// + /// + ///Index of the first visible bar number in the current chart window. + /// + public int WindowFirstVisibleBar() + { + return SendCommand(Mt5CommandType.WindowFirstVisibleBar, null); + } + + /// + ///Returns the system handle of the chart window. + /// + ///Symbol. + ///Timeframe. It can be any of Timeframe enumeration values. 0 means the current chart timeframe. + /// + ///Returns the system handle of the chart window. If the chart of symbol and timeframe has not been opened by the moment of function calling, 0 will be returned. + /// + public int WindowHandle(string symbol, int timeframe) + { + var commandParameters = new ArrayList { symbol, timeframe }; + return SendCommand(Mt5CommandType.WindowHandle, commandParameters); + } + + /// + ///Returns the visibility flag of the chart subwindow. + /// + ///Subwindow index. + /// + ///Returns true if the chart subwindow is visible, otherwise returns false. The chart subwindow can be hidden due to the visibility properties of the indicator placed in it. + /// + public bool WindowIsVisible(int index) + { + var commandParameters = new ArrayList { index }; + return SendCommand(Mt5CommandType.WindowIsVisible, commandParameters); + } + + /// + ///Returns the window index where Expert Advisor, custom indicator or script was dropped. + /// + /// + ///The window index where Expert Advisor, custom indicator or script was dropped. This value is valid if the Expert Advisor, custom indicator or script was dropped by mouse. + /// + public int WindowOnDropped() + { + return SendCommand(Mt5CommandType.WindowOnDropped, null); + } + + /// + ///Returns the maximal value of the vertical scale of the specified subwindow of the current chart. + /// + ///Chart subwindow index (0 - main chart window). + /// + ///The maximal value of the vertical scale of the specified subwindow of the current chart. + /// + public int WindowPriceMax(int index = 0) + { + var commandParameters = new ArrayList { index }; + return SendCommand(Mt5CommandType.WindowPriceMax, commandParameters); + } + + /// + ///Returns the minimal value of the vertical scale of the specified subwindow of the current chart. + /// + ///Chart subwindow index (0 - main chart window). + /// + ///The minimal value of the vertical scale of the specified subwindow of the current chart. + /// + public int WindowPriceMin(int index = 0) + { + var commandParameters = new ArrayList { index }; + return SendCommand(Mt5CommandType.WindowPriceMin, commandParameters); + } + + /// + ///Returns the price of the chart point where Expert Advisor or script was dropped. + /// + /// + ///The price of the chart point where Expert Advisor or script was dropped. This value is only valid if the expert or script was dropped by mouse. + /// + public double WindowPriceOnDropped() + { + return SendCommand(Mt5CommandType.WindowPriceOnDropped, null); + } + + /// + ///Redraws the current chart forcedly. + /// + /// + ///Redraws the current chart forcedly. It is normally used after the objects properties have been changed. + /// + public void WindowRedraw() + { + SendCommand(Mt5CommandType.WindowRedraw, null); + } + + /// + ///Saves current chart screen shot as a GIF file. + /// + ///Screen shot file name. Screenshot is saved to \Files folder. + ///Screen shot width in pixels. + ///Screen shot height in pixels. + ///Index of the first visible bar in the screen shot. If 0 value is set, the current first visible bar will be shot. If no value or negative value has been set, the end-of-chart screen shot will be produced, indent being taken into consideration. + ///Horizontal chart scale for screen shot. Can be in the range from 0 to 5. If no value or negative value has been set, the current chart scale will be used. + /// Chart displaying mode. It can take the following values: CHART_BAR (0 is a sequence of bars), CHART_CANDLE (1 is a sequence of candlesticks), CHART_LINE (2 is a close prices line). If no value or negative value has been set, the chart will be shown in its current mode. + /// + ///Returns true if succeed, otherwise false. + /// + public bool WindowScreenShot(string filename, int sizeX, int sizeY, int startBar = -1, int chartScale = -1, int chartMode = -1) + { + var commandParameters = new ArrayList { filename, sizeX, sizeY, startBar, chartScale, chartMode }; + return SendCommand(Mt5CommandType.WindowScreenShot, commandParameters); + } + + /// + ///Returns the time of the chart point where Expert Advisor or script was dropped. + /// + /// + ///The time value of the chart point where expert or script was dropped. This value is only valid if the expert or script was dropped by mouse. + /// + public DateTime WindowTimeOnDropped() + { + var res = SendCommand(Mt5CommandType.WindowTimeOnDropped, null); + return Mt5TimeConverter.ConvertFromMtTime(res); + } + + /// + ///Returns total number of indicator windows on the chart. + /// + /// + ///Total number of indicator windows on the chart (including main chart). + /// + public int WindowsTotal() + { + return SendCommand(Mt5CommandType.WindowsTotal, null); + } + + /// + ///Returns the value at X axis in pixels for the chart window client area point at which the Expert Advisor or script was dropped. + /// + /// + ///The value at X axis in pixels for the chart window client area point at which the expert or script was dropped. The value will be true only if the expert or script were moved with the mouse ("Drag'n'Drop") technique. + /// + public int WindowXOnDropped() + { + return SendCommand(Mt5CommandType.WindowXOnDropped, null); + } + + /// + ///Returns the value at Y axis in pixels for the chart window client area point at which the Expert Advisor or script was dropped. + /// + /// + ///Returns the value at Y axis in pixels for the chart window client area point at which the Expert Advisor or script was dropped. The value will be true only if the expert or script were moved with the mouse ("Drag'n'Drop") technique. + /// + public int WindowYOnDropped() + { + return SendCommand(Mt5CommandType.WindowYOnDropped, null); + } + #endregion + + #region Commands of Terminal + /// + ///Returns the value of a corresponding property of the mql4 program environment. + /// + ///Identifier of a property. Can be one of the values of the ENUM_TERMINAL_INFO_STRING enumeration. + /// + ///Value of string type. + /// + public string TerminalInfoString(ENUM_TERMINAL_INFO_STRING propertyId) + { + var commandParameters = new ArrayList { (int)propertyId }; + return SendCommand(Mt5CommandType.TerminalInfoString, commandParameters); + } + + /// + ///Returns the value of a corresponding property of the mql4 program environment. + /// + ///Identifier of a property. Can be one of the values of the ENUM_TERMINAL_INFO_INTEGER enumeration. + /// + ///Value of int type. + /// + public int TerminalInfoInteger(ENUM_TERMINAL_INFO_INTEGER propertyId) + { + var commandParameters = new ArrayList { (int)propertyId }; + return SendCommand(Mt5CommandType.TerminalInfoInteger, commandParameters); + } + + /// + ///Returns the value of a corresponding property of the mql4 program environment. + /// + ///Identifier of a property. Can be one of the values of the ENUM_TERMINAL_INFO_DOUBLE enumeration. + /// + ///Value of double type. + /// + public double TerminalInfoDouble(ENUM_TERMINAL_INFO_DOUBLE propertyId) + { + var commandParameters = new ArrayList { (int)propertyId }; + return SendCommand(Mt5CommandType.TerminalInfoDouble, commandParameters); + } + #endregion + + #region Common Functions /// ///It enters a message in the Expert Advisor log. diff --git a/TestClients/MtApi5TestClient/MainWindow.xaml b/TestClients/MtApi5TestClient/MainWindow.xaml index 44990044..8420e45c 100755 --- a/TestClients/MtApi5TestClient/MainWindow.xaml +++ b/TestClients/MtApi5TestClient/MainWindow.xaml @@ -415,7 +415,13 @@