indicator · own pane · open source

Ulcer Index

Deepwick · @deepwickv1Updated 2 Oct 2026▲ 0 users
Running…
Loading chart…

About

Ulcer Index measures depth and duration of drawdowns from the rolling high — designed to capture how painful the ride was, not just how volatile.

  • Rises during prolonged declines, falls during recoveries.
  • Common alternative to StdDev for risk-adjusted return ratios (Ulcer Performance Index).

Source code

//@version=5
indicator("Ulcer Index", overlay=false)
len = input.int(14, "Lookback", minval=2, maxval=200)
hi = ta.highest(close, len)
pdd = 100 * (close - hi) / hi
uiX = math.pow(pdd, 2)
uiSum = ta.cum(uiX) - ta.cum(uiX)[len]
ui = math.sqrt(uiSum / len)
p_UI = plot(ui, "UI", color=color.purple, linewidth=2)

Comments

No comments yet.

Sign in to comment.