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

RE: [amibroker] Counting number of Stocks in an industry group vs. time



PureBytes Links

Trading Reference Links

Try this in place of the IIF

If( C[i]>0 && C[i]!=null )
{ n=n+1 }
Else
{ n=n }



Cheers,
Graham
http://groups.msn.com/asxsharetrading
http://groups.msn.com/fmsaustralia 

-----Original Message-----
From: acesheet [mailto:acesheet@xxxxxxxxx] 
Sent: Sunday, 7 December 2003 12:22 PM
To: amibroker@xxxxxxxxxxxxxxx
Subject: [amibroker] Counting number of Stocks in an industry group vs. time


Hi folks,

I have a routine that sets up an OHLCV set of arrays for my Industry 
Groups - code is below. This calculates very well most of the time. 
However, if there is a stock that is a relatively new issue with a 
substantially different price than those in the index, like a 
averaging $100 stock and $10 ten I get a gap that I wish I didn't 
have in the industry index. This can also happen if I don't have the 
same length of price history for all the stocks in the group.

What I would like to do is count the number of stocks in the 
industry that actually have a closing price of NOT Null or Close not 
equal to zero. I thought this expression would do it, but it doesn't 
work:

   list = GetCategorySymbols( categoryIndustry, IndustryID(0) );
   n = 0;
   for( i = 0; ( sym = StrExtract( list, i ) ) != ""; i++ )
   {
      n=IIf(C>0 OR C!=Null,1,0)+n;
   }

   Plot(n,"# of Comp's",colorBlue);

My goal was to look for step changes in the value of 'n' and then 
apply a scale factor of Open/Ref(Close,1) to all the prices forward 
of the step change, thus correcting the composite index for 
additions of stocks at various times due to differing lengths 
historical data.

Any thougths on how I might accomlish this? I really thought I had 
it there.

Sincerely,

-ace

------------------------------------------------
//INDUSTRY GROUP COMPOSITE INDEX CODE
------------------------------------------------
function CreateIndustryAverage( listnum, price )
{
 // retrive comma-separated list of symbols in watch list
 list = GetCategorySymbols( categoryIndustry, listnum );
 scalefactor=1;   
 Average = 0; // just in case there are no watch list members

 for( i = 0; ( sym = StrExtract( list, i ) ) != ""; i++ )
 {
    f = Nz(Foreign( sym, price ));
    if( i == 0 ) Average = Average;
    else Average = Average + f*scalefactor;
 }
// divide by number of components
// return Cum(Average / i); 
 return Average / i; 
}
indticker="~"+IndustryID(1);
//price=CreateIndustryAverage( IndustryID(0) );
/*StrLeft(IndustryID(1),3)+StrRight(IndustryID(1),3);*/
IO=CreateIndustryAverage( IndustryID(0), "O" )*10; IH=CreateIndustryAverage(
IndustryID(0), "H" )*10; IL=CreateIndustryAverage( IndustryID(0), "L" )*10;
IC=CreateIndustryAverage( IndustryID(0), "C" )*10;
AddToComposite(IO,indticker,"O", 3); AddToComposite(IH,indticker,"H", 3);
AddToComposite(IL,indticker,"L", 3); AddToComposite(IC,indticker,"C", 3);
AddToComposite(CreateIndustryAverage( IndustryID(0), "V" )
*10,indticker,"V", 3); AddToComposite( 1, indticker, "I" );



------------------------ Yahoo! Groups Sponsor ---------------------~--> Buy
Ink Cartridges or Refill Kits for your HP, Epson, Canon or Lexmark Printer
at MyInks.com. Free s/h on orders $50 or more to the US & Canada.
http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/GHeqlB/TM
---------------------------------------------------------------------~->

Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at:
http://groups.yahoo.com/group/amibroker/files/groupfaq.html 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for your HP, Epson, Canon or Lexmark
Printer at MyInks.com. Free s/h on orders $50 or more to the US & Canada.
http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/GHeqlB/TM
---------------------------------------------------------------------~->

Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/