Note: cross posting
from Amibroker-TS list
With TJ’s help, I got
this working – the system that was published in Jan, 2005 issue of TASC, by
David Vomund. It may be of interest.
Mohan
/* AIQ's
Releative Strength Short-Term - RSR - from Jan 2005 issue of
TASC*/
/* Take the
data of the last 120 days. Break the data into quarters. Calculate
the
percentage
price change for each quarter and average them with the latest quarter's
weight
being
twice.
At the start
of the test, the 2 best performing ETSs are bought, with equal dollar
amounts
to establish
a fully invested portfolio. Two weeks later, RSR report was run again.
If the
current holdings were rated as one of the three best in the report, then there
were no
trades. If a
holding fell in the RSR report ranking and was no longer in the top 3, then
it was
soldand the highest rated ETF was purchased ( I assume , the ETF that was
bought cannot
be the same
that is already being held in the portfolio ???).
ETFs
used:
DIA, QQQ,
SPY, MDY, IJS, IJT, IWM
*/
q0 =
(C - Ref(C,-60))/Ref(C,-60);
q1 =
(Ref(C,-60) -
Ref(C,-120))/Ref(C,-120);
RSR =
100*
(2*q0 +
q1)/3 +
100;
Plot(RSR,"AIQ's
RSR",colorRed, styleLine);
Plot(MA(RSR,20),"ma(20)",colorWhite, styleLine);
SetOption("InitialEquity",
20000
);
SetTradeDelays(1,1,1,1);
RoundLotSize =
1;
EnableRotationalTrading(True);
SetOption("MaxOpenPositions",
2);
SetOption("WorstRankHeld",
3);
PositionSize =
-50;
MonthChange
= Month() !=
Ref(
Month(),
-1 );
Rebalance =
MonthChange OR
Ref(
MonthChange, -12);
// rebalance
twice a month
PositionScore =
IIf( Rebalance,
RSR, scoreNoRotate );
/*
scoreNoRotate prevents
rotation in
all days except rebalance days. */
/* The rest
of the RSR lines */
/*
a0 =
SetForeign("SPY");
qa0 =
(C - Ref(C,-60))/Ref(C,-60);
qa1 =
(Ref(C,-60) -
Ref(C,-120))/Ref(C,-120);
RSRa =
100*
(2*qa0 +
qa1)/3 +
100;
Plot(RSRa,"AIQ's
RSR(SPY)",colorRose, styleLine);
b0 =
SetForeign("QQQQ");
qb0 =
(C - Ref(C,-60))/Ref(C,-60);
qb1 =
(Ref(C,-60) -
Ref(C,-120))/Ref(C,-120);
RSRb =
100*
(2*qb0 +
qb1)/3 +
100;
Plot(RSRb,"AIQ's
RSR(QQQQ)",colorOrange, styleLine);
c0 =
SetForeign("MDY");
qc0 =
(C - Ref(C,-60))/Ref(C,-60);
qc1 =
(Ref(C,-60) -
Ref(C,-120))/Ref(C,-120);
RSRc =
100*
(2*qc0 +
qc1)/3 +
100;
Plot(RSRc,"AIQ's
RSR(MDY)",colorYellow, styleLine);
c0 =
SetForeign("IWM");
qc0 =
(C - Ref(C,-60))/Ref(C,-60);
qc1 =
(Ref(C,-60) -
Ref(C,-120))/Ref(C,-120);
RSRc =
100*
(2*qc0 +
qc1)/3 +
100;
Plot(RSRc,"\n AIQ's
RSR(IWM)",colorTurquoise, styleLine);
c0 =
SetForeign("IJS");
qc0 =
(C - Ref(C,-60))/Ref(C,-60);
qc1 =
(Ref(C,-60) -
Ref(C,-120))/Ref(C,-120);
RSRc =
100*
(2*qc0 +
qc1)/3 +
100;
Plot(RSRc,"AIQ's
RSR(IJS)",colorTeal, styleLine);
c0 =
SetForeign("IJT");
qc0 =
(C - Ref(C,-60))/Ref(C,-60);
qc1 =
(Ref(C,-60) -
Ref(C,-120))/Ref(C,-120);
RSRc =
100*
(2*qc0 +
qc1)/3 +
100;
Plot(RSRc,"AIQ's
RSR(IJT)",colorBrightGreen, styleLine);
*/