Category Trend  Published on 23/05/2021

Kijun-Sen

Description

Just Kijun-Sen from Ichimoku system. Plain and simple

Shift option is added and 2 different modes for calculation


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 KijunSen : Indicator
    {

        public enum Mode
        {

            Close,
            HighLow

        }

        [Parameter("Period", DefaultValue = 26)]
        public int Period { get; set; }
        [Parameter("Shift", DefaultValue = 0)]
        public int shift { get; set; }

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


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

        private double UpperResult;
        private double LowerResult;

        protected override void Initialize()
        {


        }

        public override void Calculate(int index)
        {

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

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

        }

    }

}


KA
kaneida84

Joined on 25.04.2021

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: Kijun Sen.algo
  • Rating: 5
  • Installs: 1894
Comments
Log in to add a comment.
CH
ChrisSpire · 1 year ago

Perfect — that is exactly what I needed! Thanks for putting the effort, I apprecate!