PureBytes Links
Trading Reference Links
|
Dan:
Sigh. I put this code into a js file. I specified a single watchlist, and
specified code that had a simple ATC for one watchlist, with the ATC name
corresponding to that watchlist (no dynamic naming attempts here as I am
trying to crawl before walking). :o
I clear (delete) the ATC from Group 253. I have AB open. I run the js
file. The AA window is opened (I started with it closed). But I can find
no evidence that the ATC was created. It certainly is not in Group 253.
So another blank wall for me on this task.
Any further coaching that would get me going.
Thanks,
Ken
_____
From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf
Of Dan Clark
Sent: Tuesday, August 08, 2006 11:03 PM
To: amibroker@xxxxxxxxxxxxxxx
Subject: RE: [amibroker] Quotes Plus - Sectors
Ken,
I'm woefully late in responding to many people who have raised issues and
asked questions. I've been involved for the last several months in
rebuilding my master bathroom (WAY more work than I planned) and have a new
contract (as a software developer) with a large software company in the
Seattle area. So, I haven't been coding AB for a while and owe apologies to
many people. That said.
I'm not exactly sure what you are looking for, but I believe there are
generally two issues. First is to limit your AA Scan or Exploration to a
filtered list of symbols, and the scan or exploration only runs on symbols
in that list. This ensures that you only start out with a specific list of
symbols. The second is to see if a symbol is within a specified list.
I.e. when you scan or explore, you are iterate through a list of symbols;
for the current iterated symbol, is that symbol in ANOTHER list?
ISSUE ONE - For the first issue, I use a Jscript script that
programmatically specifies the list to start with. Here's the Jscript that
runs a scan:
/* create AB object */
AB = new ActiveXObject("Broker.Application");
/* retrieve automatic analysis object */
AA = AB.Analysis;
/* load formula from external file */
AA.LoadFormula("C:\\Program
Files\\AmiBroker\\Formulas\\Systems_DailyScans\\B_QPAddIndexRelativeStrength
..afl")
/* setup filters */
/* backtest over symbols present in market 0 only (zero-based number) */
AA.ClearFilters();
AA.Filter( 0, "watchlist" ) = 49;
/* set apply to and range */
AA.ApplyTo = 2; // use filters
AA.RangeMode = 2; // use last day's quotes
AA.RangeN = 1;
/* run backtest and display report */
AA.Scan();
This particular scan:
1) Instantiates AB
2) Retrieves that AA object
3) Loads the AB Scan "B_QPAddIndexRelativeStrength.afl"
4) Clears the current filters
5) Sets the "Apply To" filter to use Watchlist 49
6) Runs the scan.
You can use any Watchlist number and/or can save flags to files or variables
or a DB, and then use those flags to run scans against any Watchlist you
want. For example, you can run one scan and for those symbols that meet
criteria, you can save those symbols to one or more Watchlists. Then you
can analyze those symbols and set flags in a file using a second flag.
Finally, in a third scan, you can analyze those flags and choose a specific
Watchlist based on the flags.
ISSUE TWO - For the second issue, I use the "InWatchList()" function.
I.e., "InWatchList(50)" essentially says, is the current symbol in Watchlist
50? This allows you to test for a symbols existence in one or more
Watchlists. For example, I have a Watchlist called "Symbols To Exclude"
(WL 13). In this Watchlist are all those symbols that I want to ignore
under all conditions. Here is some example code that excludes symbols in
Watchlists 13, 14 or 15.
if ( CloseMA <= PriceMax
AND NOT(InWatchList(13)) // Symbols to Exclude
AND NOT(InWatchList(14)) // Exclude Stalking - Long
AND NOT(InWatchList(15)) // Exclude Stalking - Short
)
bMeetsMinCriteria = True;
else
bMeetsMinCriteria = False;
I hope this helps.
Regards,
Dan.
_____
From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf
Of Ken Close
Sent: Tuesday, August 08, 2006 7:25 PM
To: amibroker@xxxxxxxxxxxxxxx
Subject: RE: [amibroker] Quotes Plus - Sectors
Dan Clark: this is an old message you posted which I saved and you seem
well versed in the use of ATCs esp on multiple watchlists.
Can you please answer this question for me. In using any kind of code which
reads multiple watchlists (and has dynamic naming), how do you RUN it? A
simple question I know but what filter do you apply in the AA window.
I have asked this and received a private reply from dingo saying to set the
Current symbol, and another here which suggested setting a watchlist
containing all of the symbols likely to be in the various watchlists. This
probably would be a list of all symbols.
Is there any way around this. Another suggestion was to use jscript and
various objects, which is beyond me I am afraid.
Any help?
Ken
_____
From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf
Of Dan Clark
Sent: Sunday, November 06, 2005 1:57 PM
To: amibroker@xxxxxxxxxxxxxxx
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:
http://www2.
<http://www2.standardandpoors.com/servlet/Satellite?pagename=sp/Page/Indices
BrowseMethodologyPg&r=1&l=EN&b=4&s=6&ig=51&i=128&si=&d=&xcd=500EW&f=3>
standardandpoors.com/servlet/Satellite?pagename=sp/Page/IndicesBrowseMethodo
logyPg&r=1&l=EN&b=4&s=6&ig=51&i=128&si=&d=&xcd=500EW&f=3
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);
}
_____
From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf
Of Ara Kaloustian
Sent: Sunday, November 06, 2005 9:15 AM
To: amibroker@xxxxxxxxxxxxxxx
Subject: Re: [amibroker] Quotes Plus - Sectors
Thanks Duke,
Yes I am looking at something very similar to what you are doing ... guess
I'll create the sectors using ATCs. Not the most efficient, but I expect to
run this weekly, so no big deal.
Ara
----- Original Message -----
From: Duke Jones, <mailto:Lists@xxxxxxxxxxxxx> CMT
To: amibroker@xxxxxxxxx <mailto:amibroker@xxxxxxxxxxxxxxx> ps.com
Sent: Sunday, November 06, 2005 7:32 AM
Subject: Re: [amibroker] Quotes Plus - Sectors
Ara,
I might be misinterpreting your question so my apologies if this is not what
your asking for....You could use the S&P Select Spyders (XLE - Energy etc.)
as your sectors and compare against each stock marked within AB (using
Symbol/Categories with XLE as the RS symbol) or if you have QP data you can
build your own sectors and industry group composites and compare against
them. I use QP's industry classification but create my own sector hierarchy
as in the attached picture which is showing the Banking-Midwest industry
group with an RS line measuring against the sector as well as the market. To
make all of the indicators easily I use simple symbols like BANK1 (1 always
the sector) and BANK2 etc. so that I could "find & replace" in word to make
the process easier as I have 25 Sectors and over 200 industry groups. I
then created layouts for each Sector including their corresponding industry
groups. I also created a watch list of the industry groups so I can easily
run scans on RS rankings Alpha etc.
I am sure there is a better/faster way but this worked for me. Again, not
sure this is what your asking but hopefully this may be of some help.
Relative strength of Midwest Banks to Banking Sector
Duke Jones, CMT
Ara Kaloustian wrote:
How would one compute Industry Relative Strength relative to Sectors ...
since there is sector data in QP... just sector groupings.
Compare the Industry values to the Standard and Poors sector values?
Anyone done this ?
Thanks
Ara
--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.362 / Virus Database: 267.12.8/162 - Release Date: 11/5/2005
|