OPEN-SOURCE SCRIPT
Aggiornato Candle Range Detector

Candle Range Detector
Pine Script®
Overview
This indicator automatically detects price ranges based on candle containment, then tracks when those ranges are mitigated (broken) and when a sweep occurs. It is designed for traders who want to identify liquidity events and range breaks with precision.
How It Works
- Range Detection: A range is formed when a candle is fully contained within the previous candle (its high is lower and its low is higher). This marks a potential area of price balance or liquidity.
- Mitigation: A range is considered mitigated when price closes beyond its extension levels (configurable by normal or Fibonacci logic). This signals that the range has been invalidated or "taken out" by price action.
- Sweep Detection: After mitigation, the script watches for a sweep event: a candle that both trades through the range extreme and closes decisively beyond the log-mid of the candle itself. This is a strong sign of a liquidity grab or stop run.
- Alerts & Visuals: You can enable alerts and on-chart labels for sweeps. Only the most recent mitigated range can be swept, and each range can only be swept once.
- Timeframe Sensitivity: On weekly or monthly charts, a candle can both mitigate and sweep a range on the same bar. On lower timeframes, only one event can occur per bar.
Why It Works
- Candle containment is a robust way to identify natural price ranges and liquidity pools, as it reflects where price is consolidating or being absorbed.
- Mitigation marks the moment when a range is no longer defended, often leading to new directional moves.
- Sweeps are powerful signals of stop hunts or liquidity grabs, especially when confirmed by a close beyond the log-mid of the candle, indicating strong intent.
Visual Explanation

Tip: Use this tool to spot high-probability reversal or continuation zones, and to get alerted to key liquidity events in real time.
// Pine Script v6
// Detects candle-based ranges, mitigations, and sweeps with advanced logic
Overview
This indicator automatically detects price ranges based on candle containment, then tracks when those ranges are mitigated (broken) and when a sweep occurs. It is designed for traders who want to identify liquidity events and range breaks with precision.
How It Works
- Range Detection: A range is formed when a candle is fully contained within the previous candle (its high is lower and its low is higher). This marks a potential area of price balance or liquidity.
- Mitigation: A range is considered mitigated when price closes beyond its extension levels (configurable by normal or Fibonacci logic). This signals that the range has been invalidated or "taken out" by price action.
- Sweep Detection: After mitigation, the script watches for a sweep event: a candle that both trades through the range extreme and closes decisively beyond the log-mid of the candle itself. This is a strong sign of a liquidity grab or stop run.
- Alerts & Visuals: You can enable alerts and on-chart labels for sweeps. Only the most recent mitigated range can be swept, and each range can only be swept once.
- Timeframe Sensitivity: On weekly or monthly charts, a candle can both mitigate and sweep a range on the same bar. On lower timeframes, only one event can occur per bar.
Why It Works
- Candle containment is a robust way to identify natural price ranges and liquidity pools, as it reflects where price is consolidating or being absorbed.
- Mitigation marks the moment when a range is no longer defended, often leading to new directional moves.
- Sweeps are powerful signals of stop hunts or liquidity grabs, especially when confirmed by a close beyond the log-mid of the candle, indicating strong intent.
Visual Explanation
Tip: Use this tool to spot high-probability reversal or continuation zones, and to get alerted to key liquidity events in real time.
Note di rilascio
- Fixed Issue Where latest candle forms a rangeScript open-source
In pieno spirito TradingView, il creatore di questo script lo ha reso open-source, in modo che i trader possano esaminarlo e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricorda che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.
Script open-source
In pieno spirito TradingView, il creatore di questo script lo ha reso open-source, in modo che i trader possano esaminarlo e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricorda che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.