Category Volatility  Published on 24/02/2021

Amazing Donchian

Description

Donchian with breakout option CLOSE or HIGHLOW

 


 


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);

        }

    }

}


ctrader.guru's avatar
ctrader.guru

Joined on 19.07.2018

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