Amazing Donchian free

by ctrader.guru in category Volatility at 24/02/2021
Description

Donchian with breakout option CLOSE or HIGHLOW

 


 

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 = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class AmazingDonchian : Indicator
    {

        public enum Mode
        {

            Close,
            HighLow

        }

        [Parameter("Period", DefaultValue = 60)]
        public int Period { get; set; }

        [Parameter("Mode", DefaultValue = Mode.Close)]
        public Mode Moden { get; set; }

        [Output("Upper", LineColor = "Blue", PlotType = PlotType.Line, LineStyle = LineStyle.Solid, Thickness = 1)]
        public IndicatorDataSeries UpperResult { get; set; }

        [Output("Middle", LineColor = "Gray", PlotType = PlotType.Line, LineStyle = LineStyle.DotsRare, Thickness = 1)]
        public IndicatorDataSeries MiddleResult { get; set; }

        [Output("Lower", LineColor = "Red", PlotType = PlotType.Line, LineStyle = LineStyle.Solid, Thickness = 1)]
        public IndicatorDataSeries LowerResult { get; set; }


        protected override void Initialize()
        {


        }

        public override void Calculate(int index)
        {

            UpperResult[index] = (Moden == Mode.Close) ? Bars.ClosePrices.Maximum(Period) : Bars.HighPrices.Maximum(Period);
            LowerResult[index] = (Moden == Mode.Close) ? Bars.ClosePrices.Minimum(Period) : Bars.LowPrices.Minimum(Period);

            MiddleResult[index] = LowerResult[index] + ((UpperResult[index] - LowerResult[index]) / 2);

        }

    }

}
Comments
5