Kijunsen X3 Normalised free

by Jan in category Oscilator at 13/11/2019
Description

Version Updated: 2019/11/27

Version updated: 2019/12/11

I have used Kijun-Sen (Overlay version) as a baseline for different trading strategies. I wanted to take a different look at this very basic and simple indicator and see what else it could do...

I have combined 3 Kijunsen lines that are normalized as oscillators (normally Kijun-Sen line is drawn to the chart as an overlay indicator). I have also added moving average smoothing (MA period value 0 voids smoothing).

Original KijunSen uses 26 periods, I have chosen Fibonacci sequence numbers for the default periods.

My initial idea was to use this for mean reversion strategies looking for the faster lines to diverge from the slower lines. The oscillator can also be used during a trend trade to get in on a pullback (fast pulling away from slow, slow showing trend strength).

Let me know if you find new ideas about how to use this indicator. 

What is the Kijun-Sen (Japanese for Reference / Baseline)?

The Kijun-sen is an indicator and important component of the Ichimoku Kinko Hyo method of technical analysis, which is also known as the Ichimoku cloud.

The original Kijun-sen is the midpoint price of the last 26-periods, and therefore an indicator of short- to medium-term price momentum. The indicator aids in assessing the trend, and can also be useful for identifying trading opportunities when combined with the other components of the Ichimoku cloud.

How to Calculate the original Kijun Line (Base Line)

  1. Find the highest price over the last 26 periods.
  2. Find the lowest price over the last 26 periods.
  3. Combine the high and low, then divide by two.
  4. Update the calculation after each period ends.

 

Follow cTrader Telegram group at https://t.me/cTraderCommunity; it's a new community but it will grow fast, plus everyone can talk about cTrader indicators and algorithm without restrictions, though it is not allowed to spam commercial indicators to sell them. There's also a Discord Server now @ https://discord.gg/5GAPMtp

 

Notification Publishing copyrighted material is strictly prohibited. If you believe there is copyrighted material in this section you may use the Copyright Infringement Notification form to submit a claim.
Formula / Source Code
Language: C#
Trading Platform: cAlgocTrader
´╗┐using System;
using cAlgo.API;
using cAlgo.API.Indicators;

namespace cAlgo.Indicators
{
    [Indicator(IsOverlay = false, AccessRights = AccessRights.None)]
    public class KijunSen3XNormalised : Indicator
    {


        [Parameter(" Fibonacci:: ", Group = "Fibonacci sequence - !! reference only !! - ", DefaultValue = "5,8,13,21,34,55,89,144,233,377,610")]
        public string indicatorinfo { get; set; }

        [Parameter(" 1) Fast Period", Group = "--- KijunSen Period ---", DefaultValue = 21)]
        public int Period { get; set; }

        [Parameter(" 2) Medium Period", Group = "--- KijunSen Period ---", DefaultValue = 55)]
        public int Period2 { get; set; }

        [Parameter(" 3) Slow Period", Group = "--- KijunSen Period ---", DefaultValue = 144)]
        public int Period3 { get; set; }

        [Parameter(" MA Period", Group = "--- MA Smoothing Period --- (0 = no smoothing)", DefaultValue = 10, MinValue = 0)]
        public int MAPeriod { get; set; }

        [Parameter(" Levels", Group = "--- Levels ---", DefaultValue = 0.8, Step = 0.01)]
        public double Level1 { get; set; }

        [Parameter(" Read New Bars Only!", Group = "--- Resource Manager --- (calculate only on new bar!)", DefaultValue = true)]
        public bool ReadBars { get; set; }

        [Output(" Fast ", LineColor = "Red", Thickness = 2, LineStyle = LineStyle.LinesDots)]
        public IndicatorDataSeries KijunSen1 { get; set; }

        [Output(" Medium ", LineColor = "Orange", Thickness = 2, LineStyle = LineStyle.Solid)]
        public IndicatorDataSeries KijunSen2 { get; set; }

        [Output(" Slow ", LineColor = "Aquamarine", Thickness = 2, LineStyle = LineStyle.Solid)]
        public IndicatorDataSeries KijunSen3 { get; set; }


        [Output("Overbought", LineColor = "Moccasin", LineStyle = LineStyle.LinesDots)]
        public IndicatorDataSeries overbought { get; set; }

        [Output("Oversold", LineColor = "Moccasin", LineStyle = LineStyle.LinesDots)]
        public IndicatorDataSeries oversold { get; set; }

        [Output("MidLine", LineColor = "Mintcream", LineStyle = LineStyle.Dots)]
        public IndicatorDataSeries midline { get; set; }

        private MovingAverage MA1;
        private MovingAverage MA2;
        private MovingAverage MA3;

        private IndicatorDataSeries Kijun1;
        private IndicatorDataSeries Kijun2;
        private IndicatorDataSeries Kijun3;

        int lastindex = 0;

        protected override void Initialize()
        {
            Kijun1 = CreateDataSeries();
            Kijun2 = CreateDataSeries();
            Kijun3 = CreateDataSeries();

            MA1 = Indicators.MovingAverage(Kijun1, MAPeriod, MovingAverageType.Simple);
            MA2 = Indicators.MovingAverage(Kijun2, MAPeriod, MovingAverageType.Simple);
            MA3 = Indicators.MovingAverage(Kijun3, MAPeriod, MovingAverageType.Simple);
        }


        public override void Calculate(int index)
        {
            if (index < Period || index < Period2 || index < Period3)
            {
                return;
            }

            if (ReadBars)
            {
                if (IsLastBar)
                {
                    if (index != lastindex)
                        lastindex = index;
                    else
                        return;
                }
            }

            var FastMaxHigh = MarketSeries.High.Maximum(Period);
            var FastMinLow = MarketSeries.Low.Minimum(Period);
            var MediumMaxHigh = MarketSeries.High.Maximum(Period2);
            var MediumMinLow = MarketSeries.Low.Minimum(Period2);
            var SlowMaxHigh = MarketSeries.High.Maximum(Period3);
            var SlowMinLow = MarketSeries.Low.Minimum(Period3);

            var close = MarketSeries.Close[index];
            var close2 = MarketSeries.Close[index];
            var close3 = MarketSeries.Close[index];


            if (MAPeriod > 0)
            {

                Kijun1[index] = (close - FastMinLow) / (FastMaxHigh - FastMinLow);
                Kijun2[index] = (close2 - MediumMinLow) / (MediumMaxHigh - MediumMinLow);
                Kijun3[index] = (close3 - SlowMinLow) / (SlowMaxHigh - SlowMinLow);

                KijunSen1[index] = MA1.Result[index];
                KijunSen2[index] = MA2.Result[index];
                KijunSen3[index] = MA3.Result[index];
            }
            else
            {

                Kijun1[index] = (close - FastMinLow) / (FastMaxHigh - FastMinLow);
                Kijun2[index] = (close2 - MediumMinLow) / (MediumMaxHigh - MediumMinLow);
                Kijun3[index] = (close3 - SlowMinLow) / (SlowMaxHigh - SlowMinLow);

            }

            overbought[index] = Level1;
            oversold[index] = 1 - Level1;
            midline[index] = 0.5;

        }

    }
}

/*

Old method counting MarketSeries Max & Min values for the Kijunsen period:


            for (int i = 0; i < Period; i++)
            {
                if (maxmedium < MarketSeries.High[index - i])
                {
                    maxmedium = MarketSeries.High[index - i];
                }
                if (minmedium > MarketSeries.Low[index - i])
                {
                    minmedium = MarketSeries.Low[index - i];
                }
            }
...


                Kijun1[index] = (close - minmedium) / (maxmedium - minmedium);
                Kijun2[index] = (close2 - minmedium2) / (maxmedium2 - minmedium2);
                Kijun3[index] = (close3 - minmedium3) / (maxmedium3 - minmedium3);

*/

Comments
0