Category Oscilators  Published on 06/06/2023

DMSX indicator - (Bipolar DMS)

Description

The DMSX indicator (Bipolar Directional Movement System) is calculated using the standard DMS indicator. However, compared to that, it displays data as an oscillator with a signal line and has a shorter delay.

This indicator is used to trigger events for every cross where the main component is above the signal component. If the cross happens above zero, the bullish trigger occurs. Similarly, for every cross where the main component is below the signal component, if the cross happens below zero, the bearish trigger occurs.

Similar indicator: ctrader.com/algos/indicators/show/3459

/


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

namespace cAlgo
{
    [Levels(0)]
    [Indicator(IsOverlay = false, AccessRights = AccessRights.None)]
    public class mDMSx : Indicator
    {
        [Parameter("Period (13)", DefaultValue = 13)]
        public int inpPeriod { get; set; }
        [Parameter("Smooth Period (5)", DefaultValue = 5)]
        public int inpPeriodSmooth { get; set; }
        [Parameter("Smooth Type (sma)", DefaultValue = MovingAverageType.Simple)]
        public MovingAverageType inpSmoothType { get; set; }

        [Output("mDMSx", LineColor = "Black", Thickness = 1)]
        public IndicatorDataSeries outDMSx { get; set; }
        [Output("mDMSsignal", LineColor = "Red", Thickness = 1)]
        public IndicatorDataSeries outSignal { get; set; }

        private IndicatorDataSeries _sum, _diff, _dmsx;
        private DirectionalMovementSystem _dms;
        private MovingAverage _smooth;


        protected override void Initialize()
        {
            _sum = CreateDataSeries();
            _diff = CreateDataSeries();
            _dmsx = CreateDataSeries();
            _dms = Indicators.DirectionalMovementSystem(inpPeriod);
            _smooth = Indicators.MovingAverage(_dmsx, inpPeriodSmooth, inpSmoothType);
        }

        public override void Calculate(int i)
        {
            _sum[i] = _dms.DIPlus[i] + _dms.DIMinus[i];
            _diff[i] = _dms.DIPlus[i] - _dms.DIMinus[i];
            _dmsx[i] = _sum[i] != 0 ? _diff[i] / _sum[i] : 0;

            outDMSx[i] = _dmsx[i];
            outSignal[i] = i>inpPeriod ? _smooth.Result[i] : _dmsx[i];
        }
    }
}


mfejza's avatar
mfejza

Joined on 25.01.2022

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: mDMSx.algo
  • Rating: 5
  • Installs: 461
  • Modified: 06/06/2023 11:54
Comments
Log in to add a comment.
No comments found.