Category Oscilators  at 08/06/2023

Damping Index

Description

The Damping Index Oscillator (DI) is designed to identify the damping of directed market movements.

Any value below 1.0 (by default) definitively indicates a slowing of price movement, regardless of its previous direction. In other words, when the indicator value is below the damping level, that period of time represents a time of sentiment accumulation and the best opportunity to open a position before the market triggers mark-up or mark-down.


using System;
using cAlgo.API;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;

namespace cAlgo
{
    [Levels(0)]
    [Cloud("Damping Index", "Damping Level", FirstColor = "Kagi", SecondColor = "Transparent", Opacity = 0.1)]  
    [Indicator(IsOverlay = false, AccessRights = AccessRights.None)]
    public class mDampingIndex : Indicator
    {
        [Parameter("Period (5)", DefaultValue = 5, MinValue = 2)]
        public int inpPeriod { get; set; }
        [Parameter("Smooth Type (sma)", DefaultValue = MovingAverageType.Simple)]
        public MovingAverageType inpSmoothType { get; set; }
        [Parameter("Damping Level (1.0)", DefaultValue = 1.0, MinValue = 0)]
        public double inpDampingLevel { get; set; }

        [Output("Damping Index", LineColor = "Black", PlotType = PlotType.Line, LineStyle = LineStyle.Solid, Thickness = 1)]
        public IndicatorDataSeries outDampingIndex { get; set; }
        [Output("Damping Level", LineColor = "Red", PlotType = PlotType.Line, LineStyle = LineStyle.LinesDots, Thickness = 1)]
        public IndicatorDataSeries outDampingLevel { get; set; }
        
        private IndicatorDataSeries _delta, _dampingindex;
        private MovingAverage _smoothhigh, _smoothlow;
        

        protected override void Initialize()
        {
            _delta = CreateDataSeries();
            _dampingindex = CreateDataSeries();
            _smoothhigh = Indicators.MovingAverage(Bars.HighPrices, inpPeriod, inpSmoothType);
            _smoothlow = Indicators.MovingAverage(Bars.LowPrices, inpPeriod, inpSmoothType);
        }

        public override void Calculate(int i)
        {
            _delta[i] = i>inpPeriod ? _smoothhigh.Result[i] - _smoothlow.Result[i] : Bars.HighPrices[i] - Bars.LowPrices[i];
            _dampingindex[i] = _delta[i] / (i>inpPeriod+1 && _delta[i-inpPeriod] != 0 ? _delta[i-inpPeriod] : 1.0);
            
            outDampingIndex[i] = _dampingindex[i];
            outDampingLevel[i+100] = inpDampingLevel;
        }
    }
}

mfejza's avatar
mfejza

Joined 25.01.2022

  • Type: Free
  • Language: C#
  • Trading Platform: cTrader Automate
  • Filename: mDampingIndex.algo
  • Rating: 5
  • Installs: 226
Comments
Only logged in users can post a comment
Comments not found