Bandwidth free

by qualitiedx2 in category Oscilator at 04/08/2012
Description

The Bandwidth indicator derived from the Bollinger BandsBandwidth indicator

 

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;
using cAlgo.Indicators;

namespace cAlgo.Indicators
{
    [Indicator(IsOverlay = false, AccessRights = AccessRights.None)]
    public class Bandwidth : Indicator
    {
    	[Parameter]
        public DataSeries Source { get; set; }

		[Parameter("MAType")]
		public MovingAverageType matype { get; set; }

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

        [Parameter("Standard Deviation", DefaultValue = 2.0)]
        public double std { get; set; }

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

		BollingerBands bb;

        protected override void Initialize()
        {
			bb = Indicators.BollingerBands(Source, Period, std, matype);
        }

        public override void Calculate(int index)
        {
			Result[index] = (bb.Top[index] - bb.Bottom[index]) / bb.Main[index];
        }
    }
}
Comments

firemyst - May 27, 2019 @ 03:35

Why do you divide by bb.Main[index]?

Subtracting the bottom from the top alone will provide you with the width. Or subtracting the bottom from the top and dividing by 2. 

Thank you.

5