Damiani Volameter: cTrader edition free

by kaneida84 in category Volatility at 23/05/2021
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

 

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
{
    [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;
            }

        }


    }
}
Comments
0