Match symbol from it's symbol name string.

#1
Hi there, anyone that can help me how to get (I assume simple code) to find a symbol, given by a comma separated list from a CategoryGetSymbols() criteria...?

For example:

list = CategoryGetSymbols(categoryIndustry,IndustryID(0));
and then from -list- I want to find which symbol equals its FullName() to IndustryID(1)

Thanks!
 

mastermind007

Well-Known Member
#2
Hi there, anyone that can help me how to get (I assume simple code) to find a symbol, given by a comma separated list from a CategoryGetSymbols() criteria...?

For example:

list = CategoryGetSymbols(categoryIndustry,IndustryID(0));
and then from -list- I want to find which symbol equals its FullName() to IndustryID(1)

Thanks!
Use StrExtract function; It splits string containing comma into separate strings.
 
#3
Use StrExtract function; It splits string containing comma into separate strings.
Ok, but it must be nested and how to do it is mainly my doubt....

Something like:
Code:
list = CategoryGetSymbols(categoryIndustry,IndustryID(0)) ;
matchsymbol = StrExtract(list, {how to apply condition here to match FullName()==IndustryID(1) criteria});
Thank you Sir...
 

mastermind007

Well-Known Member
#4
Code:
list = CategoryGetSymbols(categoryIndustry,IndustryID(0)) ;

[B]listSize = 1 + StrCount(list, ",");

for (i = 0; i < listSize; i++)
{
   if (IndustryID(1) == StrExtract(list, i))
   {
....
   }
}
[/B]
 
#5
Code:
list = CategoryGetSymbols(categoryIndustry,IndustryID(0)) ;

[B]listSize = 1 + StrCount(list, ",");

for (i = 0; i < listSize; i++)
{
   if (IndustryID(1) == StrExtract(list, i))
   {
....
   }
}
[/B]
Thanks MasterMind! :clap: I really need an intensive spending-time dealing with LOOP's to understand this kind of logic..! ;)
 
#6
Code:
list = CategoryGetSymbols(categoryIndustry,IndustryID(0)) ;

[B]listSize = 1 + StrCount(list, ",");

for (i = 0; i < listSize; i++)
{
   if (IndustryID(1) == StrExtract(list, i))
   {
....
   }
}
[/B]
Sorry to bother again with this Sir, but I at my understanding, "list" variable returns only Symbol names... how can I make this loop to search (and match) with FullName() string..?

Thanks again! :thumb:
 
#7
Finally I found a way to match Morningstar tickers from TC2k plugin and data to its correlate Industry and Sector Index.

Here's the final code:
Code:
Function MGIndustry() {
	Industry = IndustryID(1) ;
	IndustryN = IndustryID(0) ;
	IndustryList = CategoryGetSymbols( categoryIndustry, IndustryN);
	MGTicker = "";
	for( i = 0; ( MG = StrExtract( IndustryList , i ) ) != ""; i++ )
	{	SetForeign(MG);
		IndustryName = Name();
		IndustryNL = StrLen(IndustryName);
		if( IndustryNL == 5 AND StrLeft(IndustryName,2) == "MG" )
	{ MGTicker = MG ;		}
	  RestorePriceArrays();
	}
	return MGTicker ;  }
and:

Code:
Function MGSector() {
	MGSTicker = StrLeft(MGIndustry(),4)+"0" ;
	return MGSTicker ;	}
:thumb: