OPEN-SOURCE SCRIPT

Normalized Bollinger Band Distance

This TradingView script calculates and visualizes the Normalized Bollinger Band Distance to analyze the relative spread of Bollinger Bands as a percentage of the moving average. It also determines thresholds based on global statistics to highlight unusual market conditions. Here's a detailed description:

Indicator Overview
Purpose: The indicator measures the normalized distance between the upper and lower Bollinger Bands relative to the Simple Moving Average (SMA). It helps identify periods of high or low volatility.
Visualization: Displays the normalized distance along with dynamic thresholds based on global statistical calculations (mean and standard deviation).
Inputs
Length (length): Defines the period for the SMA and Bollinger Bands calculation. Default is 200.
Standard Deviations (stdDev): Number of standard deviations for the Bollinger Bands. Default is 2.
Calculation
Bollinger Bands:

Upper Band:
SMA
+
(
Standard Deviation
×
stdDev
)
SMA+(Standard Deviation×stdDev)
Lower Band:
SMA

(
Standard Deviation
×
stdDev
)
SMA−(Standard Deviation×stdDev)
Normalized Distance:

Normalized Distance
=
Upper Band

Lower Band
SMA
Normalized Distance=
SMA
Upper Band−Lower Band


Global Statistics:

Global Mean (
𝜇
μ): Average of all normalized distances up to the current bar.
Global Standard Deviation (
𝜎
σ): Standard deviation of all normalized distances up to the current bar.
High Threshold:
𝜇
+
1.5
×
𝜎
μ+1.5×σ
Low Threshold:
𝜇

1.5
×
𝜎
μ−1.5×σ
Visualization
Normalized Distance Plot:
The normalized distance is plotted in blue as a percentage for easy interpretation.
Threshold Lines:
High Threshold: Red line to signal unusually high volatility.
Low Threshold: Green line to signal unusually low volatility.
Mean Line: White line indicating the average normalized distance.
Zero Line: Horizontal white line for reference.
Use Case
High Threshold Breach: Indicates an unusual increase in Bollinger Band width relative to the SMA, signaling potential high market volatility.
Low Threshold Breach: Indicates an unusual narrowing of Bollinger Band width, suggesting low volatility and potential consolidation.
Trend Analysis: Observe how the normalized distance evolves over time to anticipate market conditions.
Bands and Channels

Script de código abierto

Siguiendo fielmente el espíritu de TradingView, el autor de este script lo ha publicado en código abierto, permitiendo que otros traders puedan entenderlo y verificarlo. ¡Olé por el autor! Puede utilizarlo de forma gratuita, pero tenga en cuenta que la reutilización de este código en la publicación se rige por las Normas internas. Puede añadir este script a sus favoritos y usarlo en un gráfico.

¿Quiere utilizar este script en un gráfico?

Exención de responsabilidad