diff --git a/MT5Connector/MT5Connector.cpp b/MT5Connector/MT5Connector.cpp index d350c291..68dfe1f4 100755 --- a/MT5Connector/MT5Connector.cpp +++ b/MT5Connector/MT5Connector.cpp @@ -164,7 +164,7 @@ _DLLAPI int _stdcall sendStringResponse(int expertHandle, wchar_t* response, wch _DLLAPI int _stdcall sendVoidResponse(int expertHandle, wchar_t* err) { return Execute([&expertHandle]() { - MtAdapter::GetInstance()->SendResponse(expertHandle, nullptr); + MtAdapter::GetInstance()->SendResponse(expertHandle, gcnew MtResponseObject(nullptr)); return 1; }, err, 0); } diff --git a/MtApi5/MqlBookInfo.cs b/MtApi5/MqlBookInfo.cs index 5a3c1d87..d1e4be8e 100755 --- a/MtApi5/MqlBookInfo.cs +++ b/MtApi5/MqlBookInfo.cs @@ -10,13 +10,16 @@ namespace MtApi5 this.volume = volume; } - public ENUM_BOOK_TYPE type { get; } // Order type from ENUM_BOOK_TYPE enumeration - public double price { get; } // Price - public long volume { get; } // Volume + public MqlBookInfo() + { } + + public ENUM_BOOK_TYPE type { get; set; } // Order type from ENUM_BOOK_TYPE enumeration + public double price { get; set; } // Price + public long volume { get; set; } // Volume public override string ToString() { - return $"{type}|{price}|{volume}"; + return $"type = {type}; price = {price}; volume = {volume}"; } } } diff --git a/MtApi5/MqlTradeCheckResult.cs b/MtApi5/MqlTradeCheckResult.cs index 5b5f5cad..11d18e42 100755 --- a/MtApi5/MqlTradeCheckResult.cs +++ b/MtApi5/MqlTradeCheckResult.cs @@ -4,14 +4,14 @@ namespace MtApi5 { public class MqlTradeCheckResult { - public uint Retcode { get; } // Reply code - public double Balance { get; } // Balance after the execution of the deal - public double Equity { get; } // Equity after the execution of the deal - public double Profit { get; } // Floating profit - public double Margin { get; } // Margin requirements - public double Margin_free { get; } // Free margin - public double Margin_level { get; } // Margin level - public string Comment { get; } // Comment to the reply code (description of the error) + public uint Retcode { get; set; } // Reply code + public double Balance { get; set; } // Balance after the execution of the deal + public double Equity { get; set; } // Equity after the execution of the deal + public double Profit { get; set; } // Floating profit + public double Margin { get; set; } // Margin requirements + public double Margin_free { get; set; } // Free margin + public double Margin_level { get; set; } // Margin level + public string Comment { get; set; } // Comment to the reply code (description of the error) public MqlTradeCheckResult(uint retcode , double balance @@ -32,6 +32,9 @@ namespace MtApi5 Comment = comment; } + public MqlTradeCheckResult() + { } + public override string ToString() { return $"Retcode={Retcode}; Comment={Comment}; Balance={Balance}; Equity={Equity}; Profit={Profit}; Margin={Margin}; Margin_free={Margin_free}; Margin_level={Margin_level}"; diff --git a/MtApi5/Mt5CommandType.cs b/MtApi5/Mt5CommandType.cs index a080d0a9..62f3dd5f 100755 --- a/MtApi5/Mt5CommandType.cs +++ b/MtApi5/Mt5CommandType.cs @@ -9,7 +9,6 @@ namespace MtApi5 //OrderSend = 1, OrderCalcMargin = 2, OrderCalcProfit = 3, - //OrderCheck = 4, //OrderSendAsync = 5, PositionsTotal = 6, PositionGetSymbol = 7, @@ -17,6 +16,7 @@ namespace MtApi5 PositionGetDouble = 9, PositionGetInteger = 10, PositionGetString = 11, + PositionGetTicket = 4, OrdersTotal = 12, OrderGetTicket = 13, OrderSelect = 14, @@ -107,8 +107,6 @@ namespace MtApi5 BacktestingReady = 66, IsTesting = 67, - Print = 68, - //Requests MtRequest = 155, @@ -237,9 +235,24 @@ namespace MtApi5 TerminalCompany = 68, TerminalName = 69, TerminalPath = 70, - TerminalInfoString = 153, - TerminalInfoInteger = 204, - TerminalInfoDouble = 205, + //Checkup + GetLastError = 132, + TerminalInfoString = 153, //TODO + TerminalInfoInteger = 204, //TODO + TerminalInfoDouble = 205, //TODO + + //Common Functions + Alert = 136, //TODO + Comment = 137, //TODO + GetTickCount = 138, //TODO + GetMicrosecondCount = 139, //TODO + MessageBox = 140, //TODO + PeriodSeconds = 141, //TODO + PlaySound = 142, //TODO + Print = 68, + ResetLastError = 143, + SendNotification = 144, //TODO + SendMail = 145 //TODO } } diff --git a/MtApi5/MtApi5Client.cs b/MtApi5/MtApi5Client.cs index cadd5f92..c49ac754 100755 --- a/MtApi5/MtApi5Client.cs +++ b/MtApi5/MtApi5Client.cs @@ -280,6 +280,17 @@ namespace MtApi5 return SendCommand(Mt5CommandType.PositionGetString, commandParameters); } + /// + ///The function returns the ticket of a position with the specified index in the list of open positions and automatically selects the position to work with using functions PositionGetDouble, PositionGetInteger, PositionGetString. + /// + ///Identifier of a position property. + public ulong PositionGetTicket(int index) + { + var commandParameters = new ArrayList { index }; + + return SendCommand(Mt5CommandType.PositionGetTicket, commandParameters); + } + /// ///Returns the number of current orders. /// @@ -611,11 +622,11 @@ namespace MtApi5 ///Symbol name. /// Period. ///Identifier of the requested property, value of the ENUM_SERIES_INFO_INTEGER enumeration. - public int SeriesInfoInteger(string symbolName, ENUM_TIMEFRAMES timeframe, ENUM_SERIES_INFO_INTEGER propId) + public long SeriesInfoInteger(string symbolName, ENUM_TIMEFRAMES timeframe, ENUM_SERIES_INFO_INTEGER propId) { var commandParameters = new ArrayList { symbolName, (int)timeframe, (int)propId }; - return SendCommand(Mt5CommandType.SeriesInfoInteger, commandParameters); + return SendCommand(Mt5CommandType.SeriesInfoInteger, commandParameters); } /// @@ -3006,6 +3017,26 @@ namespace MtApi5 #endregion //Date and Time + #region Checkup + + /// + ///Returns the value of the last error that occurred during the execution of an mql5 program. + /// + public int GetLastError() + { + return SendCommand(Mt5CommandType.GetLastError, null); + } + + /// + ///Sets the value of the predefined variable _LastError into zero. + /// + public void ResetLastError() + { + SendCommand(Mt5CommandType.ResetLastError, null); + } + + #endregion + #endregion // Public Methods #region Properties diff --git a/MtApi5/Properties/AssemblyInfo.cs b/MtApi5/Properties/AssemblyInfo.cs index 6c9ae86f..2eaad9a8 100755 --- a/MtApi5/Properties/AssemblyInfo.cs +++ b/MtApi5/Properties/AssemblyInfo.cs @@ -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.17")] -[assembly: AssemblyFileVersion("1.0.17")] +[assembly: AssemblyVersion("1.0.18")] +[assembly: AssemblyFileVersion("1.0.18")] diff --git a/TestClients/MtApi5TestClient/MainWindow.xaml b/TestClients/MtApi5TestClient/MainWindow.xaml index deba1b3e..8420e45c 100755 --- a/TestClients/MtApi5TestClient/MainWindow.xaml +++ b/TestClients/MtApi5TestClient/MainWindow.xaml @@ -240,6 +240,7 @@