Stochastic for Indicators free

by cysecsbin.01 in category Oscilator at 26/12/2019

Follow my cTrader Telegram group at; everyone can talk about cTrader indicators and algorithm without restrictions, though it is not allowed to spam commercial indicators to sell them. There's also a Discord Server now @ and an Instagram page

This is a stochastic oscillator with a source, it will fit on any other indicator but cannot be used to calculate stochastic on marketseries, for those you'll have to use the standard one.

Here's an example of it calculated on Pring's Special K:

Notification Publishing copyrighted material is strictly prohibited. If you believe there is copyrighted material in this section you may use the Copyright Infringement Notification form to submit a claim.
Formula / Source Code
Language: C#
Trading Platform: cAlgocTrader
´╗┐using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;

namespace cAlgo
    [Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class StochasticForIndicators : Indicator
        [Parameter("%K Period", DefaultValue = 9)]
        public int K { get; set; }
        [Parameter("%K Smoothing", DefaultValue = 3)]
        public int Ks { get; set; }
        [Parameter("%K Smoothing Type", DefaultValue = MovingAverageType.Simple)]
        public MovingAverageType Kt { get; set; }
        [Parameter("%D Period", DefaultValue = 9)]
        public int D { get; set; }
        public DataSeries Source { get; set; }

        public IndicatorDataSeries KLine { get; set; }
        [Output("%D", LineColor = "Red", LineStyle = LineStyle.Lines)]
        public IndicatorDataSeries DLine { get; set; }

        private IndicatorDataSeries Stochastic;
        private MovingAverage Smoothing, Signal;

        protected override void Initialize()
            Stochastic = CreateDataSeries();
            Smoothing = Indicators.MovingAverage(Stochastic, Ks, Kt);
            Signal = Indicators.SimpleMovingAverage(KLine, D);

        public override void Calculate(int index)
            Stochastic[index] = 100 * (Source[index] - Source.Minimum(K)) / (Source.Maximum(K) - Source.Minimum(K));
            KLine[index] = Smoothing.Result[index];
            DLine[index] = Signal.Result[index];