AG Pro Fixed Range Control Box [AGPro Series]AG Pro Fixed Range Control Box
═══════════════════════════════════════════════
Overview / What it does
═══════════════════════════════════════════════
AG Pro Fixed Range Control Box identifies a single high-conviction
price range and answers one simple question: who is in control inside
it — bulls, bears, or neither?
Instead of plotting dozens of support and resistance levels, this tool
isolates one structural range (automatically detected or manually set),
draws a volume-weighted Control Line inside it, and classifies the
current state into four clean categories: Inside, Upper (Bull Control),
Lower (Bear Control), or Failed. A compact information panel shows the
current side, range age, touch count, and hold quality.
The design philosophy is minimalist: one hero box, one story, zero
visual clutter.
═══════════════════════════════════════════════
Unique Edge
═══════════════════════════════════════════════
Most range tools show many boxes of equal weight, leaving the user to
decide which one matters. This script takes the opposite approach — it
commits to exactly one active range at a time and stops redrawing it
when the structure breaks.
Three properties make this distinctive:
1. VWAP-based Control Line (not a static midpoint). The line is the
volume-weighted average price inside the range, so it reflects where
participants have actually transacted, not geometric averaging.
2. Edge-aware fallback. If the VWAP collapses to the top or bottom 10%
of the range (meaning price has spent most time at one edge), the
line automatically falls back to the range midpoint. This keeps the
Control Line meaningful in trending conditions.
3. Frozen-on-failure state. When price closes beyond the range, the
box freezes at the break bar — it does not keep extending into the
future pretending the range is still valid. A cooldown period then
elapses before a new range is searched, preventing rapid re-triggers.
═══════════════════════════════════════════════
Methodology
═══════════════════════════════════════════════
Range detection offers four modes:
- Auto - Pivot: Uses the last confirmed pivot high and pivot low as
range boundaries. A new range is built only when the pivot set
changes meaningfully (beyond 10 ticks) and width passes the minimum
percentage filter.
- Auto - Lookback: Uses the highest high and lowest low over a fixed
bar window. Rebuilds on a schedule.
- Auto - Compression: Monitors the ratio of short-term ATR to long-term
ATR. When compression is detected (ratio below threshold), the
current compressed zone is locked as the range.
- Manual - Date: User defines a start and end timestamp. The range
tracks high/low within that window.
Control Line = rolling VWAP from range start to current bar, clamped
inside the range with edge-fallback to midpoint.
State machine:
- Inside: price oscillating within the range, control line not decisively
reclaimed.
- Upper (Bull Control): price has held above the Control Line for N
consecutive bars (N = Reclaim Confirmation, default 2).
- Lower (Bear Control): same logic, below the Control Line.
- Failed: price closed beyond range_high or range_low. Range is frozen.
Quality metrics:
- Touch Count: bars in which the candle range contained the Control
Line (price interacted with it).
- Hold Quality: percentage of bars whose close remained inside the
range, capped at 100%.
═══════════════════════════════════════════════
Signals & Alerts
═══════════════════════════════════════════════
Three alert conditions are available:
- New Control Box formed: a fresh range has been established.
- Control Line reclaimed (Bull or Bear): state transition into Upper
or Lower control.
- Control Box failed: range boundary breached; box is frozen.
All alerts fire once per bar close to reduce noise.
═══════════════════════════════════════════════
Key Inputs
═══════════════════════════════════════════════
- Range Mode: Auto-Pivot / Auto-Lookback / Auto-Compression / Manual.
- Pivot Length, Lookback Bars, Compression Window & Ratio: tune the
detection sensitivity per market and timeframe.
- Min Range Lifespan: minimum bars before a new range can replace the
current one.
- Min Range Width %: filters out micro-ranges below this percentage
width.
- Failed Cooldown Bars: enforced wait period after a Failed state
before a new range is searched.
- Strict Control Logic: requires confirmed close past the Control Line;
if disabled, wicks are used.
- Reclaim Confirmation: consecutive bars required to confirm a reclaim.
- Fade Old Boxes, Max Boxes Kept, Future Projection Bars: visual
controls.
═══════════════════════════════════════════════
How to use
═══════════════════════════════════════════════
1. Start with Auto - Pivot mode on your preferred timeframe. This is
the most intuitive detection method for most markets.
2. Watch the State field in the panel. Inside means the range is live
and being tested. Upper or Lower means one side has taken control
of the Control Line. Failed means the range has structurally broken.
3. Touch Count and Hold Quality give context for how respected the
range is. High Hold Quality (above 80%) combined with several
touches suggests a well-defined structure.
4. For lower-timeframe or choppy markets, try Auto - Compression to
lock onto low-volatility consolidations. For specific event
studies, use Manual - Date.
═══════════════════════════════════════════════
Limitations & Transparency
═══════════════════════════════════════════════
- This is an indicator, not a strategy. It does not generate buy or
sell signals and should not be treated as one.
- Range detection is retrospective. Pivot-based ranges rely on
confirmed pivots, which require pivotLen bars of hindsight on each
side. The range only finalizes after this delay.
- VWAP is computed from bar data (not tick data) and uses nz(volume,1)
as a fallback on symbols without volume data.
- On symbols with extreme trending behavior, Auto detection may
produce wide ranges that do not represent true consolidation. Manual
mode is recommended in such cases.
- Hold Quality above 95% typically indicates a very tight, well-held
range — but it is a historical description, not a prediction of
future behavior.
═══════════════════════════════════════════════
Risk Disclosure
═══════════════════════════════════════════════
This script is published for educational and analytical purposes only.
It is not financial advice, not a trading recommendation, and not a
strategy. Past behavior of any range or control structure does not
guarantee future outcomes.
All trading decisions are the sole responsibility of the user. Always
combine any single tool with your own analysis, risk management, and
broader market context. Never risk capital you cannot afford to lose.
Penunjuk Pine Script®






















