Topics

Forum Topics not found

Replies

noppanonl
20 Feb 2018, 08:05

Hi Hamidrtafx,

   You may try quick code. I assume that you already have Ichimoku indicator present in your chart. 

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 TKFlat : Indicator
    {
        [Parameter(DefaultValue = 0.0)]
        public double Parameter { get; set; }

        [Parameter("Tenkan Sen Period", DefaultValue = 9)]
        public int TenkanPeriod { get; set; }

        [Parameter("Kijun Sen Period", DefaultValue = 26)]
        public int KijunPeriod { get; set; }

        [Parameter("Senkou Span B Period", DefaultValue = 52)]
        public int SenkouPeriod { get; set; }

        private IchimokuKinkoHyo Cloud;

        protected override void Initialize()
        {
            Cloud = Indicators.IchimokuKinkoHyo(TenkanPeriod, KijunPeriod, SenkouPeriod);            
        }

        public override void Calculate(int index)
        {
            if(Cloud.TenkanSen[index] == Cloud.TenkanSen[index-1] && Cloud.KijunSen[index] == Cloud.KijunSen[index-1])
            {
                ChartObjects.DrawVerticalLine("Flat", index, Colors.Aqua, 1, LineStyle.Solid);
            }
        }
    }
}

have a good trade

Noppanon


@noppanonl