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

Re: [amibroker] Quotes Plus - Sectors



PureBytes Links

Trading Reference Links

Dan,
 
Few items ...
 
1. I tried using RS (Stock, Industry or Sector) as the scoring variable in backtests. Each one deteriorated performance. Makes no sense to me. Any comments?
 
2. I have not yet tested the market cap you suggested previously. Can't quite decide how I would use it in backtests, except treat them as separate groups. My objective is to optimize performance without  limiting the stock universe. I suppose small - mid - large cap groups would be large enough to merit being sepatare groups. Again any comments?
 
3. Do you do any backtestes or do you use your grouping manally only as visuals or lists?
 
Thanks
Ara
----- Original Message -----
From: Dan Clark
Sent: Friday, December 02, 2005 8:30 AM
Subject: RE: [amibroker] Quotes Plus - Sectors

Jason,

 

Hi.  Currently the RS ATC symbols that I’m using are based a simple RSI(9) of the ATC Index symbols.  This is stuffed into an ATC RS symbol.

 

However, this ATC RS symbol is computed for all bars in my database.  I.e., if there are 1000 bars for a Sector ATC Index, there should be 991 RSI bars.   

 

And, when I change the time period to weekly or monthly, the values roll up to the higher time period.   That said, I haven’t confirmed whether these higher timeframe numbers are valid for decision making.   I think they will be OK, but that’s not confirmed.

 

Regarding the ATC RS symbol…

 

The ATC RS symbol is then used to create a Sector ATC Rank symbol – a Sector’s RS ranking within all Sectors, and a Cap-based Sector (large, mid and small) within Sectors of the same size (large, mid or small).  Industry ranking is done the same. 

 

Then, the ATC Rank symbols are used to compare a Sector to other Sectors and an Industry to other Industries.   This is for top-down analysis.  For bottom-up analysis, I use the ATC Rank symbols are used to quickly display the Sector and Industry rank for a stock.  

 

For example, the attached image shows the Sector and Industry Ranking for AKAM (Akamai).   As you can see, the Internet Sector has been very strong for the last three months and started fading a bit starting in November.   The Internet – Services Industry has been very strong for the same period, only started fading in the last week.

 

I chose to use ATC symbols instead of computing rank on the fly because of speed.   Computing rank is a slow process.   Doing it on the fly took 2-3 seconds every time a chart was scrolled or zoomed.   Now using an ATC symbol, it’s virtually instantaneous.  

 

But all of this is based on RSI(9).  That’s just a placeholder.   When I get some other, higher-priority work complete, I’ll replace the RS calculation with a composite calculation of RSI, ROC, and position related to MAs.  This will be similar to your work.  Since I’ve already created the RS ATC symbol, it should be simple to replace the ATC’s RS code.   All of the ATC Rank code will remain the same.

 

Regards,

 

Dan.

 

 


From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf Of Jason Hart
Sent: Friday, December 02, 2005 6:24 AM
To: amibroker@xxxxxxxxxxxxxxx
Subject: RE: [amibroker] Quotes Plus - Sectors

 

I figured out the error.  On the RS templates you've been posting do you have them set to a certain time period, i.e. the template only shows 1 month of performance or will the performance figures change when you change the time period on the chart?  Similar to the relative performance charts built in on AB.

 

Thanks - Jason 

 



Dan Clark <dan_public@xxxxxxxxxxx> wrote:

Jason,

 

Hi.  I’m a little fuzzy about what part of the code is breaking.   Where is it breaking?  What’s the error message?

 

CompositeLoad is just a function that makes it easier to encapsulate the code.  When I create the composite, I run it against all symbols.  BUT, my scan has criteria built in.  I exclude with a 10Day MA price  $2.00 and 10Day MA volume < 50K.   I also exclude stocks over $2,000 (Berkshire Hathaway)

 

Let me know what error your are getting.

 

Best regards,

 

Dan.

 

 


//Get group name
GroupName =   
GroupID(1);

//Institutional Holding
InstitutionalHold =
GetExtraData("InstHolds");

//Market Cap
MarketCapNum      =   MarketCapGet();
MarketCapCategory   =   MarketCapCategoryGet(MarketCapNum);

//Init Utility Variables

SectorSymbol         =  
NumToStr(SectorID(0), 1.0);  
SectorName             =  
SectorID(1);  
IndustrySymbol       =   
NumToStr(IndustryID(0), 1.0);  
IndustryName          =   
IndustryID(1);  
MarketName            =  
MarketID(1);

VolStdAmt         =  
Nz(V/1000);

Volume10DayMA      =   
MA(VolStdAmt, 10);
LastVolume10DayMA   =   
LastValue(MA(VolStdAmt, 10));
Close10DayMA      =   
MA(Nz(C), 10);
LastClose10DayMA   =   
LastValue(MA(Nz(C), 10));

//Filter the symbols
USStock       =         LastClose10DayMA   >  
2      
               AND   LastVolume10DayMA   >  
50      
               AND   LastClose10DayMA   <=
2000   //Eliminate Berkshire Hathaway
               AND   GroupName          ==
"Common Stocks"
               AND   SectorName        !=
"Undefined"
               ;

USTradable    =         LastClose10DayMA   >= PriceMin
               AND   LastClose10DayMA   <= PriceMax
               AND   LastVolume10DayMA   >= VolumeMin             
//LastVolume10DayMA already divided by 1000
               AND   GroupName          ==
"Common Stocks"
               AND   SectorName          !=
"Undefined"
               AND    InstitutionalHold >=
10
               AND   InstitutionalHold <=
90
               ;

ADR          =         LastClose10DayMA   >  
2      //      C                   >= PriceMin
               AND   LastVolume10DayMA   >  
50      //AND   V                   >= (VolumeMin * 1000)
               AND   LastClose10DayMA   <=
2000   //high priced stocks
               AND   GroupName          ==
"ADR"
               AND   SectorName        !=
"Undefined"
               ;

ADRTradable =         LastClose10DayMA   >= PriceMin
               AND   LastClose10DayMA   <= PriceMax
               AND   LastVolume10DayMA   >= VolumeMin             
//LastVolume10DayMA already divided by 1000
               AND   GroupName          ==
"ADR"
               AND   SectorName        !=
"Undefined"
               ;

 


From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf Of Jason Hart
Sent: Thursday, December 01, 2005 9:01 AM
To: amibroker@xxxxxxxxxxxxxxx
Subject: RE: [amibroker] Quotes Plus - Sectors

 

Dan,

 

I tried using the formula at the bottom but got an error once the code got to "compositeload".  I presume I need to have the tickers already created before running the scan.  What do you run this scan against?  Is it all common stocks or do you run it against a watchlist?  Thanks in advance.

 

By the way, great idea concerning the sector charts and the sector by marketcap sizes!  I have been looking to implement something like this onto my charting panes.  I'd like to have the lone company chart above, with relative performance charts with sectors as you have done.  I use QP and do have a setup similar to this but I use the QP industry sectors, i.e. !id (then sector number), but find it limited because of the weightings they use.  I do not like how a penny stock with a 15M marketcap that happens to move +20% on a 5 cent move can totally skew the sector data.  I've seen cases where a sector is up 10% for the week but when you look at the underlying companies all of them are flat except a microcap that happens to move 50% on 30,000 shares traded 

 

Jason

Dan Clark <dan_public@xxxxxxxxxxx> wrote:

Ara,

 

I’d be happy to collaborate on trading issues.  

 

Below are some utility functions that I’ve added to my “Include” file.   I use functions and procedures in the Include file extensively.   This makes my code simpler and much more consistent.

 

Attached are two charts.  MarketSectorIndustryOverlay.gif shows a candle chart of MIDD with a Market, Sector and Industry overlay.  The Market it represented by “VTI” and is plotted in yellow.  I could have chosen to display several other total market indicators include QQQQs and my own composite indices.  Sometimes I like to choose a standard market indicator for reference.  The orange dotted line is the Small Cap Household Appliance Industry ATC index (MIDD’s industry).  The Aqua dotted line is the Consumer Cyclical Sector ATC index (MIDD’s Sector).

 

The top pane of RelativeStrength.gif shows an ROC chart comparing MIDD, VTI, and MIDD’s Industry and Sector ATC.   As you can see, MIDD has been going sideways for the last month, while its industry has been improving and MIDD has been outperforming the market and it’s sector.  

 

The middle pane shows the RANK of MIDD’s Sector and Industry.  Rank is defined by the RSI(9) of its Industry and Sector.

 

At the bottom is the RSI(9) chart of MIDD, it’s Sector and It’s Industry.

 

FYI…  I ALWAYS show the market overlays in yellow, Sectors in aqua and Industry in orange.  After experimenting with this, I found it massively confusing to have multiple colors in different charts. I strongly recommend using standard colors for this.

 

Best regards,

 

Dan.

 

 

 

function MarketCapGet()

       {

       CurDatabase = GetDatabaseName();

      

       if(CurDatabase == "QuotesPlus_Stocks")

              {

              MarketCap = round(Close[BarCount -1] * GetExtraData("shares")/1000);

              }

       else

              {

              MarketCap =   666;   //indicating N/A

              }

       return MarketCap ;

       }

 

function MarketCapCategoryGet(MarketCap)

       {

       CurDatabase = GetDatabaseName();

      

       if(CurDatabase == "QuotesPlus_Stocks")

              {

              if (MarketCap < 1000)

                     MarketCapCategory= "Small";

              else

                     {

                     if (MarketCap >= 1000 AND MarketCap < 5000)

                           MarketCapCategory= "Mid";

                     else

                           MarketCapCategory= "Large";

                     }

              }

       else

              {

              MarketCapCategory=   "N/A"; //indicating N/A

              }

       return MarketCapCategory;

       }

 

function MarketCapCodeGet(MarketCapCategory)

       {

       CurDatabase = GetDatabaseName();

      

       if(CurDatabase == "QuotesPlus_Stocks")

              {

              if (MarketCapCategory      == "Small")

                     MarketCapCode = "SC";

              else

                     {

                     if (MarketCapCategory      == "Mid")

                     MarketCapCode = "MC";

                     else

                     MarketCapCode = "LC";

                     }

              }

       else

              {

              MarketCapCode = "N/A";      //indicating N/A

              }

       return MarketCapCode;

       }

 


From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf Of Ara Kaloustian
Sent: Sunday, November 06, 2005 12:02 PM
To: amibroker@xxxxxxxxxxxxxxx
Subject: Re: [amibroker] Quotes Plus - Sectors

 

Thanks Dan,

 

You gave me a lot to think about.  I'll need a little time to absorb all you have said.

 

Yes, I would appreciate snapshots of charts. That's always helpful to visualize.

 

It would be useful if we were to use same structures so we could also collaborate on trading issues.

 

Ara

----- Original Message -----

From: Dan Clark

Sent: Sunday, November 06, 2005 10:56 AM

Subject: RE: [amibroker] Quotes Plus - Sectors

 

Ara,

 

I do this now.    Relative Strength and Relative Performance of Sectors and Industries to Markets, and Stocks to Sectors, Industries and Markets are key to my trading strategy.

 

I’ve spent a lot of effort working on this in the last six months.  Two issues are critical (IMO):

 

·         Algorithms to use – Indicators, calculations, etc.

·         Symbols to compare – Supplied Indexes (!SPX, !NYA), ETFs (QQQQ, IYF, BBH, VTI), Composite indexes and Indicators.

 

Regarding the algorithms, I’ve tried several ways of defining relative strength and performance.  You can:

 

1.       Compare several tickers using the “Relative Performance” chart (Charts à Basic Charts à Relative Performance) which measures rate of change from a particular point.   Or,

2.       Use “price relative” which is nothing more than dividing a symbols price by another symbols price (e.g., IYF/!NYA).   Or,

3.       Use the “strength” of one ticker versus another.  This could be as simple as RSI a complex algorithm where “strength” is computed base on RSI + ROC over a number of periods + number of days over/under key moving averages.   (This is Jason Hart’s work.  Look for his posts on AB forum dated 7/1, 7/9 7/13 and 7/18 of 2005.)   Or,

4.       Use the “strength” in item 3 as a means of computing the “rank” and compare the ranks.  For example, rank of a sector when compared to other sectors.

 

While the algorithms are important, more important is choosing the correct symbols to compare

 

It turns out that a stock’s Sector and Industry categorization is one of the worst “rat holes” that I’ve found in analyzing the markets.  There is no standard categorization that I can find.   GICS is one “standard”.   TC2000 has their categorization.  Quotes Plus has their categorization.     And there is not standard for ETFs.   This is important to understand when choosing an “index” for comparison.  

 

Another issue is weighting of the “index”.   It turns out that there is no weighting standard.    What’s not well known (at least to me, as of three months ago) is that most indexes and ETFs are weighted:

 

·         Most of the standard indexes (!SPX, !NYA, etc.) are Cap-Weighted.  The percent of the index is based on the market cap of the symbol.  

·         Some are using other weighting systems (I believe the Dow is equal weighted)

·         Some are weighted using an unknown algorithm.   ETFs appear to use this method.  For example, 60% of the BBH is composed of two stocks Amgen and Genentech.  I can’t find anything on why they use this weighting.

 

What is critical about weighting is that it affects how the index chosen reacts.  For example, if you use BBH as an “index”, you can see wild swings based almost completely on the movements of Amgen and Genentech.   As another example, market cap-weighted indexes movements are driven heavily by the movements of the biggest companies.   This does NOT necessarily indicate where the entire market is going and where money is flowing.

 

Here’s a link to the S&P site on indexes:

 

Click on “Index Methodology”.  The “Mathematics of Index Calculation” is actually the best and covers the three type of indexes and how to calculate them.   (This is critical to understand when creating your own indexes.)

 

Given the confusion surrounding this whole issue, I chose to:

 

·         Use Quotes Plus Industry and Sector categorization

·         Create my own Industry and sector indexes and indicators based on ATC composite symbols.

·         Create simple summation indexes.  (Sum each stocks price and volume irrespective of market cap.)

·         Categorize indexes at the Country, then market, then sector, then industry, then Market Cap (Small, Med, Large) level.

 

Below is the key scan function that I use to load a composite symbol, reset the “Full Name”, and add it to a target watch list.  Note that it is critical to use short symbol names and put the descriptive name in the FullName. 

 

Also critical is to define a naming structure that makes sense to you.  This becomes especially important when branching out from Indexes into other, more complex indicators (money flow, A/D, new hi/low, etc.).   My naming is:

 

 “~” + IndicatorType + CountryCode + LevelType + MarketCapType + NativeSymbol

 

For example, for an index of US Small Cap Energy Sector it would be:

 

“~” + “Index” + “_” + “US” + “Sec” +  “SC” + “_” + “5”  = “~Index_USSecSC_5”

 

The symbol full name would be:  “~Index_USSecSC_Energy”

 

Finally, attached is a snapshot of a relative performance (ROC) chart of my Sector composite symbols and the QP3 S&P market symbol (!SPX) for the last 21 trading days.

 

I hope this helps.  Let me know if you’d like snapshots of other charts.

 

Regards,

 

Dan.

 

 

Retrieving the Sector and Industry names:

SectorSymbol  = NumToStr(SectorID(0), 1.0); 

SectorName    = SectorID(1);  

IndustrySymbol       = NumToStr(IndustryID(0), 1.0);  

IndustryName = IndustryID(1);  

MarketName    = MarketID(1);

 

Calling the CompositeLoad procedure:

CompositeLoad("~Index_USMkt", "~Index_USMkt" , WeightedClose, WeightedOpen, WeightedHigh, WeightedLow, V/1000, iCount, atcCurrentFlags, WLKeyIndexes, WLAllIndexes);

 

CompositeLoad("~Index_USSec_" + SectorSymbol,"~Index_USSec_" + SectorName, WeightedClose, WeightedOpen, WeightedHigh, WeightedLow, V/1000, iCount, atcCurrentFlags, WLUSSectorIndex, WLAllIndexes);

 

CompositeLoad("~Index_USInd_" + IndustrySymbol , "~Index_USInd_" + IndustryName, WeightedClose, WeightedOpen, WeightedHigh, WeightedLow, V/1000, iCount, atcCurrentFlags, WLUSIndustryIndex, WLAllIndexes);

 

Load Procedure:

procedure CompositeLoad(Sym, SymName, CloseVal, OpenVal, HighVal, LowVal, VolVal, OpenIntVal, ATCFlags, TargetWLNbr, AllIndexWLNbr)

       {

       //Add To Composite

       AddToComposite(CloseVal,   Sym,   "C", ATCFlags);

       AddToComposite(OpenVal,           Sym,   "O", ATCFlags);

       AddToComposite(HighVal,           Sym,   "H", ATCFlags);

       AddToComposite(LowVal,            Sym,   "L", ATCFlags);

       AddToComposite(VolVal,            Sym,   "V", ATCFlags);

       AddToComposite(OpenIntVal, Sym,   "I", ATCFlags);

  

   //Modify Names

       cs                   = AB.Stocks(Sym)     ;                                         

       cs.FullName = SymName                    ;                                  

 

       // Add to Watchlists

       if (TargetWLNbr == 0)

              CategoryAddSymbol(Sym, categoryWatchlist, TargetWLNbr);

 

       if(StrLeft(Sym, 6) == "~Index")

              CategoryAddSymbol(Sym, categoryWatchlist, AllIndexWLNbr);  

 

       // Add to Market and Sector INdexes

 

       if (   StrLeft(Sym, 15) == "~Index_ADR_Sec_"

              OR StrLeft(Sym, 13) == "~Index_ADRMkt"

              OR StrLeft(Sym, 16) == "~Index_NasdaqMkt"

              OR StrLeft(Sym, 14) == "~Index_NYSEMkt"

              OR StrLeft(Sym, 12) == "~Index_USMkt"

              OR StrLeft(Sym, 12) == "~Index_USSec"

              )

              CategoryAddSymbol(Sym, categoryWatchlist, WLMktAndSectorIndexes);  

       }

 


 


Yahoo! Personals
Skip the bars and set-ups and start using Yahoo! Personals for free



Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com

For other support material please check also:
http://www.amibroker.com/support.html





YAHOO! GROUPS LINKS