OPEN-SOURCE SCRIPT
Mis à jour Range Detector [NJ]

✧ OVERVIEW ✧
Range Detector identifies and highlights potential ranging market structures using pivot highs and lows combined with a two-stage confirmation process.
Confirmed ranges are displayed as boxes and remain active until price closes beyond the allowed tolerance.

✧ SETTINGS ✧
Range Tolerance %
Controls how far price may close beyond the range before it is invalidated.
Range First Confirmation %
Controls the first retracement required after both range boundaries have formed.
Range Second Confirmation %
Controls the second reversal required after the first confirmation.
Bars to Confirm the Range
Controls how long the current candidate structure may remain unconfirmed before it expires.
Pivot High/Low Lookback
Controls pivot sensitivity. Lower values detect smaller and more frequent swings, while higher values focus on larger market structures.
✧ HOW IT WORKS ✧

Range Formation
The indicator uses pivot highs and lows to define potential range boundaries. Newer same-side pivots may replace earlier ones until both boundaries are established.
Two-Stage Confirmation
A range is confirmed only after two rotations.
With the default 70% / 50% settings:
High → Low: price retraces 70% toward the high, then returns to 50%.
Low → High: price retraces 70% toward the low, then returns to 50%.
Range Invalidation
The range remains active until price closes beyond a boundary by more than the selected tolerance, measured as a percentage of the range height.
Candidate Timeout
Unconfirmed candidates must complete the confirmation sequence within the selected number of bars. Otherwise, they are discarded. The timer may restart if a newer same-side pivot replaces the current candidate.
✧ VISUALIZATION ✧

Once confirmed, the range is displayed as a box between its upper and lower boundaries.
The box is drawn retrospectively from the earliest pivot used to form the range and extends forward until the range is invalidated.
Because pivot highs and lows require future bars to be confirmed, the beginning of a range can appear several bars before the indicator could have known that the pivot was valid in real time.
✧ USAGE ✧
Range Detector can be used to identify areas of:
Sideways price action
Consolidation
Mean-reversion conditions
Support and resistance
Potential breakout structures
The detected zones can provide additional market structure context for range trading, breakout analysis, or filtering trend-following setups.
As with any technical indicator, it is best used alongside other forms of analysis rather than as a standalone entry or exit signal.
Range Detector identifies and highlights potential ranging market structures using pivot highs and lows combined with a two-stage confirmation process.
Confirmed ranges are displayed as boxes and remain active until price closes beyond the allowed tolerance.
✧ SETTINGS ✧
Range Tolerance %
Controls how far price may close beyond the range before it is invalidated.
Range First Confirmation %
Controls the first retracement required after both range boundaries have formed.
Range Second Confirmation %
Controls the second reversal required after the first confirmation.
Bars to Confirm the Range
Controls how long the current candidate structure may remain unconfirmed before it expires.
Pivot High/Low Lookback
Controls pivot sensitivity. Lower values detect smaller and more frequent swings, while higher values focus on larger market structures.
✧ HOW IT WORKS ✧
Range Formation
The indicator uses pivot highs and lows to define potential range boundaries. Newer same-side pivots may replace earlier ones until both boundaries are established.
Two-Stage Confirmation
A range is confirmed only after two rotations.
With the default 70% / 50% settings:
High → Low: price retraces 70% toward the high, then returns to 50%.
Low → High: price retraces 70% toward the low, then returns to 50%.
Range Invalidation
The range remains active until price closes beyond a boundary by more than the selected tolerance, measured as a percentage of the range height.
Candidate Timeout
Unconfirmed candidates must complete the confirmation sequence within the selected number of bars. Otherwise, they are discarded. The timer may restart if a newer same-side pivot replaces the current candidate.
✧ VISUALIZATION ✧
Once confirmed, the range is displayed as a box between its upper and lower boundaries.
The box is drawn retrospectively from the earliest pivot used to form the range and extends forward until the range is invalidated.
Because pivot highs and lows require future bars to be confirmed, the beginning of a range can appear several bars before the indicator could have known that the pivot was valid in real time.
✧ USAGE ✧
Range Detector can be used to identify areas of:
Sideways price action
Consolidation
Mean-reversion conditions
Support and resistance
Potential breakout structures
The detected zones can provide additional market structure context for range trading, breakout analysis, or filtering trend-following setups.
As with any technical indicator, it is best used alongside other forms of analysis rather than as a standalone entry or exit signal.
Notes de version
Short title correction.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.
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.
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.