OPEN-SOURCE SCRIPT

Structural Liquidity Signals [BullByte]

427
Structural Liquidity Signals (SFP, FVG, BOS, AVWAP) [BullByte]

Short description
Detects liquidity sweeps (SFPs) at pivots and PD/W levels, highlights the latest FVG, tracks AVWAP stretch, arms percentile extremes, and triggers after confirmed micro BOS.

Full description

What this tool does

Structural Liquidity Signals shows where price likely tapped liquidity (stop clusters), then waits for structure to actually change before it prints a trigger. It spots:

Liquidity sweeps (SFPs) at recent pivots and at prior day/week highs/lows.
The latest Fair Value Gap (FVG) that often “pulls” price or serves as a reaction zone.
How far price is stretched from two VWAP anchors (one from the latest impulse, one from today’s session), scaled by ATR so it adapts to volatility.
A “percentile” extreme of an internal score. At extremes the script “arms” a setup; it only triggers after a small break of structure (BOS) on a closed bar.



Originality and design rationale, why it’s not “just a mashup”

This is not a mashup for its own sake. It’s a purpose-built flow that links where liquidity is likely to rest with how structure actually changes:
- Liquidity location: We focus on areas where stops commonly cluster—recent pivots and prior day/week highs/lows—then detect sweeps (SFPs) when price wicks beyond and closes back inside.
- Displacement context: We track the last Fair Value Gap (FVG) to account for recent inefficiency that often acts as a magnet or reaction zone.
- Stretch measurement: We anchor VWAP to the latest N-bar impulse and to the Daily session, then normalize stretch by ATR to assess dislocation consistently across assets/timeframes.
- Composite exhaustion: We combine stretch, wick skew, and volume surprise, then bend the result with a tanh transform so extremes are bounded and comparable.
- Dynamic extremes and discipline: Rather than triggering on every sweep, we “arm” at statistical extremes via percent-rank and only fire after a confirmed micro Break of Structure (BOS). This separates “interesting” from “actionable.”


Key concepts

SFP (liquidity sweep): A candle briefly trades beyond a level (where stops sit) and closes back inside. We detect these at:
Pivots (recent swing highs/lows confirmed by “left/right” bars).
Prior Day/Week High/Low (PDH/PDL/PWH/PWL).
FVG (Fair Value Gap): A small 3‑bar gap (bar2 high vs bar1 low, or vice versa). The latest gap often acts like a magnet or reaction zone. We track the most recent Up/Down gap and whether price is inside it.
AVWAP stretch: Distance from an Anchored VWAP divided by ATR (volatility). We use:
Impulse AVWAP: resets on each new N‑bar high/low.
Daily AVWAP: resets each new session.
PR (Percentile Rank): Where the current internal score sits versus its own recent history (0..100). We arm shorts at high PR, longs at low PR.
Micro BOS: A small break of the recent high (for longs) or low (for shorts). This is the “go/no‑go” confirmation.


How the parts work together

Find likely liquidity grabs (SFPs) at pivots and PD/W levels.
Add context from the latest FVG and AVWAP stretch (how far price is from “fair”).
Build a bounded score (so different markets/timeframes are comparable) and compute its percentile (PR).
Arm at extremes (high PR → short candidate; low PR → long candidate).
Only print a trigger after a micro BOS, on a closed bar, with spacing/cooldown rules.
What you see on the chart (legend)

Lines:
Teal line = Impulse AVWAP (resets on new N‑bar extreme).
Aqua line = Daily AVWAP (resets each session).
PDH/PDL/PWH/PWL = prior day/week levels (toggle on/off).
Zones:
Greenish box = latest Up FVG; Reddish box = latest Down FVG.
The shading/border changes after price trades back through it.
SFP labels:
SFP‑P = SFP at Pivot (dotted line marks that pivot’s price).
SFP‑L = SFP at Level (at PDH/PDL/PWH/PWL).
Throttle: To reduce clutter, SFPs are rate‑limited per direction.
Triggers:
Triangle up = long trigger after BOS; triangle down = short trigger after BOS.
Optional badge shows direction and PR at the moment of trigger.
Optional Trigger Zone is an ATR‑sized box around the trigger bar’s close (for visualization only).
Background:
Light green/red shading = a long/short setup is “armed” (not a trigger).


Dashboard (Mini/Pro) — what each item means

PR: Percentile of the internal score (0..100). Near 0 = bullish extreme, near 100 = bearish extreme.
Gauge: Text bar that mirrors PR.
State: Idle, Armed Long (with a countdown), or Armed Short.
Cooldown: Bars remaining before a new setup can arm after a trigger.
Bars Since / Last Px: How long since last trigger and its price.
FVG: Whether price is in the latest Up/Down FVG.
Imp/Day VWAP Dist, PD Dist(ATR): Distance from those references in ATR units.
ATR% (Gate), Trend(HTF): Status of optional regime filters (volatility/trend).


How to use it (step‑by‑step)

Keep the Safety toggles ON (default): triggers/visuals on bar‑close, optional confirmed HTF for trend slope.
Choose timeframe:
Intraday (5m–1h) or Swing (1h–4h). On very fast/thin charts, enable Performance mode and raise spacing/cooldown.
Watch the dashboard:
When PR reaches an extreme and an SFP context is present, the background shades (armed).
Wait for the trigger triangle:
It prints only after a micro BOS on a closed bar and after spacing/cooldown checks.
Use the Trigger Zone box as a visual reference only:
This script never tells you to buy/sell. Apply your own plan for entry, stop, and sizing.

Example:

Bullish: Sweep under PDL (SFP‑L) and reclaim; PR in lower tail arms long; BOS up confirms → long trigger on bar close (ATR-sized trigger zone shown).

snapshot

Bearish: Sweep above PDH/pivot (SFP‑L/P) and reject; PR in upper tail arms short; BOS down confirms → short trigger on bar close (ATR-sized trigger zone shown).

snapshot


Settings guide (with “when to adjust”)

Safety & Stability (defaults ON)
Confirm triggers at bar close, Draw visuals at bar close: Keep ON for clean, stable prints.
Use confirmed HTF values: Applies to HTF trend slope only; keeps it from changing until the HTF bar closes.
Performance mode: Turn ON if your chart is busy or laggy.

Core & Context

ATR Length: Bigger = smoother distances; smaller = more reactive.
Impulse AVWAP Anchor: Larger = fewer resets; smaller = resets more often.
Show Daily AVWAP: ON if you want session context.
Use last FVG in logic: ON to include FVG context in arming/score.
Show PDH/PDL/PWH/PWL: ON to see prior day/week levels that often attract sweeps.

Liquidity & Microstructure
Pivot Left/Right: Higher values = stronger/rarer pivots.
Min Wick Ratio (0..1): Higher = only more pronounced SFP wicks qualify.
BOS length: Larger = stricter BOS; smaller = quicker confirmations.
Signal persistence: Keeps SFP context alive for a few bars to avoid flicker.

Signal Gating
Percent‑Rank Lookback: Larger = more stable extremes; smaller = more reactive extremes.
Arm thresholds (qHi/qLo): Move closer to 0.5 to see more arms; move toward 0/1 to see fewer arms.
TTL, Cooldown, Min bars and Min ATR distance: Space out triggers so you’re not reacting to minor noise.

Regime Filters (optional)
ATR percentile gate: Only allow triggers when volatility is at/above a set percentile.
HTF trend gate: Only allow longs when the HTF slope is up (and shorts when it’s down), above a minimum slope.

Visuals & UX
Only show “important” SFPs: Filters pivot SFPs by Volume Z and |Impulse stretch|.
Trigger badges/history and Max badge count: Control label clutter.
Compact labels: Toggle SFP‑P/L vs full names.
Dashboard mode and position; Dark theme.


Reading PR (the built‑in “oscillator”)

PR ~ 0–10: Potential bullish extreme (long side can arm).
PR ~ 90–100: Potential bearish extreme (short side can arm).
Important: “Armed” ≠ “Enter.” A trigger still needs a micro BOS on a closed bar and spacing/cooldown to pass.


Repainting, confirmations, and HTF notes

By default, prints wait for the bar to close; this reduces repaint‑like effects.
Pivot SFPs only appear after the pivot confirms (after the chosen “right” bars).
PD/W levels come from the prior completed candles and do not change intraday.
If you enable confirmed HTF values, the HTF slope will not change until its higher‑timeframe bar completes (safer but slightly delayed).

Performance tips

If labels/zones clutter or the chart lags:
Turn ON Performance mode.
Hide FVG or the Trigger Zone.
Reduce badge history or turn badge history off.
If price scaling looks compressed:
Keep optional “score”/“PR” plots OFF (they overlay price and can affect scaling).

Alerts (neutral)

Structural Liquidity: LONG TRIGGER
Structural Liquidity: SHORT TRIGGER
These fire when a trigger condition is met on a confirmed bar (with defaults).

Limitations and risk

Not every sweep/extreme reverses; false triggers occur, especially on thin markets and low timeframes.
This indicator does not provide entries, exits, or position sizing—use your own plan and risk control.
Educational/informational only; no financial advice.


License and credits

© BullByte - MPL 2.0. Open‑source for learning and research.
Built from repeated observations of how liquidity runs, imbalance (FVG), and distance from “fair” (AVWAPs) combine, and how a small BOS often marks the moment structure actually shifts.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.