OPEN-SOURCE SCRIPT

Auto Range Detector [QuantAlgo]

16 948
🟢 Overview

The Auto Range Detector is a structural analysis tool built for traders who work around consolidation. It automatically scans every bar across multiple window sizes, tests each candidate against a set of independent structure filters, and draws a box where price rotated between two boundaries and stayed contained by them. Every stage is volatility normalized against the symbol's own history, so one configuration behaves consistently on a five minute crypto chart and a daily equity chart alike. Whether you fade the edges, trade the resolution, or simply want the ranges on your chart drawn the way you would draw them by hand, the indicator turns raw price into confirmed structures, marked breakouts, and a definition of "range" that you have complete control over on any asset and any interval.
스냅샷
🟢 How It Works

The indicator tests up to three window sizes on every bar: the base scan length, double it, and triple it. Each window places two boundaries using the method you choose, measures the band height, and ranks that height against its own history on the symbol and interval, so the volatility gate reads as a percentile of what the market normally produces. The window then has to pass four independent structure tests: enough midline crossings per bar to establish two sided rotation, enough bars reaching each boundary, a regression slope flat enough to show a stable mean, and enough closes held between the boundaries. The longest window that clears every test defines the range.

Once a structure qualifies, the left edge walks backwards through earlier history for as long as price stayed inside the band, and lands only on a bar held within the boundaries wick and all, so a box begins on a candle that belonged to the structure. The range stays provisional until it has spanned a minimum number of bars, and a provisional structure that breaks is cleared without a marker, leaving only structures that held on the chart. A break is confirmed on a close or a wick beyond the boundary, with an ATR buffer that filters marginal clears.
스냅샷
🟢 Key Features

▶ Multi-Scale Detection

The scan tests up to three window sizes on every bar: the base length, double it, and triple it, with the longest qualifying window defining the range. Boundary Basis then decides where the two edges sit and how range height is measured. Percentile band trims outlying wicks so no single spike defines the box, with the percentile itself adjustable. Absolute extremes places the edges on the extreme wicks and measures peak to trough. Body extremes works from opens and closes only, which suits instruments with erratic wicks such as thin crypto pairs. Signal Timing governs whether everything waits for the bar to close or evaluates the forming bar, and ATR Length sets the volatility unit every distance in the script is expressed in.
스냅샷
▶ Structure Filters

Five settings decide whether a candidate window is a range. Compression Percentile is the volatility gate, ranking band height against the symbol's own history so the threshold means the same thing on any instrument. Min Rotation Rate requires midline crossings per bar, which is what separates a genuine range from a reversal that happens to span the same distance. Min Boundary Touches requires both sides to be visited more than once, so a single spike high paired with a single spike low does not qualify, with Touch Definition and Touch Tolerance controlling what registers as a visit. Max Drift limits how far the mean of the window may tilt. Min Containment requires a share of closes to sit between the boundaries, rejecting structures where price only passed through the zone. Every test has its own control, so the definition can be set to tightly held rectangles or to looser rotational structures.
스냅샷
▶ Range Behavior

Range Anchoring decides where the left edge lands once a structure qualifies. Scan window only draws the box across the window the filters evaluated. Extend to containment walks the edge backwards through earlier bars that stayed inside the band, up to an adjustable ceiling, so the box covers the full consolidation. Minimum Range Bars holds a new structure provisional until it has run long enough, and a provisional structure that breaks is cleared without a marker. Absorb Overshoot lets a boundary take in a marginal wick rather than closing the box on it. Break Confirmation and Breakout Buffer decide what ends the range, on a close or a wick, and how far past the boundary price must clear. Cooldown Bars and Max Range Age govern what happens after a range resolves.
스냅샷
▶ Deviation Merging

Optional handling for a break that closes back inside the range. With this enabled, the broken structure is held open briefly and a close back between the boundaries revives it: the box resumes from its original left edge, the breakout marker is withdrawn, and the excursion is marked at its extreme, leaving one continuous structure with a failed break inside it rather than a breakout followed by a fresh box over the same price. Left disabled, every break is final.

스냅샷
▶ Range Visualization

Each structure is drawn as a gradient shaded box that fades from the boundaries toward equilibrium, with an optional midpoint line and quartile levels marking where a rotation is already extended. A live tag reports whether the structure is forming or confirmed, how many bars it has held, and its height as a percentage of price. Breakout markers print below the bar on an upside break and above it on a downside break.
스냅샷
▶ Built-in Alerts

Ready-made alert conditions fire when a new range is detected, when one breaks to the upside or downside, on any range break, and when a failed break returns price inside the structure.
스냅샷
▶ Color Presets

Six presets (Classic, Aqua, Cosmic, Cyber, Neon, Custom) drive the bullish and bearish pair, with the range color held separate so a live structure always reads as neutral against whichever pair is active. Custom mode exposes individual color pickers. Every border, line, fill, and label is contrast corrected against the chart background automatically, so a color close to your background lifts far enough to read while shading stays light enough to keep price action visible.
스냅샷

면책사항

해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.