OPEN-SOURCE SCRIPT
Mis à jour Confined Range Candle Finder

This indicator finds candlesticks which are confined within the range of a previous candlestick. This indicates volatility contraction which often leads to volatility expansion, i.e. large price movements.
While every confined range will contain at least 1 inside bar, this indicator differs from the Inside Bar Finder which only finds consecutive inside bars.
This indicator includes options such as:
- The minimum number of candlesticks confined within the range of a previous candlestick to trigger the indicator
- Labels to indicate the number of confined candles
- Signal lines to indicate the high and low of the containing candlestick
Try out this indicator with different options on different timeframes to see if confined ranges increase the probability of identifying the direction of price movements. Breaks or closes outside signal lines can be used to trigger trade signals.
While every confined range will contain at least 1 inside bar, this indicator differs from the Inside Bar Finder which only finds consecutive inside bars.
This indicator includes options such as:
- The minimum number of candlesticks confined within the range of a previous candlestick to trigger the indicator
- Labels to indicate the number of confined candles
- Signal lines to indicate the high and low of the containing candlestick
Try out this indicator with different options on different timeframes to see if confined ranges increase the probability of identifying the direction of price movements. Breaks or closes outside signal lines can be used to trigger trade signals.
Notes de version
v2 Release NotesEnhancements:
1. Added a % Tolerance so extremely small violations of the high/low can be ignored
2. Added a background fill color for the confined range
3. "Include Wicks" checkbox replaced by a "Range Boundary" dropdown: Wicks or Candle Bodies
4. Once found, a range is tracked until it breaks, with no length limit and a much faster calculation
5. Upgraded to Pine Script v6
Fixes:
1. Fixed range detection when wicks are excluded (now "Candle Bodies" mode)
2. Each confined range is now drawn once: the box, signal lines and count label extend with the range instead of stacking duplicates
3. Fixed the time calculation for assets that don't trade 24/7, so ranges anchor correctly across weekend/holiday gaps
4. Ranges longer than 50 candles are no longer cut off or re-drawn as overlapping boxes
5. Fixed false ranges on the first bars of chart history
6. Count label text is now readable (white text on the signal line color)
Notes de version
v3 Release NotesFixes:
1. Reduced default opacity
Notes de version
v4 Release NotesEnhancements:
1. Added a "Containing Candle Direction" filter (Any/Up/Down) to only find ranges whose containing candle closed up (close >= open) or down
Fixes:
1. Count label text now switches between black and white automatically for contrast, so it stays readable with light signal line colors such as white
Notes de version
v5 Release NotesEnhancements:
1. Added multi-timeframe support: a new "Timeframe" input finds confined ranges on the chart's timeframe or any higher timeframe
2. Added "Signal Mode": Confirmed (default, non-repainting, ranges appear after the candle closes) or Live (updates with the forming candle and may repaint)
3. Inputs are organized into Range Detection, Display, and Timeframe groups
4. Added a separate "Background" checkbox, so the range fill and lines can be shown independently
Changes:
1. Renamed "Show Signal Lines" to "Lines" and "Confined Range Fill Color" to "Background". Each now has its color on the same row. Any customized settings for these inputs will reset to the defaults
2. On the live bar, ranges now appear when the candle closes (Confirmed mode). Select "Live" to keep the previous behavior
Notes de version
v6 Release NotesEnhancements:
1. Added a "Midline" option: a dotted line halfway between the range boundaries, with its own color (off by default)
Changes:
1. Renamed "Lines" to "Boundary Lines". If you customized this setting, it will reset to the default (on)
Script open-source
Dans l'esprit TradingView, le créateur de ce script l'a rendu open source afin que les traders puissent examiner et vérifier ses fonctionnalités. Bravo à l'auteur! Bien que vous puissiez l'utiliser gratuitement, n'oubliez pas que la republication du code est soumise à nos Règles.
Technical analysis should be made as simple as possible, but no simpler. --Albert Einstein
Clause de non-responsabilité
Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.
Script open-source
Dans l'esprit TradingView, le créateur de ce script l'a rendu open source afin que les traders puissent examiner et vérifier ses fonctionnalités. Bravo à l'auteur! Bien que vous puissiez l'utiliser gratuitement, n'oubliez pas que la republication du code est soumise à nos Règles.
Technical analysis should be made as simple as possible, but no simpler. --Albert Einstein
Clause de non-responsabilité
Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.