Bollinger Bands (BBANDS)
Indicator Description
Bollinger Bands are a volatility indicator that creates dynamic support and resistance bands by calculating the standard deviation of price. It consists of three lines: the middle band (moving average), the upper band (resistance), and the lower band (support).
Function Information
- Function Name: BBANDS
- Input Parameters: #Kline
- Parameter Settings:
- timeperiod (default: 5)
- nbdevup (default: 2.0)
- nbdevdn (default: 2.0)
- matype (default: 0)
- Output: upper (upper band), middle (middle band), lower (lower band)
Calculation Principle
Bollinger Bands are calculated using the following formulas:
middle = MA(Close, timeperiod)
standard deviation = STD(Close, timeperiod)
upper = middle + (nbdevup * standard deviation)
lower = middle - (nbdevdn * standard deviation)
Where:
- MA is the moving average
- STD is the standard deviation
- nbdevup and nbdevdn are the standard deviation multipliers
- timeperiod is the calculation period
Usage Scenarios
- Support and resistance level identification
- Volatility analysis
- Overbought and oversold judgment
- Trend confirmation
Usage Recommendations
- Price touching the upper band may indicate overbought
- Price touching the lower band may indicate oversold
- Bandwidth narrowing may signal a breakout
- Use in combination with other indicators