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.
- Choppiness Index values below 38.2 indicate a trend; and
- 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;
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);
}
}
}
lorenzopvella
Joined on 22.08.2019
- Distribution: Free
- Language: C#
- Trading platform: cTrader Automate
- File name: CHOP.algo
- Rating: 5
- Installs: 2819
- Modified: 13/10/2021 09:54
Comments
For the cbot, i can't seem to get the correct parameters under desired periods.
Great indicator. Good job.
Greatly appreciate your comment and suggestion, I've included the MA Type as a parameter, along with the lower and upper boundaries.
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
There is a bug in the code.
Should be