OPEN-SOURCE SCRIPT

Bollinger Bands + B%

172
Overview
This script replicates the robust functionality and visual style of the Bollinger Band studies found in Sierra Chart, adapted for the TradingView environment. It is designed as an "All-in-One" suite that calculates the Bollinger Bands for the main price chart while simultaneously offering advanced oscillator studies (like %B and Bandwidth) in the pane below.

A unique feature of this script is the high degree of customization, particularly the ability to choose different Moving Average types for the Bollinger Band basis, and a dynamic coloration system for the %B indicator.

Key Features

Main Chart Overlay: Draws the Bollinger Bands (Upper, Lower, and Basis) directly on the price chart, even though the script runs in a separate pane.

Advanced %B Indicator: A visually enhanced version of Bollinger Bands %B. It features dynamic coloring based on a midline (default 0.5) and intensifies the colors when the value exceeds the high or low thresholds (simulating a band breakout).

Bollinger Bandwidth: Optional display of the bandwidth to measure volatility (Squeeze detection).

Customizable Calculation: Choose from 6 different Moving Average types to calculate the bands.

Moving Average Types Explained

The standard Bollinger Band uses a Simple Moving Average (SMA). This script allows you to change the mathematical basis of the bands to fit your specific trading strategy:

Simple (SMA): The standard calculation. Every price in the period has equal weight. Best for general use.

Exponential (EMA): Gives more weight to recent prices. Reacts faster to price changes than the SMA.

Weighted (WMA): Assigns a linear weighting factor. Recent data is more important, but the drop-off is smoother than EMA.

Linear Regression (LSMA): Calculates a linear regression line for each point. This is excellent for identifying the prevailing trend direction and "fitting" the price action.

Wilders (RMA): The smoothing method used in the RSI indicator. It reacts very slowly and smooths out significant noise.

Smoothed (SMMA): A blend that takes a broad view of price history. It is very stable and filters out minor market fluctuations effectively.

Settings & Parameters

1. Bollinger Bands (Price-Chart)

Show BB in Main Chart: Toggles the visibility of the bands on the price candles.

Length: The lookback period for the bands (Default: 20).

Standard Deviation: The multiplier for the width of the bands (Default: 2.0).

Moving Average Type: Select the algorithm for the center line (Basis).

2. Study: Bollinger Bands %B

Show %B: Toggles the %B oscillator.

High/Low Threshold: Sets the levels for the "Breakout" warnings (Default: 1.0 and 0.0).

Midline: The center point for the color switch (Default: 0.5).

Green: Value > Midline.

Red: Value < Midline.

Bright Green/Red: Value crosses the High/Low Thresholds.

3. Study: Bollinger Bandwidth

Show Bandwidth: Toggles the volatility measurement line.

Usage Tip:
Since %B (0.0 - 1.0) and Bandwidth (variable scale) use different y-axis scales, it is recommended to only enable one sub-study at a time via the checkboxes to maintain a clean chart view.

Disclaimer: This script is for educational and analytical purposes only. It is a code conversion based on public documentation of Sierra Chart Study ID 14 & 136.

Sierra Chart, best trading software, EVER!
With the best datafeet. Denali Exchange Data Feed.

Отказ от ответственности

Информация и публикации не предназначены для предоставления и не являются финансовыми, инвестиционными, торговыми или другими видами советов или рекомендаций, предоставленных или одобренных TradingView. Подробнее читайте в Условиях использования.