PROTECTED SOURCE SCRIPT
Updated

Box Chart Overlay Strategy

172
Exploring the Box Chart Overlay Strategy with RSI & Bollinger Confirmation

The “Box Chart Overlay Strategy by BD” is a sophisticated TradingView strategy script written in Pine Script (version 5). It combines a box charting method with two widely used technical indicators—Relative Strength Index (RSI) and Bollinger Bands—to generate trade entries. In this article, we break down the strategy’s components, its logic, and how it visually represents trading signals on the chart.

1. Strategy Setup and User Inputs
Strategy Declaration
At the top of the script, the strategy is declared with key parameters:

Overlay: The indicator is plotted directly on the price chart.

Initial Capital & Position Sizing: It uses a simulated trading account with an initial capital of 10,000 and positions sized as a percentage of equity (10% by default).

Commission: A commission of 0.1% is factored into trades.

Input Parameters
The strategy is highly customizable. Users can adjust various inputs such as:

Box Settings:

Box Size (RSboxSize): Defines the size of each price “box.”

Box Options: Choose from three modes:

Standard: Boxes are calculated continuously from the start of the chart.

Anchored: The first box is fixed at a specified time and price.

Daily Reset: The boxes reset each day based on a defined session time.

Color Customizations:
Options to customize the appearance of boxes, borders, labels, and even repainting the candles based on the current price’s relation to box levels.

RSI Settings:
Length, overbought, and oversold levels are set to filter trades.

Bollinger Bands Settings:
Users can set the length of the moving average and the multiplier for standard deviation, which will be used to compute the upper and lower bands.

2. The Box Chart Mechanism
Box Construction
The core idea of a box chart is to group price movement into discrete blocks—or boxes—of a fixed size. In this strategy:

Standard Mode:
The script calculates boxes starting at a rounded price level. When the price moves sufficiently above or below the current box’s boundaries, a new box is drawn.

Anchored and Daily Reset Modes:
These modes allow traders to control where the box calculations begin or to reset them during a specific intraday session.

Visual Elements
Several custom functions handle the visual components:

drawBoxUp() and drawBoxDn():
These functions create boxes in bullish or bearish directions respectively, based on whether the price has exceeded the current box’s high or low.

drawLines() and drawLabels():
Lines are drawn to extend the current box levels, and labels are updated to display key levels or the “remainder” (the difference needed to trigger a new box).

Projected Boxes:
A “projected” box is drawn to indicate potential upcoming box levels, providing an additional visual cue about the price action.

3. Integrating RSI and Bollinger Bands for Trade Confirmation
RSI Integration
The strategy computes the RSI using a user-defined length. It then uses the following conditions to validate entries:

Long Trades (Box Up):
The strategy waits for the RSI to be at or below the oversold level before considering a long entry.

Short Trades (Box Down):
It requires the RSI to be at or above the overbought level before triggering a short entry.

Bollinger Bands Confirmation
In addition to the RSI filter:

For Long Entries:
The price must be at or below the lower Bollinger Band.

For Short Entries:
The price must be at or above the upper Bollinger Band.

By combining these filters with the box breakout logic, the strategy aims to enhance the quality of its trade signals.

4. Dynamic Trade Entries and Alerts
Box Logic and Entry Functions
Two key functions—BoxUpFunc() and BoxDownFunc()—handle the creation of new boxes and also check if trade conditions are met:

When a new box is drawn, the script evaluates if the RSI and Bollinger conditions align.

If conditions are satisfied, the script places an entry order:

Long Entry: Initiated when the price moves upward, RSI indicates oversold, and the price touches or falls below the lower Bollinger Band.

Short Entry: Triggered when the price falls downward, RSI signals overbought, and the price touches or exceeds the upper Bollinger Band.

Alerts
Built-in alert functions notify traders when a new box level is reached. Users can set custom alert messages to ensure they are aware of potential trade opportunities as soon as the conditions are met.

5. Visual Enhancements and Candle Repainting
The script also includes options for repainting candles based on their relation to the current box’s boundaries:

Above, Below, or Within the Box:
Candles are color-coded using user-defined colors, making it easier to visually assess where the price is in relation to the box levels.

Labels and Lines:
These continuously update to reflect current levels and provide an immediate visual reference for potential breakout points.

Conclusion
The Box Chart Overlay Strategy by BD is a multi-faceted approach that marries the traditional box chart technique with modern technical indicators—RSI and Bollinger Bands—to refine entry signals. By offering various customization options for box creation, visual styling, and confirmation criteria, the strategy allows traders to adapt it to different market conditions and personal trading styles. Whether you prefer a continuously running “Standard” mode or a more controlled “Anchored” or “Daily Reset” approach, this strategy provides a robust framework for integrating price action with momentum and volatility measures.
Release Notes
PineWiseTrading

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.