CCI Channel

by afhacker in category Oscilator at 16/07/2016
Description

You can see CCI on your chart like Bollinger Bands for finding over bought / sold areas.

When candle is above top line it means the CCI is above over bought level and when the candle is below bottom line it means the CCI is below over sold level.

BitCoin: 1Me2TQ6Rgr8EevZNFKqvYegkbtY8C2cP5i

Download
294 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;


/*

Version 1.0
Developed by afhacker (Ahmad Noman Musleh)
Email : afhackermubasher@gmail.com

*/


namespace cAlgo
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class CCIChannel : Indicator
    {

        [Parameter("Periods", DefaultValue = 20)]
        public int periods { get; set; }

        [Parameter("Channel Width", DefaultValue = 2)]
        public int width { get; set; }

        [Parameter("Over Bought", DefaultValue = 100)]
        public double overBought { get; set; }

        [Parameter("Over Sold", DefaultValue = -100)]
        public double overSold { get; set; }


        [Output("Top Line", Color = Colors.Magenta, PlotType = PlotType.Line, Thickness = 1)]
        public IndicatorDataSeries topLine { get; set; }

        [Output("Bottom Line", Color = Colors.Magenta, PlotType = PlotType.Line, Thickness = 1)]
        public IndicatorDataSeries bottomLine { get; set; }




        private CommodityChannelIndex cci;

        protected override void Initialize()
        {
            cci = Indicators.CommodityChannelIndex(periods);
        }

        public override void Calculate(int index)
        {
            double channelWidth = (MarketSeries.High.LastValue - MarketSeries.Low.LastValue) * width;

            if (cci.Result.LastValue >= overBought)
            {
                topLine[index] = MarketSeries.Low.LastValue;
                bottomLine[index] = MarketSeries.Low.LastValue - channelWidth;
            }
            else if (cci.Result.LastValue <= overSold)
            {
                bottomLine[index] = MarketSeries.High.LastValue;
                topLine[index] = MarketSeries.High.LastValue + channelWidth;
            }
            else
            {
                topLine[index] = MarketSeries.High.LastValue + channelWidth;
                bottomLine[index] = MarketSeries.Low.LastValue - channelWidth;
            }
        }



    }
}
Comments
0