DARKPOOL ALGO
Guides/Phantom Structure Sentinel
Free Optimization Guide

Phantom Structure Sentinel Optimization Guide

What's on the chart

BOS/CHoCH lines. A flat horizontal line spans from the swing point that got broken to the bar it broke on, labeled "BOS" (Break of Structure — trend continues) or "CHoCH" (Change of Character — trend flips). Lime/above the line = bullish break, red/below the line = bearish break. Each break fires exactly once, at the moment it happens.

Order block zones. A shaded box marking the last opposing-color candle before a structural break — the "smart money" footprint of the move. Green-tinted = bullish, red-tinted = bearish. These stay on the chart, extending forward, until price closes back through them (mitigation).

Fair Value Gap (FVG) zones. A shaded box marking a 3-candle price imbalance during the impulse leg of a break. Same bull/bear coloring as order blocks, but FVG boxes are a fixed small width (not extending forward) and gradually fade in opacity as they age, so an old, unfilled FVG reads as "stale" without disappearing outright.

Gold-highlighted zone. Whichever order block or FVG zone is nearest to the most recent signal (within the Confluence Highlight Distance) turns gold. This marks the zone the current signal is reacting to — the sweep landing on an existing zone of interest is the strongest version of this setup. Only the latest signal's zone stays gold; an older signal's zone reverts to its normal color once a newer signal picks a different one.

Liquidity pool lines. Dashed orange horizontal lines marking clusters of equal highs/equal lows — the liquidity pools sweeps are detected against. Redrawn only at the chart's current last bar.

Expect Up / Expect Down markers. The signal. See below.

Panel (top-right). Market Trend, Reference Set size, Rolling Win Rate, and Status — see "Reading the panel" below.

Reading the signal

Every confirmed liquidity sweep produces exactly one call, and its direction is always the sweep's own direction — there's no secondary condition that can flip or block it:

  • Bearish sweep (price wicks above a prior high, closes back below it) → Expect Down, shown in red above the bar.
  • Bullish sweep (price wicks below a prior low, closes back above it) → Expect Up, shown in lime below the bar.

Hover any marker to see:

  • Which sweep type produced it (Bullish sweep / Bearish sweep).
  • The KNN classifier's read: "continuation-favored" (raises confidence in the call) or "reversal-favored, weaker conviction" (lowers confidence, but the call still stands) — or "insufficient history" if the reference set hasn't warmed up yet.
  • The confidence percentage behind that read.
  • Whether the signal is backed by a nearby order block/FVG zone (confluence).

The confidence percentage is inherently a small set of discrete steps, not a smooth number — with the default of 5 neighbors, a vote can only land on 3/5, 4/5, or 5/5 agreement, i.e. 60%, 80%, or 100%. That's expected behavior, not a bug: it's a direct readout of "how many of the k nearest historical sweeps agreed," not a continuously-varying probability.

Reading the panel

Row Meaning
Market Trend The structure layer's current trend state — Bullish, Bearish, or Undetermined (no break has happened yet on this chart). Useful when both an Expect Up and an Expect Down marker are visible on screen at once, since each sweep signal fires independently of the other.
Reference Set How many labeled historical sweeps the classifier has accumulated, out of its configured cap (e.g. "37 / 100").
Rolling Win Rate An approximate live pulse on classifier accuracy — compares each sweep's own live guess against that same sweep's eventual resolved outcome. Not a validated backtest metric; treat it as a rough, live-updating signal of whether the classifier currently has any edge on this chart, not a guarantee.
Status "Warming Up" until the reference set reaches twice the configured neighbor count (k); "Active" once the classifier has enough history to vote.

Configuring the inputs

Defaults are starting points established during initial build and testing — they have not been empirically optimized for any specific symbol or timeframe. Expect to adjust them per market.

Structure group

Input Default Effect
Pivot Left Bars / Pivot Right Bars 5 / 5 How many bars on each side confirm a swing high/low. Lower = more, smaller swings detected (more sensitive structure, more noise); higher = fewer, larger swings (cleaner structure, slower to confirm).
Swing Retention 50 How many swing highs/lows are kept in memory per side. Rarely needs changing — mainly affects how far back the pool-clustering logic can look.
Max Active Zones 20 Maximum order block/FVG zones shown at once (oldest evicted first). Lower this if zones are stacking into a wall of overlapping bands on a busy chart.
Zone Mitigation Buffer (x ATR) 0.1 How far past a zone's edge price must close before it's considered invalidated. Raise this if zones are disappearing too quickly on normal pullback noise; lower toward 0 for stricter (grazing-sensitive) invalidation.
Max Break Lines Shown 15 Maximum BOS/CHoCH lines/labels shown at once (oldest evicted first). Lower if break markers clutter a long-history chart.

Liquidity group

Input Default Effect
ATR Length 14 The volatility measure nearly every other distance/buffer setting in this script scales against. Shorter = more reactive to recent volatility; longer = smoother, slower-adjusting.
Pool Clustering Tolerance (x ATR) 0.1 How close together swing highs (or lows) must be to count as the same liquidity pool. Raise this on choppier markets where "equal" highs/lows are never exactly equal; lower it to require tighter clusters.

KNN group

Input Default Effect
KNN: Neighbors (k) 5 How many historical sweeps vote on each new classification. Must stay at least half of Reference Set Cap or the classifier can never leave "Warming Up." Higher k = smoother, more stable confidence read but slower to reflect a regime change; lower k = more reactive but noisier.
KNN: Reference Set Cap 100 Maximum labeled sweeps kept in memory. Higher = classifier "remembers" further back (more stable, slower to adapt to a changed regime); lower = adapts faster but on less data.
KNN: Outcome Labeling Horizon (bars) 10 How many bars after a sweep its outcome (continued vs. reversed) gets locked in. Shorter = faster-labeled reference set but judges outcome on less price action; longer = more considered labels but slower to build up the reference set.

Signal / Visual group

Input Default Effect
Show Signals Both Filter to only "Expect Up Only" or "Expect Down Only" to reduce visual noise when you're only trading one side of the market.
Max Sweep Markers Shown 15 Maximum Expect Up/Down labels shown at once (oldest evicted first).
Confluence Highlight Distance (x ATR) 0.6 How close a signal must be to an existing zone for that zone to highlight gold. Tighten this to only flag very precise zone hits as confluence; widen it to flag more zones as "nearby enough to matter."
Show Liquidity Pool Lines on Toggle the dashed orange pool-level lines.
Show Reference-Set Health Table on Toggle the top-right panel.
  • Trending markets / higher timeframes (4H and above): defaults work reasonably well as a starting point — structure breaks are less frequent but more meaningful at this scale.
  • Choppy/ranging markets or lower timeframes (15m and below): consider raising Pool Clustering Tolerance and Zone Mitigation Buffer, since "equal" highs/lows and clean zone invalidation both get noisier at faster timeframes.
  • New symbol, no track record yet: watch the Reference Set and Status fields before trusting any confidence read — a fresh chart or a rarely-swept symbol may sit in "Warming Up" for a while, during which the signal's direction is still valid (it never depends on the classifier) but its confidence annotation is not yet meaningful.