I get the MT4ManagerAPI.h from the metaquotes. Now I would like to add new symbol to the meta server but apparently its not working and keep throwing error code for me. There is so limited source and discussion for the API and I found nothing related to add new symbol on MT4ManagerAPi so any help is appreciated.
My code:
logger.info("Conencting to ... " + address);
CManagerFactory factory;
CManagerInterface* manager;
factory.Init("mtmanapi.dll");
factory.WinsockStartup();
if (factory.IsValid() == FALSE)
{
logger.error("Failed to Load Libraries");
return;
}
manager = factory.Create(ManAPIVersion);
if (manager == NULL) {
logger.error("Failed to create MetaTrader 4 Manager API interface");
return;
}
if (manager->Connect(address.c_str())!=RET_OK) {
logger.error("Connection to MT4 server failed");
return;
}
if (manager->Login(id, password.c_str()) != RET_OK) {
logger.error("Login Failed");
return;
}
logger.info("Connection Established...");
std::string myString = "Hello, LPCSTR!";
LPCSTR lpcstr = myString.c_str();
std::cout << manager->SymbolAdd(lpcstr); // it returns value 2 which means general error according to the API
Code from MT4ManagerAPI:
//+------------------------------------------------------------------+
//| Result codes |
//+------------------------------------------------------------------+
enum
{
//--- common errors
RET_OK =0, // all OK
RET_OK_NONE, // all OK-no operation
RET_ERROR, // general error
... and the rest
Add symbol function
//--- symbols
virtual int __stdcall SymbolsRefresh() =0;
virtual ConSymbol* __stdcall SymbolsGetAll(int *total) =0;
virtual int __stdcall SymbolGet(LPCSTR symbol,ConSymbol *cs) =0;
virtual int __stdcall SymbolInfoGet(LPCSTR symbol,SymbolInfo *si)=0;
virtual int __stdcall SymbolAdd(LPCSTR symbol) =0;
virtual int __stdcall SymbolHide(LPCSTR symbol) =0;