Choppiness Indicator - CHOP

by lorenzopvella in category Volatility at 22/08/2019
Description

The Choppiness Index is a volatility indicator developed by Australian commodity trader Bill Dreiss to indicate whether a market is trending or ranging. Values range between 0 and 100, with low values indicating a strong trend and high values signaling consolidation.

  1. Choppiness Index values below 38.2 indicate a trend; and
  2. Values above 61.8 signal consolidation.

The Choppiness Index does not predict future direction, it is simply a measure of current trend status.

Mathematical Notation

Choppiness Index = 100 * Log10{Sum(TrueRange,n) / [Maximum(TrueHigh,n) - Minimum(TrueLow,n)]} / Log10(n)

For referencing this indicator use:

         private CHOP  yourVariableName;

         OnStart()
            yourVariableName = Indicators.GetIndicator<CHOP>(desiredPeriods);

        OnBar() or OnTick()

.            yourVariableName.Result.LastValue; 

Download
238 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;
namespace cAlgo.Indicators
{
    [Indicator(IsOverlay = false, AccessRights = AccessRights.None)]
    public class CHOP : Indicator
    {
        [Output("Result", Color = Colors.Yellow)]
        public IndicatorDataSeries Result { get; set; }

        [Output("rangebound", Color = Colors.Turquoise)]
        public IndicatorDataSeries rangebound { get; set; }

        [Output("trending", Color = Colors.Red)]
        public IndicatorDataSeries trending { get; set; }

        [Parameter(DefaultValue = MovingAverageType.Simple)]
        public MovingAverageType atrMaType { get; set; }

        [Parameter(DefaultValue = 14, MinValue = 2)]
        public int Period { get; set; }

        [Parameter(DefaultValue = 38.2, Step = 1)]
        public double lowerLimit { get; set; }

        [Parameter(DefaultValue = 61.8, Step = 1)]
        public double upperLimit { get; set; }

        private AverageTrueRange _atr;


        protected override void Initialize()
        {
            _atr = Indicators.AverageTrueRange(Period, atrMaType);
        }

        public override void Calculate(int index)
        {
            rangebound[index] = upperLimit;
            trending[index] = lowerLimit;
            Result[index] = (100 * Math.Log10(_atr.Result.Sum(Period) / (MarketSeries.High.Maximum(Period) - MarketSeries.Low.Minimum(Period)))) / Math.Log10(Period);
        }
    }
}
Comments

jedimaster - August 22, 2019 @ 14:05

A simple but useful indicator that can be combined with timing. For commodities, it' ll be useful to be able to select the MA type. Thanks 

lorenzopvella - August 22, 2019 @ 15:36

Greatly appreciate your comment and suggestion, I've included the MA Type as a parameter, along with the lower and upper boundaries. 

0