Category Oscilators  Published on 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 on 25.01.2022

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: mDampingIndex.algo
  • Rating: 5
  • Installs: 530
  • Modified: 08/06/2023 11:49
Comments
Log in to add a comment.
mfejza's avatar
mfejza · 10 months ago

Se apprezzi l'algoritmo logico dell'indice di smorzamento, puoi anche utilizzare l'indicatore personalizzato fornito dopo il commento. Public ProAction ha una logica simile e, come proprietà aggiuntiva, mostra esattamente i Pips for Action.

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

namespace cAlgo
{
    [Levels(0)]
    [Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class mPublicProActionOsc : Indicator
    {

        [Output("PublicPro Action", LineColor = "Black", PlotType = PlotType.Line, LineStyle = LineStyle.Solid, Thickness = 1)]
        public IndicatorDataSeries outPublicProAction { get; set; }

        private IndicatorDataSeries _public, _pro, _firpublic, _firpro, _result;
        

        protected override void Initialize()
        {
            _public = CreateDataSeries();
            _pro = CreateDataSeries();
            _firpublic = CreateDataSeries();
            _firpro = CreateDataSeries();
            _result = CreateDataSeries();
        }

        public override void Calculate(int i)
        {
            _public[i] = i>1 ? Bars.ClosePrices[i-1] : Bars.TypicalPrices[i] - Bars.OpenPrices[i];
            _pro[i] = Bars.ClosePrices[i] - Bars.OpenPrices[i];
            _firpublic[i] = i>4 ? (_public[i] + 2.0 * _public[i-1] + 2.0 * _public[i-2] + _public[i-3]) / 6.0 : Bars.ClosePrices[i] - Bars.TypicalPrices[i];
            _firpro[i] = i>4 ? (_pro[i] + 2.0 * _pro[i-1] + 2.0 * _pro[i-2] + _pro[i-3]) / 6.0 : Bars.ClosePrices[i] - Bars.MedianPrices[i];
            _result[i] = _firpro[i] - _firpublic[i];
            
            //outPublicProAction[i] = Bars.ClosePrices[i] + _result[i];
            outPublicProAction[i] = (Bars.ClosePrices[i] + _result[i]) / Symbol.PipSize;
        }
    }
}
AndreaPereira's avatar
AndreaPereira · 10 months ago

Adoro questo indicatore bravo…