No of symbols based on industry in explorer

Hi All,
Little help needed

Simple exploration ! I want to count no of symbols in exploration result belongs to the same industry (industryid(1)) for each industry, and that count displayed in exploration result.

Code :

Title = "                                                                                                                " + "Marked Scrips   " ;
SU =	 				Study("su", 2302 ) ;
ST=		 				Study("ST", 2302 );
risk=					abs(SU-ST);
riskPrct=				Prec((risk / Su) *100,2) ; 
target1=				SU+(risk*2);
target2=				SU+(risk*3);
target3=				SU+(risk*4);

TradeStatus=		writeIf(LastValue(H) > target1 AND  NOT LastValue(H) > target2 AND NOT LastValue(H) > target3 ,"Target 1",
							writeIf(LastValue(H) > target2 AND NOT LastValue(H) > target3 ,"Target 2",
							writeIf(LastValue(H) > target3 ,"Target 3",
							writeIf(LastValue(C) < ST  OR LastValue(Low) < ST ,"Stopped",
							""))));


roccolor=IIf(ROC(C,1) > 0,colorGreen,colorRed);
Filter =SU > 0 ;
//Filter =Close > 15 AND (ROC(C,1) >= 2 AND ROC(C,1) < 5 );// OR ROC(C,1) <= -5) ;
SetOption("NoDefaultColumns", True );
AddtextColumn(Name(),"Name",formatChar,colorYellow,roccolor);
AddTextColumn(TradeStatus,"Status");
AddColumn(SU,"Entry",1.2);
AddColumn(target1,"TRGT 1",1.2,colorblack,colorGold);
AddColumn(target2,"TRGT 2",1.2,colorblack,colorWhite);
AddColumn(target3,"TRGT 3",1.2,colorBlack,coloraqua);
AddColumn(ST,"Stop Loss",1.2,colorBlack,colorpink);
AddColumn(RiskPrct,"% Stop",1.2,colorYellow,ColorRGB(240,0,0));
AddColumn(C,"Close",1.2,colorYellow,roccolor);
AddtextColumn(IndustryID(1),"Industry",formatChar,colorYellow,roccolor);
AddColumn(ROC(C,1), "GAIN",1.2,colorYellow,roccolor);
addcolumn(DateTime() ,"Date",formatDateTime,colorYellow,roccolor);


SetSortColumns(1);

exploration result

Ami2

Please share the idea !

// https://forum.amibroker.com/t/no-of-symbols-based-on-industry-in-explorer/27521/2
sym_industry = CategoryGetSymbols(categoryIndustry,IndustryID());
cnt_industry = StrCount(sym_industry, ",")+1;
Filter = Status("lastbarinrange");
AddTextColumn(IndustryID(1), "Industry", 1);
AddColumn(cnt_industry, "inIndustry Count", 1);

Thank you !! @fxshrat ,
This shows all symbol count in industry , I may put it wrong in question , I need only exploration result symbol count. Means in above example in screenshot result shows 4 symbol of auto/truck I need to show 4 in exploration. Thanx in advance.

First run scan then explore

// https://forum.amibroker.com/t/no-of-symbols-based-on-industry-in-explorer/27521/4
// First run scan then explore
SU = Cross(C,MA(C,20));//Study("su", 2302 );
Filter = SU > 0 AND Status("lastbarinrange");
if( Status("action") == actionScan ) { 
	if( Status("stocknum") == 0 ) 
		StaticVarRemove("cntIndustry_*"); 
	StaticVarAdd("cntIndustry_"+IndustryID(), Filter );
}
sym_industry = CategoryGetSymbols(categoryIndustry,IndustryID());
cnt_industry_all = StrCount(sym_industry, ",")+1;
cnt_industry_filt = StaticVarGet("cntIndustry_"+IndustryID());
AddtextColumn(IndustryID(1), "Industry", 1);
AddColumn(cnt_industry_all, "inIndustry Count All", 1);
AddColumn(cnt_industry_filt, "inIndustry Count Filter", 1);
2 Likes

Thanks a lot !!! as always helpful

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.