OPEN-SOURCE SCRIPT
Inside Bars / Nested Bars (+ Gaps) [jenaparadies]

๐Features
๐Method
An inside bar is any candle whose high is lower than or equal to the previous candle's high, and whose low is higher than or equal to the previous candle's low. In other words, the entire price action of the inside bar remains within the range of the previous candle without exceeding it. The preceding candle is referred to as the mother bar.
Occasionally, the candle following the inside bar may break above or below the inside bar's range, while still remaining fully within the high and low of the mother bar. These candles are referred to as nested bars and are highlighted in a different color.
Optionally, sequences of consecutive nested bars can be enclosed within a box to emphasize consolidation zones.

๐No-Gap Candles (Optional)
This feature adjusts each candleโs opening price so that it matches the closing price of the previous candle. It is particularly useful for assets that frequently experience large gaps between candles.
By extending each candle's effective range to include the previous candle's close, the indicator maintains structural consistency over timeframes, especially when the open price deviates significantly from the prior close. Inside bars are then identified relative to the extended range of the mother bar.
Optionally, the adjusted no-gap candles can be visualized directly on the chart for better clarity.

๐Bonus
Activating the "Show No-Gap Candles" option transforms any line chart into a gap-free bar chart โ ideal for visualizing economic data such as inflation rates.

- Highlight inside bars
- Highlight bars that remain within the range of a mother bar (called nested bars)
- Highlight the mother bar (optional)
- Highlight consecutive nested bars using a visual box (optional)
- Enable no-gap candle logic (optional, see below)
- Show no-gap candles on the chart (optional)
- Fully customizable colors and appearance
๐Method
An inside bar is any candle whose high is lower than or equal to the previous candle's high, and whose low is higher than or equal to the previous candle's low. In other words, the entire price action of the inside bar remains within the range of the previous candle without exceeding it. The preceding candle is referred to as the mother bar.
Occasionally, the candle following the inside bar may break above or below the inside bar's range, while still remaining fully within the high and low of the mother bar. These candles are referred to as nested bars and are highlighted in a different color.
Optionally, sequences of consecutive nested bars can be enclosed within a box to emphasize consolidation zones.
๐No-Gap Candles (Optional)
This feature adjusts each candleโs opening price so that it matches the closing price of the previous candle. It is particularly useful for assets that frequently experience large gaps between candles.
By extending each candle's effective range to include the previous candle's close, the indicator maintains structural consistency over timeframes, especially when the open price deviates significantly from the prior close. Inside bars are then identified relative to the extended range of the mother bar.
Optionally, the adjusted no-gap candles can be visualized directly on the chart for better clarity.
๐Bonus
Activating the "Show No-Gap Candles" option transforms any line chart into a gap-free bar chart โ ideal for visualizing economic data such as inflation rates.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
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.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
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.