[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Re: Sort by strongest industry ?



PureBytes Links

Trading Reference Links

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 amibroker@xxxxxxxxxxxxxxx, "gmorlosky" <gmorlosky@xxx> 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 amibroker@xxxxxxxxxxxxxxx, "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)).
> >
>




------------------------------------

**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to 
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/