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

Re: [amibroker] AddtoComposite



PureBytes Links

Trading Reference Links


On Apr 28, 2006, at 12:16 PM, Jeff Springer wrote:

John,
Thank you so much for replying. I think I understand the principle of what you wrote, I'm just not sure I know how to code it. If you wouldn't mind a few questions?
 
1) If I don't use loops, how will I iterate through each sector/industry?

You don't. The Scan iterates over each security symbol automatically. Then the SectorID() and IndustryID() function calls give you the identifier for each security. With that you do an AddToComposite() for each Security and Industry Group. Remember you're adding the value of each security's OHLC to the composite symbols which are the Security and Industry name.

You kindof have to get into the gestalt of AMIBroker's vector processing paradigm.

Think of your code being called once per security symbol (when the filter is set to "all symbols").

What are "the integer codes"?

The numeric codes for Industry Group and Sector. IndustryID() and SectorID() take parameters that direct the functions to return either string names or numeric codes.

 2) The following code gives me composite symbols in group 252 for all my sectors (for some reason, it also puts them in Market 253?) with no OHL, but an (I believe) aggregate QRS as the close price. I'm not sure if the "I" value is correct, is there a way I can see it to check it?
 
SetBarsRequired(500,0);
for(a = 1; a < 40; ++a)
{
Filter = SectorID(0) == a;
secnam = "~Sec~" + SectorID(1);
CategoryAddSymbol(secnam,categoryGroup,252);
QRS=GetExtraData("QRS");
AddToComposite( QRS , secnam, "C");
AddToComposite(1,secnam,"I");
Buy = 0;
}

I think the problem here is that you need to assign the category AFTER you add to each composite. This code adds the QRS value to the "C" field, but you also need to pass 1+ 2 + 8 + 16 into the AddToComposite flag parameter. The "1" erases the prior values at the beginning of the scan.

And get rid of the loop.

If I may, allow me to restate what your principle is:
Basically, in the first scan, you're creating composite symbols that only have the aggregate QRS values and a counter to determine how many symbols make up each composite. Then, with the second scan, you're going through each composite symbol to calculate average QRS. In the end, I should have a list of composite symbols with just average QRS values for each day, correct?

Yes that's it. Unfortunately this leaves you with a pile of composites in Group 252 that contain the summed values and the counts, which may seem wasteful, but I couldn't find any other way to calculate my averages without an intermediate set of values persisted as symbols.

If so, I don't see a problem with this, though it would be nice to simply have composites with OHLC and QRS so I'm only dealing with one list.

It would be nice!

In addition, I don't really need composites with just the average QRS since I'm only going to use the sector/industry QRS to explore for sectors/industries which have improving QRS. In that case, I could simply use the following code (for example) to explore Group 252 for the changing QRS:
 
//explore on Group 252
AvgQRS=C/OI;
AddColumn(AvgQRS,"AvgQRS");
AddColumn(Ref(AvgQRS,-30),"30AQRS");
Filter=1;

You are correct. My second scan persisted the average in new composites in Group 253. You have an exploration at that stage.

 Would there be a way to add this average QRS to perhaps the open interest field of each industry's/sector's composite so I have OHLCV and QRS in one list?

Ah, I tried clearing the old values of already existing composites and then adding new values back into them so as to consolidate everything and couldn't get it to work. It doesn't appear that existing values can be modified after the Scan.

 Thank you, again, for your time.
 
Jeff

No problem. About time I gave back to the group.

-- John


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





SPONSORED LINKS
Investment management software Real estate investment software Investment property software
Software support Real estate investment analysis software Investment software


YAHOO! GROUPS LINKS