OPEN-SOURCE SCRIPT
Bollinger Bands + B%

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.
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.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.