Skip to main content
On this page

Ulcer Index: Drawdown Calculation and TradingView Interpretation

· 4 min read
Pineify Team
Pine Script and AI trading workflow research team

Ulcer Index summarizes squared percentage drawdowns from a reference high. Larger or more persistent drawdowns raise the reading, while a series repeatedly at new highs can have a low reading despite substantial upward movement. It describes the selected historical series, not a forecast of maximum future loss.

Ulcer Index shown on a TradingView chart

Calculation in the Pineify indicator​

For each chart bar, the current implementation finds the highest close over the selected length. It calculates the close's percentage distance below that rolling high, squares the result, averages those squared values over the same length, and takes the square root.

A 10% drawdown contributes four times as much as a 5% drawdown to the squared term. That is a mathematical weighting, not a measurement of an individual investor's psychological response.

Each drawdown observation uses its own rolling high. This is not identical to measuring an entire portfolio against one all-time equity peak. As an old high leaves the rolling window, the reference can change even if price has not recovered to that old high.

Settings and comparison​

Pineify's current configuration defaults to 10 bars, not 14 days. A length always needs a timeframe: ten hourly bars and ten daily bars describe different samples. The configuration also exposes a Cutoff value; that value is not used in the current calculation function and should not be interpreted as a transformation of the Ulcer Index formula.

TradingView's Ulcer Index documentation explains the indicator's purpose. When comparing implementations, match price source, high-reference convention, averaging length, timeframe, and warm-up behavior rather than assuming the same name means identical output.

Add and inspect the indicator​

Open Pineify's indicator editor, locate Ulcer Index, and review the available inputs and entitlement. Generate the source, inspect it, then apply it through TradingView's Pine Editor. Check a short visible interval manually against the calculation and observe missing values near the start of the available history.

An exported script still needs syntax and behavior validation. A visual configuration does not make every combination of settings correct automatically.

What the reading can and cannot tell you​

A lower value means less squared drawdown under the selected definition. It does not necessarily mean lower total volatility, greater liquidity, or a safer future investment. Compare assets only on a consistent window and data basis.

An Ulcer Index of a stock's price is not the same as the Ulcer Index of a trading strategy's equity. Leverage, costs, cashflows, and periods without exposure can change the equity path substantially.

There is no universal rule that below 5 is safe, above 8 requires halving a position, or above 10 makes a strategy unusable. Such thresholds would need a documented policy and tests. A low historical reading cannot justify increasing size by itself.

Research use​

If testing a drawdown filter, define the reference series, threshold, entry and exit timing, sizing, and costs before looking at results. Compare the filtered and unfiltered strategy, including missed recoveries and turnover. Keep an untouched sample for evaluation.

The former AAPL/TSLA readings and personal portfolio-sizing anecdotes lacked source data and have been withdrawn. This page supplies the calculation and its boundaries rather than an alleged tested allocation rule.

Pineify's easy-to-use interface
Adding indicators in Pineify