Period (bb1_length): 5 The number of periods for the Simple Moving Average (SMA) used as the basis of this band. Calculation: Basis = SMA(close, 5) Lower Band = Basis - 2 * Standard Deviation(close, 5) Purpose: Short-term volatility indicator for immediate price movement. Plotting: Lower band only, in yellow with a line width of 1. BB2 (Gray, Lower Band)
Period (bb2_length): 60 The number of periods for the SMA basis. Calculation: Basis = SMA(close, 60) Lower Band = Basis - 2 * Standard Deviation(close, 60) Purpose: Medium-term volatility indicator. Plotting: Lower band only, in gray with a line width of 3. BB3 (Green, Upper Band)
Period (bb3_length): 300 The number of periods for the SMA basis. Calculation: Basis = SMA(close, 300) Upper Band = Basis + 2 * Standard Deviation(close, 300) Purpose: Long-term volatility indicator to identify price extremes over an extended period. Plotting: Upper band only, in green with a line width of 2. BB4 (Blue, Upper Band)
Period (bb4_length): 20 The number of periods for the SMA basis. Multiplier (bb4_mult): 3 Multiplies the standard deviation for a wider band. Calculation: Basis = SMA(close, 20) Upper Band = Basis + 3 * Standard Deviation(close, 20) Purpose: Custom band with a higher multiplier to capture significant price deviations. Plotting: Upper band only, in blue with a line width of 1. Code Structure and Features Inputs:
The input.int and input.float functions allow users to customize the periods and multipliers directly from the TradingView interface. Plotting:
The plot function draws the calculated bands on the chart. Each band's color, title, and line width are specified for easy distinction. Custom Bands:
The script creates a unique combination of bands with different purposes: Short-term (BB1): Tracks rapid price changes. Medium-term (BB2): Reflects intermediate trends. Long-term (BB3): Indicates overall market conditions. Custom Multiplier (BB4): Highlights larger deviations. Use Case in Trading Traders can use these bands to:
Identify overbought or oversold levels when prices touch or exceed the bands. Gauge market volatility through the width of the bands. Detect trends or reversals based on the interaction of price with the different bands.