OPEN-SOURCE SCRIPT

Inside Bars / Nested Bars (+ Gaps) [jenaparadies]

77
๐Ÿ“ŒFeatures
  • 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.
snapshot

๐Ÿ“Œ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.
snapshot

๐ŸŽ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.
snapshot

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.