Category Oscilators  Published on 15/11/2021

Bollinger Bands %B

Description

Introduction:

%B quantifies a security's price relative to the upper and lower Bollinger Band. There are six basic relationship levels:

  • %B equals 1 when price is at the upper band

  • %B equals 0 when price is at the lower band

  • %B is above 1 when price is above the upper band

  • %B is below 0 when price is below the lower band

  • %B is above .50 when price is above the middle band (20-day SMA)

  • %B is below .50 when price is below the middle band (20-day SMA)

 

Signals: Overbought/Oversold

%B can be used to identify overbought and oversold situations. However, it is important to know when to look for overbought readings and when to look for oversold readings. As with most momentum oscillators, it is best to look for short-term oversold situations when the medium-term trend is up and short-term overbought situations when the medium-term trend is down. In other words, look for opportunities in the direction of the bigger trend, such as a pullback within a bigger uptrend. Define the bigger trend before looking for overbought or oversold readings.

 

Screenshots:

 

Github: GitHub - Doustzadeh/cTrader-Indicator


using cAlgo.API;
using cAlgo.API.Indicators;

namespace cAlgo
{
    [Levels(0, 0.5, 1)]
    [Indicator(IsOverlay = false, AccessRights = AccessRights.None)]
    public class BollingerBandsPercentB : Indicator
    {
        [Parameter("Source")]
        public DataSeries Source { get; set; }

        [Parameter("Periods", Group = "Bollinger Bands", DefaultValue = 20)]
        public int Periods { get; set; }

        [Parameter("Standard Dev", Group = "Bollinger Bands", DefaultValue = 2)]
        public double StDeviation { get; set; }

        [Parameter("MA Type", Group = "Bollinger Bands", DefaultValue = MovingAverageType.Simple)]
        public MovingAverageType MaType { get; set; }

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

        private BollingerBands BBands;

        protected override void Initialize()
        {
            BBands = Indicators.BollingerBands(Source, Periods, StDeviation, MaType);
        }

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

    }
}


Doustzadeh's avatar
Doustzadeh

Joined on 20.03.2016

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: Bollinger Bands %B.algo
  • Rating: 5
  • Installs: 4994
Comments
Log in to add a comment.
No comments found.