Check if Symbol Code Exists
26 Mar 2015, 19:30
What is the best way to find out if a specific symbol is supported by looking up its code?
For example, this does NOT work:
if(MarketData.GetSymbol("XYZUSD") == true) {
Print("Symbol Supported");
}
else {
Print("Symbol Not Supported");
}

Invalid
27 Mar 2015, 09:29
RE:
Check if it is null instead of true.
MarketData.GetSymbol("holaamigos")!=null;Or you can create an extension:
[Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class NewcBot : Robot { protected override void OnStart() { Print("Symbol exists: {0}", MarketData.SymbolExists("E33URGBP")); } } public static class Ext { public static bool SymbolExists(this MarketData marketData, string symbol) { return marketData.GetSymbol(symbol) != null; } }@Invalid