Dave
There's a neat package in the Clearwater FT Monitor
Conference CDs for 2005 written by Bill Barnard
that bridges the a lot of the gaps between FT and
Amibroker, except TRADE, and provides the UI UPI metrics
plus others. You even get the black (ugh!)
screens and all the conventions of FT(red for buy
and green for sell)
The CDs have not been released yet but due to be
released any month now. Although conf was
in Feb, the coordinator Richard Boroff was
under the weather for a while but is back at it now
I believe.
Write me if you have questions about the
Explorer. Tell me what database you have and I
could clip the just the UI UPI section from it.
JOE
----- Original Message -----
Sent: Thursday, April 14, 2005 8:47
PM
Subject: [amibroker] Re: Ulcer Index and
Ulcer Performance Index
Joe, Thanks a bunch. More than I bargained
for..it'll take me a little while to digest. I'm familiar with FastTrack
crowd. Now just trying to make switch over to AB without FT and still get
some of the excellent tools I had at FT. Biggest problem is lack of
programming skill. Thanks very much Dave
--- In amibroker@xxxxxxxxxxxxxxx, "Joe
Landry" <jelandry@xxxx> wrote: > Dave 9542 - >
> All of the formulas can be attributed to Brian Stocks author of
FastTools, Ed Gilbert author TRADE and SCRIPTS written by others,
CHEESE CHARTS, > > and a local Amibroker guru (who become
well know to you in the weeks ahead as he ramps up a virtual training
room) . > > There are a few things with this routine that
can trip you up depending on your data base. One is the money market rate,
2) the > > assumed risk free interest rates where convention uses
5.4% (man I wish this were true), 3) the symbol of the Russell 2000
index, > > and the window or so called MPT period. The
latter are in two parameters to adjust. I've seen many versions of
MPT calculations and they all present somewhat different values for UI and
UPI. All of the formulas can be attributed to FastTools, >
> TRADE SCRIPTS, CHEESE CHARTS, and a local Amibroker guru.
> > You can strip the UI UPI code from this and make your own
exploration routine that doesn't depend on BUY/SELL or the equity
curve. > > Best regards > JOE > > //
*************************** Function Section to calculate Risk Free Fixed
Rate ********* > > function Irate(interest_rate) > >
{ > > // This gets the log of the daily rate > >
logbarfactor = log(1 + interest_rate / 100) / 252; > > // Force
the first bar to 0 > > logvect = IIf(BarIndex() == 0, 0,
logbarfactor); > > // Sum the log of the daily gain factors
and > > // convert back to get equity > >
return(exp(Cum(logvect))); > > } > > // General
Section > > period = 22; // 22 trading days a month >
> MPT_Period = Param("MPT Period", 252,125,500,5); > >
IndexSym = ParamStr("Russell 2000 Index Symbol","!rut"); > > //
------------------------------------MPT
Section------------------ ------------------ > > Index =
Foreign(IndexSym,"Close"); > > rfFund = Foreign("FDRXX","C");
> > riskfree = ((rffund/ Ref(rfFund,-MPT_Period)))^(252);
> > > // Correlation coefficient of Equity to the Index
> > Corr =
100*Correlation(ROC(C,1),ROC(Index,1),MPT_Period); > > SDF =
StDev(ROC(Close, 1),MPT_Period); > > SDI = StDev(ROC(Index,
1),MPT_Period); > > RelStDev = SDF/SDI; > > //
Calculation of Beta - > > Beta = Corr * RelStDev/100; //
volatily relative to benchmark > > NCAlpha =
MA(ROC(Close,1),MPT_Period) - RelStDev*MA(ROC (Index,1),MPT_Period); //
noncorrelated Alpha > > Alpha = MA(ROC(Close,1),MPT_Period) -
Beta*MA(ROC (Index,1),MPT_Period); // textbook definition > >
// SHARPE PERFORMANCE INDEX a risk adjusted measure of the performance of
an equity compared to the risk free benchmark standard rate of return =
5% > > SHARPE = ( MA(ROC(C,1),MPT_Period) -
MA(ROC(irate (2.2),1),MPT_Period) )/(SDF); > > > //
----------------------------------- UPI Code
-------------------- ------------------- > > // Retracements
from the Highest High Current Draw Down Here using Monthly Period to cal
these numbers. > > Cdd = (HHV(C,MPT_Period) -
C)/HHV(C,MPT_Period); > > // Max draw down > > MaxDD
= HHV(CDD,MPT_Period); > > // Sum of all retracements squared -
> > R2 = (Sum(Cdd*Cdd,MPT_Period))/(MPT_Period-1); >
> // Ulcer Index -Cumulative downside volatility of an equity >
> UI = sqrt(R2); > > // Annual compound percentage rate of
return > > TR = Close/Ref(Close,-MPT_Period); // Total Return for
1 year > > ANN = (exp(log(TR))-1); // Annual compounded rate of
return > > // Ulcer performance index - risk adjusted
performance of an investment. > > UPI = (ANN -
irate(2.2)/100)/UI; // I have 2.2% here, early
analysts used 5.4% > > // -----------------------------
Performance Calculation ----------- ----------------- > > EndV
= ValueWhen(DateNum()==DateNum(),C); // Today's Close > > //
hardcoded for 2005 > > BegV =
ValueWhen(DateNum()==1050103,Close); // Starts year with Jan 3, 2005
Closing Value > > YTD = 100*(EndV-BegV)/BegV; > > //
--------------------------- Calculate RSI / Stochastics - Exploration
-------------------------------------- > >
slow=LLV(C,21); > > shigh=HHV(C,21); > >
faststoc=EMA(100*(C-slow)/(shigh-slow),13)/2 + RSI(14)/2; > >
momentum=faststoc-Ref(faststoc,-6); // as used in Cheese3 and FT >
> momentumchg=((faststoc-Ref(faststoc,-6))/Ref(faststoc,-6)) *100;
//as used in Cheese3 and FT > > // ----------------------------
Test Section ----------------------- --- > > xbar =
MA(ROC(C,1),MPT_Period); > > SumR2 =
Sum((ROC(C,1)-xbar)^2,MPT_Period); > > Sigma =
(SumR2/(MPT_Period-1))^.5; > > > > Filter
=1; > > > AddTextColumn(FullName(),"Name",1.2); >
> AddColumn(Corr,"Cor Coeff"); > >
AddColumn(Alpha,"Alpha"); > >
AddColumn(NCAlpha,"NCAlpha"); > > AddColumn(Beta,"Beta"); >
> AddColumn(SDF,"Std Dev"); > >
AddColumn(RelStDev,"RelSD"); > >
AddColumn(Sharpe,"Sharpe"); > > AddColumn(100*Ann,"ANN"); >
> AddColumn(100*MaxDD,"MDD %"); > >
AddColumn(100*UI,"UI"); > > AddColumn(UPI,"UPI"); >
> AddColumn(faststoc,"Stoch/RSI",1.2); > >
AddColumn(momentum,"Mom",1.2); > >
AddColumn(momentumchg,"Mom-Chg%",1.2); > >
AddColumn(ROC(C,Period)," 1 mnth"); > > AddColumn(YTD,"
YTD"); > > AddColumn(ROC(C,MPT_Period)," 1 yr "); >
> ----- Original Message ----- > From:
dave9542 > To: amibroker@xxxxxxxxxxxxxxx
> Sent: Thursday, April 14, 2005 2:01
PM > Subject: [amibroker] Ulcer Index and Ulcer Performance
Index > > > > > Newby needs
help. > > I am interested in code that allows me to
look at Ulcer Index and > Ulcer Performance Index for
individual issues. Marcin was good enough > to point me
to code written by Ken Close and then modified by TJ but
> I still cannot get it to work. When run in Explore I'm
told > that "variable Buy is used without being
initialized". > > Is it enough to place "Buy = 1" as
first line in code or does this > distort
results? > > Here's code > >
Filter = Buy OR Sell; > Eq=Equity(0,0); >
Per = 252; > Per2 = 40; > Cdd =
(HHV(Eq,Per2) - Eq)/HHV(Eq,Per2); > MaxCdd =
HHV(Cdd,252)*100; > R2 =
(Sum(Cdd*Cdd,Per))/Per; > UI =
100*sqrt(R2); > Gain = Eq/Ref(Eq,-Per); >
ANN = 100 * ((Gain^(252/Per)) - 1); > UPI = (ANN -
0.054)/UI; >
AddColumn(MaxCdd,"MaxCdd",1.2); >
AddColumn(ANN,"ANN",1.2); >
AddColumn(UPI,"UPI",1.3); >
AddColumn(ANN/MaxCdd,"ANN/dd",1.3); > >
Thanks > Dave > > > > >
> > > > > 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 > > a.. To visit your
group on the web, go to: > http://groups.yahoo.com/group/amibroker/ >
> b.. To unsubscribe from this group, send an
email to: >
amibroker-unsubscribe@xxxxxxxxxxxxxxx >
> c.. Your use of Yahoo! Groups is subject to
the Yahoo! Terms of Service.
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
|