Category Volatility  Published on 10/04/2020

Bollinger Band Distance

Description

This indicator measures the distance between upper band to lower band in pips


using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;

namespace cAlgo
{
    [Indicator(IsOverlay = false, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class BBDistance : Indicator
    {
        [Parameter("BB SD", DefaultValue = 2)]
        public int bbsd { get; set; }

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

        [Parameter("BB MA type", DefaultValue = MovingAverageType.Simple)]
        public MovingAverageType bbmatype { get; set; }

        [Parameter("BB Source")]
        public DataSeries bbsource { get; set; }

        [Output("Main")]
        public IndicatorDataSeries Result { get; set; }

        private BollingerBands bb;


        protected override void Initialize()
        {
            bb = Indicators.BollingerBands(bbsource, bbperiod, bbsd, bbmatype);
        }

        public override void Calculate(int index)
        {

            Result[index] = (bb.Top.LastValue - bb.Bottom.LastValue) / Symbol.PipSize;

        }
    }
}


fundspreader's avatar
fundspreader

Joined on 30.01.2017

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: BB Distance.algo
  • Rating: 0
  • Installs: 1570
  • Modified: 13/10/2021 09:54
Comments
Log in to add a comment.
No comments found.