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

[amibroker] StoRSI + 144MA + BB rank



PureBytes Links

Trading Reference Links





Hi,
 
I was trying to workout a system in Amibroker that would use StoRSI 
and 144 Ma for trading rules.
 
 I wasn't having great results until I added a ranking method 
presented by Gary Serkoshian in his slideshow presentation. It used 
BollingerBands to score and rank the trades. 
 
 The following Amibroker Code is what I came up with. 
 
Try it and tell me what you think about the system if you care to comment 
and get the time. This is intended for trading a portfolio of two or 
more stocks and won't improve the score of only one stock. 
 
// Stochastic - RSI , recommended by Steve 
Karnish //

// With portfolio mode //
/*****
** REGULAR PORTFOLIO mode 
** This sample optimization
** finds what is optimum number of positions open simultaneously
** 
****/
SetOption(<FONT color=#ff00ff 
size=1>"InitialEquity", <FONT color=#ff00ff 
size=1>10000 );
SetTradeDelays(<FONT color=#ff00ff 
size=1>1,1<FONT 
size=1>,1,<FONT 
color=#ff00ff size=1>1);
RoundLotSize = 1; 

posqty = Optimize<FONT 
size=1>("PosQty", 
1, <FONT 
color=#ff00ff size=1>1, <FONT color=#ff00ff 
size=1>20, 1<FONT 
size=1> );
SetOption(<FONT color=#ff00ff 
size=1>"MaxOpenPositions", posqty);<FONT 
color=#008000 size=1>
// desired position size is 100% portfolio equity
// divided by PosQty positions
PositionSize = -100<FONT 
size=1>/posqty; 
// The StoRSI system ......
//
StoRSI = EMA<FONT 
size=1>((scRSI<FONT 
size=1>(C,8) - 
LLV(<FONT 
color=#0000ff size=1>scRSI(C,<FONT 
color=#ff00ff size=1>8),<FONT color=#ff00ff 
size=1>8))/
(HHV<FONT 
size=1>(scRSI<FONT 
size=1>(C,8<FONT 
size=1>),8) - 
LLV(<FONT 
color=#0000ff size=1>scRSI(C,<FONT 
color=#ff00ff size=1>8),<FONT color=#ff00ff 
size=1>8)),3<FONT 
size=1>)*100;
BL=11;
SL=89;<FONT 
color=#008000 size=1>
//Trend qualifier .....
x=MA<FONT 
size=1>(C,144);
MAlong=x>Ref<FONT 
size=1>(x,-1);
MAshort=x<Ref<FONT 
size=1>(x,-1<FONT 
size=1>);
//
Buy = Cross<FONT 
size=1>(11,StoRSI) 
AND MAlong;
Sell= Cross<FONT 
size=1>(StoRSI,89);
Short = Cross<FONT 
size=1>(89,StoRSI) 
AND MAshort;// AND 
MAshort=True;
Cover = Cross<FONT 
size=1>(11<FONT 
size=1>,StoRSI);
//Plot(Equity(),"Equity",1,1);<FONT 
color=#008000 size=1>
// now additional score 
// that is used to rank equities 
// when there are more ENTRY signals than available
// positions/cash
//<FONT 
face="Times New Roman">PositionScore = 100-RSI(); // prefer stocks that have low 
RSI;
//
SetOption(<FONT color=#ff00ff 
size=1>"WorstRankHeld",<FONT color=#ff00ff 
size=1>10);
numerator=(C-<FONT color=#0000ff 
size=1>BBandBot(C,<FONT color=#ff00ff 
size=1>21,2<FONT 
size=1>)) ;
denominator= BBandTop<FONT 
size=1>(C,21<FONT 
size=1>,2)-<FONT 
color=#0000ff size=1>BBandBot(C,<FONT 
color=#ff00ff size=1>21,<FONT color=#ff00ff 
size=1>2) ;
Rank= 100-(<FONT 
color=#ff00ff size=1>100*((numerator / denominator))) 
;//HighpositiveScore best Long 
Candidates,//<FONT 
color=#008000 size=1>Lownegativescore , best Shorts
//
PositionScore=rank;
 <FONT 
color=#000000>*****
 I'd be interested to know how this ranking method 
compares with the Relative Strength ones we talked about recently.
 
SetOption(<FONT color=#ff00ff 
size=1>"WorstRankHeld",<FONT color=#ff00ff 
size=1>10);
numerator=(C-<FONT color=#0000ff 
size=1>BBandBot(C,<FONT color=#ff00ff 
size=1>21,2<FONT 
size=1>)) ;
denominator= BBandTop<FONT 
size=1>(C,21<FONT 
size=1>,2)-<FONT 
color=#0000ff size=1>BBandBot(C,<FONT 
color=#ff00ff size=1>21,<FONT color=#ff00ff 
size=1>2) ;
Rank= 100-(<FONT 
color=#ff00ff size=1>100*((numerator / denominator))) 
;//HighpositiveScore best Long 
Candidates,//<FONT 
color=#008000 size=1>Lownegativescore , best Shorts
//
PositionScore=rank ;
<FONT 
color=#0000ff> <FONT 
color=#000000>*****
 
Bye for now,
Greg


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








Yahoo! Groups Sponsor


  ADVERTISEMENT 









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 the Yahoo! Terms of Service.