Ok - so far I have the code, but I can't quite get the code to loop only 
through the selected Industry set in the parameter. Can someone look this my 
looping section, which has the comment:
// Main program to start looping through each ticker in the selected Industry 
creating composites
It works in 2 steps - run Scan (creates composite) run Explore (creates top 
best)

Title = "Best of the Best";
FormulaName = "1_sectorROC_Mine";

// How to sort through by Category of each Industry, then sort out the top half 
stocks of each industry

// determine which major Category ( 3 = Industry)
function ParamCategory()
{
 global CategoryList; // This is the main category where we look for our list
 CategoryList           = "Market   ,Group    ,Sector   ,Industry 
,Watchlist,Favorite ,Index    ";
 Tickercategory = ParamList("Ticker category", 
"Market|Group|Sector|Industry|Watchlist|Favorite|Index",3);
 Category                       = TickerCategory;
 TickerCategory = (StrFind( CategoryList, Tickercategory)-1)/10;
 return TickerCategory;
}

// determine which particular Industry in selected Tickercategory ( 4 = 
Agricultural Chemicals)
function ParamListNum( Category )
{
 global ListNum;
 ListNum                        = Param("List Number", 4, 0, 255, 1);
 return ListNum;
}

TickerCategory  = ParamCategory(); // refers to function
TickerListNum           = ParamListNum(TickerCategory); // refers to function
CountAll                        = 0;
list                            = GetCategorySymbols( categoryWatchlist, 
Tickerlistnum);
for( i = 0; ( sym = StrExtract( list, i ) ) != ""; i++ )
   {
    CountAll            = CountAll +1;
   }

// create list of tickers, separated with a comma, by name from TickerCategroy 
list
function GetSymbols()
{
 TickerList             = "";
 SymbolList             = CategoryGetSymbols(TickerCategory, TickerListNum);

 for(n = 0; n < CountAll; n++)
        {
         Ticker                 = StrExtract(SymbolList,n);
         TickerList     = TickerList + Ticker + ",";
        }
 return TickerList;
}

// Main program to start looping through each ticker in the selected Industry 
creating composites
TickerList              = GetSymbols(); // refers to function
for( n = 0; (Ticker = StrExtract(TickerList, n)) != ""; n++)
{
 // Rxxt = of the Ticker
 periods = Param("Periods",14,1,50,1);
 ROCt                           = ROC (C, periods );
 RSIt                           = RSI (periods);
 AddToComposite(C,"~sumROC","X",7); AddToComposite(1,"~sumROC","V",7);
 AddToComposite(C,"~sumRSI","X",7); AddToComposite(1,"~sumRSI","V",7);
 // Rxxc = of the Composite
 ROCc                           = ROC(Foreign("~sumROC","Close"),periods);
 RSIc                           = RSIa(Foreign("~sumROC","Close"),periods);
}

// Buy Sell criteria
Buy                                     = IIf(ROCt > ROCc AND RSIt > RSIc, 1,0);
Sell                            = IIf(ROCt < ROCc AND RSIt < RSIc, -1,0);
Deal                            = IIf(Buy == 1, 1, IIf (Sell == -1, -1, 0));
// Columns
AddColumn (C,"Close");
AddColumn (Foreign("~sumROC","Close"),"sumROC");
AddColumn (Foreign("~sumRSI","Close"),"sumRSI");
AddColumn (ROCt,"ROC",1.2,colorDefault,colorDefault,40);
AddColumn (RSIt,"RSI",1.2,colorDefault,colorDefault,40);
AddColumn (ROCc,"CompROC",1.2,colorDefault,colorDefault,60);
AddColumn (RSIc,"CompRSI",1.2,colorDefault,colorDefault,60);
AddColumn(Deal,"Buy/Sell",colorDefault, IIf(Buy ==1, colorGreen, IIf(Sell == 
-1, colorRed, colorDefault)));
// Plot
Plot (ROCt,"ROCt",colorGreen, styleLine);
Plot (ROCc,"CompROC",colorRed, styleLine);
// Filter
Filter                          = 1;












--- In [email protected], "gmorlosky" <gmorlo...@...> wrote:
>
> So what I need is code to:
> 
> 1) Create composites of all 200 industries
> 2) Assign those composites to the category > industry which they came from
> 
> After that it will be easy to code a comparison between tickers of the same 
> industry.
> 
> Thanks for any help.
> 
> --- In [email protected], "gmorlosky" <gmorlosky@> wrote:
> >
> > What code would I use to find the strongest industries (RSI(21)) ? Some 
> > sort of code, to run an Explore, to look at all industries and sum up the 
> > stocks strengths and then compare to all other industries to rank the 
> > industries.
> > 
> > Next would be easy to then sort by the strongest stocks highest (RSI(14)).
> >
>


Reply via email to