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

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

Default Usage

use rust_ti::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 pytechnicalindicators as pti

# Ulcer Index with default period
period = 14

ui = pti.volatility_indicators.bulk.ulcer_index(prices, period)
print("Ulcer Index:", ui)
import init, { 
    volatility_bulk_ulcerIndex
} from 'https://cdn.jsdelivr.net/npm/ti-engine@latest/dist/web/ti_engine.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);

Interactive Chart

Use the interactive playground below to explore how different parameters affect the indicator's behavior.