Download software Tutorial videos
Subscription & data-feed pricing Class schedule


New account application Trading resources
Margin rates Stock & option commissions

Attention: Discussion forums are read-only for extended maintenance until further notice.
Welcome Guest, please sign in to participate in a discussion. Search | Active Topics |

Ulcer Index PCF? Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
mully7
Posted : Tuesday, January 31, 2006 11:49:07 AM
Registered User
Joined: 1/2/2006
Posts: 23
On Wednesday, May 25, 2005 12:38:07 PM - TomG18 wrote:

[(C-C1)/C*(C<C1)+(C1-C2)/C1*(C1<C2)]/ABS[(C<C1)+(C1<C2)] is the formula for a 2 day Ulcer Index.

yet when I pasted the above I received the error: "Error: The formula must not return a boolean value for a Formula Indicator"

An internet search found some information; can you make sense of any of this? I think I would be looking for more than 2 days of data...

The Ulcer Index (UI) is a measure of volatility over time. Lower UI values imply less daily volatility in an investment vehicle or strategy.
To compute the Ulcer Index you:

1. Square all the daily drawdowns of the vehicle or strategy.
2. Sum all the daily squared retracements.
3. UI = the square-root of the sum.

Or;

Ulcer Index = Square root of sum of squared retracements divided by number of bars.

Or;

Sqrt(Sum(Power(100*( HHV(CLOSE,Period) - CLOSE )/(HHV(CLOSE, Period)),2),Period)/Period)

Or;

The algorithm for computing UI is simple, and can be seen in the pseudo-code fragment below:

SumSq = 0
MaxValue = 0
for T = 1 to NumOfPeriods do
if Value[T] > MaxValue then MaxValue = Value[T]
else SumSq = SumSq + sqr(100 * ((Value[T] / MaxValue) - 1))
UI = sqrt(SumSq / NumOfPeriods)
Bruce_L
Posted : Tuesday, January 31, 2006 1:49:10 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
I suspect the example formula was meant as just that, an example that would need to be converted to work in TeleChart. The square brackets should produce a syntax error. Even if the brackets were converted to parentheses, it would probably produce frequent division by zero errors.

Your pseudo-code could probably be reproduced using the Personal Criteria Formula Language for fairly short periods, but would probably get too large and slow very quickly as the Period increased (unless there's a shortcut I'm not seeing). There is no way to store MaxValue, so it would have to be recalculated for each bar in the Period (with the code size for the MAX () function increasing during each trip through the "loop").

Do you have a specific Period in mind?

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
mully7
Posted : Tuesday, January 31, 2006 2:06:26 PM
Registered User
Joined: 1/2/2006
Posts: 23
A chart diplayed on Investopedia shows this indicatior in TradeStation as:

Ulcer Index (Close,14,5)

Not being familiar with TradeStation, I believe they are suggesting a 14 period, with a smoothing of 5???
Bruce_L
Posted : Tuesday, January 31, 2006 2:13:47 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
Actually, it looks like it will be simpler than I thought since the built in MAX function can be used directly with with Price.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
Bruce_L
Posted : Tuesday, January 31, 2006 2:45:03 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
Here's what I've come up with so far:

SQR(((100 * (C / MAXC14 - 1)) ^ 2 + (100 * (C1 / MAXC13.1 - 1)) ^ 2 + (100 * (C2 / MAXC12.2 - 1)) ^ 2 + (100 * (C3 / MAXC11.3 - 1)) ^ 2 + (100 * (C4 / MAXC10.4 - 1)) ^ 2 + (100 * (C5 / MAXC9.5 - 1)) ^ 2 + (100 * (C6 / MAXC8.6 - 1)) ^ 2 + (100 * (C7 / MAXC7.7 - 1)) ^ 2 + (100 * (C8 / MAXC6.8 - 1)) ^ 2 + (100 * (C9 / MAXC5.9 - 1)) ^ 2 + (100 * (C10 / MAXC4.10 - 1)) ^ 2 + (100 * (C11 / MAXC3.11 - 1)) ^ 2 + (100 * (C12 / MAXC2.12 - 1)) ^ 2) / 14)

It isn't smoothed. When used as a Custom Indicator, it is possible to just set the Smoothing Average to 5 and choose either Simple or Exponential depending on your preference.

It should be noted that this is based on the algorithm you presented. I would have interpreted the formula as using MAXC14 for each term. Please take a look and let me know if it doesn't do what you want.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
mully7
Posted : Tuesday, January 31, 2006 3:23:11 PM
Registered User
Joined: 1/2/2006
Posts: 23
It SEEMS to look right on the chart, but I am not sure from your comments if you would have created it differently. This further comment below may be useful:

To measure downside risk, the Ulcer Index computes the percentage retracement from the security's highest Closing price. The drawdown is computed on a daily basis and is averaged over time. Unlike Standard Deviation, the calculated value of Ulcer Index is essentially the same regardless of the time interval per data point.

Also, this description as posted above...

Ulcer Index = Square root of sum of squared retracements divided by number of bars.

Nevertheless, it seems to look right; can you comment on whether you are happy with it based on the information in this post?

Thanks again
Bruce_L
Posted : Tuesday, January 31, 2006 3:45:43 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
Here are two other possible interpretations you might wish to try out:

SQR(((100 * (C / MAXC14 - 1)) ^ 2 + (100 * (C1 / MAXC14 - 1)) ^ 2 + (100 * (C2 / MAXC14 - 1)) ^ 2 + (100 * (C3 / MAXC14 - 1)) ^ 2 + (100 * (C4 / MAXC14 - 1)) ^ 2 + (100 * (C5 / MAXC14 - 1)) ^ 2 + (100 * (C6 / MAXC14 - 1)) ^ 2 + (100 * (C7 / MAXC14 - 1)) ^ 2 + (100 * (C8 / MAXC14 - 1)) ^ 2 + (100 * (C9 / MAXC14 - 1)) ^ 2 + (100 * (C10 / MAXC14 - 1)) ^ 2 + (100 * (C11 / MAXC14 - 1)) ^ 2 + (100 * (C12 / MAXC14 - 1)) ^ 2 + (100 * (C13 / MAXC14 - 1)) ^ 2 ) / 14)

SQR(((100 * (C / MAXC14 - 1)) ^ 2 + (100 * (C1 / MAXC14.1 - 1)) ^ 2 + (100 * (C2 / MAXC14.2 - 1)) ^ 2 + (100 * (C3 / MAXC14.3 - 1)) ^ 2 + (100 * (C4 / MAXC14.4 - 1)) ^ 2 + (100 * (C5 / MAXC14.5 - 1)) ^ 2 + (100 * (C6 / MAXC14.6 - 1)) ^ 2 + (100 * (C7 / MAXC14.7 - 1)) ^ 2 + (100 * (C8 / MAXC14.8 - 1)) ^ 2 + (100 * (C9 / MAXC14.9 - 1)) ^ 2 + (100 * (C10 / MAXC14.10 - 1)) ^ 2 + (100 * (C11 / MAXC14.11 - 1)) ^ 2 + (100 * (C12 / MAXC14.12 - 1)) ^ 2 + (100 * (C13 / MAXC14.13 - 1)) ^ 2 ) / 14)

I really don't know how it is calculated, but based on your English language descriptions, I would tend to think your algorithm and the first formula I provided would be closest to the mark.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
mully7
Posted : Wednesday, February 1, 2006 1:36:21 PM
Registered User
Joined: 1/2/2006
Posts: 23
Your first formula definitely has the look of what I was seeking. Thanks again.

Here is a little more clarity in the words of the original creator:

"The Ulcer Index measures the depth and duration of percentage drawdowns in price from earlier highs.

Technically, it is the square root of the mean of the squared percentage drops in value." Peter Martin.

It was first described in The Investor's Guide to Fidelity Funds: Winning Strategies for Mutual Fund Investors, by Peter
Martin & Byron McCann originally published by John Wiley & Sons in 1989.

davelittlejohn
Posted : Tuesday, November 13, 2012 1:46:55 PM
Gold Customer Gold Customer

Joined: 8/6/2010
Posts: 3

I've visited this a few times now.  Here's where I'm stumped -- I'm not clear on the construction of the formula... perhaps it's too many nested layers.  Whatever the case, I'm running into errors when I try to change the time horizon of the calculation.  What I'd like to be able to do is create ulcer indexes for various time periods -- like a 5-bar, 21-bar, 40-bar, etc...  then plot them against each other (which should be a pretty simple overlay in TC2000.  Any help with the construction here would be great.  Somehow I've lost track of the parenthesis each time I try to alter the original formula.

Bruce_L
Posted : Tuesday, November 13, 2012 2:36:13 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138

A 5-Period version of the first formula with which I came up would be:

SQR(((100 * (C / MAXC5 - 1)) ^ 2 + (100 * (C1 / MAXC4.1 - 1)) ^ 2 + (100 * (C2 / MAXC3.2 - 1)) ^ 2 + (100 * (C3 / MAXC2.3 - 1)) ^ 2) / 5)

A 21-Period version would be:

SQR(((100 * (C / MAXC21 - 1)) ^ 2 + (100 * (C1 / MAXC20.1 - 1)) ^ 2 + (100 * (C2 / MAXC19.2 - 1)) ^ 2 + (100 * (C3 / MAXC18.3 - 1)) ^ 2 + (100 * (C4 / MAXC17.4 - 1)) ^ 2 + (100 * (C5 / MAXC16.5 - 1)) ^ 2 + (100 * (C6 / MAXC15.6 - 1)) ^ 2 + (100 * (C7 / MAXC14.7 - 1)) ^ 2 + (100 * (C8 / MAXC13.8 - 1)) ^ 2 + (100 * (C9 / MAXC12.9 - 1)) ^ 2 + (100 * (C10 / MAXC11.10 - 1)) ^ 2 + (100 * (C11 / MAXC10.11 - 1)) ^ 2 + (100 * (C12 / MAXC9.12 - 1)) ^ 2 + (100 * (C13 / MAXC8.13 - 1)) ^ 2 + (100 * (C14 / MAXC7.14 - 1)) ^ 2 + (100 * (C15 / MAXC6.15 - 1)) ^ 2 + (100 * (C16 / MAXC5.16 - 1)) ^ 2 + (100 * (C17 / MAXC4.17 - 1)) ^ 2 + (100 * (C18 / MAXC3.18 - 1)) ^ 2 + (100 * (C19 / MAXC2.19 - 1)) ^ 2) / 21)

And a 40-Period version would be:

SQR(((100 * (C / MAXC40 - 1)) ^ 2 + (100 * (C1 / MAXC39.1 - 1)) ^ 2 + (100 * (C2 / MAXC38.2 - 1)) ^ 2 + (100 * (C3 / MAXC37.3 - 1)) ^ 2 + (100 * (C4 / MAXC36.4 - 1)) ^ 2 + (100 * (C5 / MAXC35.5 - 1)) ^ 2 + (100 * (C6 / MAXC34.6 - 1)) ^ 2 + (100 * (C7 / MAXC33.7 - 1)) ^ 2 + (100 * (C8 / MAXC32.8 - 1)) ^ 2 + (100 * (C9 / MAXC31.9 - 1)) ^ 2 + (100 * (C10 / MAXC30.10 - 1)) ^ 2 + (100 * (C11 / MAXC29.11 - 1)) ^ 2 + (100 * (C12 / MAXC28.12 - 1)) ^ 2 + (100 * (C13 / MAXC27.13 - 1)) ^ 2 + (100 * (C14 / MAXC26.14 - 1)) ^ 2 + (100 * (C15 / MAXC25.15 - 1)) ^ 2 + (100 * (C16 / MAXC24.16 - 1)) ^ 2 + (100 * (C17 / MAXC23.17 - 1)) ^ 2 + (100 * (C18 / MAXC22.18 - 1)) ^ 2 + (100 * (C19 / MAXC21.19 - 1)) ^ 2 + (100 * (C20 / MAXC20.20 - 1)) ^ 2 + (100 * (C21 / MAXC19.21 - 1)) ^ 2 + (100 * (C22 / MAXC18.22 - 1)) ^ 2 + (100 * (C23 / MAXC17.23 - 1)) ^ 2 + (100 * (C24 / MAXC16.24 - 1)) ^ 2 + (100 * (C25 / MAXC15.25 - 1)) ^ 2 + (100 * (C26 / MAXC14.26 - 1)) ^ 2 + (100 * (C27 / MAXC13.27 - 1)) ^ 2 + (100 * (C28 / MAXC12.28 - 1)) ^ 2 + (100 * (C29 / MAXC11.29 - 1)) ^ 2 + (100 * (C30 / MAXC10.30 - 1)) ^ 2 + (100 * (C31 / MAXC9.31 - 1)) ^ 2 + (100 * (C32 / MAXC8.32 - 1)) ^ 2 + (100 * (C33 / MAXC7.33 - 1)) ^ 2 + (100 * (C34 / MAXC6.34 - 1)) ^ 2 + (100 * (C35 / MAXC5.35 - 1)) ^ 2 + (100 * (C36 / MAXC4.36 - 1)) ^ 2 + (100 * (C37 / MAXC3.37 - 1)) ^ 2 + (100 * (C38 / MAXC2.38 - 1)) ^ 2) / 40)



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
diceman
Posted : Wednesday, November 30, 2016 12:32:06 PM
Registered User
Joined: 1/28/2005
Posts: 6,049

QUOTE (Bruce_L)
Here are two other possible interpretations you might wish to try out:

SQR(((100 * (C / MAXC14 - 1)) ^ 2 + (100 * (C1 / MAXC14 - 1)) ^ 2 + (100 * (C2 / MAXC14 - 1)) ^ 2 + (100 * (C3 / MAXC14 - 1)) ^ 2 + (100 * (C4 / MAXC14 - 1)) ^ 2 + (100 * (C5 / MAXC14 - 1)) ^ 2 + (100 * (C6 / MAXC14 - 1)) ^ 2 + (100 * (C7 / MAXC14 - 1)) ^ 2 + (100 * (C8 / MAXC14 - 1)) ^ 2 + (100 * (C9 / MAXC14 - 1)) ^ 2 + (100 * (C10 / MAXC14 - 1)) ^ 2 + (100 * (C11 / MAXC14 - 1)) ^ 2 + (100 * (C12 / MAXC14 - 1)) ^ 2 + (100 * (C13 / MAXC14 - 1)) ^ 2 ) / 14)

SQR(((100 * (C / MAXC14 - 1)) ^ 2 + (100 * (C1 / MAXC14.1 - 1)) ^ 2 + (100 * (C2 / MAXC14.2 - 1)) ^ 2 + (100 * (C3 / MAXC14.3 - 1)) ^ 2 + (100 * (C4 / MAXC14.4 - 1)) ^ 2 + (100 * (C5 / MAXC14.5 - 1)) ^ 2 + (100 * (C6 / MAXC14.6 - 1)) ^ 2 + (100 * (C7 / MAXC14.7 - 1)) ^ 2 + (100 * (C8 / MAXC14.8 - 1)) ^ 2 + (100 * (C9 / MAXC14.9 - 1)) ^ 2 + (100 * (C10 / MAXC14.10 - 1)) ^ 2 + (100 * (C11 / MAXC14.11 - 1)) ^ 2 + (100 * (C12 / MAXC14.12 - 1)) ^ 2 + (100 * (C13 / MAXC14.13 - 1)) ^ 2 ) / 14)

I really don't know how it is calculated, but based on your English language descriptions, I would tend to think your algorithm and the first formula I provided would be closest to the mark.

 

Using the second version in your post, can you create, 5, 8, 13, 21 period versions?

 

Thanks

Bruce_L
Posted : Wednesday, November 30, 2016 12:47:02 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138

5 period:

SQR(((100 * (C / MAXC14 - 1)) ^ 2 + (100 * (C1 / MAXC14.1 - 1)) ^ 2 + (100 * (C2 / MAXC14.2 - 1)) ^ 2 + (100 * (C3 / MAXC14.3 - 1)) ^ 2 + (100 * (C4 / MAXC14.4 - 1)) ^ 2) / 5)

8 period:

SQR(((100 * (C / MAXC14 - 1)) ^ 2 + (100 * (C1 / MAXC14.1 - 1)) ^ 2 + (100 * (C2 / MAXC14.2 - 1)) ^ 2 + (100 * (C3 / MAXC14.3 - 1)) ^ 2 + (100 * (C4 / MAXC14.4 - 1)) ^ 2 + (100 * (C5 / MAXC14.5 - 1)) ^ 2 + (100 * (C6 / MAXC14.6 - 1)) ^ 2 + (100 * (C7 / MAXC14.7 - 1)) ^ 2) / 8)

13 period:

SQR(((100 * (C / MAXC14 - 1)) ^ 2 + (100 * (C1 / MAXC14.1 - 1)) ^ 2 + (100 * (C2 / MAXC14.2 - 1)) ^ 2 + (100 * (C3 / MAXC14.3 - 1)) ^ 2 + (100 * (C4 / MAXC14.4 - 1)) ^ 2 + (100 * (C5 / MAXC14.5 - 1)) ^ 2 + (100 * (C6 / MAXC14.6 - 1)) ^ 2 + (100 * (C7 / MAXC14.7 - 1)) ^ 2 + (100 * (C8 / MAXC14.8 - 1)) ^ 2 + (100 * (C9 / MAXC14.9 - 1)) ^ 2 + (100 * (C10 / MAXC14.10 - 1)) ^ 2 + (100 * (C11 / MAXC14.11 - 1)) ^ 2 + (100 * (C12 / MAXC14.12 - 1)) ^ 2) / 13)

21 period:

SQR(((100 * (C / MAXC14 - 1)) ^ 2 + (100 * (C1 / MAXC14.1 - 1)) ^ 2 + (100 * (C2 / MAXC14.2 - 1)) ^ 2 + (100 * (C3 / MAXC14.3 - 1)) ^ 2 + (100 * (C4 / MAXC14.4 - 1)) ^ 2 + (100 * (C5 / MAXC14.5 - 1)) ^ 2 + (100 * (C6 / MAXC14.6 - 1)) ^ 2 + (100 * (C7 / MAXC14.7 - 1)) ^ 2 + (100 * (C8 / MAXC14.8 - 1)) ^ 2 + (100 * (C9 / MAXC14.9 - 1)) ^ 2 + (100 * (C10 / MAXC14.10 - 1)) ^ 2 + (100 * (C11 / MAXC14.11 - 1)) ^ 2 + (100 * (C12 / MAXC14.12 - 1)) ^ 2 + (100 * (C13 / MAXC14.13 - 1)) ^ 2 + (100 * (C14 / MAXC14.14 - 1)) ^ 2 + (100 * (C15 / MAXC14.15 - 1)) ^ 2 + (100 * (C16 / MAXC14.16 - 1)) ^ 2 + (100 * (C17 / MAXC14.17 - 1)) ^ 2 + (100 * (C18 / MAXC14.18 - 1)) ^ 2 + (100 * (C19 / MAXC14.19 - 1)) ^ 2 + (100 * (C20 / MAXC14.19 - 1)) ^ 2) / 21)



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
donv98
Posted : Thursday, December 1, 2016 11:00:47 AM
Registered User
Joined: 7/29/2010
Posts: 417

Bruce,

  Please create a 3 period version of the first:

 

"A 5-Period version of the first formula with which I came up would be:

SQR(((100 * (C / MAXC5 - 1)) ^ 2 + (100 * (C1 / MAXC4.1 - 1)) ^ 2 + (100 * (C2 / MAXC3.2 - 1)) ^ 2 + (100 * (C3 / MAXC2.3 - 1)) ^ 2) / 5)"

 

Thank you,

Don

donv98
Posted : Thursday, December 1, 2016 11:09:03 AM
Registered User
Joined: 7/29/2010
Posts: 417

Bruce,

   I am assuming the above formulas will also work on V12.5 and V16,V17.

Is that correct?

Thanks,

Don

Bruce_L
Posted : Thursday, December 1, 2016 11:11:52 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138

A 3-Period version of the first formula with which I came up would be:

SQR(((100 * (C / MAXC3 - 1)) ^ 2 + (100 * (C1 / MAXC2.1 - 1)) ^ 2) / 3)



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
donv98
Posted : Thursday, December 1, 2016 11:15:23 AM
Registered User
Joined: 7/29/2010
Posts: 417

Wonderful!

Many thanks  for your efforts  Bruce.

Don

donv98
Posted : Friday, December 2, 2016 11:52:49 AM
Registered User
Joined: 7/29/2010
Posts: 417

This helped me better understand and interpret the Ulcer Index:

http://stockcharts.com/school/doku.php?id=chart_school:technical_indicators:ulcer_index

Users browsing this topic
Guest-1

Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.