Stochastic Histogram

by alphafx in category Oscilator at 02/08/2016
Description

The Stochastic Oscillator in the form of a histogram.

  • Buy when it moves from negative to positive in the uptrend
  • Sell when it moves from positive to negative in the downtrend

Stochastic Histogram

Download
460 downloads
How to install
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.Indicators;
using cAlgo.Indicators;

namespace cAlgo.Indicators
{
    [Levels(0.0)]
    [Indicator(IsOverlay = false, AccessRights = AccessRights.None)]
    public class StochasticHistogram : Indicator
    {
        [Parameter("%K Periods", DefaultValue = 14)]
        public int kPeriods { get; set; }

        [Parameter("%K Slowing", DefaultValue = 3)]
        public int kSlowing { get; set; }

        [Parameter("%D Periods", DefaultValue = 3)]
        public int dPeriods { get; set; }

        [Parameter("MA Type")]
        public MovingAverageType maType { get; set; }

        [Output("Histogram > 0", PlotType = PlotType.Histogram, Color = Colors.Green, Thickness = 1)]
        public IndicatorDataSeries HistogramPositive { get; set; }

        [Output("Histogram < 0", PlotType = PlotType.Histogram, Color = Colors.Green, Thickness = 1)]
        public IndicatorDataSeries HistogramNegative { get; set; }

        [Output("%K", PlotType = PlotType.Line, Color = Colors.Green, Thickness = 1)]
        public IndicatorDataSeries K { get; set; }

        [Output("%D", PlotType = PlotType.Line, LineStyle = LineStyle.Lines, Color = Colors.Red, Thickness = 1)]
        public IndicatorDataSeries D { get; set; }

        StochasticOscillator stochastic;

        protected override void Initialize()
        {
            stochastic = Indicators.StochasticOscillator(kPeriods, kSlowing, dPeriods, maType);
        }

        public override void Calculate(int index)
        {
            if (stochastic.PercentK[index] - 50 > 0)
                HistogramPositive[index] = stochastic.PercentK[index] - 50;
            if (stochastic.PercentK[index] - 50 < 0)
                HistogramNegative[index] = stochastic.PercentK[index] - 50;
            K[index] = stochastic.PercentK[index] - 50;
            D[index] = stochastic.PercentD[index] - 50;
        }
    }
}
Comments
0