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

[amibroker] Re: Ranking study



PureBytes Links

Trading Reference Links

Eric
Forgot to mention, a negative position score indicates a candidate 
for shorting, assuming you don't want to short you can prevent 
negative position scores by substituting for position score the line
PositionScore = Max(rs * NotExit,0);

Andrew
--- In amibroker@xxxxxxxxxxxxxxx, "Andrew" <a.perrin@xxxx> wrote:
> Eric
> Now your talking Rotational Trading, different strategy entirely.  
> In AFL rotational Trading Mode there are no BUY and Sell 
arguments, 
> only PositionScore and Stops.  Leaving stops aside, we want 
> PositionScore to reflect RS but also to be set to zero if the 
close 
> drops below our exit. Lets modify our exit code to 
> NotExit = Close > Av;
> So our new code looks like
> 
> RS = ROC(Close, 120);
> Av = EMA(Close, 28);
> NotExit = Close > Av;
> PositionScore = rs * NotExit; //will set score to zero if <AV
> PositionSize = -20;
> SetTradeDelays(1,1,1,1);
> 
> Now we need to set the worst ranked position held. Top 8 you said 
so
> SetOption("worstrankheld",8); 
> You also want to set maximum open positions to 5 so
> SetOption("maxopenpositions",5);
> Our new AFL now looks like
> 
> EnableRotationalTrading();
> RS = ROC(Close, 120);
> Av = EMA(Close, 28);
> NotExit = Close > Av;
> PositionScore = rs * NotExit; //will set score to zero if <AV
> PositionSize = -20;
> SetTradeDelays(1,1,1,1);
> SetOption("worstrankheld",8);
> SetOption("maxopenpositions",5);
> //ApplyStop(stopTypeLoss, stopModePercent, 20, True, False, 10 );
> //ApplyStop(stopTypeTrailing, stopModePercent, 30, True, False, 
10 );
> 
> Note the EnableRotationalTrading(); statement at the beginning of 
> the AFL. A couple of stops to play with at the end.
> Hope this helps.
> Andrew
> 
> 
> 
> --- In amibroker@xxxxxxxxxxxxxxx, "ericleake" <eleake@xxxx> wrote:
> > --- In amibroker@xxxxxxxxxxxxxxx, Eric Leake <eleake@xxxx> wrote:
> > 
> > Thanks again for the assistance Andrew. After looking at this, I 
> > am wondering if it is really accomplishing what I am trying to 
do. 
> > 
> > Has anyone here discussed Jay Kaeppel's Relative Strength 
> strategy? 
> > It is a fairly simple in concept, but I am having a difficult 
time 
> > coding it. His strategy is this:
> > 
> > -Rank the securities by their 40 week Relative Strength. (ROC)
> > -From the top 8, select five funds for 20% positions each.
> > -If there are less than 5 funds in the top 8 that are above 
their 
> > exit, hold cash for that portion.
> > -Exit if the weekly low is more than $.02 below its 28week EMA.
> > -If a fund falls out of the top 8, then replace it with the next 
> > candidate.
> > 
> > The code we have so far is only accomplishing half of this 
> strategy-
> > basically screening securities that are above their EMA, and 
> sorting 
> > them by their RS. 
> > 
> > What approach do I need to take to make sure that when a 
security 
> > falls out of the top x%, or top 8, they are sold and replaced? 
> > 
> > Thanks for the help!
> > 
> > -Eric.
> > 
> > 
> > --- In amibroker@xxxxxxxxxxxxxxx, "Andrew" <a.perrin@xxxx> wrote:
> > > Eric
> > > lets step through code first.  The line >Avg = EMA(Close, 28); 
> > needs 
> > > to be modified as Avg is a predefined identifier. It denotes 
the 
> > > average price -(High+Low+Close)/3 - so called "typical price". 
> > > The lines 
> > > > NumColumns = 3;
> > > > Column0Name = "RS Index";
> > > > Column0     = RS;
> > > can be replaced with AddColumn(rs,"RS Index"); 
> > > This is just easier.
> > > To Rank the securities you have to assign a positionScore to 
> each 
> > > security, you have calculated this in your RS array.  To buy 5 
> > > positions, set PositionSize to -20, this represents 20% of 
your 
> > > capital to each position.  Note - set Allow Position Size 
> > Shrinking 
> > > in AA settings otherwise you will only end up with 4 open 
> > positions 
> > > (each position is 20% + Commission, so available capital for 
5th 
> > > position is slightly less than 20%).
> > > For realistic EOD backtesting results, set tradedelays to 1, 
set 
> > > commissions large enough to cover both commission + slippage. 
(I 
> > use 
> > > 1% - large yes but if a system can't survive this it is not 
> going 
> > to 
> > > interest me anyway).
> > > So now our AFL looks something like 
> > > 
> > > RS = ROC(Close, 120);
> > > Av = EMA(Close, 28);
> > > Exit = Close < Av;
> > > PositionScore = rs;
> > > Buy = Close > Av;
> > > Sell = exit;
> > > PositionSize = -20;
> > > SetTradeDelays(1,1,1,1);
> > > 
> > > Filter = GroupID() == 0;
> > > AddColumn(rs,"rel Str");
> > > 
> > > The filter setting is only used in explores, so for backtests 
> > define 
> > > the Apply To filter to select Group 0 or bactest on all 
> securities 
> > > and Substitute  Buy = Close > Av AND GroupID() == 0;  (first 
> > option 
> > > is probably faster.
> > > Hope this helps
> > > Andrew 
> > > 
> > > --- In amibroker@xxxxxxxxxxxxxxx, "ericleake" <eleake@xxxx> 
> wrote:
> > > > Making my first attempt at a very simple Relative Strength 
> scan. 
> > > > Using the ROC function, I'm able to create a RS number. I'm 
> also 
> > > > able to code a simple moving average qualifier for a buy 
> signal, 
> > > as 
> > > > well as an exit. 
> > > > 
> > > > What approach should I use then to rank the securities by 
> their 
> > > new 
> > > > RS number, and buy say the top 5? Would the new Percentile 
> > > function 
> > > > be the way to handle this? Here is what I have so far:
> > > > 
> > > > Filter = GroupID() == 0;
> > > > 
> > > > RS = ROC(Close, 120);
> > > > Avg = EMA(Close, 28);
> > > > 
> > > > Exit = Close < Avg;
> > > > 
> > > > 
> > > > 
> > > > NumColumns = 3;
> > > > Column0Name = "RS Index";
> > > > Column0     = RS;
> > > > 
> > > > Any help would be appreciated!
> > > > 
> > > > -Eric.


------------------------ 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/