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

[amibroker] ranking sectors by market breadth indicators



PureBytes Links

Trading Reference Links

Hello there,

I am trying to analyse sectors with respect to market breadth. I 
created the relevnat base composites to store info such as advancing 
issues, etc and stored these composites in group 50. I then proceeded 
to calculate market thrust for each sector based on info in these 
composites and finally rank them by comparing the market thrust of 
each sector with the other sectors. However the code I have written 
does not work as intended. The rank is not what I expected and the 
problem seems to be that for some reason the code does not enable 
comparison of the market thrust resulting in var1 = var 2 and 
therefore rank remaining at 1.

I append the code below and would appreciate any help I can get on 
the matter. Thank you.

Filter=GroupID()==50;
groupnumber=50;
group=CategoryGetSymbols(categoryGroup,groupnumber);
for (i=0;(sym=StrExtract(group,i)) !="";i++)
	{
		stringlength=StrLen(sym);
		requiredstring=StrRight(sym,stringlength-3);
		VarSet("advancingissues"+requiredstring,C);
		VarSet("decliningissues"+requiredstring,O);
		VarSet("advancingvolume"+requiredstring,H);
		VarSet("declingvolume"+requiredstring,L);

		ad=C;
		De=O;
		advol=H;
		dvol=L;

		Marketthrust = (ad*advol-de*dvol)/1000000;
		VarSet("marketthrust"+requiredstring,Marketthrust);
		slope=LinRegSlope(Marketthrust,5);
		VarSet("slopeof marketthrust"+requiredstring, slope);
	}


	AddColumn(C,"advancing issues");

	AddColumn(Marketthrust,"MT");
	AddColumn(slope,"SlopeofMt");

groupnumber=50;
group=CategoryGetSymbols(categoryGroup,groupnumber);

BreakLoop = False;

for( k = 0; NOT(BreakLoop) &&( ticker = StrExtract( group, k ) ) !
= ""; k++ )
{
	if(Name()==ticker)
		Breakloop=True;
		stringlength=StrLen(ticker);
		requiredstring=StrRight(ticker,stringlength-3);
		Var1=VarGet("marketthrust"+ requiredstring);
		Rank=1;
		
for (j=0;(sym1=StrExtract(group,j)) !="";j++)
					{
				stringlength1=StrLen(sym1);
				requiredstring1=StrRight
(sym1,stringlength1-3);
				Var2=VarGet("marketthrust" + 
requiredstring1);	
				Rank= Rank + IIf(Var1<Var2,1,0);
		}
			VarSet("Rank"+requiredstring,Rank);
}
AddColumn(Count,"count");
AddTextColumn(Name(), "name");

AddColumn(VarGet("Rank"+requiredstring),"Rank");
AddColumn(Var1,"var1");
AddColumn(Var2,"var2");

AddColumn(stringlength,"strg1");
AddColumn(stringlength1,"strg2");













------------------------ Yahoo! Groups Sponsor --------------------~--> 
Try Online Currency Trading with GFT. Free 50K Demo. Trade 
24 Hours. Commission-Free. 
http://us.click.yahoo.com/RvFikB/9M2KAA/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/