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 Range | Characteristics | Use Case |
|---|---|---|
| 7-10 | High sensitivity, short-term drawdowns | Short-term trading, quick risk assessment |
| 14-20 | Balanced (default 14) | General analysis, swing trading |
| 20-30 | Moderate smoothing | Position trading, medium-term trends |
| 50-100 | Captures major drawdowns | Long-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
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.