Issue #284: MtApi4/MQL4 - added function GetSymbols

This commit is contained in:
Viacheslav Demydiuk
2025-09-27 17:29:00 +03:00
parent 96674d8763
commit 92322e866e
8 changed files with 1973 additions and 1787 deletions
+25
View File
@@ -1330,6 +1330,9 @@ int ExecuteCommand()
case 290: //GetQuote
response = Execute_GetQuote();
break;
case 291: //GetSymbols
response = Execute_GetSymbols();
break;
default:
Print("WARNING: Unknown command type = ", command_type);
@@ -4187,3 +4190,25 @@ string Execute_GetQuote()
MtQuote quote(Symbol(), tick);
return CreateSuccessResponse(quote.CreateJson());
}
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);
}