diff --git a/MtApi5/Mt5CommandType.cs b/MtApi5/Mt5CommandType.cs
index 873f029e..eabaa3dd 100755
--- a/MtApi5/Mt5CommandType.cs
+++ b/MtApi5/Mt5CommandType.cs
@@ -171,6 +171,12 @@ namespace MtApi5
iTriX = 123,
iWPR = 124,
iVIDyA = 125,
- iVolumes = 126
+ iVolumes = 126,
+
+ //Date and Time
+ TimeCurrent = 127,
+ TimeTradeServer = 128,
+ TimeLocal = 129,
+ TimeGMT = 130
}
}
diff --git a/MtApi5/MtApi5Client.cs b/MtApi5/MtApi5Client.cs
index 358c7350..ca805000 100755
--- a/MtApi5/MtApi5Client.cs
+++ b/MtApi5/MtApi5Client.cs
@@ -1667,8 +1667,6 @@ namespace MtApi5
#region Technical Indicators
- #endregion //Technical Indicators
-
///
///The function creates Accelerator Oscillator in a global cache of the client terminal and returns its handle.
///
@@ -2196,6 +2194,7 @@ namespace MtApi5
///input-parameters of a custom indicator. If there is no parameters specified, then default values will be used.
public int iCustom(string symbol, ENUM_TIMEFRAMES period, string name, double[] parameters)
{
+ Log.Debug("iCustom: called.");
var response = SendRequest(new ICustomRequest
{
Symbol = symbol,
@@ -2204,6 +2203,7 @@ namespace MtApi5
Params = new ArrayList(parameters),
ParamsType = ICustomRequest.ParametersType.Double
});
+ Log.Debug($"iCustom: response = {response}.");
return response;
}
@@ -2216,6 +2216,7 @@ namespace MtApi5
///input-parameters of a custom indicator. If there is no parameters specified, then default values will be used.
public int iCustom(string symbol, ENUM_TIMEFRAMES period, string name, int[] parameters)
{
+ Log.Debug("iCustom: called.");
var response = SendRequest(new ICustomRequest
{
Symbol = symbol,
@@ -2224,6 +2225,7 @@ namespace MtApi5
Params = new ArrayList(parameters),
ParamsType = ICustomRequest.ParametersType.Int
});
+ Log.Debug($"iCustom: response = {response}.");
return response;
}
@@ -2236,6 +2238,7 @@ namespace MtApi5
///input-parameters of a custom indicator. If there is no parameters specified, then default values will be used.
public int iCustom(string symbol, ENUM_TIMEFRAMES period, string name, string[] parameters)
{
+ Log.Debug("iCustom: called.");
var response = SendRequest(new ICustomRequest
{
Symbol = symbol,
@@ -2244,6 +2247,7 @@ namespace MtApi5
Params = new ArrayList(parameters),
ParamsType = ICustomRequest.ParametersType.Int
});
+ Log.Debug($"iCustom: response = {response}.");
return response;
}
@@ -2256,6 +2260,7 @@ namespace MtApi5
///input-parameters of a custom indicator. If there is no parameters specified, then default values will be used.
public int iCustom(string symbol, ENUM_TIMEFRAMES period, string name, bool[] parameters)
{
+ Log.Debug("iCustom: called.");
var response = SendRequest(new ICustomRequest
{
Symbol = symbol,
@@ -2264,9 +2269,60 @@ namespace MtApi5
Params = new ArrayList(parameters),
ParamsType = ICustomRequest.ParametersType.Int
});
+ Log.Debug($"iCustom: response = {response}.");
return response;
}
+ #endregion //Technical Indicators
+
+ #region Date and Time
+
+ ///
+ ///Returns the last known server time, time of the last quote receipt for one of the symbols selected in the "Market Watch" window.
+ ///
+ public DateTime TimeCurrent()
+ {
+ Log.Debug("TimeCurrent: called.");
+ var response = SendCommand(Mt5CommandType.TimeCurrent, null);
+ Log.Debug($"TimeCurrent: response = {response}.");
+ return Mt5TimeConverter.ConvertFromMtTime(response);
+ }
+
+ ///
+ ///Returns the calculated current time of the trade server. Unlike TimeCurrent(), the calculation of the time value is performed in the client terminal and depends on the time settings on your computer.
+ ///
+ public DateTime TimeTradeServer()
+ {
+ Log.Debug("TimeTradeServer: called.");
+ var response = SendCommand(Mt5CommandType.TimeTradeServer, null);
+ Log.Debug($"TimeTradeServer: response = {response}.");
+ return Mt5TimeConverter.ConvertFromMtTime(response);
+ }
+
+ ///
+ ///Returns the local time of a computer, where the client terminal is running.
+ ///
+ public DateTime TimeLocal()
+ {
+ Log.Debug("TimeLocal: called.");
+ var response = SendCommand(Mt5CommandType.TimeLocal, null);
+ Log.Debug($"TimeLocal: response = {response}.");
+ return Mt5TimeConverter.ConvertFromMtTime(response);
+ }
+
+ ///
+ ///Returns the GMT, which is calculated taking into account the DST switch by the local time on the computer where the client terminal is running.
+ ///
+ public DateTime TimeGMT()
+ {
+ Log.Debug("TimeGMT: called.");
+ var response = SendCommand(Mt5CommandType.TimeGMT, null);
+ Log.Debug($"TimeGMT: response = {response}.");
+ return Mt5TimeConverter.ConvertFromMtTime(response);
+ }
+
+ #endregion //Date and Time
+
#endregion // Public Methods
#region Properties
diff --git a/TestClients/MtApi5TestClient/MainWindow.xaml b/TestClients/MtApi5TestClient/MainWindow.xaml
index 0c58f62f..13c800ac 100755
--- a/TestClients/MtApi5TestClient/MainWindow.xaml
+++ b/TestClients/MtApi5TestClient/MainWindow.xaml
@@ -389,6 +389,15 @@
+
+
+
+
+
+
+
+
+
diff --git a/TestClients/MtApi5TestClient/ViewModel.cs b/TestClients/MtApi5TestClient/ViewModel.cs
index 8079ecbd..18fd5329 100755
--- a/TestClients/MtApi5TestClient/ViewModel.cs
+++ b/TestClients/MtApi5TestClient/ViewModel.cs
@@ -60,6 +60,11 @@ namespace MtApi5TestClient
public DelegateCommand PrintCommand { get; private set; }
public DelegateCommand iCustomCommand { get; private set; }
+
+ public DelegateCommand TimeCurrentCommand { get; private set; }
+ public DelegateCommand TimeTradeServerCommand { get; private set; }
+ public DelegateCommand TimeLocalCommand { get; private set; }
+ public DelegateCommand TimeGMTCommand { get; private set; }
#endregion
#region Properties
@@ -246,6 +251,11 @@ namespace MtApi5TestClient
PrintCommand = new DelegateCommand(ExecutePrint);
iCustomCommand = new DelegateCommand(ExecuteICustom);
+
+ TimeCurrentCommand = new DelegateCommand(ExecuteTimeCurrent);
+ TimeTradeServerCommand = new DelegateCommand(ExecuteTimeTradeServer);
+ TimeLocalCommand = new DelegateCommand(ExecuteTimeLocal);
+ TimeGMTCommand = new DelegateCommand(ExecuteTimeGMT);
}
private bool CanExecuteConnect(object o)
@@ -866,6 +876,30 @@ namespace MtApi5TestClient
AddLog($"Custom Moving Average: result - {retVal}");
}
+ private async void ExecuteTimeCurrent(object o)
+ {
+ var retVal = await Execute(() => _mtApiClient.TimeCurrent());
+ AddLog($"TimeCurrent: {retVal}");
+ }
+
+ private async void ExecuteTimeTradeServer(object o)
+ {
+ var retVal = await Execute(() => _mtApiClient.TimeTradeServer());
+ AddLog($"TimeTradeServer: {retVal}");
+ }
+
+ private async void ExecuteTimeLocal(object o)
+ {
+ var retVal = await Execute(() => _mtApiClient.TimeLocal());
+ AddLog($"TimeLocal: {retVal}");
+ }
+
+ private async void ExecuteTimeGMT(object o)
+ {
+ var retVal = await Execute(() => _mtApiClient.TimeGMT());
+ AddLog($"TimeGMT: {retVal}");
+ }
+
private static void RunOnUiThread(Action action)
{
Application.Current?.Dispatcher.Invoke(action);
diff --git a/mq5/MtApi5.ex5 b/mq5/MtApi5.ex5
index 582a6bd7..c9270526 100755
Binary files a/mq5/MtApi5.ex5 and b/mq5/MtApi5.ex5 differ
diff --git a/mq5/MtApi5.mq5 b/mq5/MtApi5.mq5
index 8c709851..456a4eba 100755
--- a/mq5/MtApi5.mq5
+++ b/mq5/MtApi5.mq5
@@ -489,9 +489,9 @@ int executeCommand()
case 65: //PositionOpen
Execute_PositionOpen(false);
break;
- case 1065: //PositionOpenWithResult
- Execute_PositionOpen(true);
- break;
+// case 1065: //PositionOpenWithResult
+// Execute_PositionOpen(true);
+// break;
case 66: //BacktestingReady
Execute_BacktestingReady();
break;
@@ -665,6 +665,18 @@ int executeCommand()
case 126: //iVolumes
Execute_iVolumes();
break;
+ case 127: //TimeCurrent
+ Execute_TimeCurrent();
+ break;
+ case 128: //TimeTradeServer
+ Execute_TimeTradeServer();
+ break;
+ case 129: //TimeLocal
+ Execute_TimeLocal();
+ break;
+ case 130: //TimeGMT
+ Execute_TimeGMT();
+ break;
default:
Print("Unknown command type = ", commandType);
sendVoidResponse(ExpertHandle, _response_error);
@@ -5427,6 +5439,38 @@ void Execute_iVolumes()
PrintResponseError("iVolumes", _response_error);
}
}
+
+void Execute_TimeCurrent()
+{
+ if (!sendLongResponse(ExpertHandle, TimeCurrent(), _response_error))
+ {
+ PrintResponseError("TimeCurrent", _response_error);
+ }
+}
+
+void Execute_TimeTradeServer()
+{
+ if (!sendLongResponse(ExpertHandle, TimeTradeServer(), _response_error))
+ {
+ PrintResponseError("TimeTradeServer", _response_error);
+ }
+}
+
+void Execute_TimeLocal()
+{
+ if (!sendLongResponse(ExpertHandle, TimeLocal(), _response_error))
+ {
+ PrintResponseError("TimeLocal", _response_error);
+ }
+}
+
+void Execute_TimeGMT()
+{
+ if (!sendLongResponse(ExpertHandle, TimeGMT(), _response_error))
+ {
+ PrintResponseError("TimeGMT", _response_error);
+ }
+}
void PrintParamError(string paramName)
{