CCI With Heikin Ashi

by afhacker in category Oscilator at 05/05/2016
Description

I just made this indicator for my personal use and I thought it maybe useful for others too, It's CCI indicator but the color of histogram bars are based on Heikin Ashi candles color so you can remove Heikin Ashi from your chart and just you can rely on this indicator alongside with your normal jap candlestick chart.

CCI with HA

Download
1085 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.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;

namespace cAlgo
{
    [Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class CCIWithHA : Indicator
    {
        [Parameter("Smooth HA?", DefaultValue = false)]
        public bool smoothHA { get; set; }

        [Parameter("Smooth HA MA Type", DefaultValue = MovingAverageType.Simple)]
        public MovingAverageType smoothHAMAType { get; set; }

        [Parameter("Smooth HA MA Periods", DefaultValue = 5)]
        public int smoothHAMAPeriods { get; set; }

        [Parameter("Show CCI Line?", DefaultValue = false)]
        public bool showLine { get; set; }

        [Parameter("CCI Periods", DefaultValue = 14)]
        public int cciPeriods { get; set; }

        [Output("Up Bar", Color = Colors.Green, PlotType = PlotType.Histogram, Thickness = 4)]
        public IndicatorDataSeries upBar { get; set; }

        [Output("Down Bar", Color = Colors.Red, PlotType = PlotType.Histogram, Thickness = 4)]
        public IndicatorDataSeries downBar { get; set; }

        [Output("CCI Line", Color = Colors.BlueViolet, PlotType = PlotType.Line, Thickness = 2)]
        public IndicatorDataSeries cciLine { get; set; }


        CommodityChannelIndex cci;
        HeikinAshiSmooth haSmooth;
        HeikenAshi haNormal;

        protected override void Initialize()
        {
            cci = Indicators.CommodityChannelIndex(cciPeriods);
            haSmooth = Indicators.GetIndicator<HeikinAshiSmooth>(smoothHAMAPeriods, smoothHAMAType);
            haNormal = Indicators.GetIndicator<HeikenAshi>(1);
        }

        public override void Calculate(int index)
        {

            if (smoothHA)
            {
                if (haSmooth.Open[index] < haSmooth.Close[index])
                {
                    downBar[index] = 0;
                    upBar[index] = cci.Result[index];
                }
                else if (haSmooth.Open[index] > haSmooth.Close[index])
                {
                    upBar[index] = 0;
                    downBar[index] = cci.Result[index];
                }
            }
            else
            {
                if (haNormal.Open[index] < haNormal.Close[index])
                {
                    downBar[index] = 0;
                    upBar[index] = cci.Result[index];
                }
                else if (haNormal.Open[index] > haNormal.Close[index])
                {
                    upBar[index] = 0;
                    downBar[index] = cci.Result[index];
                }
            }

            if (showLine)
                cciLine[index] = cci.Result[index];
        }

    }
}
Comments

ironmine - May 11, 2016 @ 13:58

Can you please make the indicator which would color the normal Japanese Candlesticks with the Heikin Ashi colors?

afhacker - May 11, 2016 @ 14:31

There is already one : http://ctdn.com/algos/show/60

ironmine - May 12, 2016 @ 04:03

No, it's different. It shows different bodies and wicks. Where the Japanese candlesticks have bodies, the indicator, which you mentioned above, has wicks.

What I meant was different: that the candlesticks should be Japanese in form (the length of wicks and bodies), but they should be Heiken Ashi in color.

ironmine - May 13, 2016 @ 04:07

This is great! This is what I wanted. Thank you!

0