Ulcer Index

Measures downside volatility and risk by tracking the depth and duration of price drawdowns.

About the Ulcer Index

The Ulcer Index is a volatility indicator developed by Peter Martin in 1987 that measures downside volatility by focusing exclusively on the depth and duration of price drawdowns from recent highs. Unlike standard deviation which treats upside and downside movements equally, the Ulcer Index only considers drawdowns, making it particularly useful for risk-averse investors who are more concerned about losing money than missing gains.

The name "Ulcer Index" reflects the anxiety or "ulcers" an investor might experience when watching their portfolio decline. A higher Ulcer Index value indicates greater downside volatility and potential investor discomfort, while a lower value suggests a smoother, more stable price trajectory with smaller drawdowns.

What It Measures

The Ulcer Index measures the depth and duration of percentage drawdowns from the highest price over a specified period. It calculates the root mean square of all percentage drawdowns, giving more weight to larger declines. This provides a single number representing the "pain" of holding an investment during price declines.

When to Use

  • Risk Assessment: Compare the downside volatility of different investments or portfolios
  • Portfolio Selection: Identify investments with smoother performance and smaller drawdowns
  • Position Sizing: Adjust position sizes based on an asset's downside risk profile
  • Performance Evaluation: Use in risk-adjusted return calculations (e.g., Martin Ratio)
  • Market Timing: Identify periods of elevated downside risk

Period Selection Guidelines

The period parameter affects the sensitivity to drawdowns:

Period RangeCharacteristicsUse Case
7-10High sensitivity, short-term drawdownsShort-term trading, quick risk assessment
14-20Balanced (default 14)General analysis, swing trading
20-30Moderate smoothingPosition trading, medium-term trends
50-100Captures major drawdownsLong-term investing, macro risk analysis

Interpretation

  • Low Values (0-2): Indicates a relatively stable price with minimal drawdowns; lower investor anxiety
  • Moderate Values (2-5): Represents normal volatility with typical market fluctuations
  • High Values (5+): Signals significant downside volatility with deeper or more prolonged drawdowns
  • Rising Ulcer Index: Suggests increasing downside risk and potential for larger losses
  • Falling Ulcer Index: Indicates stabilizing prices and reduced drawdown severity
  • Comparison Use: The Ulcer Index is most valuable when comparing relative risk between assets rather than as an absolute threshold

Example Usage

use centaur_technical_indicators::volatility_indicators::bulk::ulcer_index;

pub fn main() {
    // fetch the data in your preferred way
    // let prices = vec![...];  // price data
    
    let period = 14;
    
    let ui = ulcer_index(&prices, period);
    println!("Ulcer Index: {:?}", ui);
}
import centaur_technical_indicators as cti

# Ulcer Index with default period
period = 14

ui = cti.volatility_indicators.bulk.ulcer_index(prices, period)
print("Ulcer Index:", ui)
import init, { 
    volatility_bulk_ulcerIndex
} from 'https://cdn.jsdelivr.net/npm/centaur-technical-indicators@latest/dist/web/centaur-technical-indicators.js';

await init();

// fetch the data in your preferred way
// const prices = [...];  // price data

const period = 14;

const ui = volatility_bulk_ulcerIndex(prices, period);
console.log("Ulcer Index:", ui);