OPEN-SOURCE SCRIPT
Updated

Chained Inside Bars

This script identifies consecutive inside bars by referencing only the most recent non-inside bar, so it avoids excessive lookback. An “inside” bar means its high is lower than the reference bar’s high, and its low is higher than the reference bar’s low. If the current bar is inside, it’s colored white; once price breaks outside, the script updates that new bar as the next reference.

Key Points
• Bars are compared against the last non-inside bar, chaining consecutive inside bars off that same reference bar.
• Inside bars are highlighted in white (non-inside bars retain default chart colors).
• Includes an alert condition for when a new inside bar forms.
• Prevents large dynamic indexing, making it more stable and efficient.

Use this indicator to quickly spot consecutive inside-bar formations without needing to track every single bar-to-bar relationship.
Release Notes
This script identifies consecutive inside bars by referencing only the most recent non-inside bar, so it avoids excessive lookback. An “inside” bar means its high is lower than the reference bar’s high, and its low is higher than the reference bar’s low. If the current bar is inside, it’s colored white; once price breaks outside, the script updates that new bar as the next reference.

Key Points
• Bars are compared against the last non-inside bar, chaining consecutive inside bars off that same reference bar.
• Inside bars are highlighted in white (non-inside bars retain default chart colors).
• Includes an alert condition for when a new inside bar forms.
• Prevents large dynamic indexing, making it more stable and efficient.

Use this indicator to quickly spot consecutive inside-bar formations without needing to track every single bar-to-bar relationship.

=== Update 2025/01/20 ===
This “Chained Inside Bars” indicator prevents abnormally large (outlier) bars from becoming the reference bar and trapping all future bars inside their range. It uses a user-configurable average range length and range multiplier to identify when a bar is “too big.” Such huge bars are automatically skipped, so the script can properly detect normal inside-bar formations.
Release Notes
Fixed the case when the high or low of the previous candle equals the current one.
Release Notes
Inside bars can be useful in several cases:

1 - If you trade using the inside bar strategy. I won’t go into detail about this here, as you can easily find numerous descriptions of this strategy, as well as videos explaining how to use such bars. With this indicator, it will be much easier for you to spot these bars on the chart, no matter what scale you’re using.

2 - If you trade using smart money concepts. Highlighted inside bars will help you avoid mistakes when defining structure (highs and lows), as such bars should not be marked as structural points.

Additionally, if you use automated scripts for strategy-based trading, my script triggers an alert the moment an inside bar appears, which you can process as needed.
Release Notes
Chart update

Disclaimer