Directional Volatility indicator free

by mfejza in category Oscilator at 09/01/2023
Description

Directional Volatility indicator. The indicator displays two volatility lines; bullish (green component) and bearish (red component).

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.Collections;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;

namespace cAlgo
{
    [Levels(0)]
    [Indicator(IsOverlay = false, AutoRescale = false, AccessRights = AccessRights.None)]
    public class mDirectionalVolatility : Indicator
    {
        [Parameter("Periods (14)", DefaultValue = 14)]
        public int inpPeriods { get; set; }
        [Parameter("Deviation (3.0)", DefaultValue = 3.0)]
        public double inpDeviation { get; set; }

        [Output("DirectionalVolatility Bullish", LineColor = "Green", PlotType = PlotType.Line, LineStyle = LineStyle.Solid, Thickness = 1)]
        public IndicatorDataSeries outDirectionalVolatilityBullish { get; set; }
        [Output("DirectionalVolatility Bearish", LineColor = "Red", PlotType = PlotType.Line, LineStyle = LineStyle.Solid, Thickness = 1)]
        public IndicatorDataSeries outDirectionalVolatilityBearish { get; set; }
        
        private IndicatorDataSeries _pricelong, _priceshort;
        private MovingAverage _malong, _mashort;
        private StandardDeviation _stddevmalong, _stddevmashort;
        

        protected override void Initialize()
        {
            _pricelong = CreateDataSeries();
            _priceshort = CreateDataSeries();
            _malong = Indicators.MovingAverage(_pricelong, inpPeriods, MovingAverageType.Exponential);
            _mashort = Indicators.MovingAverage(_priceshort, inpPeriods, MovingAverageType.Exponential);
            _stddevmalong = Indicators.StandardDeviation(_malong.Result, inpPeriods, MovingAverageType.Simple);
            _stddevmashort = Indicators.StandardDeviation(_mashort.Result, inpPeriods, MovingAverageType.Simple);
        }

        public override void Calculate(int i)
        {
            _priceshort[i] = Bars.ClosePrices[i-1] - Bars.LowPrices[i];
            _pricelong[i] = Bars.HighPrices[i] - Bars.ClosePrices[i-1];
            
            outDirectionalVolatilityBullish[i] = (_malong.Result[i] + inpDeviation * _stddevmalong.Result[i]) / Symbol.TickSize;
            outDirectionalVolatilityBearish[i] = (_mashort.Result[i] + inpDeviation * _stddevmashort.Result[i]) / Symbol.TickSize;        
        }
    }
}
Comments

saxophonebritish - January 10, 2023 @ 11:32

love your post. It's help me alot

moto x3m

scottdunn449 - January 25, 2023 @ 09:56

Launching Experts are amazon services llc ein provider. This LLC is a single-member limited liability company. It is often used by small business owners, who want to limit their personal liability.

0