How to get all Industries

I want to write a code which will provide the best performing industries of the whole market.
In order to get this I will have to loop through all Industries.
My problem is to get all Industries user in the database. Simply a list with all used Industry numbers.
Thanks a lot for Ideas in advance.

function GetFilledIndustries() {
	category = categoryIndustry;
	IndStr = "";
	// iterate industries and store filled ones
	for ( i = 0; i < 256; i++ )	{    
		Indmembers = CategoryGetSymbols(category, i);		
		if ( Indmembers != "" )
			IndStr += CategoryGetName(category, i) + ",";
	}
	return StrTrim( IndStr, "," );
}

indnames = GetFilledIndustries();
printf( "List of filled Industries: %s\n", indnames );

// Industry numbers (of FILLED ones)
for ( i = 0; i < StrCount(indnames, ",")+1; i++ )	{	
	indnum = CategoryFind( StrExtract(indnames, i), categoryIndustry );
	printf( "\nIndustry Name %s", StrExtract(indnames, i));
	printf( "\nIndustry number: %g", indnum );
}
8 Likes

Thanks a lot. This helped me.