The Ulcer Index (UI) indicator can be used to determine downside risk by displaying the depth and duration of price declines from their earlier highs. A high UI value is generally an indication that the instrument's price has moved further away from its previous high and may take longer to return to this value.
The indicator is calculated in three steps:
\[ Percentage\; Drawdown = \frac{Close - (n\text{-}period\; High\; Close)}{n\text{-}period\; High\; Close} \times 100 \]
\[ Squared\;Average = \frac{\sum_{n=1}^{n\text{-}period} (Percentage\;Drawdown)^2}{n\text{-}period} \]
\[ Ulcer\;Index = \sqrt{Squared\;Average} \]