diff --git a/MtApi5/MtApi5Client.cs b/MtApi5/MtApi5Client.cs
index bb01e2fa..6a2e5cab 100755
--- a/MtApi5/MtApi5Client.cs
+++ b/MtApi5/MtApi5Client.cs
@@ -2,6 +2,7 @@
using MtClient;
using MtApi5.MtProtocol;
using MtApi5.MtProtocol.ICustomRequest;
+using System.Data;
namespace MtApi5
{
@@ -188,6 +189,15 @@ namespace MtApi5
}
}
+ ///
+ ///Load symbols
+ ///
+ public List? GetSymbols(bool selected)
+ {
+ Dictionary cmdParams = new() { { "Selected", selected } };
+ return SendCommand>(ExecutorHandle, Mt5CommandType.GetSymbols, cmdParams);
+ }
+
///
///Checks if the Expert Advisor runs in the testing mode..
///
diff --git a/MtApi5/MtProtocol/Mt5CommandType.cs b/MtApi5/MtProtocol/Mt5CommandType.cs
index ba318900..4af91bdb 100755
--- a/MtApi5/MtProtocol/Mt5CommandType.cs
+++ b/MtApi5/MtProtocol/Mt5CommandType.cs
@@ -259,6 +259,7 @@ namespace MtApi5.MtProtocol
OrderSendAsync = 302,
OrderCheck = 303,
Buy = 304,
- Sell = 305
+ Sell = 305,
+ GetSymbols = 306
}
}
diff --git a/TestClients/MtApi5TestClient/MainWindow.xaml b/TestClients/MtApi5TestClient/MainWindow.xaml
index 0a7cdbb4..ec02f639 100755
--- a/TestClients/MtApi5TestClient/MainWindow.xaml
+++ b/TestClients/MtApi5TestClient/MainWindow.xaml
@@ -473,22 +473,34 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/TestClients/MtApi5TestClient/ViewModel.cs b/TestClients/MtApi5TestClient/ViewModel.cs
index 67345750..470c6651 100755
--- a/TestClients/MtApi5TestClient/ViewModel.cs
+++ b/TestClients/MtApi5TestClient/ViewModel.cs
@@ -160,6 +160,8 @@ namespace MtApi5TestClient
public DelegateCommand GlobalVariablesTotalCommand { get; private set; }
public DelegateCommand UnlockTicksCommand { get; private set; }
+
+ public DelegateCommand GetSymbolsCommand { get; private set; }
#endregion
#region Properties
@@ -314,6 +316,19 @@ namespace MtApi5TestClient
OnPropertyChanged("PositionTicketValue");
}
}
+
+ public bool GetSymbolsSelected { get; set; } = false;
+
+ private List _symbols;
+ public List Symbols
+ {
+ get { return _symbols; }
+ set
+ {
+ _symbols = value;
+ OnPropertyChanged("Symbols");
+ }
+ }
#endregion
#region Public Methods
@@ -475,6 +490,8 @@ namespace MtApi5TestClient
GlobalVariablesTotalCommand = new DelegateCommand(ExecuteGlobalVariablesTotal);
UnlockTicksCommand = new DelegateCommand(ExecuteUnlockTicks);
+
+ GetSymbolsCommand = new DelegateCommand(ExecuteGetSymbols);
}
private bool CanExecuteConnect(object o)
@@ -1726,6 +1743,19 @@ namespace MtApi5TestClient
_mtApiClient.UnlockTicks();
}
+ private async void ExecuteGetSymbols(object o)
+ {
+ var result = await Execute(() => _mtApiClient.GetSymbols(GetSymbolsSelected));
+ if (result == null)
+ return;
+
+ AddLog($"ChartScreenShot: {result.Count} count of symbols");
+ RunOnUiThread(() =>
+ {
+ Symbols = result;
+ });
+ }
+
private static void RunOnUiThread(Action action)
{
Application.Current?.Dispatcher.Invoke(action);
diff --git a/mq5/MtApi5.ex5 b/mq5/MtApi5.ex5
index 44caa1b4..2d54c91d 100755
Binary files a/mq5/MtApi5.ex5 and b/mq5/MtApi5.ex5 differ
diff --git a/mq5/MtApi5.mq5 b/mq5/MtApi5.mq5
index 461a95a4..e7373c10 100644
--- a/mq5/MtApi5.mq5
+++ b/mq5/MtApi5.mq5
@@ -1,7 +1,7 @@
#property copyright "Vyacheslav Demidyuk"
#property link ""
-#property version "2.0"
+#property version "2.1"
#property description "MtApi (MT5) connection expert"
#include
@@ -380,6 +380,7 @@ int preinit()
ADD_EXECUTOR(303, OrderCheck);
ADD_EXECUTOR(304, Buy);
ADD_EXECUTOR(305, Sell);
+ ADD_EXECUTOR(306, GetSymbols);
return (0);
}
@@ -3450,6 +3451,28 @@ string Execute_Sell()
return CreateSuccessResponse(result_value_jo);
}
+string Execute_GetSymbols()
+{
+ GET_JSON_PAYLOAD(jo);
+ GET_BOOL_JSON_VALUE(jo, "Selected", selected);
+
+ const int symbolsCount = SymbolsTotal(selected);
+ JSONArray* jaSymbols = new JSONArray();
+ int idx = 0;
+ for(int idxSymbol = 0; idxSymbol < symbolsCount; idxSymbol++)
+ {
+ string symbol = SymbolName(idxSymbol, selected);
+ string firstChar = StringSubstr(symbol, 0, 1);
+ if(firstChar != "#" && StringLen(symbol) == 6)
+ {
+ jaSymbols.put(idx, new JSONString(symbol));
+ idx++;
+ }
+ }
+
+ return CreateSuccessResponse(jaSymbols);
+}
+
int PositionCloseAll()
{
CTrade trade;