Pro Bollinger Bands Strategy [Breno]

Core Strategy Logic
This Strategy implements a comprehensive trend-following and mean-reversion strategy primarily leveraging the Bollinger Bands (BB) indicator for entry and exit signals, complemented by an Average True Range (ATR)-based Stop Loss mechanism and an optional EMA filter. It is designed with robust features for capital management, including configurable leverage and a sophisticated position averaging (scaling) system.
- Long Entry: A long position is initiated when the closing price crosses over the Lower Bollinger Band (ta.crossover(close,lowerBB)). This signals a potential mean-reversion opportunity following a price dip.
- Short Entry: A short position is initiated when the closing price crosses under the Upper Bollinger Band (ta.crossunder(close,upperBB)). (Note: Short entries are disabled by default in the script inputs).
- Exit Conditions (Profit Target): Long positions aim to exit upon interaction with the Upper Bollinger Band. Users can select from three exit methods:
- "Close When Touch": Exits when close≥upperBB.
- "Close Above then Below": Exits when the previous close was above the upper band, and the current close is below it (a reversal signal).
- "High Above": Exits when high>upperBB. The strategy features an optional profitOnly setting, which restricts all exits to only occur if the trade is currently in profit (i.e., close is above the strategy.position_avg_price for longs).
- "Close When Touch": Exits when close≥upperBB.
Key Features and Customization
Bollinger Bands & Filters -
- Customizable BB Parameters: The Length and Deviation of the Bollinger Bands are fully adjustable, allowing users to fine-tune the sensitivity of the entry and exit signals.
- Optional EMA Filter: An optional EMA Filter can be enabled to align entries with the prevailing trend, where a Long entry is only permitted if close≥EMA(EmaFilterRange).
Risk and Capital Management -
- Equity Allocation: Position size is dynamically calculated based on a Percentage of Equity (capitalPerc) combined with the set Leverage multiplier.
- Dynamic Stop Loss (ATR-Based):
An optional Stop Loss (SL) is calculated using a multiple (slAtrInput) of the Average True Range (ATR).
The SL is set relative to the entry price upon trade activation, providing a volatility-adjusted risk management layer. - Position Averaging (Scaling): The script supports the addition of multiple units (pyramiding) to an existing position based on three user-selected criteria:
- "No": No averaging.
- "Percent": Adds to the position if the price has dropped by a set percentage (addPct) from the average price.
- "ATR": Adds to the position if the current price is significantly below a calculated ATR-based support level from the average price.
- "No": No averaging.
Core Strategy Logic
This Strategy implements a comprehensive trend-following and mean-reversion strategy primarily leveraging the Bollinger Bands (BB) indicator for entry and exit signals, complemented by an Average True Range (ATR)-based Stop Loss mechanism and an optional EMA filter. It is designed with robust features for capital management, including configurable leverage and a sophisticated position averaging (scaling) system.
- Long Entry: A long position is initiated when the closing price crosses over the Lower Bollinger Band (ta.crossover(close,lowerBB)). This signals a potential mean-reversion opportunity following a price dip.
- Short Entry: A short position is initiated when the closing price crosses under the Upper Bollinger Band.
- Exit Conditions (Profit Target): Long positions aim to exit upon interaction with the Upper Bollinger Band. Users can select from three exit methods:
- "Close When Touch": Exits when close≥upperBB.
- "Close Above then Below": Exits when the previous close was above the upper band, and the current close is below it (a reversal signal).
- "High Above": Exits when high>upperBB. The strategy features an optional profitOnly setting, which restricts all exits to only occur if the trade is currently in profit.
- "Close When Touch": Exits when close≥upperBB.
Key Features and Customization
Bollinger Bands & Filters -
- Customizable BB Parameters: The Length and Deviation of the Bollinger Bands are fully adjustable, allowing users to fine-tune the sensitivity of the entry and exit signals.
- Optional EMA Filter: An optional EMA Filter can be enabled to align entries with the prevailing trend, where a Long entry is only permitted if close≥EMA(EmaFilterRange).
Risk and Capital Management -
- Equity Allocation: Position size is dynamically calculated based on a Percentage of Equity combined with the set Leverage multiplier.
- Dynamic Stop Loss (ATR-Based):
An optional Stop Loss (SL) is calculated using a multiple (slAtrInput) of the Average True Range (ATR).
The SL is set relative to the entry price upon trade activation, providing a volatility-adjusted risk management layer. - Position Averaging (Scaling): The script supports the addition of multiple units (pyramiding) to an existing position based on three user-selected criteria:
- "No": No averaging.
- "Percent": Adds to the position if the price has dropped by a set percentage (addPct) from the average price.
- "ATR": Adds to the position if the current price is significantly below a calculated ATR-based support level from the average price.
- "No": No averaging.
Tập lệnh chỉ hiển thị cho người được mời
Chỉ những người dùng được tác giả chấp thuận mới có thể truy cập tập lệnh này. Bạn sẽ cần yêu cầu và được cấp quyền sử dụng. Thông thường quyền này được cấp sau khi thanh toán. Để biết thêm chi tiết, làm theo hướng dẫn của tác giả bên dưới hoặc liên hệ trực tiếp với brenosilver.
TradingView KHÔNG khuyến nghị bạn trả phí hoặc sử dụng một tập lệnh trừ khi bạn hoàn toàn tin tưởng vào tác giả và hiểu cách hoạt động của tập lệnh. Bạn cũng có thể tìm các lựa chọn miễn phí, mã nguồn mở trong các script cộng đồng của chúng tôi.
Hướng dẫn của tác giả
Thông báo miễn trừ trách nhiệm
Tập lệnh chỉ hiển thị cho người được mời
Chỉ những người dùng được tác giả chấp thuận mới có thể truy cập tập lệnh này. Bạn sẽ cần yêu cầu và được cấp quyền sử dụng. Thông thường quyền này được cấp sau khi thanh toán. Để biết thêm chi tiết, làm theo hướng dẫn của tác giả bên dưới hoặc liên hệ trực tiếp với brenosilver.
TradingView KHÔNG khuyến nghị bạn trả phí hoặc sử dụng một tập lệnh trừ khi bạn hoàn toàn tin tưởng vào tác giả và hiểu cách hoạt động của tập lệnh. Bạn cũng có thể tìm các lựa chọn miễn phí, mã nguồn mở trong các script cộng đồng của chúng tôi.