Category Oscilators  Published on 16/08/2018

Inverse Cyber Cycle

Description

The Inverse Fisher Transform version of the CyberCycle indicator. This method once applied gives more clear and unequivocal signals also helping to avoid some whipsaw trades.

 


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

namespace cAlgo.Indicators
{
    [Indicator(IsOverlay = false, AccessRights = AccessRights.None)]
    [Levels(0.0)]
    public class InverseCycle : Indicator
    {
        [Parameter(DefaultValue = 0.01)]
        public double Alpha { get; set; }

        [Parameter(DefaultValue = 21, MinValue = 5)]
        public int length { get; set; }

        [Output("InverseCyberCycle", Color = Colors.YellowGreen, Thickness = 2)]
        public IndicatorDataSeries invcycle { get; set; }

        private IndicatorDataSeries _price;
        private IndicatorDataSeries _smooth;
        private IndicatorDataSeries cycle;
        private IndicatorDataSeries value1;

        protected override void Initialize()
        {
            _price = CreateDataSeries();
            _smooth = CreateDataSeries();
            cycle = CreateDataSeries();
            value1 = CreateDataSeries();
        }

        public override void Calculate(int index)
        {
            _price[index] = (MarketSeries.High[index] + MarketSeries.Low[index]) / 2;

            _smooth[index] = (_price[index] + 2 * _price[index - 1] + 2 * _price[index - 2] + _price[index - 3]) / 6;

            cycle[index] = (1 - 0.5 * Alpha) * (1 - 0.5 * Alpha) * (_smooth[index] - 2 * _smooth[index - 1] + _smooth[index - 2]) + 2 * (1 - Alpha) * cycle[index - 1] - (1 - Alpha) * (1 - Alpha) * (cycle[index - 2]);

            if (index < 7)
            {
                cycle[index] = (_price[index] - 2 * _price[index - 1] + _price[index - 2]) / 4;
            }

            double ccgH = cycle[index];
            double ccgL = cycle[index];
            for (int i = index - length + 1; i <= index; i++)
            {
                if (ccgH < cycle[i])
                {
                    ccgH = cycle[i];
                }
                if (ccgL > cycle[i])
                {
                    ccgL = cycle[i];
                }
            }
            if (ccgH != ccgL)
            {
                value1[index] = ((cycle[index] - ccgL) / (ccgH - ccgL));
            }

            invcycle[index] = (Math.Exp(2 * value1[index]) - 1) / (Math.Exp(2 * value1[index]) + 1);
        }
    }
}


cwik_m's avatar
cwik_m

Joined on 26.06.2018

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: InverseCycle.algo
  • Rating: 0
  • Installs: 1885
  • Modified: 13/10/2021 09:54
Comments
Log in to add a comment.
No comments found.