tenkensen and kijensen are flat together

Created at 18 Feb 2018, 17:58
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
HA

hamidrtafx@gmail.com

Joined 18.02.2018

tenkensen and kijensen are flat together
18 Feb 2018, 17:58


hi.

 

I need when tenkensen and kijensen are flat together, and after moving, they will not break.
 and At that time, a vertical line is drawn up automatically.

can you help me?


@hamidrtafx@gmail.com
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

hamidrtafx@gmail.com
20 Feb 2018, 19:10

RE:

noppanonl said:

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

thanks a lot

 

but  have a error:

 

Error : Error occured during parsing project file: 'System does not support 'ut-kf-8' encoding. Line 1, position 31.'

 

why?


@hamidrtafx@gmail.com

hamidrtafx@gmail.com
20 Feb 2018, 19:42 ( Updated at: 21 Dec 2023, 09:20 )

for example picture:

i need when for example picture:

 

tenken &kijun flat equal :

 


@hamidrtafx@gmail.com

noppanon
22 Feb 2018, 08:07 ( Updated at: 21 Dec 2023, 09:20 )

Hi Hamidrtafx,

   You may try to cut and past the code to notepad and save as ANSI text file to clean any encoding.

   I modified the code so that you can change how many periods you want to check for flating. 

   Here is sample if flat periods is 3.

TK Flat parameters

 

 

Here is the code.

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("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; }

        [Parameter("Flat Period", DefaultValue = 3)]
        public int FlatPeriod { get; set; }

        private IchimokuKinkoHyo Cloud;
        private Random ChartID;

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

        public override void Calculate(int index)
        {
            for (int i = 0; i < FlatPeriod; i++ )
            {                
                if (Cloud.TenkanSen[index - i] != Cloud.TenkanSen[index - i - 1])
                {
                    return;
                }
            }

            for (int j = 0; j < FlatPeriod; j++)
            {
                if (Cloud.KijunSen[index - j] != Cloud.KijunSen[index - j - 1])
                {
                    return;
                }
            }
            ChartObjects.DrawVerticalLine("Flat_" + ChartID.Next(0, 100000).ToString(), index, Colors.Aqua, 2, LineStyle.Solid);
        }
    }
}

Happy trading,

Noppanon

 


@noppanon

hamidrtafx@gmail.com
22 Feb 2018, 15:08 ( Updated at: 21 Dec 2023, 09:20 )

RE:

noppanon said:

Hi Hamidrtafx,

   You may try to cut and past the code to notepad and save as ANSI text file to clean any encoding.

   I modified the code so that you can change how many periods you want to check for flating. 

   Here is sample if flat periods is 3.

TK Flat parameters

 

 

Here is the code.

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("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; }

        [Parameter("Flat Period", DefaultValue = 3)]
        public int FlatPeriod { get; set; }

        private IchimokuKinkoHyo Cloud;
        private Random ChartID;

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

        public override void Calculate(int index)
        {
            for (int i = 0; i < FlatPeriod; i++ )
            {                
                if (Cloud.TenkanSen[index - i] != Cloud.TenkanSen[index - i - 1])
                {
                    return;
                }
            }

            for (int j = 0; j < FlatPeriod; j++)
            {
                if (Cloud.KijunSen[index - j] != Cloud.KijunSen[index - j - 1])
                {
                    return;
                }
            }
            ChartObjects.DrawVerticalLine("Flat_" + ChartID.Next(0, 100000).ToString(), index, Colors.Aqua, 2, LineStyle.Solid);
        }
    }
}

Happy trading,

Noppanon

 

thanks a lot.

but i wan any time  just dimension flat kijun and tenken are eqaul. not eny flat!!

are you understand?

 

send  me email please.

 

thanks


@hamidrtafx@gmail.com

noppanon
24 Feb 2018, 15:28

Hi,

   Feel free to modify the code to fit your expection.

Noppanon


@noppanon