Dynamic Range CCI free

by mfejza in category Oscilator at 08/09/2022
Description

This CCI (Commodity Index Channel) custom indicator show/correct the CCI indicator levels -100 and +100, based on standard deviation on indicator value

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
{
    [Levels(-100, +100, 0)]
    [Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class mDynamicRangeCCI : Indicator
    {
        [Parameter("Main Period CCI", DefaultValue = 20)]
        public int PeriodCCI { get; set; }
        [Parameter("Smooth Period CCI", DefaultValue = 1)]
        public int SmoothCCI { get; set; }


        [Output("Main", LineColor = "Black", PlotType = PlotType.Line, LineStyle = LineStyle.Solid, Thickness = 1)]
        public IndicatorDataSeries outMain { get; set; }
        [Output("Up", LineColor = "Red", PlotType = PlotType.Line, LineStyle = LineStyle.Solid, Thickness = 1)]
        public IndicatorDataSeries outUp { get; set; }
        [Output("Down", LineColor = "Red", PlotType = PlotType.Line, LineStyle = LineStyle.Solid, Thickness = 1)]
        public IndicatorDataSeries outDown { get; set; }


        private IndicatorDataSeries _price;
        private MovingAverage _sma;
        private StandardDeviation _std;
        private IndicatorDataSeries _cci;
        private MovingAverage _ema1;
        private MovingAverage _ema2;
        private StandardDeviation _stdposneg;
        private IndicatorDataSeries _max;
        private IndicatorDataSeries _min;
        private IndicatorDataSeries _h;
        private IndicatorDataSeries _l;


        protected override void Initialize()
        {
            _price = CreateDataSeries();
            _cci = CreateDataSeries();
            _sma = Indicators.MovingAverage(_price, PeriodCCI, MovingAverageType.Simple);
            _std = Indicators.StandardDeviation(_price, PeriodCCI, MovingAverageType.Simple);
            _ema1 = Indicators.MovingAverage(_cci, SmoothCCI, MovingAverageType.Exponential);
            _ema2 = Indicators.MovingAverage(_ema1.Result, SmoothCCI, MovingAverageType.Exponential);
            _stdposneg = Indicators.StandardDeviation(_ema2.Result, PeriodCCI, MovingAverageType.Simple);
            _max = CreateDataSeries();
            _min = CreateDataSeries();
            _h = CreateDataSeries();
            _l = CreateDataSeries();
        }

        public override void Calculate(int i)
        {
            if (i < PeriodCCI + 2)
            {
                _price[i] = Symbol.PipSize * 100;
                _cci[i] = Symbol.PipSize;
                outMain[i] = 0;
                return;
            }

            _price[i] = Bars.ClosePrices[i] - Bars.ClosePrices[i - 1];
            _cci[i] = (_price[i] - _sma.Result[i]) / (0.015 * _std.Result[i]);

            _max[i] = Math.Max(_stdposneg.Result[i], -_stdposneg.Result[i]);
            _min[i] = Math.Min(_stdposneg.Result[i], -_stdposneg.Result[i]);
            _h[i] = _max.Maximum(PeriodCCI);
            _l[i] = _min.Minimum(PeriodCCI);

            outMain[i] = _ema2.Result[i];
            outUp[i] = _h[i];
            outDown[i] = _l[i];
        }
    }
}
Comments

junealexis001 - September 12, 2022 @ 11:50

Awesome post i love it keep posting more!  https://painterseugeneoregon.com

brianwilsonrt - September 13, 2022 @ 07:46

Nice post! This is a very nice blog that I will definitively come back to more times this year! Thanks for informative  lewdle post. 

bottombend - September 20, 2022 @ 10:54

The information is very special, I will have to follow you. 

slope game
 

0