MACD & Bollinger Bands Overbought Oversold

This indicator combines the power of MACD divergence analysis with Bollinger Bands to help traders identify potential reversal points in the market.
Key Features:
MACD Calculation & Divergence:
The script calculates the standard MACD components (MACD line, Signal line, and Histogram) using configurable fast, slow, and signal lengths. It includes a simplified divergence detection mechanism that flags potential bearish divergence—when the price makes a new swing high but the MACD fails to confirm the move. This divergence can serve as an early warning that the bullish momentum is waning.
Bollinger Bands:
A 20-period simple moving average (SMA) is used as the basis, with upper and lower bands drawn at 2 standard deviations. These bands help visualize overbought and oversold conditions. For example, a close at or above the upper band suggests the market may be overextended (overbought), while a close at or below the lower band may indicate oversold conditions.
Visual Alerts:
The indicator plots the Bollinger Bands on the chart along with labels marking overbought and oversold conditions. Additionally, it marks potential bearish divergence with a downward triangle, providing a quick visual cue to traders.
Usage Suggestions:
Confluence with Other Signals:
Use the divergence signals and Bollinger Band conditions as filters. For example, even if another indicator suggests a long entry, you might avoid it if the price is overbought or if MACD divergence warns of weakening momentum.
Customization:
All key parameters, such as the MACD lengths, Bollinger Band period, and multiplier, are fully configurable. This flexibility allows you to adjust the indicator to suit different markets or trading styles.
Disclaimer:
This script is provided for educational purposes only. Always perform your own analysis and backtesting before trading with live capital.
• v1.0 – Initial release
• v1.1 – Added once-per-day OB/OS logic & refreshed color palette
Description
This script overlays two well-established technical indicators—MACD and Bollinger Bands—into a unified visual tool for identifying potential reversals and extreme price conditions. It is designed for traders who want to monitor both momentum and volatility, while maintaining a clean chart with minimal noise. One of the key enhancements in this version is that overbought and oversold signals (from the Bollinger Bands) are restricted to only one occurrence per trading day, helping reduce redundant signals and allowing for clearer decision-making.
MACD Divergence Detection
The MACD (Moving Average Convergence Divergence) is calculated using a fast exponential moving average (default: 12), a slow EMA (default: 26), and a signal line (default: 9-period EMA of the MACD line). This script tracks the MACD line relative to price highs to identify a basic form of bearish divergence. Specifically, when the price makes a new local high but the MACD fails to make a new high, it may suggest that bullish momentum is weakening. When this condition is met, a red triangle is plotted above the bar as a warning signal.
This simplified divergence model provides an intuitive early alert for momentum slowdown, especially when observed near key resistance levels. It does not require complex peak-trough recognition logic, making it efficient and suitable for real-time alerts.
Bollinger Bands Overbought/Oversold with Daily Limit
Bollinger Bands are based on a 20-period simple moving average (SMA) and a configurable standard deviation multiplier (default: 2.0). The upper and lower bands represent statistical extremes, and price movement beyond these bands may indicate overbought or oversold conditions.
This script plots a visual label ("OB" for overbought or "OS" for oversold) only once per day per condition. That is, if the price closes above the upper band during the day, only the first occurrence triggers an "OB" label. Similarly, if the price closes below the lower band, only the first "OS" is shown. These labels appear in visually calming colors to reduce cognitive strain during live chart monitoring.
This once-per-day limitation helps reduce clutter on the chart, especially during volatile market conditions where price may repeatedly hit the bands within the same session. The goal is to emphasize meaningful volatility extremes rather than overwhelm the user with repetitive labels.
Customization and Inputs
All major parameters are user-adjustable:
MACD Fast Length (default: 12)
MACD Slow Length (default: 26)
MACD Signal Smoothing (default: 9)
Bollinger Bands Length (default: 20)
Bollinger Bands Standard Deviation Multiplier (default: 2.0)
Recommended Use Cases
This tool is useful for traders seeking to:
Confirm weakening momentum through MACD divergence
Identify early reversal setups in combination with overbought or oversold conditions
Reduce visual noise on charts by limiting extreme-condition signals to once per day
Customize sensitivity and visual presentation based on timeframe or trading style
Common strategies include combining the MACD divergence alert with an overbought or oversold signal to time entries or exits more precisely. For example, a single "OS" label near a key support zone, accompanied by bullish MACD divergence, could serve as a potential long entry signal.
Version Notes
Version 1.0: Initial release with MACD and Bollinger Band integration
Version 1.1: Added one-signal-per-day logic for overbought/oversold and updated color scheme for better chart readability
Disclaimer
This script is provided for educational and informational purposes only. It is not intended as investment advice. Trading involves risk and should always be tested thoroughly in a simulated environment before applying to live capital. Past performance is not indicative of future results.
Script open-source
In pieno spirito TradingView, il creatore di questo script lo ha reso open-source, in modo che i trader possano esaminarlo e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricorda che la ripubblicazione del codice è soggetta al nostro Regolamento.
Per un accesso rapido a un grafico, aggiungi questo script ai tuoi preferiti: per saperne di più clicca qui.
Declinazione di responsabilità
Script open-source
In pieno spirito TradingView, il creatore di questo script lo ha reso open-source, in modo che i trader possano esaminarlo e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricorda che la ripubblicazione del codice è soggetta al nostro Regolamento.
Per un accesso rapido a un grafico, aggiungi questo script ai tuoi preferiti: per saperne di più clicca qui.