Comparing stocks to parent index

#1
Hi,

I was looking to use the EOD data of NIFTY500 stocks and find which stocks have faired better or performed badly in comparison to the parent index i.e NIFTY. I would appreciate if someone can give a clue as to how the comparison should be done and how ranking should be done so that it is easy to get a list of 10 stocks which are performing better than the index and 10 stocks which are performing poorly in comparison to the index.

Thanks in advance.
 
#2
For comparing stocks performance with its index you can take help of the performance indicator “Beta”. Beta shows us the volatility measure of a stock and how it is performing with its index. Positive Beta will indicate that stock is increasing with the increase in index vice versa. While negative beta indicates that when Index is falling your stock will perform opposite to index, meaning your stock will chart higher and vice versa. You can check the beta value of a stock by simply doing Google search.
On the basis of this you rank stocks according to their performance with their index.
 

jlmalhotra

Active Member
#4
Code:
periods1 = Param("Periods1", 5, 1, 200, 1 );
periods2 = Param("Periods2", 5, 1, 200, 1 );
periods3 = Param("Periods3", 5, 1, 200, 1 );


dSy = ROC( Close, periods1);

_SECTION_BEGIN("Extra Ticker");
_N( Symbol2= ParamStr("Symbol2", "NIFTY") );
SetForeign( Symbol2 );
C2 = C;
RestorePriceArrays();
dInd =  ROC( C2, periods1);
_SECTION_END();

Cond1 = dSy > dInd ;
Cond2 = dSy < dInd ;
ST = dSy - dInd ;
//

dSy2 = ROC( Close, periods2);

_SECTION_BEGIN("Extra Ticker");
_N( Symbol2= ParamStr("Symbol2", "NIFTY") );
SetForeign( Symbol2 );
C2 = C;
RestorePriceArrays();
dInd2 =  ROC( C2, periods2);
_SECTION_END();

Cond3 = dSy2 > dInd2 ;
Cond4 = dSy2 < dInd2 ;
ST2 = dSy2 - dInd2 ;

//

dSy3 = ROC( Close, periods3);

_SECTION_BEGIN("Extra Ticker");
_N( Symbol2= ParamStr("Symbol2", "NIFTY") );
SetForeign( Symbol2 );
C2 = C;
RestorePriceArrays();
dInd3 =  ROC( C2, periods3);

Cond3 = dSy3 > dInd3 ;
Cond4 = dSy3 < dInd3 ;
ST3 = dSy3 - dInd3 ;
_SECTION_END();


_SECTION_BEGIN("Range Vol Ratio  1");
pds = Param("Periods", 21, 2, 300, 1, 10 );;


V0=TimeFrameGetPrice( "Volume", inDaily, 0 ) ;
V1=TimeFrameGetPrice( "Volume", inDaily, -1 ) ;

Vox = 100*V0/V1;

Vol1 = 100*V/MA(V,pds);
_SECTION_END();



///Exploration

Filter = -1;

FGCol =
 
IIf(Vox , colorBlack ,
IIf(Vol1 , colorblack ,
IIf(ST , colorBlack ,
IIf(ST2 , colorBlack ,
IIf(ST3 , colorblack , colorDefault)))));



BGCol =

IIf(ST > 0, colorLime ,
IIf(ST < 0, colorLightOrange , colorDefault));

BGCol1 =

IIf(ST2 > 0, colorLime ,
IIf(ST2 < 0, colorLightOrange , colorDefault));

BGCol2 =

IIf(ST3 > 0, colorLime ,
IIf(ST3 < 0, colorLightOrange , colorDefault));

BGColV =

IIf(Vol1 > 100, colorLightOrange , colorDefault);

BGColV1 =

IIf(Vol1 > 100, colorLightOrange , colorDefault);


AddColumn(ST , "Period 1" , 1.3 , FGCol , BGCol);
AddColumn(ST2 , "Period 2   " , 1.3 , FGCol , BGCol1);
AddColumn(ST3 , "Period 3" , 1.3 , FGCol , BGCol2);

AddColumn(Vox , "% PreviousDay" , 1.3 , FGCol , BGColV);
AddColumn(Vol1 , "% Monthly   " , 1.3 , FGCol , BGColV1);


Try this . Not much familiar with Amibroker language , but works for me
 
#5
For comparing stocks performance with its index you can take help of the performance indicator “Beta”. Beta shows us the volatility measure of a stock and how it is performing with its index. Positive Beta will indicate that stock is increasing with the increase in index vice versa. While negative beta indicates that when Index is falling your stock will perform opposite to index, meaning your stock will chart higher and vice versa. You can check the beta value of a stock by simply doing Google search.
On the basis of this you rank stocks according to their performance with their index.
@Soh325R There is an AFL which comes with Amibroker which simply plots the beta. I'll extend it so that I can run an exploration using the same.

I was wondering if you are aware of the way to use the symbol to be used as the base symbol listed under the Beta field under "Symbol > Categories > Market Tab"

@jlmalhotra Thanks mate for sharing the AFL. I tried running some exploration but it would be helpful if you could share more as to how you go about using it and start making sense of the exploration results. Thanks.
 

jlmalhotra

Active Member
#6
@Soh325R There is an AFL which comes with Amibroker which simply plots the beta. I'll extend it so that I can run an exploration using the same.

I was wondering if you are aware of the way to use the symbol to be used as the base symbol listed under the Beta field under "Symbol > Categories > Market Tab"

@jlmalhotra Thanks mate for sharing the AFL. I tried running some exploration but it would be helpful if you could share more as to how you go about using it and start making sense of the exploration results. Thanks.
AFL calculates rate of change of stock and rate of change of index.
If ROC of stock is more than roc of index , means stock is over performing index else underperforming

I use 21 days,8 days, and 3 days for my exploration ( can change in parameters, )

% previous day is volume compared to previous days vol and Monthly is current day vol compared to avg of last 21 days of vol

BAJAJFINSV most over performing stock in last 21 days in FnO
 

Attachments

Last edited:
#7
AFL calculates rate of change of stock and rate of change of index.
If ROC of stock is more than roc of index , means stock is over performing index else underperforming

I use 21 days,8 days, and 3 days for my exploration ( can change in parameters, )

% previous day is volume compared to previous days vol and Monthly is current day vol compared to avg of last 21 days of vol

BAJAJFINSV most over performing stock in last 21 days in FnO
Cool. Got it. Thanks for sharing these details. Appreciate it.