Docs

ta.ulcer

Measure how deep and how long a series has sat below its recent highs, as a single percentage.

itm
ta.ulcer(source, length)

Ulcer index in its rolling form: the percentage drawdown of each bar from the highest value over the trailing length bars, then the root of the mean of the squared drawdowns over length bars. The maximum is taken over the trailing length bars, not over the whole run. It reads 0 on a series that never falls below its recent high.

Parameters

A series parameter takes a value on every bar. A constant parameter must be known before the first bar, such as a number or an input.

NameKindTypeDefaultRangeDescription
sourceSeriesnumber--The series to read.
lengthConstantnumber141 to 10000Window in observed bars.

Output

NameType
valuenumber

Warm-up and missing values

Warm-up
2 * length - 1 bars. Names in the warm-up are this operator’s parameters.
Missing values
Returns na until 2 * length - 1 consecutive non-na observations are in the window. An na resets the accumulation. Also na where the highest value in a window is zero or below.

Example

itm
ta.ulcer(close, 14)
itm
plot(ta.ulcer(close, 14), "Ulcer 14")