Hi guys,
Could anybody suggest a solution for this, i've been puzzled...
Using Norgate Data base...
PSEUDOCODE
- retrieve all stocks from a GICS, say GICS10
- run the ranking on them and store in sector-specific staticvar
VarSet("G10",1);//
VarSet("G15",1);//
VarSet("G20",1);//
VarSet("G25",1);//
VarSet("G30",1);//
VarSet("G35",1);//
VarSet("G40",1);//
VarSet("G45",1);//
VarSet("G50",1);//
VarSet("G55",1);//
VarSet("G60",1);//
if( Status( "stocknum" ) == 0 )
{
// cleanup variables created in previous runs (if any)
StaticVarRemove( "ranksec*" );
StaticVarRemove( "sector*" );
for( i = 10; i < 30; i+=5 )
{
if(VarGet("G"+i)==1)
{
List = CategoryGetSymbols( categoryGICS, i ) ;
for( n = 0; ( Symbol = StrExtract( List, n ) ) != ""; n++ )
{
SetForeign( symbol );
volumeFilter = C*MA(V,15)>10000000;
Pricefilter = C > 1;
values = IIf(volumeFilter AND priceFilter ,ROC(C,200) ,0 );
RestorePriceArrays();
// write ranked values to a static variable
StaticVarSet( "sector" + i + "_" + symbol, values );
}
StaticVarGenerateRanks( "ranksec", "sector" + i +"_", 0, 1234 );
}
}
}
symbol = Name();
for( i = 10; i < 30; i+=5 )
{
values = StaticVarGet( "sector" +i + "_" + symbol ); // retrieve actual values (ranking is performed in 1 afl, separate ranking for each GCIS [ie, GICS10,GICS15,etc.]
rank = StaticVarGet( "ranksec" + "sector" +i + "_" + symbol ); // retrieve ranking of each sector
AddColumn( values, "AnnSlope"+i );
AddColumn( rank, "rank"+i );
//AddTextColumn( GICSID( 1 ), "Sector" );
//AddtextColumn( StrLeft( GicsID( 0 ), 2 ), "Sector No", 1 );
}
Filter = rank<100;
Output in Exploration:
What I would like to achieve is that the exploration only displays the top x stocks per sector. Say top 50 for GICS10, top 50 for GICS15 etc.,(there will obviously be blanks for stocks not in a specific sector).
If I set the filter like above, I believe it gets overwritten several times, hence the output gets truncated as in the picture (meaning it only shows the rankings of the LAST SECTOR). If I set filter to 1 filter= 1;
, I get all stocks, obviously.
Any thoughts on this would be greatly appreciated. Thanks for your time.