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

RE: [amibroker] Question on RS, possibly for Tomasz



PureBytes Links

Trading Reference Links

Jason,

 

I’m still wading through your code.  There’s LOTS of good material here.   I’ve been able to figure out most of your code.  However, I’m confused about this code:

 

b = 1041231;

a=DateNum()==b;

i  = ValueWhen(a,C);

ii = ((C-i)/i)*100;

 

b appears to be the number representing the quotation date for the last day of 2004.   And, “i” appears to the value at the end of last year.  And, “ii” appears to be the YTD% change for 2005.    But…

 

“a=DateNum()==b” throws me.  What does the “…DateNum()==b” portion mean?

 

Thanks and regards,

 

Dan.

 

 


From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf Of Jason Hart
Sent: Wednesday, July 13, 2005 9:21 AM
To: amibroker@xxxxxxxxxxxxxxx
Subject: RE: [amibroker] Question on RS, possibly for Tomasz

 

Dan,

The full code is listed below.  This is a "dashboard" so to speak of what the different sectors are doing, a top down look.  I'm more of a top down investor vs bottom up so this fits my style better.  What I typically do is run it against an ETF watchlist of about 150 different ETFs and then I'll also run it against a WL that has 450 of my favorite mutual funds. 

This is more of a rotational trading tool.  I don't use this exploration with individual stocks, I think it is more useful for ETFs and funds.  What I'll try to do with this code is to invest in 3-5 ETFs/Funds that are in the top 25% in terms of strength.  However, if you want more octane and less diversification, you can also see which sector funds/ETFs are the strongest and buy the individual stocks that these funds hold.

The code is still a work in progress but I'll explain what some of the outputs are.  The first column "TotalB" is derived from differing ROC periods and where the ETF is trading relative to different MAs.  If it is trading above MAs it gets more points and vice versa.  I was comparing it to other indicators and it is very similar to Martin Pring's "KST" indicator. 

RSC is similar to TotalB but it incorporates some other momentum components into the ranking.  I'm still working on this one

"B -10" is what the TotalB was 10 days ago and the "difference" column is the difference between the two columns.  What I look for in the difference column is maybe some bottom feeding opportunities where there is a big swing in the score of an ETF that has been struggling.  I haven't looked into how effective this is in great detail.  A current example is the BHH ETF but I'm not to keen on the sector.

Then the RS columns list current RS, RS 10 days ago and RS 20 days ago.  If the RS is greater than the previous n periods it is green and if the RS is lower then it is RED. 

"ST SD" is a shorter term measure of standard deviation and then the "hist SD" is the short term less the historical StDev.  Thus, if you get a negative value in the "hist SD" column then the security is trading at a lower volatility level relative to its historical average.  I like these two columns b/c they can help determine your asset weightings.  Say you have two investment candidates: security one with a SD over 30 and the second at a SD of 15.....then you can weight your decisions based on how much octane you want.  If you want less octane you could do a 75% / 25% security2 / security 1 weighting.  Or if you want more octane have a greater weighting in security 1 with the 30 SD.

The ROC columns are for visual purposes and can help you quickly determine how strong a stock is.  If all three ROC columns are green then the security is strong.  What I do here is look at the shorter term ROC.  Say the longer term ROCs are green but the shorter term ROC is yellow or Red then that could be an indication that the current trend is weakening or there is a change in trend altogether on the horizon.....then the opposite is true.  If LT ROCs are red but the ST ROC is yellow or green then it is showing ST strength and it could be reversing.

YTD, 30D%, 10d%, etc are the % change for those periods

SPX and Nasdaq columns are the securities correlation to the S&P 500 and Nasdaq composite

Finally EMA 170 & 50:  shows if the security is rising relative to its 170 and 50 day MAs.  If it is 1 then it is rising, if it is 0 then the stock is falling relative to these MAs.

I think I got it all covered.  Like I said this is still a work in progress and would appreciate any feedback.  The first few columns of the exploration are all relatively the same.  What I would like to do is incorporate some sort of ranking in this scan the uses a combination of the three outputs.  I haven't figured out the ranking part yet.  I saw the "osaka plug in / ranking" posts from last week but I haven't had time to work with them yet.

Jason   

_______________________________

//Filter=Cross(PDI(14),MDI(14)) AND StochD(14) < 50;

Filter = C > 0;

a= MA(ROC(C,5),5);

a1 = MA(ROC(C,10),5);

a2= MA(ROC(C,20),5);

a3=MA(ROC(C,50),5);

a4=MA(ROC(C,100),5);

a5 = MA(ROC(C,200),5);

aa = Ref(MA(ROC(C,5),5),-5);

aa1 = Ref(MA(ROC(C,10),5),-5);

aa2 = Ref(MA(ROC(C,20),5),-5);

aa3 = Ref(MA(ROC(C,50),5),-5);

aa4 = Ref(MA(ROC(C,100),5),-5);

aa5 = Ref(MA(ROC(C,200),5),-5);

ab = Ref(MA(ROC(C,5),5),-10);

ab1 = Ref(MA(ROC(C,10),5),-10);

ab2 = Ref(MA(ROC(C,20),5),-10);

ab3 = Ref(MA(ROC(C,50),5),-10);

ab4 = Ref(MA(ROC(C,100),5),-10);

ab5= Ref(MA(ROC(C,200),5),-10);

 

x0 = (a+aa+ab)*.35;

x1 = (a1+aa1+ab1)*.65;

x2 = (a2+aa2+ab2)*(1.65);

x3 = (a3+aa3+ab3)*(1.75);

x4 = (a4+aa4+ab4)*(1.5);

x5 = (a5+aa5+ab5)*(.65);

b = (C - MA(C,20))/C;

b1 = (C-MA(C,50))/C;

b2 = (C-MA(C,100))/C;

b3 = (C-MA(C,200))/C;

bb = (b*1.7)*100;

bb1 = (b1*2.0)*100;

bb2 = (b2*1.2)*100;

bb3 = (b3*(1.2))*100;

z = x0+x1+x2+x3+x4+x5+bb+bb1+bb2+bb3;

b = 1041231;

a=DateNum()==b;

i=ValueWhen(a,C);

ii = ((C-i)/i)*100;

week = ((C - Ref(C,-5))/ Ref(C,-5))*100;

Mth = ((C- Ref(C,-30))/Ref(C,-30))*100;

tenday = ((C - Ref(C,-10))/Ref(C,-10))*100;

Oneday = ((C - Ref(C,-1))/Ref(C,-1))*100;

j = Foreign("!spx", "c");

j1 = RelStrength("!spx");

j2 = RelStrength("!spx")/Ref(j1,-20);

j3 = RelStrength("!spx")/Ref(j1,-30);

j4 = RelStrength("!spx")/Ref(j1,-50);

j5 = RelStrength("!spx")/Ref(j1,-100);

j6 = RelStrength("!spx")/Ref(j1,-120);

j7 = RelStrength("!spx")/Ref(j1,-150);

j8 = RelStrength("!spx")/Ref(j1,-200);

mamPeriod = 13;

mam = 100*(Close/MA(Close, (2*mamPeriod) +1) -1);

mom= MA(MAm,5)*100;

vol1 = StDev(log(C/Ref(C,-1)),720) * sqrt(260)*100;

vol2 = StDev(log(C/Ref(C,-1)),20) * sqrt(260)*100;

vol3 = StDev(log(C/Ref(C,-1)),50) * sqrt(260)*100;

vol4 = StDev(log(C/Ref(C,-1)),90) * sqrt(260)*100;

Vol5 = (Vol2 + Vol3+ Vol4)/3;

Vol6 = Vol5-Vol1;

Final = (j2*1) + (j3*1.2) + (j4*1.3)+(j5*1.4) + (j6*1.5) + (j7*1.7) + (j8*1.7);

Combined = (.50*final)+(.5*z);

CombinedI= (.35*final)+(.35*z)+(.3*mom);

CombinedII=MA(CombinedI,25);

//Filter = CombinedI > CombinedII AND Cross(PDI(14),MDI(14)) AND z-Ref(z,-5) > 20;

//Filter = final > 10 AND Cross(PDI(14),MDI(14));

PositionSize = -25;

Buy = final > 10 AND Cross(PDI(14),MDI(14)) AND z-Ref(z,-10) > 15 AND ADX(14) > Ref(ADX(14),-5);

Sell = Cross(MDI(14),PDI(14)) OR Cross(Signal(),MACD());

ApplyStop( stopTypeNBar, stopModeBars, 70, True );

AddTextColumn(FullName(),"Name",5);

ro11 = MA(ROC(C,20),10);

ro1 = MA(ROC(C,50),10);

ro2 = MA(ROC(C,120),10);

AddColumn(z,"TotalB");

AddColumn(CombinedII,"RSC");

AddColumn(Ref(z,-10), "B -10 dys");

AddColumn(z-Ref(z,-10), "difference");

AddColumn(final,"RS",1.2,colorDefault,IIf(final==0,colorBlue,IIf(final>=Ref(final,-10),colorGreen,colorRed)));

AddColumn(Ref(final,-10),"10 days",1.2,colorDefault,IIf(final==0,colorBlue,IIf(Ref(final,-10)>=Ref(final,-20),colorGreen,colorRed)));

AddColumn(Ref(final,-20),"20 days",1.2,colorDefault,IIf(final==0,colorBlue,IIf(Ref(final,-20)>=Ref(final,-30),colorGreen,colorRed)));

AddColumn(Vol5,"ST SD");

AddColumn(vol6,"Hist SD");

AddColumn(ro11, "ROC20",1.2,colorDefault,IIf(ro11>0 AND ro11<5,colorYellow,IIf(ro11 > 5 ,colorGreen,colorRed)));

AddColumn(ro1, "ROC50",1.2,colorDefault,IIf(ro1>0 AND ro1<5,colorYellow,IIf(ro1 > 5 ,colorGreen,colorRed)));

AddColumn(ro2, "ROC120",1.2,colorDefault,IIf(ro2>0 AND ro2<5 ,colorYellow,IIf(ro2 > 5 ,colorGreen,colorRed)));

AddColumn(ii, "YTD%",1.2,colorDefault,IIf(ii> 0 ,colorGreen,colorRed));

AddColumn(Mth, "30d %",1.2,colorDefault,IIf(Mth> 0 ,colorGreen,colorRed));

AddColumn(tenday, "10d %",1.2,colorDefault,IIf(tenday > 0.005 AND tenday < 0.009 ,colorYellow,IIf(tenday > 0 ,colorGreen,colorRed)));

AddColumn(week, "5d %",1.2,colorDefault,IIf(week > 0.005 AND week < 0.009 ,colorYellow,IIf(week > 0 ,colorGreen,colorRed)));

AddColumn(oneDay, "1d %",1.2,colorDefault,IIf(oneDay > 0.005 AND oneDay < 0.009 ,colorYellow,IIf(oneDay > 0 ,colorGreen,colorRed)));

RS1=Foreign("!spx","C");

RS2 = Foreign("!comp","C");

Corr1 = ROC(RS1,1);

Corr2 = ROC(C,1);

Corr3 = ROC(RS2,1);

Corr4 = ROC(C,1);

test=Correlation(corr1,Corr2,20);

test1=Correlation(Corr3,Corr4,30);

test=Correlation(Corr1,Corr2,125);

test1=Correlation(Corr3,Corr4,125);

AddColumn(test,"SPX");

AddColumn(test1,"Nasdaq");

rising = EMA(C,170) > Ref(EMA(C,170),-47);

rising1 = EMA(C,50) > Ref(EMA(C,50),-25);

rising ==1;

rising1==1;

AddColumn(rising,"ema 170");

AddColumn(rising1,"ema 50");

 

 

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

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






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