Spaces:
Sleeping
Sleeping
Download STRATEGY_DETAILED_SPEC.txt from abyXsmart/FVG-Delta-Crypto-Core: direct link, hf CLI and curl.
- Browser
- Download file 34.1 kB
-
https://huggingface.co/spaces/abyXsmart/FVG-Delta-Crypto-Core/resolve/main/STRATEGY_DETAILED_SPEC.txt
- Command line
-
hf download hf://spaces/abyXsmart/FVG-Delta-Crypto-Core/STRATEGY_DETAILED_SPEC.txt
-
curl -L -o STRATEGY_DETAILED_SPEC.txt https://huggingface.co/spaces/abyXsmart/FVG-Delta-Crypto-Core/resolve/main/STRATEGY_DETAILED_SPEC.txt
34.1 kB
| FVG-Delta Crypto Signal Engine β Strategy Detailed Spec (v6.0) | |
| =============================================================== | |
| Overview | |
| -------- | |
| The engine is a lock-forward staged Smart-Money state machine driven by a strict | |
| sequence on CLOSED 15m candles: | |
| 0) FVG + impulse context detected (zone acquired) | |
| 1) First retracement liquidity locked + BoS CLOSE through the impulse wick extreme | |
| 2) Price returns and BREAKS+CLOSES past the first liquidity (sweep) | |
| 3) Price interacts with the FVG zone | |
| 4) Opposite-direction confirmation candle -> verified entry (dynamic SL/TP) | |
| "Lock-forward" means: each stage transition is searched ONCE and its bar index is | |
| stored in state. Subsequent cycles only search for the NEXT transition. A stage is | |
| never lost to a transient empty per-cycle search window β only to hard invalidation | |
| or TTL/age expiry. (This is the central v6.0 correctness fix.) | |
| Universe & timeframe | |
| -------------------- | |
| - Exchange: MEXC UST-M perpetuals (contract.mexc.com) | |
| - Timeframe: 15m, CLOSED candles only (the most recent closed candle is bars[-2]; | |
| the still-forming candle bars[-1] is never used for decisions) | |
| - Scanner: sharded full-universe rotation + every active-stage symbol re-checked each cycle | |
| - Network: requests send Accept-Encoding gzip,deflate AND the `brotli` package is | |
| installed, so MEXC brotli responses always decode (a missing brotli decoder was a | |
| silent data-layer failure mode). | |
| Core definitions | |
| ---------------- | |
| - FVG bullish: candle1.high < candle3.low (gap = [candle1.high, candle3.low]) | |
| - FVG bearish: candle1.low > candle3.high (gap = [candle3.high, candle1.low]) | |
| - Impulse wick extreme (immutable BoS level once locked): | |
| - bullish = highest wick high in the validated impulse leg | |
| - bearish = lowest wick low in the validated impulse leg | |
| - First retracement liquidity: | |
| - bullish = first post-impulse swing LOW that stays clear ABOVE the FVG top | |
| - bearish = first post-impulse swing HIGH that stays clear BELOW the FVG low | |
| Impulse qualification (detect_latest_zone) | |
| ------------------------------------------ | |
| A 3-candle FVG (i-1, i, i+1) is accepted only if the middle/displacement candle and | |
| its leg pass ALL of: | |
| - Gap size >= 0.12 * ATR | |
| - Displacement candle body >= 0.40 * ATR and range >= 0.75 * ATR | |
| - Gap not instantly refilled by the next 1-2 candles | |
| - Impulse leg has >= MIN_IMPULSE_CANDLES same-direction candles, with at most | |
| MAX_OPPOSING_INSIDE_IMPULSE opposite candles inside it | |
| - Leg body sum >= MIN_IMPULSE_BODY_MULT * ATR (scaled by leg length) | |
| - Leg range >= MIN_IMPULSE_RANGE_MULT * ATR and >= MIN_VELOCITY_RANGE_MULT * ATR | |
| - Impulse progression ratio >= IMPULSE_PROGRESS_MIN_RATIO | |
| - Directional body dominance >= 62% and displacement >= 0.90 * ATR | |
| - Internal swing noise <= IMPULSE_NOISE_MAX_SWINGS | |
| - Direction flips <= IMPULSE_MAX_ALTERNATIONS (rejects choppy green-red-green-red legs) | |
| - Impulse origin sits at/near a recent swing low (bullish) / high (bearish) | |
| A single long candle alone is never enough. | |
| Stage logic (strict, lock-forward) | |
| ---------------------------------- | |
| Stage 0 | |
| - A zone is acquired (FVG + impulse). Waiting for first liquidity + BoS. | |
| Stage 1 (Qualified) β requires ALL: | |
| 1) First retracement liquidity identified and LOCKED (stays clear of FVG by | |
| RETRACEMENT_FVG_CLEARANCE_ATR) | |
| 2) A candle CLOSE breaks the impulse wick extreme (BoS close): | |
| - bullish: close > impulse wick high | |
| - bearish: close < impulse wick low | |
| 3) Before that BoS close: the FVG is NOT mitigated, AND the first liquidity is NOT tapped | |
| - Before the BoS close it is NOT Stage 1 (it stays Stage 0). | |
| - The BoS level is immutable once locked from the impulse wick extreme. | |
| Stage 2 | |
| - Requires Stage 1. | |
| - A 15m candle BREAKS AND CLOSES past the first liquidity (a wick tap is NOT enough): | |
| - bullish: close < liq_level - buffer | |
| - bearish: close > liq_level + buffer | |
| Stage 3 | |
| - Requires Stage 2. | |
| - Price interacts with the FVG zone (candle overlaps [fvg_low, fvg_high] within buffer). | |
| - Interaction-only; does NOT by itself create a verified entry. | |
| Stage 4 (verified entry) | |
| - Requires Stage 3. | |
| - An opposite-direction confirmation candle appears (resuming the trend out of the FVG): | |
| - bullish entry: bullish candle with strong body (>= 0.55*ATR) OR strong lower-wick | |
| rejection (lower_wick/range >= 0.45 and body >= 0.18*ATR) | |
| - bearish entry: mirror with upper wick | |
| - Entry = confirmation candle close. Dynamic SL/TP are built (see below). | |
| Invalidation & expiry | |
| --------------------- | |
| - HARD invalidation (Stage 1..3): a candle CLOSE back through the FVG against the | |
| setup direction (bullish: close < fvg_low - buf; bearish: close > fvg_high + buf) | |
| -> state reset, zone re-acquired fresh. | |
| - TTL: zone older than ZONE_TTL_SECONDS or MAX_ZONE_AGE_CANDLES -> reset. | |
| - Stage 4 resolution: only candles that close AFTER the entry candle can resolve a | |
| live Stage-4 (SL / TP1 / TP2). This prevents pre-entry candles from instantly | |
| invalidating a fresh setup. | |
| Dynamic SL / TP (build_trade_levels) | |
| ------------------------------------ | |
| SL (LONG): | |
| protective = min(last_candle_before_confirmation.low, deepest FVG-interaction low) | |
| sl = protective - SL_FVG_BUFFER_ATR*ATR | |
| if sl is still inside the FVG (sl > fvg_low - buffer): sl = fvg_low - SL_FVG_BUFFER_ATR*ATR | |
| -> stop is dynamic but never rests inside the imbalance. | |
| SL (SHORT): mirror, using highs and fvg_high. | |
| Risk unit: | |
| R = max(structural_distance, MIN_STOP_ATR_MULT*ATR, entry*MIN_STOP_PCT/100) | |
| TP2: | |
| rr_target = entry +/- TP2_RR * R | |
| swing_target = nearest resting liquidity / opposing swing beyond entry within | |
| TP_SWING_LOOKBACK candles | |
| TP2 = the farther of {rr_target, swing_target}; target_source records which one. | |
| TP1: | |
| TP1 = midpoint(entry, TP2) (i.e. 50% of the target distance β NOT 1.5R) | |
| Leverage suggestion: derived from stop distance % (tighter stop -> higher suggested leverage). | |
| Direction labeling (v6.0) | |
| ------------------------- | |
| - External/UI/alerts/history use LONG / SHORT only. | |
| - bullish/bearish are internal labels and are not shown in direction outputs. | |
| Chart overlay requirements | |
| -------------------------- | |
| Candles + EMA21, FVG zone rectangle, impulse leg line, first liquidity line, | |
| BoS level line, BoS anchor marker + break marker + anchor->break segment, and | |
| Entry/SL/TP1/TP2 when Stage 4 is active. | |
| Alerts | |
| ------ | |
| - Telegram: Stage 3 and Stage 4 ONLY (Stage 1/2 are dashboard-only). | |
| - Delivery order: screenshot first, then text. | |
| - Stage 3 = interaction context; Stage 4 = verified entry details. | |
| - Cooldown + per-stage alerted flags prevent duplicate sends. | |
| Trade history (in-memory only) | |
| ------------------------------ | |
| - Storage: TRADE_HISTORY in-memory deque (session-scoped). No disk persistence; the | |
| HuggingFace Spaces filesystem is ephemeral/read-only; history is wiped on restart. | |
| - A live Stage-4 open is registered in STAGE3_ACTIVE and shown in the Stage-4 table | |
| until it resolves. | |
| - A history row is written when a genuine Stage-4 entry resolves to SL / TP1 / TP2 / | |
| invalidation / expiry. A confirmation that already played out before detection is | |
| opened and immediately resolved with its correct outcome (legit setups are never | |
| dropped). No phantom rows on plain stage re-detection. | |
| - Newest-first. History "Chart" links render the STORED setup snapshot via | |
| /api/trade_chart.png (not the live chart). | |
| Dashboard behavior | |
| ------------------ | |
| - No full page reload. Client polls /api/state and patches rows/metrics in place. | |
| - Header: v6.0 ACTIVE badge + live last-scan heartbeat. | |
| - Stage 1/2 cards labeled Dashboard; Stage 3/4 cards labeled Telegram. | |
| =============================================================== | |
| v6.0 ADDENDUM β Engine refinements (supersedes conflicting text above) | |
| =============================================================== | |
| Sequential staging (no skipping) | |
| -------------------------------- | |
| Stage is now the sequentially-derived value from LOCKED indices (bos_break_idx, | |
| stage2_break_idx, fvg_interaction_idx). The old max() that could force a jump | |
| 0 -> 4 (skipping Stage 3) was removed. Stage 3 is therefore visible whenever an | |
| FVG interaction has printed but no clean confirmation exists yet. | |
| FVG-clean rule for Stage 1 & 2 | |
| ------------------------------ | |
| While a setup is at Stage 1 or 2 the FVG must remain completely untouched. If any | |
| candle enters the FVG BEFORE the first-liquidity sweep, the textbook order is | |
| broken and the setup is invalidated ("FVG touched before liquidity sweep"). Only | |
| Stage 3 (interaction) and Stage 4 (confirmation) involve the FVG being entered. | |
| Stage-3 invalidation (never promote to Stage 4) | |
| ----------------------------------------------- | |
| After the FVG interaction, if any candle CLOSES back through the FVG against the | |
| setup (bullish: close < fvg_low - buf; bearish: close > fvg_high + buf) BEFORE a | |
| clean confirmation, the setup is a Stage-3 invalidation and is reset. It is never | |
| promoted to Stage 4. Only a clean reversal out of the FVG with a valid | |
| confirmation candle becomes Stage 4. | |
| Freshness gate (only NEW opportunities) | |
| --------------------------------------- | |
| When a Stage-4 confirmation is found, the engine checks _levels_already_hit(): | |
| if SL or TP1 or TP2 were already touched by candles AFTER the entry candle, the | |
| setup already played out and is DISCARDED silently (not shown at any stage, not | |
| written to Trade History). This is why a single-instant snapshot rarely shows | |
| Stage 4 β only confirmations whose entry candle is the latest closed candle (and | |
| have not moved yet) qualify and stay live. Over a continuous live session these | |
| accumulate and resolve into Trade History. | |
| Dynamic SL (FVG-anchored, not distant) | |
| -------------------------------------- | |
| LONG: anchor = z.low (FVG far edge). If a recent order-block / body swing low | |
| sits BELOW z.low but within OB_MAX_DISTANCE_ATR*ATR, anchor to it instead. | |
| sl = anchor - SL_FVG_BUFFER_ATR*ATR. SL never sits far from the FVG. | |
| SHORT: mirror with z.high and body highs. | |
| Risk floors (MIN_STOP_ATR_MULT, MIN_STOP_PCT) still apply so one candle can't | |
| instant-stop. TP2 = max(TP2_RR*R, nearest resting liquidity). TP1 = midpoint. | |
| Outcome resolution (order-aware) + Breakeven | |
| -------------------------------------------- | |
| _sequential_outcome() walks post-entry candles in TIME ORDER: | |
| - SL touched before TP1 -> "Hit SL" | |
| - TP2 touched -> "Hit TP2" | |
| - TP1 touched, then price returns to entry -> "Breakeven (TP1 then entry)" | |
| (models the user moving SL to breakeven once TP1 prints) | |
| - TP1 touched, still running -> stays live (not terminal) | |
| Only SL / TP2 / Breakeven are terminal and write a Trade History row. | |
| BoS plotting | |
| ------------ | |
| BoS is a HORIZONTAL line at the impulse wick extreme drawn from the anchor | |
| (impulse-extreme) candle across to the candle that CLOSED through it. A diamond | |
| marks the anchor (swept extreme); an arrow marks the breaking candle; a dotted | |
| vertical tick connects the level to the break candle's close. No drooping diagonal. | |
| ================================================================================ | |
| v6.0 ADDENDUM β Refinements from 10h back-test (supersedes conflicting text above) | |
| ================================================================================ | |
| IMPULSE QUALITY | |
| - A valid impulse is a TIGHT one-way displacement of >=3 consecutive same-direction | |
| candles that CREATES the FVG and does not re-enter/invalidate it. Legs with too | |
| many opposing candles, frequent direction flips, or staggered structure are | |
| rejected (IMPULSE_MIN_CONSEC_DISPLACEMENT=3, IMPULSE_MAX_ALTERNATIONS=1, | |
| IMPULSE_MIN_DIR_BODY_RATIO=0.68, IMPULSE_NOISE_MAX_SWINGS=4). The gap/displacement | |
| candle must itself be a strong body (>=50% of its range). | |
| FIRST RETRACEMENT (Stage 1) | |
| - The FIRST retracement is either (a) a single candle that closes past the OPEN of | |
| the immediate impulse candle, or (b) a 2+ candle counter move. Its extreme is the | |
| first-liquidity line. Later retracements may occur but the FIRST BoS stays intact. | |
| - HARD GAP: the first-liquidity line can NEVER rest on the FVG edge; it must clear | |
| the FVG by >= RETRACEMENT_MIN_FVG_GAP_ATR*ATR so price can sweep liquidity INTO | |
| the gap, BoS into that gap, THEN tap the FVG. | |
| - INVARIANT: for longs the BoS (impulse high) sits ABOVE the liquidity line; for | |
| shorts BoS sits BELOW. A setup that would invert this never reaches Stage 1. | |
| STAGE 3 / STAGE 4 | |
| - Stage 3 invalidates only on a CLOSE beyond the FVG. A wick THROUGH the FVG that | |
| CLOSES back inside remains valid and can still produce a Stage-4 entry. | |
| - A long rejection wick with an opposite-direction close is a valid confirmation. | |
| - SL has breathing room: it anchors beyond the interaction wick (+ SL_WICK_BUFFER_ATR) | |
| rather than the exact FVG edge. | |
| MONITORING & LIFECYCLE | |
| - Stage 3 and Stage 4 symbols are re-checked every cycle and resolve on CLOSED | |
| candles, so expected actions fire at candle close, not on shard rotation. | |
| - Stage 4 emits a per-trade alert chain: Entry -> TP1 (close 50% + SL to break-even) | |
| -> terminal SL Hit / TP2 Hit / Break-Even Close. Only terminal Stage-4 outcomes | |
| are written to Trade History; all Stage 1-3 invalidations are removed beforehand. | |
| LEVERAGE | |
| - Automatic, volatility-aware: leverage = round_to_5(50 / stop_distance_%), | |
| clamped 20x..50x and to the pair's exchange max. Wider stop -> lower leverage. | |
| TP uncapped (rides structural TP1/TP2). | |
| UNIVERSE | |
| - Liquidity-ranked: top-N USDT perps by 24h turnover, majors first; tokenized | |
| equities/commodities/indices excluded (incl. the xStock family via "STOCK"). | |
| FVG PLOTTING | |
| - The FVG box is drawn from the identified imbalance candle extending right to the | |
| current price. | |
| =============================================================================== | |
| v6.1 ADDENDUM β PRE-ENTRY FILTER STACK + STAGE SPLIT (4 -> 4 & 5) | |
| =============================================================================== | |
| Motivation | |
| ---------- | |
| The v6.0 trigger correctly identifies the SMC continuation sequence but enters on | |
| the gap with NO market context, sampling high- and low-quality setups equally. v6.1 | |
| adds a scored qualifier layer between confirmation and entry. The structural trigger | |
| logic is UNCHANGED; the new layer only decides which confirmed setups are allowed to | |
| become live trades. | |
| Stage split | |
| ----------- | |
| The old Stage 4 (verified entry) is split into two: | |
| Stage 4 "Qualified Entries" β every confirmed setup lands here, pass OR fail. It | |
| is a DASHBOARD-only screening room where the filter stack is evaluated and | |
| displayed per pair. No Telegram, no Trade-History. | |
| Stage 5 "Verified Entry" β the old Stage-4 trade (same amber accent, same | |
| Telegram alert, same Trade-History-on-expiry behaviour). Only filter-pass | |
| setups reach it. | |
| This makes the screening fully transparent: you see EVERY setup that the strategy | |
| would previously have entered, with a per-gate breakdown and a 0-100 quality score, | |
| and only the genuinely high-context ones are promoted and alerted. | |
| The filter checkpoint (runs each cycle while a setup sits in Stage 4) | |
| -------------------------------------------------------------------- | |
| A single evaluate_entry_filters() scores six gates. Each returns pass/fail + a short | |
| phrase and carries a weight; two are COMPULSORY (hard gates). | |
| F1 HTF directional bias COMPULSORY w=30 1H trend (EMA pos+slope); 4H shown | |
| F5 BTC correlation COMPULSORY w=15 block alts fighting BTC; BTC exempt | |
| F3 Return volume optional w=25 displacement up-vol, pullback down-vol | |
| F2 Premium / Discount optional w=20 long in discount, short in premium | |
| F4 Volatility regime optional w=10 ATR expanding vs its MA | |
| R7 Confirmation quality optional w=10 real body close, no doji | |
| score = 100 * (sum weights of passed enabled gates / sum weights of enabled gates) | |
| PROMOTE to Stage 5 iff: all enabled COMPULSORY gates pass AND score >= 70 (default). | |
| Because only F1 and F5 are hard gates and the rest are weighted, quality setups still | |
| promote regularly, while the two biggest loss buckets β counter-trend entries and | |
| alts fighting BTC β are hard-blocked regardless of how clean the structure looks. | |
| Worked example | |
| -------------- | |
| ETH long, confirmation printed. 1H trend up (F1 pass), BTC up (F5 pass), impulse on | |
| heavy volume with a quiet pullback (F3 pass), entry at 38% of range = discount (F2 | |
| pass), ATR expanding (F4 pass), strong confirmation body (R7 pass) -> score ~92 -> | |
| "Strong" -> promotes to Stage 5, Telegram entry fires. | |
| Same setup but 1H is making lower-highs -> F1 (compulsory) fails -> HELD in Stage 4 | |
| with a red F1 chip and a "Held" verdict, no alert, even though every other gate is | |
| green. | |
| Mechanical refinements | |
| ---------------------- | |
| R6 Consumer-equilibrium reference: the FVG midpoint is computed and carried on the | |
| setup (ce_entry) for display/optional use. | |
| R8 Stop beyond liquidity: on promotion the stop is pushed to sit just past the swept | |
| liquidity pool (+ an ATR buffer). It only widens the structural stop, never | |
| tightens it β directly targeting the stop-run that was hitting tight FVG-edge stops. | |
| Expiry / lifecycle | |
| ------------------ | |
| Stage 4 is re-scored every cycle (HTF/BTC/volume drift, so a setup can promote a cycle | |
| later while still fresh). It leaves Stage 4 by: promotion to 5; a close back through | |
| the FVG against it; or a freshness timeout (STAGE4_QUALIFY_TTL_SECONDS, default 6h). | |
| Stage 4 never writes Trade History. Only Stage 5 terminal outcomes (SL / TP2 / | |
| Break-even, resolved intrabar) are recorded. | |
| Every gate is an env toggle (default ON) and every rejection is logged | |
| (filter_rejected with symbol, score and reason) so the screening is fully auditable. | |
| See VARIABLES_AND_SECRETS_GUIDE.txt Β§16 for every variable, default and example. | |
| v7.0 maintenance patch β runtime behaviour (no strategy/stage logic changed) | |
| ---------------------------------------------------------------------------- | |
| Scan throughput and the live-trade lifecycle were tightened. The structural triggers | |
| (impulse, FVG, first-liquidity lock, BoS close, sweep, FVG interaction, confirmation) | |
| are byte-for-byte unchanged. | |
| 1) Prompt advancement without throttling. Each cycle the scanner re-checks every | |
| committed setup (Stage 1-5) AND every Stage-0 pair that already holds a candidate | |
| zone, so a pair advances on the next closed candle rather than only when its shard | |
| rotates around (~4 min). A short-TTL 15m kline cache (BARS_CACHE_TTL_SECONDS, | |
| default 75s) lets those re-checks reuse a recent pull so the extra re-checks do not | |
| throttle MEXC. Example: a pair that detected a zone but has not yet locked Stage-1 | |
| liquidity is re-evaluated every cycle and locks the moment the qualifying candle | |
| closes β it no longer "waits its turn". | |
| 2) Live trades exit intrabar (Stage 4 qualified + Stage 5 verified). Committed setups | |
| bypass the cache and fetch a fresh window every cycle, so SL / Break-even / TP | |
| resolve the instant price touches the level and the row is written to Trade History | |
| within a cycle β NOT after the 15m candle closes. Example: entry at 10:01, stop tagged | |
| at 10:05; the trade is closed and recorded on the ~10:05 scan, not at 10:15. | |
| 3) Permanent Trade-History snapshot. On a terminal Stage-5 outcome the chart is rendered | |
| FROZEN at close time and saved to /data/trade_snapshots/ (persistent); the Trade | |
| History Pair link opens that saved image, so the picture is time-invariant and survives | |
| restart/update. (Older rows without a saved snapshot fall back to a live render.) | |
| 4) Stage-4 Invalidations log (dashboard table after Trade History). Any setup that leaves | |
| Stage 4 WITHOUT promoting to Stage 5 β a close-through invalidation, a qualified entry | |
| that resolved (SL/TP/BE) while held back by the filters, or the STAGE4_QUALIFY_TTL | |
| freshness timeout β is logged with its pair, a frozen snapshot, and the exact filter | |
| chips + score it held in Stage 4. This is an in-memory, 3-day, NON-persistent log: it | |
| is wiped on restart by design (a recent-history aid, not a trade record). Trade History | |
| still records ONLY terminal Stage-5 results. | |
| =============================================================== | |
| ADDENDUM β Stage-5 Trade Guardian (v7.2 post-entry conviction) | |
| =============================================================== | |
| Scope | |
| ----- | |
| Everything above (Stages 0-4 detection: impulse β FVG β first-liquidity + BoS β | |
| sweep β FVG interaction β verified entry, plus the v6.1 pre-entry filter stack that | |
| promotes Stage 4 β Stage 5) is UNCHANGED. The Guardian is a strictly post-entry | |
| ADVISORY layer that activates only once a trade is live in Stage 5. It never alters | |
| stage detection, entry, SL, TP or Break-even logic. | |
| Purpose | |
| ------- | |
| After entry, answer continuously: does the trade still have fuel to reach TP, or is | |
| a reversal building? It produces two composite scores and a short verdict, shown on | |
| the live Stage-5 dashboard row and stamped on the Trade-History row at close. | |
| Drive (0-100) = continuation fuel. | |
| Risk (0-100) = reversal pressure. | |
| Inputs (all live, per cycle, for the live symbol only) | |
| ------------------------------------------------------ | |
| 1. Candle structure on the trade timeframe (15m): recent directional closes, close | |
| location in range, EMA(9) vs EMA(21) alignment, pullback depth from peak (MFE). | |
| 2. Order flow: | |
| - CVD (Cumulative Volume Delta) from the live aggressor trade tape (MEXC deals; | |
| T=1 buyer-initiated, T=2 seller-initiated). Falls back to a candle-derived CVD | |
| proxy if the tape is unavailable. | |
| - Open Interest + funding rate from the MEXC ticker (one request per cycle for the | |
| whole universe; OI delta distinguishes new money from short-covering). | |
| 3. Lower-timeframe structure (default Min5): BoS in-direction (fuel) vs CHoCH | |
| against (early mechanical reversal). | |
| 4. Rejection-zone proximity: nearest OPPOSING FVG / liquidity / equilibrium ahead. | |
| 5. BTC kill-switch: Bitcoin's lower-TF trend fighting an alt position. | |
| Drive metrics (D1-D5) and Risk metrics (R1-R6) | |
| ---------------------------------------------- | |
| Drive: D1 Continuation, D2 Order Flow (CVD), D3 Open Interest, D4 LTF Push (BoS), | |
| D5 Pullback quality. | |
| Risk: R1 Exhaustion (separates a REAL exhaustion/hard adverse move from a FAKE | |
| low-volume stall β a fake stall must NOT raise risk), R2 LTF Break (CHoCH | |
| against), R3 Rejection Zone proximity, R4 Funding stress, R5 Volatility fade, | |
| R6 BTC context. | |
| Each metric maps to 0-100 and contributes to its composite by the G_W_* weights. | |
| Advisory verdicts (non-terminal, can change cycle to cycle) | |
| ----------------------------------------------------------- | |
| Examples (sentence case): "Prepare For Big Move", "Strong β Hold For More Profit", | |
| "Hold For More Profit", "Fake Move β Hold Position", "Approaching Rejection Zone β | |
| Tighten SL", "Move SL To Break-Even", "Caution β Tighten SL", "Lower-Timeframe | |
| Shift β Watch Closely", "No Push To Continue β Consider Exit". | |
| Terminal verdict (latched): "Close Trade Before Reversal" | |
| --------------------------------------------------------- | |
| The ONLY sticky verdict. It is multi-confirmed and persistent so it never | |
| flip-flops. It latches only when ALL hold: | |
| - >= 3 concurrent independent reversal signals (real exhaustion / hard adverse; | |
| LTF CHoCH against; OI hollow = short-covering / counter-build; decisive CVD | |
| against with |ratio| > 0.12; BTC opposing; price at a rejection zone), AND | |
| - Risk >= 70 and Drive < 45, AND | |
| - conditions persist for GUARDIAN_TERMINAL_CONFIRMS cycles (default 3), AND | |
| - confidence >= GUARDIAN_TERMINAL_MIN_CONF (default 80). | |
| Once latched it is frozen for the trade's life and fires a one-time Telegram + | |
| dashboard alert. It is ADVISORY: it is independent of TP1/TP2 and does NOT auto-close | |
| the position β the SL/TP/BE lifecycle remains the sole mechanism that closes a trade. | |
| Trade-History conviction stamp | |
| ------------------------------ | |
| At close, the final Drive/Risk, verdict, confidence and peak reward (MFE in R) are | |
| recorded with the trade row and shown in the Trade-History "Conviction" column. | |
| Legacy rows closed before v7.2 show an em-dash. | |
| Worked example (bullish/LONG) | |
| ----------------------------- | |
| Entry fires from a verified Stage-5 long. Early cycles: price makes higher closes, | |
| CVD ratio +0.30 (buyers), OI rising with price (D3 "New Money"), Min5 prints BoS up | |
| β Drive ~74, Risk ~26 β "Strong β Hold For More Profit". Price runs +1.8R (MFE). | |
| Later: price stalls into a 4H opposing FVG one ATR ahead (R3 "Near"), CVD flips to | |
| -0.18 (sellers), OI starts falling while price stalls (OI hollow), Min5 prints CHoCH | |
| down. That is 3+ concurrent signals; Risk climbs to 78, Drive falls to 38. If this | |
| holds for 3 cycles at confidence >= 80, the Guardian latches "Close Trade Before | |
| Reversal" and alerts β recommending the user banks the open profit before the move | |
| rolls over, without waiting for the structural SL. | |
| Configuration | |
| ------------- | |
| All knobs (GUARDIAN_* and the G_W_* weights) are documented with defaults and | |
| examples in VARIABLES_AND_SECRETS_GUIDE.txt Β§17 and exposed on the Settings page | |
| (Stage-5 Trade Guardian section). Disable the whole layer with GUARDIAN_ENABLED=false. | |
| =============================================================== | |
| ADDENDUM β v7.3 Verdict Phase Machine (advisory stability) | |
| =============================================================== | |
| Problem solved | |
| -------------- | |
| The Guardian chips (D1-D5 / R1-R6) are tactical and SHOULD react to every tick. The | |
| verdict, however, was previously derived per-cycle from Drive/Risk thresholds, so it | |
| flickered with dynamic price even when price had not left the entry zone. v7.3 makes the | |
| verdict a strategic, stateful read that thinks in trade phases, like the trader would. | |
| How it works (no change to chips, terminal latch, or the SL/TP/BE lifecycle) | |
| ---------------------------------------------------------------------------- | |
| 1. PHASE β where price is in the journey, anchored to the trade's own levels with ATR | |
| buffers and a sticky "left the zone" milestone: | |
| entry price still around the entry / FVG band | |
| underwater price below entry (long) / above entry (short), defending the stop | |
| advancing_tp1 price has left the zone and is working toward TP1 | |
| at_tp1 price is at / around TP1 (before or after the partial) | |
| advancing_tp2 TP1 banked, runner heading to TP2 | |
| at_tp2 price has reached TP2 | |
| Because phases are level-based, they almost never flicker. | |
| 2. MESSAGE β each phase has its own message set, chosen from SMOOTHED Drive/Risk | |
| (VERDICT_SMOOTH_WINDOW) plus confluence: OI state, CVD, LTF BoS/CHoCH, exhaustion | |
| (real vs fake), rejection-zone proximity, and entry-zone retest STRENGTH (how well the | |
| zone is holding across repeated taps β higher-lows defending vs deeper pokes toward SL). | |
| 3. DEBOUNCE β a calmer message must persist VERDICT_CONFIRM_CYCLES cycles AND the current | |
| message must have met VERDICT_MIN_DWELL_SECONDS before it is replaced. Rising danger or | |
| a genuine phase change commits immediately. Result: stable when nothing meaningful | |
| changes, fast to warn, slow to relax. | |
| Representative messages by phase (sentence case) | |
| ------------------------------------------------ | |
| entry: "Holding Entry Zone β Building For The Move" / | |
| "Consolidating At Entry β Waiting For Direction" / | |
| "Entry Zone Weakening β Watch For Stop" / | |
| "Entry Zone Failing β Reversal Building, Consider Exit" | |
| underwater: "Underwater β Entry Still Defending, Give It Room" / | |
| "Dip Below Entry β Looks Like A Shake-Out, Holding" / | |
| "Pressing Your Stop β Reversal Building, Consider Exit" | |
| advancing_tp1: "Structure Broken β Strong Drive To TP1" / | |
| "In Profit β On Track For TP1" / | |
| "Pullback Looks Like A Shake-Out β Trend Intact" / | |
| "Push Is Short-Covering β May Revisit Entry" / | |
| "Move Stalling Before TP1 β Possible Pullback To Entry" / | |
| "Approaching <Zone> β Tighten Stop Into It" | |
| at_tp1: "Reaching TP1 β Secure Partial / Move Stop To Break-Even" / | |
| "At TP1 β Rejecting, Secure Profit Now" / | |
| "TP1 Banked β Strong, Holding Runner For TP2" / | |
| "Post-TP1 Reversal β Protect Profit, Consider Full Exit" | |
| advancing_tp2: "Running To TP2 β Trail Your Stop" / | |
| "Losing Steam Before TP2 β Consider Banking" / | |
| "Approaching <Zone> β Trail Tightly" | |
| at_tp2: "At TP2 β Target Reached, Let Winner Run On Trail" / | |
| "At TP2 β Target Reached, Take Profit" | |
| terminal: "Close Trade Before Reversal" (latched; unchanged) | |
| UI | |
| -- | |
| The verdict now renders on its OWN line beneath the chip row, with a small phase tag | |
| ("ENTRY ZONE", "-> TP1", "AT TP1", ...) and the confidence %, so the chip row stays | |
| short and the strategic read is clear at a glance. Emerald accent unchanged. | |
| Tunables: VERDICT_CONFIRM_CYCLES, VERDICT_MIN_DWELL_SECONDS, VERDICT_SMOOTH_WINDOW, | |
| VERDICT_ZONE_BAND_ATR, VERDICT_TPX_BUFFER_ATR β see VARIABLES_AND_SECRETS_GUIDE.txt Β§18 | |
| and the Settings page (Stage 5 Β· Verdict Stability). | |
| =============================================================== | |
| v7.5 ADDENDUM β Predictive Sweep-Aware Stage 4 + Stage-5 Realism | |
| =============================================================== | |
| WHY STAGE 4 WAS REBUILT | |
| ----------------------- | |
| v6.1βv7.4 screened a confirmed setup with a HARD gate: HTF bias AND BTC bias must | |
| both agree, both derived from EMA position+slope (a LAGGING indicator). In practice | |
| the gate only turned green AFTER price had already displaced from the zone β by then | |
| the move was halfway to TP1. The engine was reacting to price that had ALREADY moved, | |
| not predicting price that was ABOUT to move. The hard gate also vetoed perfectly valid | |
| countertrend reactions off fresh FVGs. | |
| KEY REFRAME: entry, SL and TP are printed the instant a setup reaches Stage 4. So a | |
| liquidity sweep / stop-hunt that happens BEFORE promotion is not a failure β in Smart | |
| Money terms it is the *engineered* grab of resting stops that PRECEDES the real move. | |
| The old code invalidated the setup on that sweep (it saw "price hit SL"), throwing away | |
| exactly the setups that were about to run. | |
| THE v7.5 MODEL (leading, confidence-from-behaviour) | |
| --------------------------------------------------- | |
| Stage 4 now scores what price is LIKELY to do while it sits in the zone: | |
| E1 HTF context ....... soft lean only (+/-18, +12 if 4H agrees). NEVER a gate. | |
| E2 Zone quality ...... FVG gap size + IMPULSE DISPLACEMENT (ATRs the impulse | |
| travelled = how strongly the gap will be defended) + OB | |
| confluence + discount/premium positioning. | |
| E3 Order flow ........ flow-with-us scores directly; ABSORPTION (aggressive | |
| opposite delta exhausting while the zone holds) scores as | |
| reversal FUEL β the leading tell that a turn is loading. | |
| E4 New money ......... OI rising into the zone. | |
| E6 LTF structure ..... lower-timeframe CHoCH/BoS in our direction (entry trigger). | |
| E8 LIQUIDITY SWEEP ... the crown jewel. Resting stops beyond SL are FUEL, not a | |
| threat: the engine EXPECTS the grab. swept+reclaimed = 95 | |
| (highest-confidence enter), swept = 60, sweep-expected = 40, | |
| no-stops = 62. | |
| E5 Zone integrity .... caution drag: deeper pokes / closes through the zone. | |
| E7 Vitality .......... market not dead (turnover/ATR regime). | |
| BTC veto: the ONLY hard kill, and rare β it fires only when BTC's latest CLOSED candle | |
| is a >=0.6-body impulse directly against the trade (a real-time threat), never on a | |
| stale EMA label. | |
| SWEEP-AWARE RESOLUTION (_pre_entry_resolution) | |
| ---------------------------------------------- | |
| While a setup is held at Stage 4, each cycle classifies any touch of the stop: | |
| * WICK through SL that reclaims (no CLOSED candle body settles beyond SL) | |
| -> "swept": HOLD the setup, stamp pe_swept + the swept extreme + pe_reclaimed. | |
| Next cycle E8 reads swept+reclaimed and the verdict becomes | |
| "Enter β Liquidity Swept, Move Starting". | |
| * CLOSED candle body beyond SL -> the premise is wrong -> invalidate (Hit SL). | |
| * TP2 / break-even that played out without us -> recorded as missed and removed. | |
| The live forming candle is excluded from the decisive-close test (favours holding). | |
| PROMOTION | |
| --------- | |
| passed = (conviction streak >= confirm_cycles) OR FAST-TRACK, where fast-track = | |
| conviction >= threshold-8 AND (fresh LTF BoS in our direction OR reclaimed sweep). This | |
| gets you in as the move STARTS rather than chasing after TP1. No HTF/BTC gate is involved. | |
| STAGE 5 VERDICT REALISM | |
| ----------------------- | |
| The phase machine's sticky "left zone" milestone used to flip on a single live WICK | |
| 0.10*ATR past the zone, so the advisory printed "Approaching <zone> β tighten stop" | |
| while price was really still at entry. It now requires a CLOSED candle to close | |
| >=0.5*ATR beyond the zone before "left zone" latches β a genuine departure, not | |
| intrabar noise. Everything else (chips, Drive/Risk, terminal latch, SL/TP/BE lifecycle) | |
| is unchanged. | |
| TP1 ACCOUNTING (Trade History) | |
| ------------------------------ | |
| TP1 closes 50% of the position, so reaching TP1 banks +0.5*R1 even if the runner is | |
| later stopped at break-even. Trade History now derives R from the trade's own levels for | |
| deterministic outcomes (TP2 = 0.5*R1+0.5*R2, TP1/BE-after-TP1 = 0.5*R1, SL = -1R) before | |
| falling back to the stored realized_rr (manual closes only). Win-rate, net R and profit | |
| factor all count TP1-reached trades as wins/profit. | |
| No new Settings knobs were introduced in v7.5 (existing c_w_* weights are reused), so | |
| settings_schema.json is unchanged and there is no migration step. | |