Check if string is valid symbol
06 Aug 2015, 21:40
Hello everyone!
I am struggling with some code, and was hoping someone could point me in the right direction. I am combining to currencies, and want to check if the combination of the two is a valid symbol.
For example if I combine CHF and USD in both orders, CHFUSD and USDCHF, I need to be able to determine which is a valid symbol. If the indicator attempts USDCHF (the valid symbol) first, it proceeds as expected, but if an invalid symbol is tried the indicator halts.
Here is the code I am trying to check the symbols with:
private bool checkSymbol(string symbolCode)
{
try
{
Symbol testSymbol = MarketData.GetSymbol(symbolCode);
if (testSymbol.Bid == 0.0)
{
return false;
}
return true;
} catch
{
return false;
}
}
Any help would be greatly appreciated. Thanks in advance!

Spotware
17 Aug 2015, 18:54
Dear Trader,
Please have a look at the following code snippet:
private bool checkSymbol(string symbolCode) { Symbol testSymbol = MarketData.GetSymbol(symbolCode); if (testSymbol == null) { return false; } else { return true; } }@Spotware