Signals Help Center
  • About Signals
  • Getting Started
    • Tutorials
      • Your First Strategy
        • Create a New Strategy
        • Define Variables
        • Define Setup Method
        • Define Register Actions Method
        • Backtest
        • Deploy Strategy & Start Receiving Signals
    • Dashboard
    • Strategies
      • Strategy Tools and Settings
        • Editor
        • Strategy Detail
        • Backtests
          • Backtest Detail
          • Deploying a Backtest
          • Delete a Backtest
        • Deployments
          • Deployment Detail
          • Edit About, Rules & Alternative Markets
          • Undeploy an Active Deployment
          • (Un)Publish a Deployment
          • (Un)Follow a Deployment
          • Delete a Deployment
        • Followings
          • Following Detail
          • Unfollow a Deployment
          • Delete Record of Following
      • Strategies Marketplace
        • Follow a Strategy
        • Publish Strategy
      • Strategy Details
      • Strategy Metrics
        • Initial Capital
        • Initial Capital (USDT)
        • Strategy Balance
        • Strategy Balance (USDT)
        • Total Performance
        • Total Performance (USDT)
      • Strategy Types
        • Single Market Strategy
        • Multi Market Strategy
    • Account
      • Change Plan
      • Change or Reset Password
      • Change Name, Username, or E-mail
  • Framework Documentation
    • Strategy
      • Methods
        • Setup()
          • DataMarketplace
          • IndicatorsMarketplace
        • RegisterActions()
        • Orders Management
          • CancelOrder()
          • CancelAllPendingOrders()
          • EnterLong()
          • EnterLongLimit()
          • EnterShort()
          • EnterLongStop()
          • EnterShortLimit()
          • ExitLong()
          • EnterShortStop()
          • ExitLongLimit()
          • ExitShort()
          • ExitShortLimit()
          • ExitLongStop()
          • ExitShortStop()
        • Risk Management
          • SetProfitTarget()
          • SetStopLoss()
      • Properties
        • Market
        • Markets
        • PendingOrders
        • Position
        • Time
      • Types
        • IOrder
        • PendingOrder
    • Data
    • Logs
  • Knowledge Base
    • Vocabulary
      • Base currency
      • Deployment
      • Following
      • Quote currency
      • Strategy
    • Technical Indicators
      • Oscillators
        • Average Directional Index (ADX)
        • Momentum Indicator (MOM)
        • Moving Average Convergence Divergence (MACD)
        • Relative Strength Index (RSI)
        • Stochastic RSI (STOCH RSI)
      • Volatility
        • Average True Range (ATR)
        • Bollinger Bands (BB)
      • Trend Analysis
        • Exponential Moving Average (EMA)
        • Simple Moving Average (SMA)
        • Volume-weighted Moving Average (VWMA)
        • Weighted Moving Average (WMA)
      • Volume
        • Accumulation/Distribution Line (ADL)
  • Have a question?
    • FAQ
    • Ask on the forums
    • Contact us
Powered by GitBook
On this page
  • Trading application
  • Calculation
  • Parameters
  • Examples
  1. Knowledge Base
  2. Technical Indicators
  3. Volatility

Bollinger Bands (BB)

Indicator used to show upper and lower limits of potential price movements.

PreviousAverage True Range (ATR)NextTrend Analysis

Last updated 5 years ago

Bollinger Bands (BB) are an indicator used to show upper and lower limits of potential price movements. Based on standard deviation, the spacing of the bands widens as markets become more volatile, then becomes narrower as prices stabilize. For signals, Bollinger Bands can be used to identify M-Tops and W-Bottoms or to determine the strength of the trend.

Trading application

The upper and lower bands represent the limits of typical price move deviation. When the price breaks these limits, it can be used as an entry signal to open a new trading position. The closer the prices move to the upper band, the more overbought the market can be said to be. The closer the prices move to the lower band, the more oversold the market is, triggering a buy signal.

The Squeeze or BB Squeeze is the central concept behind using Bollinger Bands indicators. When the market becomes too slow and there is low volatility, the price moves sideways and the Bollinger upper and lower bands become closer to each other. Traders consider this a potential sign of increased volatility and possible trading opportunities. The wider the bands move, the more likely the chance of decreased volatility and the greater the possibility of exiting a trade.

Calculation

MiddleBand=SimpleMovingAverage(SMA)Middle Band = Simple Moving Average (SMA) MiddleBand=SimpleMovingAverage(SMA)
UpperBand=SMA+(StandardDeviationOfPrice∗2)Upper Band = SMA + (Standard Deviation Of Price * 2)UpperBand=SMA+(StandardDeviationOfPrice∗2)
LowerBand=SMA−(StandardDeviationOfPrice∗2)Lower Band = SMA - (Standard Deviation Of Price * 2)LowerBand=SMA−(StandardDeviationOfPrice∗2)

Parameters

Input Parameters

Name

Type

Range of value

Description

stdDev

double

(0, double.MaxValue)

Standard deviation of bollinger bands.

period

int

<1, int.MaxValue>

Number of bars used in the calculation.

Output Parameters

Indicator ouptuts an object of values.

Name

Type

Range of value

Description

Upper

double

(0, double.MaxValue)

Upper band output value.

Middle

double

(0, double.MaxValue)

Middle band output value.

Lower

double

(0, double.MaxValue)

Lower band output value.

Examples

// Prints the current upper band value of a 20 period BB with standard
// deviation set to 2 using the daily bars close price value.
bb = indicators.Bollinger(2, 20).OnSeries(dailyBars.Close);
Log("The current upper band value is " + bb.Value.Upper.ToString());

// Prints the current middle band value
bb = indicators.Bollinger(2, 20).OnSeries(dailyBars.Close);
Log("The current middle band value is " + bb.Value.Middle.ToString());

// Prints the current lower band value
bb = indicators.Bollinger(2, 20).OnSeries(dailyBars.Close);
Log("The current lower band value is " + bb.Value.Lower.ToString());

// Prints the previous upper band value
bb = indicators.Bollinger(2, 20).Keep(2).OnSeries(dailyBars.Close);
Log("The previous upper band value is " + bb.Values[1].Upper.ToString());

Complete example

using Signals.DataSeries.Bars;
using Signals.Framework;
using Signals.Indicators.Bollinger;

public class MyStrategy : SingleMarketStrategy
{
    private Bars dailyBars;
    private Bollinger bb;

    public override void Setup(DataMarketplace data, IndicatorsMarketplace indicators)
    {
        dailyBars = data.Bars(BarPeriodType.Day, 1).WithOffset(25);
        bb = indicators.Bollinger(2, 20).Keep(2).OnSeries(dailyBars.Close);
    }

    public override void RegisterActions()
    {
        OnUpdateOf(dailyBars).Do(() =>
        {   
            // Prints the current upper band value
            Log("The current upper band value is " + bb.Value.Upper.ToString());

            // Prints the previous upper band value
            Log("The previous upper band value is " + bb.Values[1].Upper.ToString());

            // Prints the current middle band value
            Log("The current middle band value is " + bb.Value.Middle.ToString());

            // Prints the current lower band value
            Log("The current lower band value is " + bb.Value.Lower.ToString());
        });
    }
}