Category Oscilators  Published on 14/08/2024

KTV

Description

value = tenkan sen - kijun sen

 

 




////////////////////////////////////////////////////////////////////////////////////////
///                                     KTV                                          ///
///                                                                                  ///
///         Publish date  18-DEC-2021                                                ///
///         Version  1.1.0                                                           ///
///         By  mohamadreza chaji                                                    ///
///         License  MIT                                                             ///
///         Contact  mr.ch1371@gmail.com                                             ///
///                                                                                  ///
////////////////////////////////////////////////////////////////////////////////////////

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

namespace cAlgo
{
    [Indicator(IsOverlay = false, TimeZone = TimeZones.EasternStandardTime, AccessRights = AccessRights.None)]
    [Cloud("ktv ssa", "ktv ssb", Opacity = 0.2)]
     [Levels(0)]
    public class ktv : Indicator
    {
      
        [Parameter("Tenkan sen", DefaultValue = 9, MinValue = 1, Group = "Period")]
        public int T_Period { get; set; }

        [Parameter("Kijun sen", DefaultValue = 26, MinValue = 1, Group = "Period")]
        public int K_Period { get; set; }
        
        [Parameter("senkou span p", DefaultValue = 52, MinValue = 1, Group = "Period")]
        public int SSB_Period { get; set; }

        [Parameter("SMA length", DefaultValue = 38, MinValue = 1, Group = "Period")]
        public int SMA_Period { get; set; }
       
        [Parameter("MA Type", DefaultValue = MovingAverageType.Simple)]
        public MovingAverageType MAType { get; set; }
        [Output("Main", LineStyle = LineStyle.Solid, LineColor = "gray")]
        public IndicatorDataSeries Result { get; set; }
        [Output("ma", LineStyle = LineStyle.Solid, LineColor = "#2CFFFF00")]
        public IndicatorDataSeries ma { get; set; }
        [Output("ktv kijun", LineStyle = LineStyle.Solid, LineColor = "#0000FFFF")]
        public IndicatorDataSeries KIJUNKTV { get; set; }
        [Output("ktv ssa", LineStyle = LineStyle.Solid, LineColor = "#83008000")]
        public IndicatorDataSeries SSAKTV { get; set; }
        [Output("ktv ssb", LineStyle = LineStyle.Solid, LineColor = "red")]
        public IndicatorDataSeries SSBKTV { get; set; }     
        
        [Parameter("Show MA?", DefaultValue = true, Group = "show or not")]
        public bool SHMA { get; set; }
        [Parameter("Show cloud?", DefaultValue = true, Group = "show or not")]
        public bool SHKUMO { get; set; }
        
        public IndicatorDataSeries T_Result { get; set; }
        
            private IchimokuKinkoHyo _ICHI;
            private MovingAverage movingAverage;
        protected override void Initialize()
        {
           _ICHI = Indicators.IchimokuKinkoHyo(T_Period, K_Period, SSB_Period);
           movingAverage = Indicators.MovingAverage(Result, SMA_Period, MAType);
            T_Result=CreateDataSeries();
        }

        public override void Calculate(int index)
        {
           var vmax=0.0;
           var vmin=0.0;
           Result[index]=  _ICHI.TenkanSen.Last(0)-_ICHI.KijunSen.Last(0) ;
           if(SHKUMO){
            vmax=Functions.Maximum(Result,K_Period);
            vmin=Functions.Minimum(Result,K_Period);
            KIJUNKTV[index]=(vmin+vmax)/2;
            
            vmax=Functions.Maximum(Result,T_Period);
            vmin=Functions.Minimum(Result,T_Period);
            T_Result[index]=(vmin+vmax)/2;
            vmax=Functions.Maximum(Result,SSB_Period);
            vmin=Functions.Minimum(Result,SSB_Period);
            SSBKTV[index+K_Period]=(vmin+vmax)/2;
            SSAKTV[index+K_Period]=(T_Result[index]+KIJUNKTV[index])/2;
            }
            if(SHMA)
                 ma[index]=movingAverage.Result[index];
         
        }
    }
}

mr.ch1371's avatar
mr.ch1371

Joined on 11.08.2024

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: ktv_withSourceCode.algo
  • Rating: 5
  • Installs: 345
  • Modified: 17/08/2024 12:20
Comments
Log in to add a comment.
No comments found.