"Inspired by William O'Neil's theory that a stock's relative strength is significantly influenced by its industry and sector performance, I have coded extensive and successfully developed a method to calculate sectoral Relative Strength (RS).
Currently, my 1-month sectoral RS rankings update with each daily bar. However, O'Neil emphasizes that daily group movements introduce considerable noise into the analysis, making weekly rankings far more reliable.
I would like to maintain the current display while ensuring that the rankings update only at weekly intervals rather than daily. I have attempted to implement this using timeframe parameters but have been unable to achieve the desired outcome."
Enclosed chart you would find the Sector Rank.
_SECTION_BEGIN(" Sector RS Exploration");
// More robust sector handling
LastSectorNumber = 23;
// Pre-calculate sector RS only once using StaticVar
if(Status("stocknum") == 0)
{
for(i = 1; i <= LastSectorNumber; i++)
{
SECTORName = CategoryGetName(categorySector, i);
if(SECTORName != "")
{
SectorTickerlist = CategoryGetSymbols(categorySector, i);
SectorChange = 0;
CountSectorSymbols = 0;
for(j = 0; (SectorTicker = StrExtract(SectorTickerlist, j)) != ""; j++)
{
if ( Status("actionex") != actionExEditVerifyFormula )
SetForeign(SectorTicker, 1); // 1 = pad with Null for missing data
notnull = NOT IsNull(C) AND NOT IsNull(Ref(C,-126));
CountSectorSymbols += IIf(notnull,1, 0 );
printf("\n CountSectorSymbols == %f", SelectedValue(CountSectorSymbols));
CloseAtBar = SelectedValue(C);
CloseAt21Bar = SelectedValue(Ref(C, -21));
SectorChange += IIf(notnull, SafeDivide(CloseAtBar, CloseAt21Bar), 0);
RestorePriceArrays();
}
if(SelectedValue(CountSectorSymbols) > 0)
{
SectorRS = (SelectedValue(SafeDivide(SectorChange, CountSectorSymbols)) - 1) * 100;
StaticVarSet("SectorRS_" + i, SectorRS);
StaticVarSet("SectorCount_" + i, CountSectorSymbols);
}
}
}
}
GfxTextOut("Sector Rank "+StaticVarGet("SectorRank_" + SectorID()),300,40);




