Category Volatility  Published on 15/06/2021

Damiani Volameter: cTrader edition

Description

The Damiani Volameter is another trend and range filter.When the green line is above the yellow line, the market is trending. The indicator does not display which direction the market is trending, thus, you might need to add another directional indicator like momentum, to make it a complete trading system.

Note: v1.1 small bug fix

 


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

namespace cAlgo
{
    [Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class DamianiVolatometer : Indicator
    {
        [Parameter("Viscosity", DefaultValue = 13)]
        public int viscosity { get; set; }

        [Parameter("Sedimentation", DefaultValue = 50)]
        public int sedimentation { get; set; }

        [Parameter("Threshold_level", DefaultValue = 1.3)]
        public double threshold { get; set; }

        [Parameter("Lag_supressor", DefaultValue = true)]
        public bool lag_supressor { get; set; }

        [Parameter(DefaultValue = MovingAverageType.Simple)]
        public MovingAverageType MA { get; set; }

        [Parameter()]
        public DataSeries Source { get; set; }

        [Output("LineP", Color = Colors.LimeGreen)]
        public IndicatorDataSeries lineP { get; set; }
        [Output("LineM", LineColor = "#FFFFFF66")]
        public IndicatorDataSeries lineM { get; set; }

        private AverageTrueRange atrV, atrS;
        private StandardDeviation sdV, sdS;
        private double lag_s_K = 0.5;


        protected override void Initialize()
        {
            atrV = Indicators.AverageTrueRange(viscosity, MovingAverageType.Simple);
            atrS = Indicators.AverageTrueRange(sedimentation, MovingAverageType.Simple);
            sdV = Indicators.StandardDeviation(Source, viscosity, MA);
            sdS = Indicators.StandardDeviation(Source, sedimentation, MA);


        }

        public override void Calculate(int index)
        {

            if (lag_supressor == true)
            {
                double s1 = NZ(lineP[index - 1]);
                double s3 = NZ(lineP[index - 3]);
                lineP[index] = atrV.Result[index] / atrS.Result[index] + lag_s_K * (s1 - s3);
                lineM[index] = threshold - (sdV.Result[index] / sdS.Result[index]);
            }
            else
            {
                lineP[index] = atrV.Result[index] / atrS.Result[index];
                lineM[index] = threshold - (sdV.Result[index] / sdS.Result[index]);
            }



        }

        private double NZ(double number)
        {
            if (double.IsNaN(number))
            {
                return 0;

            }
            else
            {
                return number;
            }

        }


    }
}


KA
kaneida84

Joined on 25.04.2021

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: DamianiVolatometer.algo
  • Rating: 0
  • Installs: 1502
  • Modified: 13/10/2021 09:54
Comments
Log in to add a comment.
No comments found.