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

Re: [amibroker] AddtoComposite



PureBytes Links

Trading Reference Links

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? What are "the integer 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;
}

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?
 
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. 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;
 
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?
 
Thank you, again, for your time.
 
Jeff
John Nelson <trader@xxxxxxxxxxxxxxx> wrote:
Jeff,

Here's my two cents...

1) First, get the SectorID and IndustryID for each security in the 
scan with a simple call to these functions and construct new 
composite symbols from their names. Do not use the integer codes. 
Ditch the loops... not needed.

2) Use AddToComposite to accumulate the OHLC's for each security and 
add them to the new composite names constructed from the Sector and 
Industry Group names. In your case, I guess you would replace the "C" 
field with the QRS values.

3) Count the number of securities by adding "1" to the "I" field of 
each composite. This running count should be the same for all bars.

4) Store the composites in Group 252 using CategoryAddSymbol.

5) Set your AA filter to Group 252 so that the next scan sees your 
new composites.

6) In a second scan, calculate the average using the EndBar open 
interest value as the total count for each Industry Group or Sector.

7) Add these averages to a new set of composites in Group 253 with 
AddToComposite.

I'm not really sure compositing QRS like this is really going to buy 
you anything but I'd be interested in hearing what comes of this.

All the best,

-- John


On Apr 27, 2006, at 11:23 PM, fatboycato wrote:

> Once again, I turn to the smart people on this forum for help. I
> have code (from here) that creates composites of sectors and
> industries. I would like to also include a chart of the QuotesPlus
> QRS reading on a sector and industry basis. I thought it would be as
> easy as including a couple lines like: QRS=GetExtraData("QRS");
> AddToComposite(QRS,"mySecName","QRS");. Then I realized that
> C,O,H,L,I, and X are the only fields available for ATC. So, I tried
> putting in AddToComposite(QRS,"mySecName","I"); but that didn't work
> either. I think it's a problem in the GetExtraData() call in that
> it's not getting the QRS for each stock and storing it in the "I"
> field.
>
> As I thought about it more, I realized that just having the
> cummulative QRS for each stock in the composite is going to be
> meaningless since it should probably be an average. In that case,
> I'm going to need to calculate just how many stocks are in each
> sector/industry. That probably won't be a problem, but suggestions
> would be nice.
>
> My code is below since my explanations are rarely very clear. Any
> help would be much appreciated. Even if it's just to give me
> something more to think about.
>
> // use this in scan to calculate the composites for all sectors
> SetBarsRequired(500,0);
> QRS=GetExtraData("QRS");
>
> for(a = 1; a < 40; ++a)
> {
> Filter = SectorID(0) == a;
> secnam = "~Sec~" + SectorID(1);
> AddToComposite( C , secnam, "C");
> AddToComposite( O , secnam, "O");
> AddToComposite( H , secnam, "H");
> AddToComposite( L , secnam, "L");
> AddToComposite( V/1000 , secnam, "V");
> AddToComposite(QRS,secnam,"I");
> Buy = 0;
> }
>
> for(a = 1; a < 110; ++a)
> {
> Filter = IndustryID(0) == a;
> indnam = "~Ind~" + IndustryID(1);
> AddToComposite( C , indnam, "C");
> AddToComposite( O , indnam, "O");
> AddToComposite( H , indnam, "H");
> AddToComposite( L , indnam, "L");
> AddToComposite( V/1000 , indnam, "V");
> Buy = 0;
> }
>
> I've also tried putting the GetExtraData() call inside the for
> loops. In the end, a graphical representation of the composite QRS
> wouldn't be all that necessary (though nice). I would only need to
> reference the QRS in explorations on the composites.
>
> Thank you, in advance.
>
> Jeff


__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com


Get amazing travel prices for air and hotel in one click on Yahoo! FareChase

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