I am using API manager for the trading platform MetaTrader 4
I need to get ALL SECURITIES per GROUP
for example GROUP=preliminary|SECUTIRY_0=Forex|SECUTIRY_1=CFD|SECUTIRY_2=|
i have some tips how to do it below:
my code is below but can not get the desired result, in the code below i get the list with SECURITIES AND THE LIST WITH GROUPS but can not get indexes based on description above to get the result in this format
GROUP=preliminary|SECUTIRY_0=Forex|SECUTIRY_1=CFD|SECUTIRY_2=|
// 1 step
// request all securities
// list with securities
ConSymbolGroup securities[MAX_SEC_GROUP];
int result = ExtManager->CfgRequestSymbolGroup(securities);
// 2 step
// request all groups
// list with groups
ConGroup *groups = ExtManager->CfgRequestGroup(&total);
ConGroupSec secgroups[MAX_SEC_GROUPS];
int index_secgroup = 0;
int index_security = 0;
for (int i = 0; i < MAX_SEC_GROUP; i++)
for (int i =0; i < total; i++)
ExtProcessor.PrintResponse(size,
"GROUP=%s|"
"SECUTIRY_0=%s|"
"SECUTIRY_1=%s|"
"SECUTIRY_2=%s|\r\n",
groups[i].group,
securities[0].name,
securities[1].name,
securities[2].name);
}
Here is code snippet which will give you required data, so you can output it as you need:
ConSymbolGroup sgconfigurations[MAX_SEC_GROUP];
_manager->Manager->CfgRequestSymbolGroup(sgconfigurations);
int total = 0;
ConGroup* result = _manager->Manager->CfgRequestGroup(&total);
for (int i = 0; i < total; i++)
{
for (int j = 0; j < MAX_SEC_GROUP; j++) {
if (result[i].secgroups[j].show == 1 && sgconfigurations[j].name != NULL && sgconfigurations[j].name[0] != '\0') {
char* groupName = result[i].group;
char* securityName = sgconfigurations[j].name;
}
}
}