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

Re: [amibroker] AddtoComposite



PureBytes Links

Trading Reference Links

Jeff,

I am sure there are easier and more efficient ways to code the following 
but this might get you started. Adjust the following code to your needs 
then do a scan

//Average QRS Rank
sym1="^" + "SP1500"  + "Count";
sym2= "^" + "SP1500-"  + "RS";
QRS=GetExtraData("QRS");
AddToComposite(1,sym,"I");
AddToComposite(QRS, sym, "C");

Then to plot create an indicator using your data streams of dividing the 
QRS by Number of symbols.
//Smoothed Plot of Average QRS
Plot(MA(Foreign( "^SP1500-RS", "C" )/Foreign( "^SP1500Count", "C" 
),10),"S&P 1500 Avg RS Rank",colorBlue,styleLine=4);

Just a note of caution you might want to some code to check for null 
values  to keep the symbol from being added to the count if there is no 
value. Its not a big deal but it does change the value slightly.

Regards,

Duke Jones, CMT


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? 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 
> <http://farechase.yahoo.com/;_ylc=X3oDMTFpMnJnZ3IxBF9TAzk3NDA3NTg5BHNlYwNtYWlsLXRhZ2xpbmVzBHNsawNmYXJlY2hhc2UtMDQyNzA2> 
>
>
> 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 
> <http://groups.yahoo.com/gads?t=ms&k=Investment+management+software&w1=Investment+management+software&w2=Real+estate+investment+software&w3=Investment+property+software&w4=Software+support&w5=Real+estate+investment+analysis+software&w6=Investment+software&c=6&s=200&.sig=_XXUzbE9l5lGlZNcMu4KNQ> 
> 	Real estate investment software 
> <http://groups.yahoo.com/gads?t=ms&k=Real+estate+investment+software&w1=Investment+management+software&w2=Real+estate+investment+software&w3=Investment+property+software&w4=Software+support&w5=Real+estate+investment+analysis+software&w6=Investment+software&c=6&s=200&.sig=5_sgDczz3ArKGMtJ9tFSJA> 
> 	Investment property software 
> <http://groups.yahoo.com/gads?t=ms&k=Investment+property+software&w1=Investment+management+software&w2=Real+estate+investment+software&w3=Investment+property+software&w4=Software+support&w5=Real+estate+investment+analysis+software&w6=Investment+software&c=6&s=200&.sig=_N6zcwefgp4eg5n6oX5WZw> 
>
> Software support 
> <http://groups.yahoo.com/gads?t=ms&k=Software+support&w1=Investment+management+software&w2=Real+estate+investment+software&w3=Investment+property+software&w4=Software+support&w5=Real+estate+investment+analysis+software&w6=Investment+software&c=6&s=200&.sig=MJ2jP31F3n64RDZkDadU8w> 
> 	Real estate investment analysis software 
> <http://groups.yahoo.com/gads?t=ms&k=Real+estate+investment+analysis+software&w1=Investment+management+software&w2=Real+estate+investment+software&w3=Investment+property+software&w4=Software+support&w5=Real+estate+investment+analysis+software&w6=Investment+software&c=6&s=200&.sig=GmF8PlAJASx0wrSaX5-Zlw> 
> 	Investment software 
> <http://groups.yahoo.com/gads?t=ms&k=Investment+software&w1=Investment+management+software&w2=Real+estate+investment+software&w3=Investment+property+software&w4=Software+support&w5=Real+estate+investment+analysis+software&w6=Investment+software&c=6&s=200&.sig=aMgGsKT4w29dMAYUzQUKzg> 
>
>
>
> ------------------------------------------------------------------------
> YAHOO! GROUPS LINKS
>
>     *  Visit your group "amibroker
>       <http://groups.yahoo.com/group/amibroker>" on the web.
>        
>     *  To unsubscribe from this group, send an email to:
>        amibroker-unsubscribe@xxxxxxxxxxxxxxx
>       <mailto:amibroker-unsubscribe@xxxxxxxxxxxxxxx?subject=Unsubscribe>
>        
>     *  Your use of Yahoo! Groups is subject to the Yahoo! Terms of
>       Service <http://docs.yahoo.com/info/terms/>.
>
>
> ------------------------------------------------------------------------
>


------------------------ Yahoo! Groups Sponsor --------------------~--> 
GFT Forex Trading Accounts As low as $250 with up to 400:1 Leverage. Free Demo.
http://us.click.yahoo.com/lpv1TA/jlQNAA/U1CZAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

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

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> 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/
 

PNG image