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

RE: [amibroker] AFL help



PureBytes Links

Trading Reference Links

Jason,

 

Right now, I’m experimenting with several types of indicators (including one that uses parts of your relative strength scan).      As I fine tune the system, I’m sure that I’ll cut back on the types of indicators and the number of periods used.   But…

 

In general, I’m using several types of composite “indicators” and am thinking about using another:

 

  1. Summation index of all stocks whose Group is “Common Stocks” and whose Sector <> “Undefined”
  2. Custom Money Flow indicator similar to Chaikin, but computed using price and volume.
  3. New Hi’s/Lows’s in the last 10 days and in the last 6 months.
  4. Advance/Decline counts and volume.
  5. Relative Strength of the summation index (item 1, above)
  6. Ranking of ATC symbols using relative strength (item 5, above) within its hierarchy level (see below).
  7. RSI Counts (currently early experimentation with this one).

 

With the exception of #7 above, each of the indicators are broken down by Group (US Stocks vs ADR), then by Sector, then by Industry.   Orthogonally, each of the levels (Group, Sector, etc.) is further broken down into four components – Large Cap, Mid Cap, Small Cap, and All Caps.      In addition, all stock symbols are mapped to an industry and Group.  Industries are mapped to a Sector.  Finally, I have Market-related indicators (NYSE, NASDAQ, etc).  

 

For analysis, I can chart or scan on any of the ATC symbols looking for strongest/weakest groups, sectors, industries, in total or by cap level.     Or, I can use the ATC symbols as overlays on a stock chart.   I.e., I can chart a stock symbol and overlay an indicator of its group, sector and industry (by Market Cap or not) – either the index, money flow, new hi/lows, AD, relative strength, or RS rank. 

 

As you can see from the attached “ABAXWithNewHiLow.gif” file, any of the indicators can be chosen as an overlay and parameters drive how it’s displayed.  For example, I can choose the “New HiLow Period” of either Short (10 days) or Long (125 days).   For AD, I can select either to use the AD Volume or AD Count displayed as either a raw value or as percent of total value.     

 

The ABAXWithNewHiLow.gif shows the symbol ABAX.  Its industry is “Health-Instruments”.  It’s a “Small Cap” stock.   I’ve overlaid the Short-term New Hi/Low indicator (new highs and lows in the last 10 days) for the US, Small Cap, Health-Instruments stocks.    (As you can see, small cap Health Instruments is getting more volatile in the last 10 days.)

 

For example, the attached Top2StrongestWeakestSectorsMidCap.gif shows a Relative Performance (ROC) chart of Mid Cap Sectors for the last 21 trading days.   It is filtered to show only the top and bottom two sectors.   The NYSE Composite Index (“!NYA” Quotes Plus symbol) is plotted for comparison.   AllStrongestWeakestSectorsAllCap.gif shows the same thing with all Sectors displayed (not just top and bottom 2) and showing the “All Cap” indexes (not just the Mid Cap indexes).

 

Crunching these indicators takes three scans which run in about 35 minutes end-to-end.   I’ll be automating the scan process shortly, but now I run 1, then 2, then 3.  Once created, scanning or charting the indicator symbol is very quick (just like any other symbols).  

 

I’m a Data Warehouse Architect by profession.  One of the key strategies in Data Warehousing is preprocessing and pre-“crunching” data for customers.  I.e., massage and aggregate data offline so the customers get high-speed results.    That’s what I’ve done here.   Now I focus on analysis and I’m not slowed down waiting for data to be crunched.   In many cases, what I’m doing would be virtually impossible if the indicators were calculated real-time.

 

One of the key issues here is that I’m experimenting.  Some of my ideas are pretty stupid.  Some work out nicely.    But I don’t know which is which until I try them out.   Using pre-processed ATC symbols, I can run tests and experiment very quickly.   Without ATC symbols, testing would be long and arduous at best, and impossible at worst.

 

I think that ATC is the MOST powerful, but least appreciated feature in AB.    While AB has a very powerful feature set, the other power features pale in comparison to ATC!   (IMO, of course.)

 

Regards,

 

Dan.

 


From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf Of Jason Hart
Sent: Thursday, October 27, 2005 5:33 AM
To: amibroker@xxxxxxxxxxxxxxx
Subject: RE: [amibroker] AFL help

 

Dan,

 

I read you have constructed something like 4,000 composites.  Can you share as to what you do with all of these?!  I don't have many, maybe a little over a dozen or so, but I mostly use mine for market sentiment purposes.    I'm curious how other AB users apply this powerful tool.

 

Jason 

Dan Clark <dan_public@xxxxxxxxxxx> wrote:

Pankaj,

 

As Jason and others have said, you need to use AddToComposite.  There are actually two parts.  First is the AddToComposite Exploration to create the ATC symbol.  Second is the Chart plotting AFL to plot the ATC symbol. 

 

As a quick exercise, I created both (below). 

 

Notes:

 

  • I used the “H” and “L” values to save the GT and LT counts.  
  • I use an Exploration so that I can audit the values produced.  A bit slower, but more accurate.
  • The procedure allows you to package the code and more easily reuse if you want to create more symbols.  I.e., you could change the name of the symbol and then add additional symbols by calculating different RSI values and simply calling CompositeLoad multiple times:
    • CompositeLoad("~RSI_9_40Counts"…
    • CompositeLoad("~RSI_9_50Counts"…
    • CompositeLoad("~RSI_14_40Counts"…

 

ATC is a very nice AB feature.  Currently, I’m creating about 4,000 ATC symbols. 

 

Regards,

 

Dan.

 

 

Chart Plot:

//Save to file name like, “PlotRSICounts.afl” and then add as a pane.

if(Name() == "~RSICounts")

   {

   RSIGreaterThanTargetCount  = H;  

   RSILessThanTargetCount     = L;

  

   Plot(RSIGreaterThanTargetCount , "RSI >= 40", colorGreen, styleLine | styleThick);

   Plot(RSILessThanTargetCount       , "RSI < 40"  ,  colorRed, styleLine | styleThick);

   }

 

ATC Exploration:

//Save this to a file named like, “RSICountsComposite.afl.

 

//Open file in AA. Use a filter to define the source Watchlist, group, etc.

//Click “Parameters” and set your target RSI Value (like “40”), the

//number of RSI Periods (like “9”) and the target Watchlist number (like “61”)

//where you want to resulting symbol to be saved.

 

// Instantiate Broker.Application

AB = CreateStaticObject("Broker.Application");

 

//Procedure to add to Composite values

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

   {

   //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);

   }

  

//Parameters

RSIPeriods              = Param( "Number of RSI Periods", 9, 1, 100, 1 );

RSITargetValue          = Param( "RSI Target Value", 40, 1, 100, 1 );

 

//Set Watchlist to save target symbol

TargetWatchListNbr      = Param( "Target Watchlist Number", 61, 1, 63, 1 );

 

//Get RSI Value

RSIValue             = RSI(RSIPeriods);

 

//Set the counts

RSIGreaterThanTargetCount  =  IIf(RSIValue >= RSITargetValue, 1, 0);

RSILessThanTargetCount     =  IIf(RSIValue < RSITargetValue, 1, 0);

      

//AddToCompositeFlags

atcCurrentFlags =  atcFlagResetValues + atcFlagCompositeGroup + atcFlagEnableInExplore;

 

//Load composite symbols and add to watchlist

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

CompositeLoad("~RSICounts", "~RSI Counts GT and LT 40", 0, 0, RSIGreaterThanTargetCount, RSILessThanTargetCount, 0, 0, atcCurrentFlags, TargetWatchListNbr);

 

//Filter for exploration - get all symbols

Filter = Buy = 1;

 

//Exploration columns

SetOption("NoDefaultColumns"   , True );

AddTextColumn(Name()       , "Symbol");

AddTextColumn(FullName()      , "Company");

AddColumn(RSIValue                , "RSIValue");

AddColumn(RSIGreaterThanTargetCount   , "RSIGreaterThanTargetCount"  , format = 1.0);

AddColumn(RSILessThanTargetCount      , "RSILessThanTargetCount"     , format = 1.0);

 

 


From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf Of Pankaj Chawla
Sent: Tuesday, October 25, 2005 4:36 AM
To: amibroker@xxxxxxxxxxxxxxx
Subject: [amibroker] AFL help

 

Given below is what am lookin for

I want to plot the NUMBER of issues(scrips) with rsi
below 40 and also plot the NUMBER of issues with rsi
above 40.

say if out of 100 issues.. there are 30 scrips
matching rsi (10)<40, and 70 matching rsi(10) > 40.

how would i get those figures n how do i plot them as
a indicator. I want to plot two lines one for each

match on a daily basis.

Hope am clear on what i want.

Thanks

Pankaj
 

 


Yahoo! FareChase - Search multiple travel sites in one click.


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




Attachment: AllStrongtestWeakestSectorsAllCap.gif
Description: GIF image

Attachment: Top2StrongtestWeakestSectorsMidCap.gif
Description: GIF image

Attachment: ABAXWithNewHiLow.gif
Description: GIF image