Check if symbol exists

 

Hi,

Any functions that can check if symbol exists for trading? 

 
doshur:

Hi,

Any functions that can check if symbol exists for trading? 

SymbolSelect()
 
angevoyageur:
SymbolSelect()
thanks
 

Not yet mentioned in the MQL Reference, but 'SymbolExist' is already highlighted as a valid Keyword in the MetaEditor (build 1970)

bool SymbolExist(const string symbol_name, bool &is_custom)

 

sounds a bit extreme to select a symbol just to verify it exists...


void OnStart()

  {

//---


Print(IsSymbol("EURUSD"));

Print(IsSymbol("I Ain't No Symbol, Biyatch!"));

   

  }

//+------------------------------------------------------------------+


bool IsSymbol(string symbol) {

    SymbolInfoDouble(symbol, SYMBOL_BID);

    return GetLastError() != ERR_MARKET_UNKNOWN_SYMBOL;

}

 
   int i = StringSplit(strBasket, StringGetCharacter(",", 0), Basket);

   if(i > 0)
   {
      for(int x = 0; x < i; x++)
      {
         if(!SymbolExist(Basket[x], false)) return(INIT_PARAMETERS_INCORRECT);
      }
   }
   else
   {
      return(INIT_PARAMETERS_INCORRECT);
   }

'false' - variable expected JPY Basket.mq5 32 37

how to use symbolexist properly?

the input is not a bool?

Thanks in advance

 
Release note 14, from version Built 2005 ( 21 FEB 2019)
New SYMBOL_EXIST property in the ENUM_SYMBOL_INFO_INTEGER enumeration, means that the symbol under this name exists. 
MetaTrader 5 Platform build 2005: Economic Calendar, MQL5 applications as services and R language API
MetaTrader 5 Platform build 2005: Economic Calendar, MQL5 applications as services and R language API
  • 2019.02.21
  • MetaQuotes Software Corp.
  • www.metatrader5.com
Completely revised built-in Economic Calendar. The Economic Calendar is our proprietary solution. Therein you will find over 600 financial news and indicators related to the 13 largest global economies: USA, European Union, Japan, UK, Canada, Australia, China among others. Relevant data is collected from open sources in real time. The new...
Reason: