Disparity Index indicator free

by mfejza in category Oscilator at 13/09/2022
Description

The Disparity Index indicator is used to define price reversal levels.


The histogram bars (disparity index) when rising above the upper band, the overbought level is reached.
The histogram bars when decreasing below the lower band, the oversold level is reached.

 

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;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;

namespace cAlgo
{
    [Levels(0)]
    [Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class mDisparityIndex : Indicator
    {
        [Parameter("Periods (10)", DefaultValue = 10, Group = "DisparityIndex")]
        public int inpPeriods { get; set; }
        [Parameter("Levels Coefficients (2.618)", DefaultValue = 2.618, Group = "DisparityIndex")]
        public double inpLevelsCoefficients { get; set; }
        [Parameter("Smooth Type (sma)", DefaultValue = MovingAverageType.Simple, Group = "DisparityIndex")]
        public MovingAverageType inpSmoothType { get; set; }

        [Output("Disparity Index", LineColor = "Transparent", LineStyle = LineStyle.Solid, Thickness = 1)]
        public IndicatorDataSeries outDisparityIndex { get; set; }
        [Output("Band Up", LineColor = "Black", LineStyle = LineStyle.Solid, Thickness = 1)]
        public IndicatorDataSeries outDisparityIndexUp { get; set; }
        [Output("Band Down", LineColor = "Black", LineStyle = LineStyle.Solid, Thickness = 1)]
        public IndicatorDataSeries outDisparityIndexDown { get; set; }
        [Output("Histogram Up", PlotType = PlotType.Histogram, LineColor = "Green", Thickness = 3)]
        public IndicatorDataSeries outDisparityIndexUpC { get; set; }
        [Output("Histogram Down", PlotType = PlotType.Histogram, LineColor = "Red", Thickness = 3)]
        public IndicatorDataSeries outDisparityIndexDnC { get; set; }


        private IndicatorDataSeries _absroc, _di;
        private MovingAverage _maprice, _maabsroc;


        protected override void Initialize()
        {
            _absroc = CreateDataSeries();
            _di = CreateDataSeries();
            _maprice = Indicators.MovingAverage(Bars.ClosePrices, inpPeriods, inpSmoothType);
            _maabsroc = Indicators.MovingAverage(_absroc, inpPeriods, inpSmoothType);
        }

        public override void Calculate(int i)
        {
            _absroc[i] = Math.Abs(Bars.ClosePrices[i] - Bars.ClosePrices[i - 1]) / Bars.ClosePrices[i] * 100;

            _di[i] = 100 * (Bars.ClosePrices[i] - _maprice.Result[i]) / (_maprice.Result[i]);

            outDisparityIndex[i] = _di[i];
            outDisparityIndexUp[i] = _maabsroc.Result[i] * inpLevelsCoefficients;
            outDisparityIndexDown[i] = -_maabsroc.Result[i] * inpLevelsCoefficients;

            if (!double.IsNaN(_di[i]))
            {
                if (_di[i] > 0)
                {
                    outDisparityIndexUpC[i] = _di[i];
                    outDisparityIndexDnC[i] = double.NaN;
                }
                else
                {
                    outDisparityIndexUpC[i] = double.NaN;
                    outDisparityIndexDnC[i] = _di[i];
                }
            }
            else
            {
                outDisparityIndexUpC[i] = double.NaN;
                outDisparityIndexDnC[i] = double.NaN;
            }
        }
    }
}
Comments

harryjacki336 - September 14, 2022 @ 11:40

It's really helpful, and the excellent content flow makes it even simpler for me to understand the website page. gaming jacket It's great to see that some people can still produce high-quality posts!

mikle.jk2009 - September 21, 2022 @ 14:31

Hello. I would like to advise you a very good company that will give you a Gambling license in El Salvador https://www.eternitylaw.com/news/gambling-license-in-el-salvador/ . Just go to their website and take a look at the information.

0