SYMBOL_PATH

- www.mql5.com
I am porting my code to MQL5
I have a requirement to access the brokers group name (System type or the category that a symbol belongs to). The code below works in MT4 - I found it on the web.
Anybody know how to get the same information in MQL5?
This code is obsolete, as in mql5, you can also use SYMBOL_PATH in mql4.
string path = SymbolInfoString("EURUSD",SYMBOL_PATH);
Path contains: Forex/EURUSD
Simple - many thanks Alain
//+------------------------------------------------------------------+ //|Get the Brokers Group Name for the Symbol | //+------------------------------------------------------------------+ string symbolType(string symbol) { string outVal=NULL; string path=NULL; ResetLastError();//zero last error SymbolInfoString(symbol,SYMBOL_PATH,outVal); if(!GetLastError()) { path=SymbolInfoString(symbol,SYMBOL_PATH); StringReplace(path,symbol,""); } else Alert("Cannot Find: ",symbol," Path"); return path; } //+------------------------------------------------------------------+
int OnInit() { string string1 = "EURUSD"; string string2 = "RUON-1.18"; string string3 = "XXX"; string brokerGroupName1=symbolType(string1); Print("This Brokers Group Name for: ",string1,": ",brokerGroupName1); string brokerGroupName2=symbolType(string2); Print("This Brokers Group Name for: ",string2,": ",brokerGroupName2); string brokerGroupName3=symbolType(string3); Print("This Brokers Group Name for: ",string3,": ",brokerGroupName3); return(INIT_SUCCEEDED); }
StringReplace(path,symbol,"");
It is not right.
ok - whats wrong with it? If you had the code - could have saved me a job and posted it?
StringReplace(path,symbol,NULL);
vacuous statement like its not right is not very helpful?
Do you mean that it needs to be more robust in symbol search in group string?
A clue would be helpful since I dont have all day to guess what you mean
If you had the code - could have saved me a job and posted it?
path = StringSubstr(path, 0, StringLen(path) - StringLen(symbol));
Yes - more robust thankyou
//+------------------------------------------------------------------+ //|Get the Brokers Group Name for the Symbol | //+------------------------------------------------------------------+ string symbolType(string symbol) { string outVal=NULL, path=NULL; ResetLastError();//zero last error SymbolInfoString(symbol,SYMBOL_PATH,outVal); if(!GetLastError()) return StringSubstr(SymbolInfoString(symbol,SYMBOL_PATH),0,StringLen(SymbolInfoString(symbol,SYMBOL_PATH))-(StringLen(symbol)+1)); else Alert("Cannot Find: ",symbol," Path"); return path; } //+------------------------------------------------------------------+
string symbolType(string symbol) { string path = NULL; if (SymbolInfoString(symbol,SYMBOL_PATH,path)) return StringSubstr(path,0,StringLen(path)-(StringLen(symbol)+1)); else Alert("Cannot Find: ",symbol," Path"); return path; }

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I am porting my code to MQL5
I have a requirement to access the brokers group name (System type or the category that a symbol belongs to). The code below works in MT4 - I found it on the web.
Anybody know how to get the same information in MQL5?