Systemicalpha

Ulcer Index

systemic:core-uiIndicatorsfunction1 cr

Inputs

NameTypeDescription
Windowinteger- **Description**: The window parameter represents the number of periods over which the Ulcer Index is calculated. It defines the look-back period for assessing price drawdowns and volatility.
Pricefloatarray- **Description**: This refers to the historical price data of the security or asset for which the Ulcer Index is being computed. The price data typically includes daily, weekly, or monthly closing prices.

Outputs

NameTypeDescription
UIfloatarray- **Description**: The Ulcer Index (UI) itself is the primary output of the Ulcer Index calculation. It measures the degree of drawdown or volatility of an asset's price over a specified window.

The Ulcer Index measures downside volatility by quantifying the depth and duration of drawdowns. Unlike standard deviation, it focuses exclusively on price declines, making it a true measure of investment pain.

UI=∑i=1nRi2nUI = \sqrt{\frac{\sum_{i=1}^{n} R_i^2}{n}}

Where RiR_i = Percentage drawdown from the highest high over the period.


How It Works

flowchart TD
    subgraph Input["Price Series"]
        P["Closing Prices"]
    end
    
    subgraph Calc["Calculation Steps"]
        HH["Track rolling highest high"]
        DD["Drawdown = (High - Price) / High × 100"]
        SQ["Square each drawdown"]
        AVG["Average of squared drawdowns"]
        SQRT["Square root"]
    end
    
    subgraph Output["Result"]
        UI["Ulcer Index"]
    end
    
    P --> HH --> DD --> SQ --> AVG --> SQRT --> UI

Interpreting UI

UI ValueInterpretation
< 5Low stress — shallow drawdowns
5-10Moderate drawdown risk
10-20Elevated volatility
> 20High stress — deep/prolonged drawdowns
flowchart LR
    subgraph Stress["Ulcer Index Levels"]
        LOW["<5<br/>Low stress"]
        MOD["5-10<br/>Moderate"]
        HIGH["10-20<br/>Elevated"]
        VHIGH[">20<br/>High stress"]
    end
    
    LOW --> MOD --> HIGH --> VHIGH

Why Ulcer Index?

Traditional volatility measures (like standard deviation) treat upside and downside equally. But for investors:

MeasureCaptures
Standard DeviationAll price movement
Ulcer IndexOnly drawdown pain

Most investors don't mind upside volatility — they worry about losses.


Applications

1. Risk Assessment

Compare UI across different assets to identify which have historically caused more investor distress.

2. UPI (Ulcer Performance Index)

A risk-adjusted return metric:

UPI=ReturnUlcer IndexUPI = \frac{Return}{Ulcer\ Index}

Higher UPI = better return per unit of drawdown pain.

3. Position Sizing

Lower UI assets can warrant larger position sizes in a portfolio.


UI vs Other Risk Metrics

MetricFocusTreats Up/Down
Ulcer IndexDrawdownsDownside only
Std DevAll volatilityEqually
Max DrawdownWorst declineSingle event
Sortino RatioDownside deviationDownside only

Advantages

  • Investor-aligned — Measures what actually hurts portfolios
  • Captures duration — Prolonged drawdowns penalized more
  • Risk-adjusted returns — Foundation for UPI metric
  • Comparable — Works across asset classes

Disadvantages

  • Backward-looking — Based on historical drawdowns
  • Period sensitive — Depends on lookback window
  • Less known — Not as standard as Sharpe ratio
  • Requires high prices — Needs continuous price series

Further Reading


Missing Data

A closed-market or missing-data bar (null) is never fabricated — not padded with 0.0 ("no stress"), not held stale across a gap. The rolling max-drawdown RMS runs over the observed bars only (window-bar UI = window observed bars, weekends bridged), then the result is placed back at the original grid slots:

ScenarioOutput
Closed-market gapNone at that slot; the surrounding observed bars bridge the gap as adjacent bars (Friday→Monday), never a stale ffilled UI value
Warm-up (< window observed bars seen)None — never the retired 0.0 ("no stress") fill
All bars missingEvery slot None, no crash
Live tick on a gap slot[None] — correct and non-starving, not the retired ffilled value

Indicator Assessment

The following chart positions the Ulcer Index based on its complexity (ease of understanding and implementation) versus reliability (consistency of signals across market conditions). Points closer to the top indicate higher reliability; points to the left indicate lower complexity.

quadrantChart
    title Ulcer Index Assessment
    x-axis Low Complexity --> High Complexity
    y-axis Low Reliability --> High Reliability
    quadrant-1 Complex & Reliable
    quadrant-2 Simple & Reliable
    quadrant-3 Simple & Unreliable
    quadrant-4 Complex & Unreliable
    Stocks: [0.40, 0.75]
    Crypto: [0.40, 0.65]

Assessment Breakdown

DimensionStocksCryptoNotes
Popularity5/104/10Niche but respected; more common in fund analysis than retail trading
Reliability7.5/106.5/10Excellent for measuring downside risk; crypto's extreme volatility causes higher UI readings
Complexity4/104/10Conceptually simple—drawdown squared and averaged; straightforward to interpret
Versatility6/105/10Excellent for risk comparison and portfolio construction; less applicable as a trading signal
Recent Interest5/104/10Steady adoption in risk-adjusted analysis; growing interest post-2022 market declines
Rendering diagrams...
© 2026 WanoLabs. All rights reservedAlpha build v0.1.5