Alarm cross tenkansen and kijunsen

Created at 09 Jun 2021, 19:06
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!
AF

afshinhemmati

Joined 09.06.2021

Alarm cross tenkansen and kijunsen
09 Jun 2021, 19:06


Hello

I want to give my cross alarm time

I found this source Apparently part of it is a problem

 

Please help

 

 

using System;
using cAlgo.API;
using cAlgo.API.Indicators;

namespace cAlgo.Indicators
{
    [Indicator(IsOverlay = true, AccessRights = AccessRights.None)]
    public class IchimokuKinkoHyo : Indicator
    {
        [Parameter(DefaultValue = false)]
        public bool ShowAlarm { get; set; }

        [Parameter(DefaultValue = 9)]
        public int periodFast { get; set; }

        [Parameter(DefaultValue = 26)]
        public int periodMedium { get; set; }

        [Parameter(DefaultValue = 52)]
        public int periodSlow { get; set; }

        [Parameter(DefaultValue = 103)]
        public int periodbig { get; set; }

        [Parameter(DefaultValue = 26)]
        public int DisplacementChikou { get; set; }

        [Parameter(DefaultValue = 26)]
        public int DisplacementCloud { get; set; }

        [Parameter(DefaultValue = 26)]
        public int Displacementkijunsen { get; set; }

        [Parameter("star", DefaultValue = "▲")]
        public string star_s { get; set; }

        [Output("TenkanSen", Color = Colors.Red)]
        public IndicatorDataSeries TenkanSen { get; set; }

        [Output("Kijunsen", Color = Colors.Blue)]
        public IndicatorDataSeries KijunSen { get; set; }

        [Output("ChikouSpan", Color = Colors.DarkViolet)]
        public IndicatorDataSeries ChikouSpan { get; set; }

        [Output("qualityline", Color = Colors.White)]
        public IndicatorDataSeries qualityline { get; set; }

        [Output("qualityline103", Color = Colors.Brown)]
        public IndicatorDataSeries qualityline103 { get; set; }

        [Output("SenkouSpanB", Color = Colors.Red, LineStyle = LineStyle.Lines)]
        public IndicatorDataSeries SenkouSpanB { get; set; }

        [Output("SenkouSpanA", Color = Colors.Green, LineStyle = LineStyle.Lines)]
        public IndicatorDataSeries SenkouSpanA { get; set; }

        [Output("Down Point", Color = Colors.Orange, PlotType = PlotType.Points, Thickness = 5)]
        public IndicatorDataSeries DownPoint { get; set; }

        double maxfast, minfast, maxmedium, minmedium, maxslow, minslow, maxbig, minbig;
        public override void Calculate(int index)
        {
            if (IsLastBar)
                DisplaySpreadOnChart();
            if ((index < periodFast) || (index < periodSlow))
            {
                return;
            }

            maxfast = MarketSeries.High[index];
            minfast = MarketSeries.Low[index];
            maxmedium = MarketSeries.High[index];
            minmedium = MarketSeries.Low[index];
            maxbig = MarketSeries.High[index];
            minbig = MarketSeries.Low[index];
            maxslow = MarketSeries.High[index];
            minslow = MarketSeries.Low[index];

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

            for (int i = 0; i < periodbig; i++)
            {
                if (maxbig < MarketSeries.High[index - i])
                {
                    maxbig = MarketSeries.High[index - i];
                }
                if (minbig > MarketSeries.Low[index - i])
                {
                    minbig = MarketSeries.Low[index - i];
                }
            }
            for (int i = 0; i < periodSlow; i++)
            {
                if (maxslow < MarketSeries.High[index - i])
                {
                    maxslow = MarketSeries.High[index - i];
                }
                if (minslow > MarketSeries.Low[index - i])
                {
                    minslow = MarketSeries.Low[index - i];
                }
            }
            TenkanSen[index] = (maxfast + minfast) / 2;
            KijunSen[index] = (maxmedium + minmedium) / 2;
            ChikouSpan[index - DisplacementChikou] = MarketSeries.Close[index];

            SenkouSpanA[index + DisplacementCloud] = (TenkanSen[index] + KijunSen[index]) / 2;
            SenkouSpanB[index + DisplacementCloud] = (maxslow + minslow) / 2;
            qualityline[index + Displacementkijunsen] = (maxmedium + minmedium) / 2;
            qualityline103[index + Displacementkijunsen] = (maxbig + minbig) / 2;
            var dt1 = DateTime.Now.AddHours(-40);
            /*   if(TenkanSen[index] == KijunSen[index] && ShowAlarm)
            {
            
                Notifications.PlaySound(alarmFile)
            
            }
            */
            if (TenkanSen[index] == KijunSen[index])
            {
                ChartObjects.DrawVerticalLine("vLine", dt1, Colors.Red, 5, LineStyle.Solid);
            }
        }
        private void DisplaySpreadOnChart()
        {
            var spread = Math.Round(Symbol.Spread / Symbol.PipSize, 2);
            string text = string.Format("{0}", spread);
            ChartObjects.DrawText("Label", "Spread:", StaticPosition.TopLeft, Colors.Yellow);
            ChartObjects.DrawText("spread", "\t" + text, StaticPosition.TopLeft, Colors.White);
        }
    }
}

 


@afshinhemmati