mirror of
https://github.com/vdemydiuk/mtapi.git
synced 2026-08-24 08:08:18 +00:00
Issue #31: Implemented function TerminalInfoInteger in MtApi MT4
This commit is contained in:
Executable
+27
@@ -0,0 +1,27 @@
|
||||
namespace MtApi
|
||||
{
|
||||
// https://docs.mql4.com/constants/environment_state/terminalstatus#enum_terminal_info_integer
|
||||
public enum EnumTerminalInfoInteger
|
||||
{
|
||||
TERMINAL_BUILD = 5, // The client terminal build number
|
||||
TERMINAL_COMMUNITY_ACCOUNT = 23, // The flag indicates the presence of MQL5.community authorization data in the terminal
|
||||
TERMINAL_COMMUNITY_CONNECTION = 24, // Connection to MQL5.community
|
||||
TERMINAL_CONNECTED = 6, // Connection to a trade server
|
||||
TERMINAL_DLLS_ALLOWED = 7, // Permission to use DLL
|
||||
TERMINAL_TRADE_ALLOWED = 8, // Permission to trade
|
||||
TERMINAL_EMAIL_ENABLED = 9, // Permission to send e-mails using SMTP-server and login, specified in the terminal settings
|
||||
TERMINAL_FTP_ENABLED = 10, // Permission to send reports using FTP-server and login, specified in the terminal settings
|
||||
TERMINAL_NOTIFICATIONS_ENABLED = 26, // Permission to send notifications to smartphone
|
||||
TERMINAL_MAXBARS = 11, // The maximal bars count on the chart
|
||||
TERMINAL_MQID = 22, // The flag indicates the presence of MetaQuotes ID data to send Push notifications
|
||||
TERMINAL_CODEPAGE = 12, // Number of the code page of the language installed in the client terminal
|
||||
TERMINAL_CPU_CORES = 21, // The number of CPU cores in the system
|
||||
TERMINAL_DISK_SPACE = 20, // Free disk space for the MQL4\Files folder of the terminal, Mb
|
||||
TERMINAL_MEMORY_PHYSICAL = 14, // Physical memory in the system, Mb
|
||||
TERMINAL_MEMORY_TOTAL = 15, // Memory available to the process of the terminal , Mb
|
||||
TERMINAL_MEMORY_AVAILABLE = 16, // Free memory of the terminal process, Mb
|
||||
TERMINAL_MEMORY_USED = 17, // Memory used by the terminal , Mb
|
||||
TERMINAL_SCREEN_DPI = 27, // The resolution of information display on the screen is measured as number of Dots in a line per Inch (DPI). Knowing the parameter value, you can set the size of graphical objects so that they look the same on monitors with different resolution characteristics.
|
||||
TERMINAL_PING_LAST = 28 // The last known value of a ping to a trade server in microseconds. One second comprises of one million microseconds
|
||||
}
|
||||
}
|
||||
@@ -62,6 +62,7 @@
|
||||
<Compile Include="EnumSeriesInfoInteger.cs" />
|
||||
<Compile Include="EnumSymbolInfoDouble.cs" />
|
||||
<Compile Include="EnumSymbolInfoInteger.cs" />
|
||||
<Compile Include="EnumTerminalInfoInteger.cs" />
|
||||
<Compile Include="ExtensionMethods.cs" />
|
||||
<Compile Include="Monitors\AvailabilityOrdersEventArgs.cs" />
|
||||
<Compile Include="MqlRates.cs" />
|
||||
|
||||
+157
-29
@@ -498,79 +498,226 @@ namespace MtApi
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Check Status
|
||||
#region Checkup
|
||||
|
||||
///<summary>
|
||||
///Returns the contents of the system variable _LastError.
|
||||
///After the function call, the contents of _LastError are reset.
|
||||
///</summary>
|
||||
///<returns>
|
||||
///Returns the value of the last error that occurred during the execution of an mql4 program.
|
||||
///</returns>
|
||||
public int GetLastError()
|
||||
{
|
||||
return SendCommand<int>(MtCommandType.GetLastError, null);
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///Checks connection between client terminal and server.
|
||||
///</summary>
|
||||
///<returns>
|
||||
///It returns true if connection to the server was successfully established, otherwise, it returns false.
|
||||
///</returns>
|
||||
public bool IsConnected()
|
||||
{
|
||||
return SendCommand<bool>(MtCommandType.IsConnected, null);
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///Checks if the Expert Advisor runs on a demo account.
|
||||
///</summary>
|
||||
///<returns>
|
||||
///Returns true if the Expert Advisor runs on a demo account, otherwise returns false.
|
||||
///</returns>
|
||||
public bool IsDemo()
|
||||
{
|
||||
return SendCommand<bool>(MtCommandType.IsDemo, null);
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///Checks if the DLL function call is allowed for the Expert Advisor.
|
||||
///</summary>
|
||||
///<returns>
|
||||
///Returns true if the DLL function call is allowed for the Expert Advisor, otherwise returns false.
|
||||
///</returns>
|
||||
public bool IsDllsAllowed()
|
||||
{
|
||||
return SendCommand<bool>(MtCommandType.IsDllsAllowed, null);
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///Checks if Expert Advisors are enabled for running.
|
||||
///</summary>
|
||||
///<returns>
|
||||
///Returns true if Expert Advisors are enabled for running, otherwise returns false.
|
||||
///</returns>
|
||||
public bool IsExpertEnabled()
|
||||
{
|
||||
return SendCommand<bool>(MtCommandType.IsExpertEnabled, null);
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///Checks if the Expert Advisor can call library function.
|
||||
///</summary>
|
||||
///<returns>
|
||||
///Returns true if the Expert Advisor can call library function, otherwise returns false.
|
||||
///</returns>
|
||||
public bool IsLibrariesAllowed()
|
||||
{
|
||||
return SendCommand<bool>(MtCommandType.IsLibrariesAllowed, null);
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///Checks if Expert Advisor runs in the Strategy Tester optimization mode.
|
||||
///</summary>
|
||||
///<returns>
|
||||
///Returns true if Expert Advisor runs in the Strategy Tester optimization mode, otherwise returns false.
|
||||
///</returns>
|
||||
public bool IsOptimization()
|
||||
{
|
||||
return SendCommand<bool>(MtCommandType.IsOptimization, null);
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///Checks the forced shutdown of an mql4 program.
|
||||
///</summary>
|
||||
///<returns>
|
||||
///Returns true, if the _StopFlag system variable contains a value other than 0.
|
||||
///A nonzero value is written into _StopFlag, if a mql4 program has been commanded to complete its operation.
|
||||
///In this case, you must immediately terminate the program, otherwise the program will be completed
|
||||
///forcibly from the outside after 3 seconds.
|
||||
///</returns>
|
||||
public bool IsStopped()
|
||||
{
|
||||
return SendCommand<bool>(MtCommandType.IsStopped, null);
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///Checks if the Expert Advisor runs in the testing mode.
|
||||
///</summary>
|
||||
///<returns>
|
||||
///Returns true if the Expert Advisor runs in the testing mode, otherwise returns false.
|
||||
///</returns>
|
||||
public bool IsTesting()
|
||||
{
|
||||
return SendCommand<bool>(MtCommandType.IsTesting, null);
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///Checks if the Expert Advisor is allowed to trade and trading context is not busy.
|
||||
///</summary>
|
||||
///<returns>
|
||||
///Returns true if the Expert Advisor is allowed to trade and trading context is not busy, otherwise returns false.
|
||||
///</returns>
|
||||
public bool IsTradeAllowed()
|
||||
{
|
||||
return SendCommand<bool>(MtCommandType.IsTradeAllowed, null);
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///Returns the information about trade context.
|
||||
///</summary>
|
||||
///<returns>
|
||||
///Returns true if a thread for trading is occupied by another Expert Advisor, otherwise returns false.
|
||||
///</returns>
|
||||
public bool IsTradeContextBusy()
|
||||
{
|
||||
return SendCommand<bool>(MtCommandType.IsTradeContextBusy, null);
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///Checks if the Expert Advisor is tested in visual mode.
|
||||
///</summary>
|
||||
///<returns>
|
||||
///Returns true if the Expert Advisor is tested with checked "Visual Mode" button, otherwise returns false.
|
||||
///</returns>
|
||||
public bool IsVisualMode()
|
||||
{
|
||||
return SendCommand<bool>(MtCommandType.IsVisualMode, null);
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///Returns the code of a reason for deinitialization.
|
||||
///</summary>
|
||||
///<returns>
|
||||
///Returns the value of _UninitReason which is formed before OnDeinit() is called.
|
||||
///Value depends on the reasons that led to deinitialization.
|
||||
///</returns>
|
||||
public int UninitializeReason()
|
||||
{
|
||||
return SendCommand<int>(MtCommandType.UninitializeReason, null);
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///Print the error description.
|
||||
///</summary>
|
||||
public string ErrorDescription(int errorCode)
|
||||
{
|
||||
var commandParameters = new ArrayList { errorCode };
|
||||
return SendCommand<string>(MtCommandType.ErrorDescription, commandParameters);
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///Returns the value of a corresponding property of the mql4 program environment.
|
||||
///</summary>
|
||||
///<param name="propertyId">Identifier of a property. Can be one of the values of the ENUM_TERMINAL_INFO_STRING enumeration.</param>
|
||||
///<returns>
|
||||
///Value of string type.
|
||||
///</returns>
|
||||
public string TerminalInfoString(ENUM_TERMINAL_INFO_STRING propertyId)
|
||||
{
|
||||
var commandParameters = new ArrayList { (int)propertyId };
|
||||
return SendCommand<string>(MtCommandType.TerminalInfoString, commandParameters);
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///Returns the value of a corresponding property of the mql4 program environment.
|
||||
///</summary>
|
||||
///<param name="propertyId">Identifier of a property. Can be one of the values of the ENUM_TERMINAL_INFO_INTEGER enumeration.</param>
|
||||
///<returns>
|
||||
///Value of int type.
|
||||
///</returns>
|
||||
public int TerminalInfoInteger(EnumTerminalInfoInteger propertyId)
|
||||
{
|
||||
var commandParameters = new ArrayList { (int)propertyId };
|
||||
return SendCommand<int>(MtCommandType.TerminalInfoInteger, commandParameters);
|
||||
}
|
||||
|
||||
//TODO: TerminalInfoDouble
|
||||
|
||||
///<summary>
|
||||
///Returns the name of company owning the client terminal.
|
||||
///</summary>
|
||||
///<returns>
|
||||
///The name of company owning the client terminal.
|
||||
///</returns>
|
||||
public string TerminalCompany()
|
||||
{
|
||||
return SendCommand<string>(MtCommandType.TerminalCompany, null);
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///Returns client terminal name.
|
||||
///</summary>
|
||||
///<returns>
|
||||
///Client terminal name.
|
||||
///</returns>
|
||||
public string TerminalName()
|
||||
{
|
||||
return SendCommand<string>(MtCommandType.TerminalName, null);
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///Returns the directory, from which the client terminal was launched.
|
||||
///</summary>
|
||||
///<returns>
|
||||
///The directory, from which the client terminal was launched.
|
||||
///</returns>
|
||||
public string TerminalPath()
|
||||
{
|
||||
return SendCommand<string>(MtCommandType.TerminalPath, null);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Account Information
|
||||
@@ -732,25 +879,6 @@ namespace MtApi
|
||||
|
||||
#endregion
|
||||
|
||||
#region Client Terminal Functions
|
||||
|
||||
public string TerminalCompany()
|
||||
{
|
||||
return SendCommand<string>(MtCommandType.TerminalCompany, null);
|
||||
}
|
||||
|
||||
public string TerminalName()
|
||||
{
|
||||
return SendCommand<string>(MtCommandType.TerminalName, null);
|
||||
}
|
||||
|
||||
public string TerminalPath()
|
||||
{
|
||||
return SendCommand<string>(MtCommandType.TerminalPath, null);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Date and Time Functions
|
||||
|
||||
public int Day()
|
||||
@@ -1403,6 +1531,15 @@ namespace MtApi
|
||||
return response?.Rates;
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///Returns information about the state of historical data.
|
||||
///</summary>
|
||||
///<param name="symbolName">Symbol name.</param>
|
||||
///<param name="timeframe">Period.</param>
|
||||
///<param name="propId">Identifier of the requested property, value of the ENUM_SERIES_INFO_INTEGER enumeration.</param>
|
||||
///<returns>
|
||||
///Returns value of the long type.
|
||||
///</returns>
|
||||
public long SeriesInfoInteger(string symbolName, ENUM_TIMEFRAMES timeframe, EnumSeriesInfoInteger propId)
|
||||
{
|
||||
var response = SendRequest<SeriesInfoIntegerResponse>(new SeriesInfoIntegerRequest
|
||||
@@ -1417,15 +1554,6 @@ namespace MtApi
|
||||
|
||||
#endregion
|
||||
|
||||
#region Checkup
|
||||
public string TerminalInfoString(ENUM_TERMINAL_INFO_STRING propertyId)
|
||||
{
|
||||
var commandParameters = new ArrayList { (int)propertyId };
|
||||
return SendCommand<string>(MtCommandType.TerminalInfoString, commandParameters);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Market Info
|
||||
|
||||
///<summary>
|
||||
|
||||
@@ -58,6 +58,12 @@ namespace MtApi
|
||||
IsVisualMode = 37,
|
||||
UninitializeReason = 38,
|
||||
ErrorDescription = 39,
|
||||
TerminalCompany = 68,
|
||||
TerminalName = 69,
|
||||
TerminalPath = 70,
|
||||
TerminalInfoString = 153,
|
||||
TerminalInfoInteger = 204,
|
||||
//TerminalInfoDouble = 205,
|
||||
|
||||
//Account Information
|
||||
AccountBalance = 40,
|
||||
@@ -91,11 +97,6 @@ namespace MtApi
|
||||
SendMail = 66,
|
||||
Sleep = 67,
|
||||
|
||||
//Client Terminal
|
||||
TerminalCompany = 68,
|
||||
TerminalName = 69,
|
||||
TerminalPath = 70,
|
||||
|
||||
//Date and Time
|
||||
Day = 71,
|
||||
DayOfWeek = 72,
|
||||
@@ -188,8 +189,6 @@ namespace MtApi
|
||||
//
|
||||
RefreshRates = 150,
|
||||
//
|
||||
TerminalInfoString = 153,
|
||||
SymbolInfoString = 154,
|
||||
|
||||
//Requests
|
||||
MtRequest = 155,
|
||||
@@ -197,7 +196,8 @@ namespace MtApi
|
||||
//Backtesting
|
||||
BacktestingReady = 156,
|
||||
|
||||
//Symbols
|
||||
//Market Info
|
||||
SymbolInfoString = 154,
|
||||
SymbolsTotal = 200,
|
||||
SymbolName = 201,
|
||||
SymbolSelect = 202,
|
||||
|
||||
Regular → Executable
+1
@@ -1,5 +1,6 @@
|
||||
namespace MtApi
|
||||
{
|
||||
// https://docs.mql4.com/constants/errorswarnings/errorcodes
|
||||
public enum MtErrorCode
|
||||
{
|
||||
MtApiCustomError = -1, // Error occurred in MtApi.
|
||||
|
||||
+25
@@ -162,6 +162,8 @@
|
||||
this.label30 = new System.Windows.Forms.Label();
|
||||
this.comboBox8 = new System.Windows.Forms.ComboBox();
|
||||
this.button34 = new System.Windows.Forms.Button();
|
||||
this.button35 = new System.Windows.Forms.Button();
|
||||
this.comboBox9 = new System.Windows.Forms.ComboBox();
|
||||
this.groupBox1.SuspendLayout();
|
||||
this.statusStrip1.SuspendLayout();
|
||||
this.groupBox2.SuspendLayout();
|
||||
@@ -1044,6 +1046,8 @@
|
||||
//
|
||||
// tabPage4
|
||||
//
|
||||
this.tabPage4.Controls.Add(this.comboBox9);
|
||||
this.tabPage4.Controls.Add(this.button35);
|
||||
this.tabPage4.Controls.Add(this.button34);
|
||||
this.tabPage4.Controls.Add(this.comboBox8);
|
||||
this.tabPage4.Controls.Add(this.label30);
|
||||
@@ -1608,6 +1612,25 @@
|
||||
this.button34.UseVisualStyleBackColor = true;
|
||||
this.button34.Click += new System.EventHandler(this.button34_Click);
|
||||
//
|
||||
// button35
|
||||
//
|
||||
this.button35.Location = new System.Drawing.Point(208, 128);
|
||||
this.button35.Name = "button35";
|
||||
this.button35.Size = new System.Drawing.Size(111, 23);
|
||||
this.button35.TabIndex = 33;
|
||||
this.button35.Text = "TerminalInfoInteger";
|
||||
this.button35.UseVisualStyleBackColor = true;
|
||||
this.button35.Click += new System.EventHandler(this.button35_Click);
|
||||
//
|
||||
// comboBox9
|
||||
//
|
||||
this.comboBox9.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.comboBox9.FormattingEnabled = true;
|
||||
this.comboBox9.Location = new System.Drawing.Point(13, 130);
|
||||
this.comboBox9.Name = "comboBox9";
|
||||
this.comboBox9.Size = new System.Drawing.Size(186, 21);
|
||||
this.comboBox9.TabIndex = 34;
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
@@ -1788,6 +1811,8 @@
|
||||
private System.Windows.Forms.Label label30;
|
||||
private System.Windows.Forms.ComboBox comboBox8;
|
||||
private System.Windows.Forms.Button button34;
|
||||
private System.Windows.Forms.Button button35;
|
||||
private System.Windows.Forms.ComboBox comboBox9;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ namespace TestApiClientUI
|
||||
comboBox6.DataSource = Enum.GetNames(typeof(ENUM_TIMEFRAMES));
|
||||
comboBox7.DataSource = Enum.GetNames(typeof(EnumSymbolInfoDouble));
|
||||
comboBox8.DataSource = Enum.GetNames(typeof(MarketInfoModeType));
|
||||
comboBox9.DataSource = Enum.GetNames(typeof(EnumTerminalInfoInteger));
|
||||
|
||||
_apiClient.QuoteUpdated += apiClient_QuoteUpdated;
|
||||
_apiClient.QuoteAdded += apiClient_QuoteAdded;
|
||||
@@ -1264,5 +1265,15 @@ namespace TestApiClientUI
|
||||
PrintLog($"SymbolInfoTick: Tick - time = {result.Time}, Bid = {result.Bid}, Ask = {result.Ask}, Last = {result.Last}, Volume = {result.Volume}");
|
||||
}
|
||||
}
|
||||
|
||||
//TerminalInfoInteger
|
||||
private async void button35_Click(object sender, EventArgs e)
|
||||
{
|
||||
EnumTerminalInfoInteger propId;
|
||||
Enum.TryParse(comboBox9.Text, out propId);
|
||||
|
||||
var result = await Execute(() => _apiClient.TerminalInfoInteger(propId));
|
||||
PrintLog($"TerminalInfoInteger: result = {result}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user