Category Trend  Published on 07/02/2023

Bollinger Bands 3x StdDev

Description

This version of Bollinger Bands contain 3x components, in standard deviation ranges (1, 2, 3); and the levels from Mean with period of 200, acting as support and resistance, also try to identify intensity of trend

The idea is from video: youtube.com/watch?v=GmbGLZk9eDY


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

namespace cAlgo
{
    [Indicator(IsOverlay = true, AccessRights = AccessRights.None)]
    public class mBollingerBands3  : Indicator
    {
        [Parameter("Bollinger Bands Periods (200)", DefaultValue = 200)]
        public int inpPeriods { get; set; }
        [Parameter("Smooth Type (sma)", DefaultValue = MovingAverageType.Exponential)]
        public MovingAverageType inpSmoothType { get; set; }
        [Parameter("First Deviation (1.0)", DefaultValue = 1.0)]
        public double inpStdDDev1 { get; set; }
        [Parameter("Second Deviation (2.0)", DefaultValue = 2.0)]
        public double inpStdDDev2 { get; set; }
        [Parameter("Third Deviation (3.0)", DefaultValue = 3.0)]
        public double inpStdDDev3 { get; set; }

        [Output("Mid", LineColor = "Black", PlotType = PlotType.Line, Thickness = 1)]
        public IndicatorDataSeries outBBmid { get; set; }
        [Output("Top", LineColor = "Green", PlotType = PlotType.Line, Thickness = 1)]
        public IndicatorDataSeries outBBup { get; set; }
        [Output("Down", LineColor = "Green", PlotType = PlotType.Line, Thickness = 1)]
        public IndicatorDataSeries outBBdn { get; set; }
        [Output("Top 2", LineColor = "Magenta", PlotType = PlotType.Line, Thickness = 1)]
        public IndicatorDataSeries outBBup2 { get; set; }
        [Output("Down 2", LineColor = "Magenta", PlotType = PlotType.Line, Thickness = 1)]
        public IndicatorDataSeries outBBdn2 { get; set; }
        [Output("Top 3", LineColor = "Silver", PlotType = PlotType.Line, Thickness = 1)]
        public IndicatorDataSeries outBBup3 { get; set; }
        [Output("Down 3", LineColor = "Silver", PlotType = PlotType.Line, Thickness = 1)]
        public IndicatorDataSeries outBBdn3 { get; set; }

        private BollingerBands _bbands1, _bbands2, _bbands3;

        protected override void Initialize()
        {
            _bbands1 = Indicators.BollingerBands(Bars.ClosePrices, inpPeriods, inpStdDDev1, inpSmoothType);
            _bbands2 = Indicators.BollingerBands(Bars.ClosePrices, inpPeriods, inpStdDDev2, inpSmoothType);
            _bbands3 = Indicators.BollingerBands(Bars.ClosePrices, inpPeriods, inpStdDDev3, inpSmoothType);
        }

        public override void Calculate(int i)
        {
            outBBmid[i] = _bbands1.Main[i];
            outBBup[i] = _bbands1.Top[i];
            outBBdn[i] = _bbands1.Bottom[i];
            outBBup2[i] = _bbands2.Top[i];
            outBBdn2[i] = _bbands2.Bottom[i];
            outBBup3[i] = _bbands3.Top[i];
            outBBdn3[i] = _bbands3.Bottom[i];
        }
    }
}


mfejza's avatar
mfejza

Joined on 25.01.2022

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: mBollingerBands3.algo
  • Rating: 5
  • Installs: 613
Comments
Log in to add a comment.
EN
englishisabelaalboran · 1 year ago

Re: drift boss

I like Bollinger Bands 3x StdDev