Detecting existence or nonexistence of symbol ...

 
Is there an reliable method for detecting if an symbol does exist or does not?

Curently I use this:

boolean function IsSymbol(string SY) {
double tmpTickValue = MarketInfo( SY ,MODE_TICKVALUE);
if ( tmpTickValue > 0) {
  // This Symbol does exist
  return(true);
} else {
  return(false);
}

Is It OK?
What you use?

Petr "Qaxi" Klima
http://sourceforge.net/projects/mql4-qaxi-libs/
 

No, not reliable. You should check last error, not returned value

double bid=MarketInfo(SY,MODE_BID);
if(GetLastError()==4106) // unknown symbol
   return(false)
else return(true)

You can use other modes: MODE_LOW,MODE_HIGH,MODE_TIME,MODE_ASK,MODE_POINT,MODE_DIGITS, MODE_SPREAD,MODE_MARGINREQUIRED. Then You check nonselected symbols.

If You use MODE_TICKVALUE or other unlisted above modes You can get information about nonselected in the MarketWatch window symbols (however symbol can exist). In this case if last error is 4106 then symbol is nonselected and nonexisted.

 
Thanks

That is exactly what I need.

The perfectly described answer.

Thank you very much.

Petr Qaxi
 

My question, which remains unanswered, is how to "discover" symbols.

Yes, we can run through a list of all possible currencies, but that does not address additional securities or indexes that may be available at a Dealer.

 
phy:

My question, which remains unanswered, is how to "discover" symbols.

Yes, we can run through a list of all possible currencies, but that does not address additional securities or indexes that may be available at a Dealer.


Unfortunately, this information cannot be obtained programmatically
 

stringo:

Unfortunately, this information cannot be obtained programmatically

 

1.  Right click on Market Watch, then select Show All.  That will display all existing symbols

2.  Right click on Market Watch again.  Select Sets, Save As....  Call it Universe.set.  This set file is saved into symbolsets folder.

3.  Make a link to your symbolsets folder by entering the command in your dos prompt.

    mklink /d "C:\Program Files (x86)\MetaTrader\experts\files\symbolsets" "C:\Program Files (x86)\MetaTrader\symbolsets" 

 The command above creates a subfolder under your experts\files folder.  Everything inthis folder including subfolders are accessible with FILEOPEN.

4. Once the symbolic link is established, you may now FILEOPEN("symbolsets\universe.set",FILE_CSV|FILE_READ);

5. You may read through your file universe.set just like any other text file.

 

 

 
stringo:

Unfortunately, this information cannot be obtained programmatically
phy:

My question, which remains unanswered, is how to "discover" symbols.

Yes, we can run through a list of all possible currencies, but that does not address additional securities or indexes that may be available at a Dealer.

 

1. Right click on Market Watch, then select Show All. That will display all existing symbols

2. Right click on Market Watch again. Select Sets, Save As.... Call it Universe.set. This set file is saved into symbolsets folder.

3. Make a link to your symbolsets folder by entering the command in your dos prompt.

mklink /d "C:\Program Files (x86)\MetaTrader\experts\files\symbolsets" "C:\Program Files (x86)\MetaTrader\symbolsets"

The command above creates a subfolder under your experts\files folder. Everything inthis folder including subfolders are accessible with FILEOPEN.

4. Once the symbolic link is established, you may now FILEOPEN("symbolsets\universe.set",FILE_CSV|FILE_READ);

5. You may read through your file universe.set just like any other text file. 

 
fdeguzman:

1.  Right click on Market Watch, then select Show All.  That will display all existing symbols

2.  Right click on Market Watch again.  Select Sets, Save As....  Call it Universe.set.  This set file is saved into symbolsets folder.

3.  Make a link to your symbolsets folder by entering the command in your dos prompt.

    mklink /d "C:\Program Files (x86)\MetaTrader\experts\files\symbolsets" "C:\Program Files (x86)\MetaTrader\symbolsets" 

 The command above creates a subfolder under your experts\files folder.  Everything inthis folder including subfolders are accessible with FILEOPEN.

4. Once the symbolic link is established, you may now FILEOPEN("symbolsets\universe.set",FILE_CSV|FILE_READ);

5. You may read through your file universe.set just like any other text file.


It took you 5 years to answer this post ?

Why not just do it the same way that allmarketdata does it ?  https://www.mql5.com/en/forum/141214
 
Ray:

My question, which remains unanswered, is how to "discover" symbols.

Yes, we can run through a list of all possible currencies, but that does not address additional securities or indexes that may be available at a Dealer.


for( i=0; i<SymbolsTotal(false); i++) Print( SymbolName( i, false));