Ulcer Index free

by Doustzadeh in category Volatility at 08/12/2021
Description

Developed by Peter Martin and Byron McCann in 1987, the Ulcer Index is a volatility indicator that measures downside risk. It was first introduced in their 1989 book, The Investor's Guide to Fidelity Funds. Originally, the index was designed with mutual funds in mind, which is why it is only focused on downside risk. Mutual funds are designed to make money by increasing in value; the only risk, therefore, is the drawdown or downside. As its name implies, the Ulcer Index measures the drawdown investors can expect to stomach on any given security. Many consider the Ulcer Index superior to the standard deviation and other measures of risk.

 

Github: GitHub - Doustzadeh/cTrader-Indicator

 

Notification Publishing copyrighted material is strictly prohibited. If you believe there is copyrighted material in this section you may use the Copyright Infringement Notification form to submit a claim.
Formula / Source Code
Language: C#
Trading Platform: cAlgocTrader
´╗┐using System;
using cAlgo.API;

namespace cAlgo
{
    [Indicator(IsOverlay = false, AccessRights = AccessRights.None)]
    public class UlcerIndex : Indicator
    {
        // Percent-Drawdown = ((Close - 14-period Max Close) / 14-period Max Close) x 100
        // Squared Average = (14-period Sum of Percent-Drawdown Squared) / 14 
        // Ulcer Index = Square Root of Squared Average

        [Parameter("Periods", DefaultValue = 14)]
        public int Periods { get; set; }

        [Output("Ulcer Index", LineColor = "Red")]
        public IndicatorDataSeries Result { get; set; }

        private IndicatorDataSeries PercentDrawdown, PercentDrawdownSquared;

        protected override void Initialize()
        {
            PercentDrawdown = CreateDataSeries();
            PercentDrawdownSquared = CreateDataSeries();
        }

        public override void Calculate(int index)
        {
            PercentDrawdown[index] = ((Bars.ClosePrices[index] - Bars.ClosePrices.Maximum(Periods)) / Bars.ClosePrices.Maximum(Periods)) * 100;
            PercentDrawdownSquared[index] = Math.Pow(PercentDrawdown[index], 2);
            double SquaredAverage = PercentDrawdownSquared.Sum(Periods) / Periods;
            Result[index] = Math.Sqrt(SquaredAverage);
        }
    }
}
Comments

togolese273duhduh - April 29, 2022 @ 08:16

Being able to compare a real-time event (the current day’s open) with historical events (the previous day’s volume profile) and make a trading decision based on the relationship is an excellent example of this.

 

Fence contractor

junealexis001 - September 12, 2022 @ 12:34

Interesting site i love it keep posting more!  bathroom remodel fresno

0