OPEN-SOURCE SCRIPT

GProf - Break & Retest

365
GProf - Break & Retest
═══════════════════════════════════════════

OVERVIEW

This indicator detects one complete sequence: consolidation against a key level, a breakout WITH momentum, and the retest of the broken level. It watches the levels for you, stays silent through weak drifts and fakeouts, and speaks at the two moments that matter — when a level breaks with force, and when price comes back to test it.

The core idea is polarity: a level that held for hours gets violated with conviction, and the trade is the market returning to confirm the flip — old support rejecting as new resistance, or old resistance holding as new support.

───────────────────────────────────────────
TWO CONSOLIDATION PATTERNS, ONE CONFIRMATION GATE

PATTERN 1 — TIGHT COIL: a short compressed window pressing directly against the level, with zero closes beyond it. Price knocking on a door.

PATTERN 2 — RANGE-SIT: price spends an extended window entirely on one side of the level, the whole range within a capped height of it, then breaks the boundary. This captures the classic premarket-range breakout or breakdown, where the premarket high or low is the boundary of the consolidation itself.

Either pattern must then be CONFIRMED. A break with no force is fully silent — no label, no alert:

• MOMENTUM CANDLE — the breakout (or a continuation candle within a few bars) has a body of at least a set percentage of the daily ATR; OR
• QUALIFIED FVG — a Fair Value Gap of a set minimum size prints within the confirmation window.

Whichever arrives first arms the setup, and the alert tells you which one it was.

───────────────────────────────────────────
LEVELS AND THE ONE-BREAK DOCTRINE

Tracked levels: PMH/PML, YH/YL, PDC, WH/WL — computed internally, non-repainting, with session boundaries read in exchange time so they hold up through daylight-saving changes and holiday-shortened weeks.

LIFETIME VIRGINITY: a level may signal ONE break per lifetime. The first close beyond it consumes the level; wicks never spend it — sweeps that close back are probes, not violations. A spent level renews when its value changes or at the session roll. This kills re-break noise: a level violated at midday cannot fire again in the evening.

LIVE-LEVEL MATURITY: running levels (WH/WL always; PMH/PML while the premarket window is open) must rest untouched for a set number of bars before they can arm — every new weekly high is technically a "break of WH," and this suppresses that churn while keeping the first quality break.

WHEN "YESTERDAY" ROLLS: Roll Mode is Auto by default — futures roll at the 18:00 ET session open, equities at the next regular-session open — so evening and overnight sessions trade against the levels of the session that just completed.

The full doctrine in one sentence: a level may signal one break per lifetime, provided it has aged while live and is broken with momentum.

───────────────────────────────────────────
THE RETEST — TWO SPECIES

IMMEDIATE KISS-BACK: while the breakout leg is still building, a return to within tolerance of the broken level fires the retest — the fast test-and-reject, often within a bar or two of the break.

SWING 50% RETEST: if price runs instead, the swing confirms, the leg's 50% level is drawn, and the deeper retracement to the 50% or the level — whichever price reaches first — fires the retest.

A+ FLAG: when the leg's 50% coincides with the broken level itself, the retest is tagged A+ — two independent trade logics agreeing on one price.

───────────────────────────────────────────
SIGNALS AND ALERTS

On the chart: the consolidation box, a "B&R [LEVEL]" label on the confirmed break, a dotted 50% line once the swing confirms, and a "RETEST [LEVEL]" label (with A+ when earned). Breaks that armed but failed are marked with a small x; unconfirmed breaks leave no trace.

Two independent alert stages, each toggleable:
• CONFIRMED BREAKOUT — the level, the direction, and which confirmation fired.
• RETEST ENTERED — the level and price, with the A+ tag when the 50% sits on the level. Off by default; many traders use the breakout alert to get to the chart and watch the retest form.

Alert setup: ONE alert per chart, condition "Any alert() function call", expiration Open-ended. The toggles in settings control what fires. Note: TradingView alerts snapshot settings at creation — after changing settings, recreate the alert.

───────────────────────────────────────────
HOW TO USE IT

Traders who study break-and-retest setups typically treat the breakout alert as the heads-up and the retest as the decision point — watching for a confirmation candle at the retest before acting. The consolidation box shows you what broke; the tags tell you how it was confirmed.

This indicator identifies structure and sequence. It does not generate buy/sell recommendations, does not place trades, and does not replace your own analysis and risk management.

───────────────────────────────────────────
TECHNICAL NOTES

• Non-repainting: every state transition confirms on bar close; ATR uses completed daily bars; no lookahead anywhere.
• Intraday timeframes only. Built for index and commodity futures but works on any liquid symbol; thresholds are a percentage of daily ATR with tick floors, so they travel across instruments and volatility regimes.
• Coil and range windows, momentum and FVG thresholds, maturity, timeouts, retest tolerance, and session times are fully configurable.

───────────────────────────────────────────
DISCLAIMER

This script is for informational and educational purposes only. It does not constitute financial, investment, or trading advice. A broken level retesting is a pattern, not a guarantee of future price behavior. All trading decisions made using this tool are solely the responsibility of the user.

Feragatname

Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, alım satım veya diğer türden tavsiye veya öneriler anlamına gelmez ve teşkil etmez. Kullanım Koşulları bölümünde daha fazlasını okuyun.