Category Trend  Published on 01/04/2023

Donchian Plus

Description

If you're on the lookout for an interesting indicator to add to your collection, I recommend the Donchian Plus Indicator. And the best part is that you can place it above the others you're already using, such as RSI, ATR, MACD, and so on. Give it a try and let me know!

 



// --> cTrader Guru: https://ctrader.guru

using cAlgo.API;
using cAlgo.API.Indicators;

namespace cAlgo
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)]
    public class DonchianPlus : Indicator
    {

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

        [Parameter("Period", DefaultValue = 60)]
        public int Period { 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; }

        MovingAverage MA;

        protected override void Initialize()
        {

            MA = Indicators.MovingAverage(Source, 1, MovingAverageType.Simple);

        }

        public override void Calculate(int index)
        {

            if(index < Period)return;
            
            UpperResult[index] = MA.Result.Maximum(Period);
            LowerResult[index] = MA.Result.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: Donchian Plus.algo
  • Rating: 5
  • Installs: 633
  • Modified: 01/04/2023 08:58
Comments
Log in to add a comment.
No comments found.