Category Oscilators  Published on 04/07/2017

Double Stochastic Oscillator

Description

Double Stochastic Oscillator


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

namespace cAlgo.Indicators
{
    [Indicator(IsOverlay = false, TimeZone = TimeZones.UTC)]
    public class DoubleStochastic : Indicator
    {
        [Parameter(DefaultValue = 5)]
        public int PeriodsFast { get; set; }

        [Parameter(DefaultValue = 20)]
        public int PeriodsSlow { get; set; }

        [Parameter(DefaultValue = 1)]
        public int KSmoothFast { get; set; }

        [Parameter(DefaultValue = 1)]
        public int KSmoothSlow { get; set; }

        [Parameter(DefaultValue = 2)]
        public int DSmoothFast { get; set; }

        [Parameter(DefaultValue = 2)]
        public int DSmoothSlow { get; set; }

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

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


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


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


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


        [Output("DSlow", Color = Colors.AliceBlue, LineStyle = LineStyle.LinesDots)]
        public IndicatorDataSeries DSlow { get; set; }


        private StochasticOscillator StochFast;
        private StochasticOscillator StochSlow;


        protected override void Initialize()
        {

            StochFast = Indicators.StochasticOscillator(PeriodsFast, KSmoothFast, DSmoothFast, MovingAverageType.Simple);
            StochSlow = Indicators.StochasticOscillator(PeriodsSlow, KSmoothSlow, DSmoothSlow, MovingAverageType.Simple);


        }

        public override void Calculate(int index)
        {
            overbought[index] = 80;
            oversold[index] = 20;

            KFast[index] = StochFast.PercentK[index];
            DFast[index] = StochFast.PercentD[index];

            KSlow[index] = StochSlow.PercentK[index];
            DSlow[index] = StochSlow.PercentD[index];

        }


        private int GetIndexByDate(MarketSeries series, DateTime time)
        {
            for (int i = series.Close.Count - 1; i > 0; i--)
            {
                if (time == series.OpenTime[i])
                    return i;
            }
            return -1;
        }
    }
}


DI
dizer1983

Joined on 04.07.2017

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: Double Stochastic.algo
  • Rating: 0
  • Installs: 3299
  • Modified: 13/10/2021 09:54
Comments
Log in to add a comment.
EM
Empawerism · 4 years ago

is it opossible make it multi time frame with price field and iterpolate options?