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

[amibroker] Re: Using AFL to process many stocks: creating your own index



PureBytes Links

Trading Reference Links

Re: automating composite or index creation?

I didn't answer Q3 because I am not that strong in the area.
Yes, others do it.
I think if you nominated a specific preference and a specific example 
someone is likely to help you, especially if you start a fresh topic 
as your question 3 may have got lost amongst my chat.

It can be done from within AFL.

Search the AFl library for *composites* to find discussion/code by 
Mark H. and Fred Tonetti under WL Build Process and Calculate 
Composites for Tickers in List Files.


Also below is an example of the type of discussion in the forum 
listed under an *ATC* search. I think it is by Herman or Anthony 
Faragasso around the #60-70000 message mark.

if(InWatchList(1))

{

sym="~" + "ABC";

AddToComposite( L, sym,"L");

AddToComposite( O, sym,"O");

AddToComposite( H, sym,"H");

AddToComposite( C, sym,"C");

AddToComposite( V, sym, "V");

}

else if(InWatchList(2))

{

sym = "~" + "XYZ";

AddToComposite( L, sym,"L");

AddToComposite( O, sym,"O");

AddToComposite( H, sym,"H");

AddToComposite( C, sym,"C");

AddToComposite( V, sym, "V");

}

Buy=Sell=Short=Cover=0;

Filter=1;

Herman or Anthony Faragasso

There are other ways to go about it as well.

Read below for a bit more chat.

--- In amibroker@xxxxxxxxxxxxxxx, "foginthehills" <andrewdelin@xxx> 
wrote:

I still need 
> to work out how to process many tickers into an index, 
automatically -
> - I might look at VBScript to drive AB to achieve this, or 
> automatically generating indicator definitions as .afl text files 
> before starting AB.

I believe some use VB for automation.
That would be for multiple indexes and ongoing updates I would 
presume.
You will need some one elses help for that.

I would like to give a more fulsome answer.
Time presses.
To make sure all of the background info has been covered.

ATC is the method.
A simple scan run over a watchlist easily produces a custom index.

It depends on what type of index you want to create.
In this case the philosphy is a way harder than the application.

The simplest index assumes that one share of each constituent is 
purchased and held for the period (day,week,month,year?).
My group file example is a variation on that where the initial number 
of shares purchased is *weighted* by  equal $ values.

A weighting can be based on any measure.
My approach is to reduce them to a number 1 based relative scale.

MoneyFlow or capital for stock A,B and C could be 2,3,5 or 200k, 300k 
and 500K, the relative weighting is still the same and it is applied 
in a similar method to the *carlacash* example.

Convert to relative weighting by dividing all by lowest or highest 
value e.g 2/2, 3/2 and 5/2 == 1,1.5 and 2.5 Weighting Factor.

So for a buy&hold equivalent index (similar to DJIA?) the scan would 
sum the close for all constituents bar by bar.

For a weighted index ATC could sum(close *weighting factor) for all 
constituents bar by bar.
The weighting factor could be picked up from a file list or 
calculated within AFL.
They can also be stored as a constant in VarSet but that is only good 
for the session.
Storing them as a constant means they don't have to be recalced for 
each bar which saves processing time.

The MF *method* you mentioned is a variation of inverse weighting so
for stock A,B or C above the relative weighting is 1/2,1/3 and 1/5 
which *standardised* to a one based scale == 1, 0.6666, and 0.4 

Over time stock C may grow at a faster rate than A or B and C then 
unduly influences the index.
That's OK if it suits the strategy.
To get arond this *problem* indexes are periodically rebalanced.

The question is what weighting to apply and how often and/or how to 
rebalance.
Corporate index makers turn themselves inside out trying to achieve 
this and keep their paying customers happy at the same time.

There is also the little problem of rotating membership and price 
adjustments for splitting stocks etc.

Some traders use what I call the *Traders Index*.
It normalises by using ave(ROC per period), so that the index 
reflects average bar by bar growth.

I can't post anything on that topic at the moment due to other 
commitments.

> One question: given most sectors have a few major (*Big*) players 
and 
> then many smaller stocks, does the largest player in a sector work 
as 
> a proxy for the sector index? E.g. if Bio+Pharm is rising as a 
> sector, can we just use GLAXO as a substitute for creating an 
index? 
> (Or GLAXO plus the next 2 largest?)

I don't know.
I have never tried it.

Like your other idea, it is not so crazy.
Creative thinkers always get paid a lot more than drones ;-)

The proof of the pudding is in the eating.
As long as you can objectively define, measure and test your ideas.  


Selecting a subset of a sector is a way of customising sectors which 
is a huge topic.


Brian.

Your pen name reminds me of a poem I picked up in the 70's or 80's.

I think it came from Alan Watts book, *The Way of Zen* but I doubt if 
he was the author.


I saw the boy beneath the pines,
he said;

"The MASTERS gone alone,
herb picking somewhere on the MOUNT,
cloud hidden, whereabouts unknown."


> -------------------------
> 
> --- In amibroker@xxxxxxxxxxxxxxx, "brian_z321" <brian_z321@> wrote:
> >
> > Hello foginthehills,
> > 
> > --- In amibroker@xxxxxxxxxxxxxxx, "foginthehills" <andrewdelin@> 
> > wrote:
> > > A few questions:
> > > 
> > > 1) How can I do this in AFL? Backtesting or scanning doesn't 
seem 
> > to 
> > > be the mode to perform comparative tasks across all stocks in a 
> > > watch list?
> > 
> > Indexes and sector classification are huge subjects, each worthy 
of 
> a 
> > book, not the least because they are a real rats nest of various 
> > methods and approaches.
> > 
> > The answers around meassage # 108612 in topic *help with weighted 
> > index* by carlacash might help get you started.
> > 
> > I also posted a rough and ready GUI method of doing buy&hold 
> indexes 
> > via the backtester. Refer CompareIndexToPortfolio in files area.
> > It provides a quick comparision between the buy&hold versus 
> weighted 
> > at a conceptual level.
> > 
> > IMO all indexes, theoretically speaking, are ranged somewhere 
> between 
> > buy&hold on one hand and equal weighted on the other with 
> weightings 
> > of various kinds making up the middle ground.
> > 
> > To my mind understanding the difference and knowing how to 
> calculate 
> > each type is the starting point.
> > 
> > Those answers are only scratching the surface though.
> > 
> > A lot of discussion in this area took place under ATC.
> > 
> > Once construction of the various index types has been mastered 
> there 
> > is a chapter in Howard's book that opens the door to some 
creative 
> > ways of applying sector analysis.
> >  
> > > 2) Any suggestions or problems with this crude index approach? 
I 
> > > just want a simple sector index and my data provider doesn't 
> supply 
> > > this from S&P. The indexes aren't available on Yahoo either.
> > 
> > The index to use is a personal preference choice.
> > Custom indexes are one area where AB users can gain an advantage.
> > I think most long term users have worked with them as some point.
> > Some specialise in the area and go right into it.
> > 
> > There are downloadable docs that describe the various methods and 
> > nomenclatures used by the *corporate index makers* at places like 
> the 
> > S&P, Russell and Dow web sites.
> >  
> > Money flow weightings would probably be close to cap weighted 
> indexes 
> > as the *big* cap companies will come out near the top for price 
and 
> > volume anyway.
> > 
> > You might have some problems with big numbers exceeding capacity 
if 
> > you are going to sum (vol*price).
> > 
> > Since the weightings would be used for relative comparision there 
> is 
> > no need to keep to absolute values.
> > Divide vol by a common factor to get smaller numbers or just use 
MA 
> > of MoneyFlow rather than the sum.
> > 
> > You are probably better off smoothing MF anyway.
> > 
> > Brian.
> >
>




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 NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html
 
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/