Category Oscilators  Published on 17/01/2023

DonChain Percentage indicator

Description

DonChain Percentage oscillator displays a relative price position inside the Donchian channel as oscillator.

Remark, indicator above or below level 50 for sentiment zone.


using System;
using cAlgo.API;
using cAlgo.API.Collections;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;

namespace cAlgo
{
    [Levels(0, 50, 100)]
    [Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class mDonChainProcent : Indicator
    {
        [Parameter("Periods (20)", DefaultValue = 20)]
        public int inpPeriods { get; set; }

        [Output("DonChain Procent", LineColor = "Black", PlotType = PlotType.Line, LineStyle = LineStyle.Solid, Thickness = 1)]
        public IndicatorDataSeries outDonChainProcent { get; set; }        
        
        private DonchianChannel _donchainchannel;
        private IndicatorDataSeries _top, _bottom, _dcprocent;
        

        protected override void Initialize()
        {
            _donchainchannel = Indicators.DonchianChannel(inpPeriods);
            _top = CreateDataSeries();
            _bottom = CreateDataSeries();
            _dcprocent = CreateDataSeries();
        }

        public override void Calculate(int i)
        {            
            _top[i] = i>inpPeriods ? _donchainchannel.Top.Maximum(inpPeriods) : _donchainchannel.Top[i];
            _bottom[i] = i>inpPeriods ? _donchainchannel.Bottom.Minimum(inpPeriods) : _donchainchannel.Bottom[i];
            _dcprocent[i] = ((Bars.ClosePrices[i] - _bottom[i]) / (_top[i] - _bottom[i])) * 100.0;
            
            outDonChainProcent[i] = _dcprocent[i];
        }
    }
}

mfejza's avatar
mfejza

Joined on 25.01.2022

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: mDonChainProcent.algo
  • Rating: 5
  • Installs: 676
  • Modified: 16/01/2023 23:56
Comments
Log in to add a comment.
MA
masonleo0310 · 1 year ago

Re: pizza tower

I'm learning about DonChian