OPEN-SOURCE SCRIPT
Updated

Abhi's Bollinger Band Reversal Signal

338
This Pine Script indicator is designed to detect reversal trade opportunities using Bollinger Band breakouts. It identifies both buy and sell setups with clearly defined entry, stop-loss (SL), and target (TP) conditions. It also manages trades visually with real-time signal plotting, and limits entries per trading day.

⚙️ How It Works
🔽 Sell Signal Conditions
- The previous candle must close above the upper Bollinger Band, and its entire body must be above the band
- The current candle must fail to break the previous high, and must break below the previous low
- Entry is taken at the previous candle’s low, with SL at its high
- Target is calculated based on a configurable Risk:Reward ratio

🔼 Buy Signal Conditions
- The previous candle must close below the lower Bollinger Band, and its entire body must be below the band
- The current candle must fail to break the previous low, and must break above the previous high
- Entry is at the previous candle’s high, with SL at its low
- Target is calculated using the same Risk:Reward ratio

⏰ Time-Based Exit
- If a trade is still active by a user-defined exit time (e.g. 15:15), the trade is closed
- Labels are plotted to show whether this exit was a profit or loss

🧩 User Inputs
- Start Time for signals
- Exit Time for open trades
- Bollinger Band Settings: Period and Std Dev
- Max Entries Per Day
- Risk:Reward Ratio: Dropdown for 1:1, 1:1.5, ..., 1:3

🎨 Visual Features
✅ BUY and SELL signals are plotted when valid conditions are detected
🟢 TP and 🔴 SL labels show trade outcome
🕒 TIME EXIT labels appear at user-set exit time with green/red coloring based on profitability
📉 Bollinger Bands plotted for visual context

📌 Notes:
- Designed for intraday trading, resets entry counter daily
- Uses bar_index > tradeBarIndex to avoid SL/TP being triggered on the same candle as entry
- Tracks only one trade at a time (tradeActive) — ensures clear, non-overlapping logic
Release Notes
This indicator detects potential mean-reversion trades using Bollinger Band breakout and reversal patterns. It:

- Identifies Buy signals when price closes below the lower Bollinger Band and then forms a strong bullish candle
- Identifies Sell signals when price closes above the upper Bollinger Band and then reverses bearishly
- Supports configurable Risk:Reward ratios (1:1 to 1:4) with automatic Take Profit and Stop Loss plotting
- Switches between Intraday mode (exits at end of day if time frame is <=30 mins) and CNC mode (multi-day trades if time frame is > 30mins) based on chart timeframe
- Limits number of entries per day to avoid overtrading
- Displays clear labels for entry, SL/TP hits, and time exits
- Includes alert conditions for automation or webhook-based notification

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.