Category Trend  Published on 03/04/2023

Donchian Fibo

Description

A combination of Donchian channel and Fibonacci levels.

5 levels: Min, 0.382, 0.5, 0.618, Max are plotted.

Period: the period for getting Min, Max.

At every moment, the 3 levels FiboDn, Mid, FiboUp are calculated based on the Top and Bot of that moment.


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using cAlgo.API;
using cAlgo.API.Collections;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;

namespace cAlgo
{
    [Indicator(IsOverlay = true, AutoRescale = true, AccessRights = AccessRights.None)]
    public class LT_Ind_DonchianFibo : Indicator
    {
        [Parameter(DefaultValue = 20)]
        public int Periods { get; set; }

        [Output("Top", LineColor = "Red", LineStyle = LineStyle.Dots)]
        public IndicatorDataSeries Top { get; set; }
        [Output("FiboUp", LineColor = "Red", LineStyle = LineStyle.DotsRare)]
        public IndicatorDataSeries FiboUp { get; set; }
        [Output("Mid", LineColor = "Green", LineStyle = LineStyle.DotsRare)]
        public IndicatorDataSeries Mid { get; set; }
        [Output("Bot", LineColor = "Blue", LineStyle = LineStyle.Dots)]
        public IndicatorDataSeries Bot { get; set; }
        [Output("FiboDn", LineColor = "Blue", LineStyle = LineStyle.DotsRare)]
        public IndicatorDataSeries FiboDn { get; set; }

        DonchianChannel _donchian;
        protected override void Initialize()
        {
            _donchian = Indicators.DonchianChannel(Periods);
        }

        public override void Calculate(int index)
        {
            Top[index] = _donchian.Top[index];
            Mid[index] = _donchian.Middle[index];
            Bot[index] = _donchian.Bottom[index];
            FiboDn[index] = Bot[index] + (Top[index] - Bot[index]) * 0.382;
            FiboUp[index] = Bot[index] + (Top[index] - Bot[index]) * 0.618;
        }
    }
}

dhnhuy's avatar
dhnhuy

Joined on 03.04.2023

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: LT_Ind_DonchianFibo.algo
  • Rating: 0
  • Installs: 792
  • Modified: 03/04/2023 03:50
Comments
Log in to add a comment.
No comments found.