Category Oscilators  Published on 28/10/2019

Stochastic Oscillator with an alert for

Description

using System;

using cAlgo.API;

using cAlgo.API.Internals;

using cAlgo.API.Indicators;

using cAlgo.Indicators;

 

namespace cAlgo

{

    [Indicator(IsOverlay = false, ScalePrecision = 0, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]

    public class StochasticCrossAlert : Indicator

    {

 

        private StochasticOscillator stoc;

 

        bool b = true;

        bool a = true;

        [Parameter("Sound ON", DefaultValue = true)]

        public bool PlaySound { get; set; }

 

        [Parameter("Media File", DefaultValue = "c:\\windows\\media\\reaction.mp3")]

        public string MediaFile { get; set; }

 

        [Parameter("K_Periods", DefaultValue = 8, MinValue = 1)]

        public int K_Period { get; set; }

 

        [Parameter("Slow_K", DefaultValue = 3, MinValue = 2)]

        public int Slow_K { get; set; }

 

        [Parameter("D_Period", DefaultValue = 3, MinValue = 0)]

        public int D_Period { get; set; }

 

        [Parameter("MA Type", DefaultValue = MovingAverageType.Simple)]

        public MovingAverageType MAType { get; set; }

 

 

        [Output("%D", Color = Colors.Blue, PlotType = PlotType.Line, LineStyle = LineStyle.Lines)]

        public IndicatorDataSeries Percent_D { get; set; }

 

        [Output("%K", Color = Colors.Red)]

        public IndicatorDataSeries Percent_K { get; set; }

 

 

 

 

        protected override void Initialize()

        {

            // Initialize and create nested indicators

            stoc = Indicators.StochasticOscillator(K_Period, Slow_K, D_Period, MAType);

 

        }

 

 

 

        public override void Calculate(int index)

        {

            // Calculate value at specified index

            // Result[index] = ...

 

 

            Percent_K[index] = stoc.PercentK.LastValue;

            Percent_D[index] = stoc.PercentD.LastValue;

 

 

 

 

            if (stoc.PercentK.LastValue > stoc.PercentD.LastValue && a == true && PlaySound == true)

            {

 

                Notifications.PlaySound(MediaFile);

 

                a = false;

                b = true;

            }

 

            if (stoc.PercentD.LastValue > stoc.PercentK.LastValue && b == true && PlaySound == true)

            {

 

                Notifications.PlaySound(MediaFile);

                b = false;

                a = true;

            }

     }

  }

}

 


u

MR
MR.LUDAED68

Joined on 28.10.2019

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: Belkhayate Polynomial Regression.algo
  • Rating: 0
  • Installs: 1803
Comments
Log in to add a comment.
BA
BaliTrader · 2 years ago

You might want to check your upload. File is called Belkhayate Polynomial Regression and has no relation to Stochastic Oscillator with an alert.