Spaces:
Sleeping
Download README.md from abyXsmart/FVG-Delta-Crypto-Core: direct link, hf CLI and curl.
- Browser
- Download file 29.9 kB
-
https://huggingface.co/spaces/abyXsmart/FVG-Delta-Crypto-Core/resolve/main/README.md
- Command line
-
hf download hf://spaces/abyXsmart/FVG-Delta-Crypto-Core/README.md
-
curl -L -o README.md https://huggingface.co/spaces/abyXsmart/FVG-Delta-Crypto-Core/resolve/main/README.md
license: mit
title: FVG-Delta Crypto Core v7.5
sdk: docker
emoji: π
colorFrom: blue
colorTo: indigo
pinned: true
short_description: Strict Smart-Money Scanner for MEXC Perpetuals
Instruction for maintainers and AI agents: The metadata block above (from the first --- to the second ---) must remain a valid Hugging Face Space header β keep every key, the order, spacing and the sdk: docker / emoji / colour / pinned lines exactly so hosting never breaks. Only the title and short_description values track the current release (now v7.5, "FVG-Delta Crypto Core").
FVG-Delta Crypto Core (v7.5)
A production-style MEXC UST-M perpetual scanner on closed 15m candles. It runs a strict, lock-forward staged Smart-Money model (Impulse β FVG β First-liquidity lock β BoS close β liquidity sweep β FVG interaction β verified entry), delivers Telegram alerts (screenshot first, message second), renders annotated chart screenshots, and serves a live auto-updating dashboard with an in-memory Trade History.
What this app does
- Scans MEXC UST-M pairs in shards with active-stage priority (every active setup is re-checked each cycle, plus a rotating shard of the full universe).
- Detects high-quality multi-candle impulse + FVG structures (not single-candle spikes).
- Enforces a strict, monotonic Stage 1 β 2 β 3 β 4 sequence that never silently regresses.
- Sends Telegram and browser alerts for Stage 5 verified entries only (screenshot first, message second) plus their TP1/TP2/SL/Break-even lifecycle. Stage 3 (FVG interaction) is now a dashboard-only milestone.
- Keeps closed Stage-4 trades in a durable Trade History β SQLite on the persistent disk at
/dataβ plus a JSON live-state snapshot, so trades and active setups survive restarts and are recalled (and re-validated) on boot. - Auto-updates the dashboard in place via polling β no full page reload.
- Uses LONG / SHORT direction tags consistently across UI, alerts, and history.
The strategy, in plain terms
The engine is hunting for the classic SMC continuation: a strong move leaves an unfilled gap (FVG), price pulls back and builds a liquidity pool, structure breaks in the trend direction (BoS), price then returns to sweep that liquidity and tap the FVG, and finally a confirmation candle fires the entry back in the trend direction.
Worked example (LONG / bullish context)
- Impulse + FVG β BTC rips up over 4 green 15m candles. Candle-1 high is below Candle-3 low β a bullish FVG gap forms inside the leg. The middle candle is a strong displacement candle (big body, ATR-normalized). Impulse leg locked.
- First liquidity lock β price pulls back and prints its first swing low.
That low must stay above the FVG top (by
RETRACEMENT_FVG_CLEARANCE_ATR) so the gap is still unmitigated. First liquidity = that swing low. BoS level = the impulse wick high (immutable). - Stage 1 (BoS close) β a candle closes above the impulse wick high, with the FVG still untouched and the first-liquidity low still untapped before that close. Now it is Stage 1 β not before.
- Stage 2 (sweep) β price rotates down and a candle breaks and closes below the first-liquidity low (a wick tap is not enough).
- Stage 3 (FVG interaction) β price continues down and touches the FVG zone. Telegram fires a Stage-3 interaction alert.
- Stage 4 (verified entry) β a bullish confirmation candle prints out of the FVG (strong body or strong rejection wick). Entry = its close. Telegram fires the Stage-4 entry alert with full levels.
SHORT context is the mirror image (bearish FVG, first swing high, BoS close below the impulse wick low, sweep above liquidity, rejection down from the FVG).
Why "lock-forward"?
Each stage is searched once and its index is locked into state. Later cycles only look for the next transition. This is the core v6.0 fix: previously a stage could vanish if a single per-cycle search window came up empty (e.g. because a swing needs 2 confirming bars), which is why almost nothing reached Stage 4. Now a stage is only lost on hard invalidation (a close back through the FVG against the setup) or expiry (TTL / max-age), never on a transient empty scan.
Dynamic SL / TP construction (v6.0)
After a Stage-4 confirmation:
- Stop loss is anchored just past the FVG far edge (
z.lowfor LONG,z.highfor SHORT) plus a smallSL_FVG_BUFFER_ATR. If a recent order-block / body swing sits just beyond the FVG withinOB_MAX_DISTANCE_ATR(default 1.0ΓATR), the stop anchors to that instead β but it is never placed far from the FVG. A minimum risk floor (MIN_STOP_ATR_MULT,MIN_STOP_PCT) prevents a single 15m candle from instantly stopping you out. - Risk unit
R = max(structural_distance, MIN_STOP_ATR_MULTΒ·ATR, entryΒ·MIN_STOP_PCT/100). - TP2 =
max(TP2_RR Β· R, nearest resting liquidity / opposing swing beyond entry)scanned overTP_SWING_LOOKBACKcandles. The chart/alert shows whether TP2 came from the 3R target or from a structural liquidity level (target_source). - TP1 = the midpoint between entry and TP2 (i.e. 50% of the target distance).
- Breakeven is a real outcome: once TP1 prints you move SL to entry, so if price
returns to entry after TP1 the trade is recorded as
Breakeven (TP1 then entry).
Engine rules that keep setups clean (v6.0)
- Sequential staging β stages never skip; Stage 3 is visible while waiting for a clean confirmation (no more 0β4 jumps).
- FVG clean for Stage 1 & 2 β any candle entering the FVG before the liquidity sweep invalidates the setup. Only Stage 3 & 4 involve the FVG being entered.
- Stage-3 invalidation β a close back through the FVG after interaction means the setup is dead and is never promoted to Stage 4.
- Only new opportunities β a confirmation whose SL/TP already played out is discarded (not shown, not recorded). Only genuinely fresh, live setups reach Stage 4 and stay active until SL / TP2 / breakeven.
For the full maintainer/agent handover (architecture, fix log, update rules) see
AGENT.md.
Worked numbers (the live CROSS_USDT SHORT this build detected):
entry 0.085920, SL 0.087030 (above entry, just past the FVG), risk R β 0.00111,
TP2 0.082589 (β entry β 3R), TP1 0.084255 (halfway entryβTP2), source 3R.
Chart overlays
- Candles + EMA21
- FVG zone rectangle (anchored to the real 3-candle imbalance, extended to the current price area)
- Impulse leg line
- First liquidity line
- BoS level line + BoS anchorβbreak segment (anchor marker on the impulse wick extreme, break marker on the close-break candle)
- Entry / SL / TP1 / TP2 (Stage 4)
Telegram behavior (Stage 3 / 4)
- Stage 1, Stage 2 and Stage 3 are dashboard-only (no Telegram).
- Stage 5 alerts send in strict order: 1) chart screenshot, 2) message text, to Telegram and the browser.
- Stage 3 = FVG-interaction context (dashboard). Stage 4 = scored screening room. Stage 5 = verified entry (entry/SL/TP1/TP2/R:R/leverage).
- An anti-spam cooldown (
ALERT_COOLDOWN_SECONDS) and per-stage "alerted" flags prevent duplicates.
Telegram delivery on Hugging Face (reverse proxy required)
Hugging Face Spaces block direct outbound traffic to api.telegram.org (an
anti-spam / anti-bot policy). With nothing else configured the engine reaches MEXC
fine but its Telegram alerts silently never arrive β the single most common "alerts
stopped working" cause. The fix is a free, self-owned reverse proxy that forwards
your bot's calls to Telegram.
Setup (about 5 minutes, browser only β no install, no card, phone-friendly):
- Open the Deno Deploy dashboard and sign in (GitHub or Google β free).
- Click New Playground, delete the sample code, and paste in the entire contents
of
telegram_proxy_worker.js(shipped flat in this project), then Save & Deploy. - Copy the project URL shown at the top, e.g.
https://your-name-123.deno.dev. - On the engine's Settings page, set Telegram API Base URL to that URL (no trailing slash) and Save.
- Click Test Telegram β the test message should arrive. Done.
The bot token only ever transits your own worker (nothing is stored or logged). Deno
Deploy's free tier allows roughly 100k requests/day β far more than a 24/7 alert bot
needs. To rotate it later, redeploy and update the URL in Settings; no restart needed.
Leave Telegram API Base URL at its default (https://api.telegram.org) only if you
host somewhere that can reach Telegram directly.
Any equivalent Telegram Bot API reverse proxy works too (e.g. a self-hosted telebridge instance) β just paste its base URL into the same Settings field. The proxy must forward
/bot<token>/<method>verbatim.
Persistence (Hugging Face mounted disk at /data)
The Space uses a persistent disk mounted at /data (Xet-backed). The engine writes
files there if absent and reads them on boot, so state and history survive restarts.
- Trade History β SQLite at
PERSIST_DIR/fvgdelta.db(defaultPERSIST_DIR=/data). Queryable, which powers every metric and time filter on the Trade History dashboard. - Live state β JSON at
PERSIST_DIR/state.jsonβ active Stage 1β4 setups (each with timestamp-anchored locks), open Stage-4 trades, and counters, rewritten each scan cycle. - Boot recall β on start the engine opens/creates the DB, loads
state.json, and re-validates recalled setups against the current timeline: Stage 1β2 are re-checked against TTL/age, while Stage 3β4 are kept unless invalidated. - Graceful fallback β if
/datais not writable the engine falls back to a local./datadirectory so it still runs anywhere (history is then container-local).
Example (worked): a confirmed Stage-4 BTC_USDT long is saved to state.json; the Space
restarts; on boot the long is recalled with its entry/SL/TP and locked candle timestamps,
re-pinned to the freshly loaded candles, and continues its TP1βTP2/SL/BE lifecycle.
Trade History
- A live Stage-4 open is tracked in
STAGE3_ACTIVEand stays visible in the Stage-4 table until it resolves. - A history row is written (and persisted to SQLite) when a genuine Stage-4 entry hits SL / TP1 / TP2 / break-even. A confirmation that already played out before detection is opened and immediately resolved into history with the correct outcome (so legitimate setups are never dropped). No phantom rows on plain re-detection.
- Newest-first. Each row links to
/api/trade_chart.png(the stored setup snapshot, not the live chart) and to TradingView. - The Trade History heading is a link to a full dashboard at
/tradesβ win rate by TP/SL/BE, net result in R, profit factor, most-traded pair, long/short performance, best/worst trade, average leverage, an outcome donut, a cumulative-R curve, top-pairs and long/short charts, time filters (15m β all time), and a sortable, searchable closed-trades table. It has a Return To Main Page link in its header.
Dashboard (v6.0)
- Animated scanning logo, wavy header banner, a v7.5 live badge, a settings gear, and a live heartbeat showing the last scan time.
- Grouped, collapsible Market Intelligence rail and Engine Metrics strip: symbols, scanned/cycle, zones, and per-stage counts (Stage 1/2/3/4 = Dashboard, Stage 5 = Telegram).
- Stage 1β4 tables + Trade History + Recent Alerts + Runtime Events.
- Client polls
/api/stateeveryDASHBOARD_REFRESH_SECONDSand patches rows/metrics in place β no reload blink.
API endpoints
GET /β main dashboardGET /tradesβ full Trade History dashboard (metrics + charts + filterable table)GET /healthGET /api/stateβ full live state (stats, per-stage states, alerts, events, trade history)GET /api/stagesGET /api/trades?since=<unix>&limit=<n>β persisted closed trades (powers/trades)GET /api/marketβ crypto market-context indicators (Fear & Greed, capital rotation, funding/OI, bias, squeeze, news, composite)GET /api/test_telegramβ send a test message to confirm bot token + chat id workGET /api/chart.png?symbol=BTC_USDTβ live-state chartGET /api/trade_chart.png?symbol=BTC_USDT&opened_ts=...β closed-trade snapshot from a stored history rowGET /market.jsβ dashboard market-rail / notifications / Telegram-test script
Run locally
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
export TELEGRAM_BOT_TOKEN=... TELEGRAM_CHAT_ID=...
uvicorn app:app --host 0.0.0.0 --port 7860
On HuggingFace Spaces (Docker SDK) the container runs start.sh, which runs
preflight_check.py then launches uvicorn on $PORT (default 7860). Set
TELEGRAM_BOT_TOKEN and TELEGRAM_CHAT_ID as Space secrets.
Key files (all flat β no folders, so they upload individually)
app.pyβ engine, scanner, charting, dashboard, persistence, APItrades.htmlβ Trade History dashboard page (served by/trades)market.jsβ market rail + browser notifications + Telegram-test (served by/market.js)telegram_proxy_worker.jsβ the free Deno Deploy reverse proxy for Telegram (see "Telegram delivery on Hugging Face")Dockerfileβ Hugging Face Docker SDK build (non-root uid 1000 so/datais writable)preflight_check.pyβ env + module readiness checkrequirements.txtβ pinned deps (includesbrotliso MEXC's brotli responses always decode; SQLite is stdlib)start.sh/run_one_shot.shβ entrypointsSTRATEGY_DETAILED_SPEC.txtβ exact strategy behaviorVARIABLES_AND_SECRETS_GUIDE.txtβ every env var, with tuning guidanceAGENT.mdβ maintainer / AI-agent handover guide (fix log + safe-update rules)
What's new in v7.0
- Settings page (
/settings) β every env-configurable option in plain language with presets, custom values, per-field "Make Default", and a global Save All / Reset To Default. Written tosettings.jsonon the persistent disk and applied live (no restart). It is now the single source of config, including the Telegram bot token and chat I.D (the Space is private). Example: set Promotion Score to 80 and Alert Cooldown to 30 minutes, click Save, and the engine re-scores against the new threshold on the next cycle. - Telegram delivery fixed β the bot uses its own IPv4-pinned connection plus a
stdlib fallback, and now routes through a configurable Telegram API Base URL
(
TELEGRAM_API_BASE, in Settings). Hugging Face blocks direct traffic toapi.telegram.org, so point it at the freetelegram_proxy_worker.jsreverse proxy on Deno Deploy and alerts deliver reliably. See "Telegram delivery on Hugging Face". - Stage 5 only receives Telegram and browser alerts (Stage 3 Telegram removed).
- Browser alert sound β a soft chime (cached to disk) plays on every alert when enabled; toggle it in Settings.
- 24h Stage 1 & 2 TTL; Stages 3/4/5 never expire on age (only invalidation / trade outcome).
- Rebranded to FVG-Delta Crypto Core; new wavy header, grouped collapsible metric containers, alternating Stage-4 filter-row blocks, and a single Chart β link that opens TradingView (the pair name still opens the annotated screenshot).
- Performance β symbols/icons cached to disk and reused across restarts; HTF cache bounded; Telegram decoupled from the scan session.
What's new in v6.0
- Cleaner impulses β staggered/cluttered legs are rejected; a real impulse is a tight burst of 3+ consecutive displacement candles that creates the FVG.
- Stage-1 correctness β a hard gap is enforced between the first-liquidity line and the FVG, and BoS must sit above liquidity for longs (below for shorts).
- SL breathing room β stops anchor beyond the FVG-interaction wick, not the exact edge.
- Automatic leverage β sized so hitting SL β 50% of margin, snapped to 20x/25x/.../50x and capped to the pair's exchange max. TP is uncapped.
- Majors lead the scan β the universe is ranked by 24h turnover; tokenized stocks/commodities/indices are excluded.
- Per-trade Telegram lifecycle β Entry β TP1 (close 50% + move SL to break-even) β SL Hit / TP2 Hit / Break-Even Close, each on candle close.
- Trade History = terminal Stage-4 results only (no Stage 1β3 invalidation noise).
- Dashboard β compact "Ver. 6.0" badge, mobile-optimised header, responsive tables, Title-Case events, +/- collapse toggles, Stage-4 (amber) and Trade-History (violet) theming, MEXC-scale prices, and browser-local timestamps.
v6.0 maintenance update
- Drift fix (core stability) β every locked reference (impulse, FVG, BoS, liquidity, sweep, interaction) is now anchored to its candle timestamp and re-resolved to the current index each cycle (
_rebase_indices). Previously these were absolute indices into a rolling window that scrolled by one candle per close, so over time lines/zones scattered and confirmed Stage-4 setups regressed or vanished. Setups now stay pinned and stable no matter how long the engine runs. - Stage 3 & 4 are permanent β TTL/age expiry applies to Stage 1 & 2 only. Stage 3/4 leave solely via real invalidation (a close through the FVG) or a Stage-4 outcome (SL / TP2 / break-even). Stage 3 keeps the wick-through-then-close-inside nuance (valid); a full body close past the FVG removes it.
- Persistence to
/dataβ SQLite trade history + JSON live state, recalled and re-validated on boot (see Persistence above). - Trade History dashboard at
/tradesβ full visual performance metrics, charts, time filters and a searchable table, themed to match the main dashboard, with a Return To Main Page link. - Market pulse rail β Fear & Greed, capital rotation (BTC.D / USDT.D / TOTAL3 with trend arrows and a plain-language verdict such as BTC Leading / Alt Season / Risk-Off Β· Cash Bid), funding + open interest, directional bias, squeeze risk, a 0β100 composite, and a live headline. All sourced from CoinGecko + alternative.me (no exchange keys; Binance/Bybit are intentionally avoided because they are geo-blocked on Hugging Face).
- Browser notifications β a header toggle (in the same tag group) requests permission and fires native notifications on new Stage 3/4 alerts; its label/colour reflects on/off state. Works alongside Telegram.
- Telegram β modern slim message divider and icons, resilient delivery (the text alert is sent even if the chart image fails to render), a boot connectivity ping, and a Test Telegram button so you can confirm your token + chat id immediately.
- Responsive header β the logo and title form one block with the indicator tags arranged beneath it, and a uniform circular sweep animation that no longer distorts across screen sizes.
- Dockerfile added for the Hugging Face Docker SDK build.
v7.0 maintenance patch β throughput, intrabar exits, invalidation log
This patch fixes engine throughput and adds two operator-facing improvements. No strategy or stage-detection logic changed (impulse, FVG, liquidity, BoS and entry are untouched), and the dashboard aesthetics are unchanged.
- Faster, fuller pair flow (no more "stuck climbing from Stage 1"). Every cycle the
scanner now re-checks every committed setup and every Stage-0 pair that already
holds a candidate zone, so pairs advance promptly instead of waiting for their shard to
rotate (~4 minutes). To make that affordable, a short-TTL 15m kline cache
(
BARS_CACHE_TTL_SECONDS, default 75s) stops the per-cycle re-check from re-pulling hundreds of pairs and throttling MEXC β the throttle that previously starved the funnel so few pairs reached Stage 3/4/5. The freshly-scanned multi-stage sorter still places a pair directly into Stage 2/3/4 on first sight. - Live trades exit on time, not on the candle. Committed Stage-4 (qualified) and Stage-5 (verified) setups always fetch a fresh window each cycle (they bypass the cache), so SL / Break-even / TP resolve intrabar β the moment price touches the level β and are recorded to Trade History within a cycle, without waiting for a 15m candle to close. Example: a setup that hits its stop 4 minutes into a 15m candle is closed and written to history on the next ~30s scan, not 11 minutes later.
- Permanent Trade-History snapshots. When a Stage-5 trade closes, the engine renders
the chart frozen at close time and saves the PNG to the persistent disk
(
/data/trade_snapshots/), storing its path on the trade row (in SQLite). The Trade History Pair link now opens that saved image, so the screenshot always shows the trade exactly as it played out β time-invariant and surviving restarts/rebuilds (older rows predating this fall back to a live render). - New "Stage 4 Invalidations" table (placed right after Trade History). It logs any
setup that left Stage 4 without being promoted to Stage 5 β a close-through
invalidation, a qualified entry that resolved while held by the filters, or a freshness
timeout β capturing the pair, a frozen snapshot, and the filter chips + score exactly as
they stood in Stage 4 (same two-row design as the Stage 4 table). It is an in-memory
3-day log: it is not written to persistent storage and is wiped on restart (by
design β it is only a recent-history aid). Its snapshots live in the ephemeral
/data/inval_snapshots/(also cleared on every boot). - Recent Alerts table β natural columns + horizontal scroll. The Recent Alerts table now uses the same layout schematic as the Stage tables: columns size to their content on desktop and the table scrolls horizontally (instead of squeezing) when content is wide, while keeping the collapse toggle and the width flow of the other tables. Runtime Events keeps its wrapping layout (its Message column reads better wrapped).
v6.0 maintenance build β fixes in this release
- Strict-pristine FVG. The Fair-Value Gap must stay completely untouched (any wick or body) from creation until the Stage-2 liquidity sweep β the only valid interaction is the Stage-3 tap after the sweep. Spurious interactions from impulse continuation, shallow retracements or secondary impulses no longer slip through. Toggle with
FVG_PRISTINE_STRICT(default on). - Dynamic gap to liquidity. The first-liquidity line always keeps real clean air from the FVG β never printed on it or bridged by a wick β using a gap that scales with both volatility (ATR) and the gap's own height.
- Multi-stage sorting. A freshly-scanned pair can be placed directly into Stage 2/3/4 (not forced to climb from Stage 1): the engine evaluates several recent zones and adopts the one already valid at the most advanced stage. Pairs already at Stage 3/4 stay locked until invalidation or expiry. Tune the look-back with
MAX_CANDIDATE_ZONES. - Telegram self-diagnosis. Credentials are read from your Space Variables and secrets and always override any bundled
.env. The Test Telegram button now reports the exact reason on failure (e.g. chat not found, Unauthorized, bot was blocked) plus a masked view of which credentials are loaded. - Working news feed. The market-rail headline now comes from free, no-key RSS (CoinDesk β Cointelegraph β Decrypt).
- MEXC pair logos are shown before each pair, pulled from MEXC and cached on the persistent disk (
/data/icon_map.json) so they load instantly after a restart without re-downloading. - UI polish. The version badge is properly aligned top-right on every screen size; pair names are dashed-underline links that open the chart; the Open Interest card explains what the value means for long/short scenarios; the toggle/link pills clearly read as clickable and the Browser-Alerts toggle is reliable; Runtime Events is collapsed by default; the Trade History page header is mobile-optimised.
- Dockerfile runs as a non-root user so the persistent
/datadisk is writable (SQLite trade history, live state and the icon cache).
v6.1 β Pre-entry filter stack (Stage 4 β Stage 5)
v6.1 keeps the v6.0 structural trigger unchanged and adds a scored qualifier layer so the bot takes fewer, higher-quality entries.
- Stage 4 β Qualified Entries (dashboard only): every confirmed setup lands here and is screened by six gates. Each pair shows a per-gate breakdown (green pass / red fail / grey disabled, β = compulsory) and a 0β100 quality score with a colour mode (Strong / Good / Weak / Reject).
- Stage 5 β Verified Entry (Telegram + Trade History): the old Stage 4. A setup is promoted here only when both compulsory gates pass and the score clears the threshold (default 70).
Gates: F1 Higher-timeframe bias (β
), F5 BTC correlation (β
), F3 Return volume,
F2 Premium/Discount, F4 Volatility regime, R7 Confirmation quality. Plus R8 β stops are
placed beyond the swept liquidity (anti stop-run). Every gate is an env toggle (default
on); every rejection is logged. Set FILTERS_ENABLED=false for legacy direct entries.
See STRATEGY_DETAILED_SPEC.txt (v6.1 addendum) and
VARIABLES_AND_SECRETS_GUIDE.txt Β§16 for the full math, defaults and examples.
A flat Dockerfile (HF Spaces, non-root for /data) is included.
v7.2 β Stage-5 Trade Guardian (post-entry conviction)
v7.2 leaves the entire v7.0 trigger and the v6.1 filter stack unchanged and adds a post-entry advisory layer. Once a setup is promoted to Stage 5 (a live, verified trade), the Guardian re-reads live market data every cycle and answers one question: does the trade still have fuel to reach TP, or is a reversal building?
- Two scores. It blends 15m candle structure (recent closes, close location, EMA(9)/EMA(21) alignment, pullback depth from peak) with order flow β live Cumulative Volume Delta from the MEXC trade tape (buyer- vs seller-initiated), Open Interest and funding from the MEXC ticker β plus lower-timeframe (Min5) BoS/CHoCH, the nearest opposing rejection zone, and a Bitcoin lower-timeframe kill-switch. The result is a Drive score (0β100, continuation fuel) and a Risk score (0β100, reversal pressure).
- Advisory verdicts. Short, sentence-cased guidance shown on the Stage-5 dashboard row, e.g. Strong β Hold For More Profit, Approaching Rejection Zone β Tighten SL, Move SL To Break-Even, No Push To Continue β Consider Exit. These update each cycle and never move your SL/TP or close the trade.
- One latched terminal verdict β Close Trade Before Reversal. This is the only
sticky verdict. It latches only when at least three independent reversal signals
agree (real exhaustion / hard adverse move, lower-timeframe CHoCH against, OI
hollowing into short-covering, decisive CVD against, BTC opposing, price at a
rejection zone), Risk β₯ 70, Drive < 45, the conditions persist for
GUARDIAN_TERMINAL_CONFIRMScycles, and confidence β₯GUARDIAN_TERMINAL_MIN_CONF. Once latched it is frozen for the life of the trade and sends a one-time Telegram + dashboard alert. It is advisory β it banks-before-reversal guidance, independent of TP1/TP2; the SL/TP/Break-even lifecycle remains the only thing that closes a trade. - Conviction in Trade History. At close, the final Drive/Risk, verdict, confidence and peak reward (MFE in R) are stamped on the Trade-History Conviction column.
- Frugal. Order-flow context is refreshed with one ticker request per cycle and only while a trade is live, so the layer costs nothing when nothing is open.
Disable the whole layer with GUARDIAN_ENABLED=false. All GUARDIAN_* and G_W_*
knobs are on the Settings page (Stage-5 Trade Guardian section) and documented in
VARIABLES_AND_SECRETS_GUIDE.txt Β§17 and the STRATEGY_DETAILED_SPEC.txt addendum.
v7.3 β Verdict Phase Machine (advisory stability)
The Guardian's advisory verdict now behaves like a trader watching the position rather than a readout that flips with every candle. The Drive/Risk chips stay tick-by-tick; the verdict sits above them as a calmer, strategic message.
- It tracks the trade journey. A stable, level-based phase β Entry Zone β Defending Entry β Toward TP1 β At TP1 β Toward TP2 β At TP2 β anchored to your own entry, stop and targets. The current phase is shown as a small tag on the verdict line.
- It reasons per phase. In the entry zone it judges whether the zone is holding or about to fail from repeated retests; after a breakout it asks whether the move is real continuation, a healthy pullback, a liquidity grab, or a fake move coming back for your stop; at TP1 it talks about securing a partial / moving to break-even and whether the runner can reach TP2.
- It stays steady. Messages are chosen from smoothed Drive/Risk and only change after they persist (confirm cycles) and a minimum hold time β so dynamic price wiggles no longer churn the verdict. Rising danger still warns immediately.
- Unchanged: the chips, the Drive/Risk scoring, the latched Close Trade Before Reversal verdict, and the stop-loss / break-even / take-profit lifecycle.
Tune it under Settings β "Stage 5 Β· Verdict Stability" (VERDICT_CONFIRM_CYCLES,
VERDICT_MIN_DWELL_SECONDS, VERDICT_SMOOTH_WINDOW, VERDICT_ZONE_BAND_ATR,
VERDICT_TPX_BUFFER_ATR); full docs in VARIABLES_AND_SECRETS_GUIDE.txt Β§18.