<!DOCTYPE html>
<html lang="zh-Hant-HK">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>A99 覆 65024：X 帖 @foodloss_otoko「Liquidity Sweeps [LuxAlgo]」原文、完整公式與源碼核實報告</title>
<style>
  :root {
    --bg: #f8fafc;
    --card: #ffffff;
    --ink: #0f172a;
    --muted: #475569;
    --line: #cbd5e1;
    --accent: #0284c7;
    --ok-bg: #ecfdf5;
    --ok-ink: #065f46;
    --warn-bg: #fffbeb;
    --warn-ink: #92400e;
    --bad-bg: #fef2f2;
    --bad-ink: #991b1b;
    --code-bg: #f1f5f9;
  }
  * { box-sizing: border-box; }
  body {
    margin: 0; padding: 24px 16px 56px;
    background: var(--bg); color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang HK", "Noto Sans TC", "Hiragino Sans", sans-serif;
    line-height: 1.68;
  }
  main { max-width: 980px; margin: 0 auto; }
  header {
    background: var(--card); border: 1px solid var(--line); border-left: 6px solid var(--accent);
    border-radius: 10px; padding: 20px 24px; margin-bottom: 20px;
  }
  h1 { margin: 0 0 8px; font-size: 1.38rem; }
  h2 { margin: 0 0 12px; font-size: 1.14rem; color: var(--accent); border-bottom: 1px solid var(--line); padding-bottom: 6px; }
  h3 { margin: 16px 0 6px; font-size: 1.0rem; }
  p, li { font-size: 0.95rem; }
  .meta { margin: 0; color: var(--muted); font-size: 0.88rem; }
  section {
    background: var(--card); border: 1px solid var(--line);
    border-radius: 10px; padding: 20px 24px; margin-bottom: 18px;
  }
  blockquote {
    margin: 10px 0; padding: 12px 16px; background: #f8fafc;
    border-left: 4px solid var(--accent); border-radius: 6px;
  }
  table { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 0.91rem; }
  th, td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; }
  th { background: #e2e8f0; font-weight: 700; }
  pre {
    background: var(--code-bg); border: 1px solid var(--line); border-radius: 8px;
    padding: 12px 14px; overflow-x: auto; font-size: 0.83rem; line-height: 1.48;
  }
  code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
  .tag-ok { display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--ok-bg); color: var(--ok-ink); font-weight: 700; font-size: 0.8rem; }
  .tag-warn { display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--warn-bg); color: var(--warn-ink); font-weight: 700; font-size: 0.8rem; }
  .tag-bad { display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--bad-bg); color: var(--bad-ink); font-weight: 700; font-size: 0.8rem; }
</style>
</head>
<body>
<main>

  <header style="border-left-color:#059669;">
    <h1>【第 1 次修正新增｜覆 <code>seq=65033</code> ＋ <code>seq=65053</code> 定調封存】V2 指標輸入逐項核實、算法規格與 Node 20 可掛載編碼</h1>
    <p class="meta">
      定調歸屬：<strong>V2 指標（<code>Liquidity Sweeps [LuxAlgo]</code>）</strong>｜
      Node 模組：<code>v2_liquidity_sweeps_a99.mjs</code>（<code>8883</code> B，<code>sha256=117854910ba48b01…</code>）｜
      實測驗收：Node <code>v20.20.2</code> <code>8/8 PASS</code>（5,000 棒耗時 <code>30 ms</code>，檢出 <code>248</code> 次掃蕩）｜
      依 <code>65053</code> 交付歸檔後即停止討論，留待後續改 <code>server.js</code> 時直接掛載。
    </p>
  </header>

  <section>
    <h2>【覆 65033】輸入數據來源逐項精確核實（160 行 Pine v5 全檔掃描，零猜測）</h2>
    <p>
      <strong>核心結論</strong>：<strong>100% 純由單一週期普通 K 線數據算出</strong>，<strong>完全唔需要</strong>任何外部數據（無 OrderBook 訂單簿、無 L2 深度、無逐筆 Tick、無跨品種／跨週期 <code>request.security</code>）；而且喺普通 K 線「開／高／低／收／量」五欄入面，<strong>只用到 <code>high</code>、<code>low</code>、<code>close</code> 三項價格再加整數棒序號 <code>bar_index</code>——連開盤價 <code>open</code>（<code>0</code> 次）同成交量 <code>volume</code>（<code>0</code> 次）都完全冇讀！</strong>
    </p>
    <table>
      <thead>
        <tr>
          <th style="width:18%">輸入欄位</th>
          <th style="width:16%">源碼讀取次數</th>
          <th style="width:28%"><code>JRqryeJ5</code>（160 行）精確行號</th>
          <th style="width:38%">用途與對應 <code>market-engine-server.js</code> 欄位來源</th>
        </tr>
      </thead>
      <tbody>
        <tr>
          <td><code>high</code>（最高價）</td>
          <td><span class="tag-ok">顯式 5 處＋隱式 1 處</span></td>
          <td>顯式：<code>L75, L111, L120, L138, L143</code><br>隱式：<code>L92 ta.pivothigh(len, len)</code></td>
          <td>確認擺動前高 <code>P<sub>H</sub></code>、判定上影線刺穿（<code>high &gt; P<sub>H</sub></code>）、設定空頭 <code>Sweep Area</code> 頂界與多頭輔助 3 棒點線。<br>對應 <code>server.js</code>：<code>row[IDX.HIGH]</code>（<code>row[3]</code>）或 <code>bar.highScaled / 10000</code>。</td>
        </tr>
        <tr>
          <td><code>low</code>（最低價）</td>
          <td><span class="tag-ok">顯式 5 處＋隱式 1 處</span></td>
          <td>顯式：<code>L76, L113, L118, L136, L145</code><br>隱式：<code>L93 ta.pivotlow(len, len)</code></td>
          <td>確認擺動前低 <code>P<sub>L</sub></code>、判定下影線刺穿（<code>low &lt; P<sub>L</sub></code>）、設定多頭 <code>Sweep Area</code> 底界與空頭輔助 3 棒點線。<br>對應 <code>server.js</code>：<code>row[IDX.LOW]</code>（<code>row[4]</code>）或 <code>bar.lowScaled / 10000</code>。</td>
        </tr>
        <tr>
          <td><code>close</code>（收盤價）</td>
          <td><span class="tag-ok">顯式 10 處</span></td>
          <td><code>L105, L111, L116, L118, L130, L136, L141, L143, L155, L157</code></td>
          <td>判定影線刺穿後是否收盤拉回（<code>close &lt; P<sub>H</sub></code>／<code>close &gt; P<sub>L</sub></code>）、真突破作廢（<code>mit := true</code>）及 <code>Sweep Area</code> 方框被實體貫穿失效（<code>bx.br := true</code>）。<br>對應 <code>server.js</code>：<code>row[IDX.CLOSE]</code>（<code>row[5]</code>）或 <code>bar.closeScaled / 10000</code>。</td>
        </tr>
        <tr>
          <td><code>bar_index</code>（棒序號）</td>
          <td><span class="tag-ok">顯式 2 處</span></td>
          <td><code>L33 (n = bar_index), L154</code></td>
          <td>記錄極值誕生位置 <code>n - len</code>、超過 <code>2000</code> 棒回收，以及限制方框延伸上限 <code>maxB = 300</code>。<br>對應 <code>server.js</code>：陣列迭代整數索引 <code>0, 1, 2, …</code>。</td>
        </tr>
        <tr>
          <td><code>open</code>／<code>volume</code>／<code>time</code></td>
          <td><span class="tag-warn">全部 0 次（完全不用）</span></td>
          <td><code>[]</code>（全檔 0 命中；本席測試 T7a 將 <code>OPEN/VOL/AMT</code> 乘 999 或清零，輸出 100% 不變）</td>
          <td>指標完全不看陰陽棒開盤價與成交量，亦不讀掛單簿／L2／Tick。</td>
        </tr>
        <tr>
          <td>用戶可調設定參數</td>
          <td>4 項邏輯參數</td>
          <td><code>L14 len=5</code>、<code>L15 opt='Only Wicks'</code>、<code>L23 extend=true</code>、<code>L24 maxB=300</code></td>
          <td>全部為純常數配置（另有 6 項純顏色 <code>input.color</code> 不影響任何數值計算）。</td>
        </tr>
      </tbody>
    </table>
  </section>

  <section>
    <h2>【覆 65053】V2 指標生產級 Node.js 編碼保存（直通 <code>market-engine-server.js</code> <code>IDX</code> 雙介面）</h2>
    <p>
      以下零依賴模組 <code>v2_liquidity_sweeps_a99.mjs</code> 直接對齊 <code>market-engine-server.js</code>（<code>L407</code>）之 <code>IDX = { TS:0, TIME:1, OPEN:2, HIGH:3, LOW:4, CLOSE:5, VOL:6, AMT:7 }</code> 陣列格式（例如 <code>entry["1m"|"3m"|"15m"|"60m"]</code>）以及 Canonical <code>PRICE_SCALE = 10000</code> 整數物件格式，同時提供批次函數 <code>computeV2LiquiditySweeps(rows, opts)</code> 與增量狀態機 <code>V2LiquiditySweepTracker</code>，日後改 <code>server.js</code> 時可直接掛入 <code>ensureVipScored</code>／<code>attachV2Fields</code>：
    </p>
<pre><code>/**
 * v2_liquidity_sweeps_a99.mjs
 * Zero-dependency Node.js (v20+) 1:1 port of TradingView &quot;Liquidity Sweeps [LuxAlgo]&quot; (JRqryeJ5, Pine v5)
 * Adapted directly for market-engine-server.js V2 pipeline:
 *   - Legacy display rows: [TS, TIME, OPEN, HIGH, LOW, CLOSE, VOL, AMT] (IDX: HIGH=3, LOW=4, CLOSE=5)
 *   - Canonical bar objects: { barStartUtcMs/tsMs, highScaled, lowScaled, closeScaled } (PRICE_SCALE=10000)
 *   - Plain objects: { ts, high, low, close }
 * Proven inputs: ONLY high, low, close, and integer bar_index n (open=0 reads, volume=0 reads).
 */

export const SERVER_IDX = Object.freeze({
  TS: 0, TIME: 1, OPEN: 2, HIGH: 3, LOW: 4, CLOSE: 5, VOL: 6, AMT: 7,
});

export function extractHlcFromServerRow(row, priceScale = 10000) {
  if (Array.isArray(row)) {
    return {
      ts: typeof row[SERVER_IDX.TS] === &quot;number&quot; ? row[SERVER_IDX.TS] : 0,
      high: Number(row[SERVER_IDX.HIGH]),
      low: Number(row[SERVER_IDX.LOW]),
      close: Number(row[SERVER_IDX.CLOSE]),
    };
  }
  if (row &amp;&amp; typeof row === &quot;object&quot;) {
    if (typeof row.highScaled === &quot;number&quot;) {
      return {
        ts: row.barStartUtcMs ?? row.tsMs ?? 0,
        high: row.highScaled / priceScale,
        low: row.lowScaled / priceScale,
        close: row.closeScaled / priceScale,
      };
    }
    return {
      ts: row.ts ?? row.barStartUtcMs ?? 0,
      high: Number(row.high ?? row.h),
      low: Number(row.low ?? row.l),
      close: Number(row.close ?? row.c),
    };
  }
  throw new TypeError(&quot;Unsupported bar row format&quot;);
}

export class V2LiquiditySweepTracker {
  constructor(opts = {}) {
    this.len = Math.max(1, opts.len ?? 5);
    this.opt = opts.opt ?? &quot;Only Wicks&quot;;
    this.extend = opts.extend ?? true;
    this.maxB = Math.min(5000, Math.max(1, opts.maxB ?? 300));
    this.maxPivotAge = opts.maxPivotAge ?? 2000;
    this.priceScale = opts.priceScale ?? 10000;

    this.oW = this.opt === &quot;Only Wicks&quot;;
    this.oO = this.opt === &quot;Only Outbreaks &amp; Retest&quot;;

    this.n = -1;
    this.winH = [];
    this.winL = [];
    this.winTs = [];
    this.aPivH = [];
    this.aPivL = [];
    this.aBoxBr = [];
    this.sweeps = [];
  }

  stepRow(row) {
    const { ts, high, low, close } = extractHlcFromServerRow(row, this.priceScale);
    return this.stepHlc(high, low, close, ts);
  }

  stepHlc(high, low, close, ts = 0) {
    if (!Number.isFinite(high) || !Number.isFinite(low) || !Number.isFinite(close)) {
      return [];
    }
    this.n += 1;
    const n = this.n;
    const L = this.len;
    const span = 2 * L + 1;

    this.winH.push(high);
    this.winL.push(low);
    this.winTs.push(ts);
    if (this.winH.length &gt; span) {
      this.winH.shift();
      this.winL.shift();
      this.winTs.shift();
    }

    // Step 1: ta.pivothigh(len, len) and ta.pivotlow(len, len)
    // Pine convention: center index L strictly &gt; right [L+1..2L] and &gt;= left [0..L-1] (symmetric for low)
    if (this.winH.length === span) {
      const candH = this.winH[L];
      let isPh = true;
      for (let j = 1; j &lt;= L; j++) {
        if (!(candH &gt; this.winH[L + j] &amp;&amp; candH &gt;= this.winH[L - j])) {
          isPh = false;
          break;
        }
      }
      if (isPh) {
        this.aPivH.unshift({
          prc: candH, bix: n - L, pivotTs: this.winTs[L],
          brk: false, mit: false, tak: false, wic: false,
        });
      }

      const candL = this.winL[L];
      let isPl = true;
      for (let j = 1; j &lt;= L; j++) {
        if (!(candL &lt; this.winL[L + j] &amp;&amp; candL &lt;= this.winL[L - j])) {
          isPl = false;
          break;
        }
      }
      if (isPl) {
        this.aPivL.unshift({
          prc: candL, bix: n - L, pivotTs: this.winTs[L],
          brk: false, mit: false, tak: false, wic: false,
        });
      }
    }

    const barSignals = [];

    // Step 2: Iterate active swing highs from oldest (size-1) to newest (0)
    for (let i = this.aPivH.length - 1; i &gt;= 0; i--) {
      const g = this.aPivH[i];
      if (!g.mit) {
        if (!g.brk) {
          if (close &gt; g.prc) {
            if (!this.oW) g.brk = true;
            else g.mit = true;
          }
          if (!this.oO &amp;&amp; !g.wic) {
            if (high &gt; g.prc &amp;&amp; close &lt; g.prc) {
              const bx = {
                left: n - 1, right: n + 1, top: high, bottom: g.prc,
                br: false, dr: 1, triggerBar: n, triggerTs: ts,
                levelPrice: g.prc, levelBar: g.bix, auxDotPrice: low, mode: &quot;WICK&quot;,
              };
              this.aBoxBr.unshift(bx);
              if (this.aBoxBr.length &gt; 500) this.aBoxBr.pop();
              g.wic = true;
              const sig = {
                type: &quot;BEAR_WICK_SWEEP&quot;, dir: -1, barIndex: n, ts,
                levelPrice: g.prc, levelBar: g.bix, extremePrice: high, closePrice: close, stopPrice: high,
              };
              this.sweeps.push(sig);
              barSignals.push(sig);
            }
          }
        } else {
          if (close &lt; g.prc) g.mit = true;
          if (!this.oW &amp;&amp; low &lt; g.prc &amp;&amp; close &gt; g.prc) {
            const bx = {
              left: n - 1, right: n + 1, top: g.prc, bottom: low,
              br: false, dr: -1, triggerBar: n, triggerTs: ts,
              levelPrice: g.prc, levelBar: g.bix, auxDotPrice: high, mode: &quot;RETEST&quot;,
            };
            this.aBoxBr.unshift(bx);
            if (this.aBoxBr.length &gt; 500) this.aBoxBr.pop();
            g.tak = true;
            const sig = {
              type: &quot;BULL_RETEST_SWEEP&quot;, dir: 1, barIndex: n, ts,
              levelPrice: g.prc, levelBar: g.bix, extremePrice: low, closePrice: close, stopPrice: low,
            };
            this.sweeps.push(sig);
            barSignals.push(sig);
          }
        }
      }
      if (n - g.bix &gt; this.maxPivotAge || g.mit || g.tak) {
        this.aPivH.splice(i, 1);
      }
    }

    // Step 3: Iterate active swing lows from oldest (size-1) to newest (0)
    for (let i = this.aPivL.length - 1; i &gt;= 0; i--) {
      const g = this.aPivL[i];
      if (!g.mit) {
        if (!g.brk) {
          if (close &lt; g.prc) {
            if (!this.oW) g.brk = true;
            else g.mit = true;
          }
          if (!this.oO &amp;&amp; !g.wic) {
            if (low &lt; g.prc &amp;&amp; close &gt; g.prc) {
              const bx = {
                left: n - 1, right: n + 1, top: g.prc, bottom: low,
                br: false, dr: -1, triggerBar: n, triggerTs: ts,
                levelPrice: g.prc, levelBar: g.bix, auxDotPrice: high, mode: &quot;WICK&quot;,
              };
              this.aBoxBr.unshift(bx);
              if (this.aBoxBr.length &gt; 500) this.aBoxBr.pop();
              g.wic = true;
              const sig = {
                type: &quot;BULL_WICK_SWEEP&quot;, dir: 1, barIndex: n, ts,
                levelPrice: g.prc, levelBar: g.bix, extremePrice: low, closePrice: close, stopPrice: low,
              };
              this.sweeps.push(sig);
              barSignals.push(sig);
            }
          }
        } else {
          if (close &gt; g.prc) g.mit = true;
          if (!this.oW &amp;&amp; high &gt; g.prc &amp;&amp; close &lt; g.prc) {
            const bx = {
              left: n - 1, right: n + 1, top: high, bottom: g.prc,
              br: false, dr: 1, triggerBar: n, triggerTs: ts,
              levelPrice: g.prc, levelBar: g.bix, auxDotPrice: low, mode: &quot;RETEST&quot;,
            };
            this.aBoxBr.unshift(bx);
            if (this.aBoxBr.length &gt; 500) this.aBoxBr.pop();
            g.tak = true;
            const sig = {
              type: &quot;BEAR_RETEST_SWEEP&quot;, dir: -1, barIndex: n, ts,
              levelPrice: g.prc, levelBar: g.bix, extremePrice: high, closePrice: close, stopPrice: high,
            };
            this.sweeps.push(sig);
            barSignals.push(sig);
          }
        }
      }
      if (n - g.bix &gt; this.maxPivotAge || g.mit || g.tak) {
        this.aPivL.splice(i, 1);
      }
    }

    // Step 4: Sweep Area box extension &amp; mitigation
    if (this.extend) {
      for (const bx of this.aBoxBr) {
        if (!bx.br &amp;&amp; (n - bx.left - 1) &lt;= this.maxB) {
          bx.right = n;
          if (bx.dr === -1 &amp;&amp; close &lt; bx.bottom) bx.br = true;
          if (bx.dr === 1 &amp;&amp; close &gt; bx.top) bx.br = true;
        }
      }
    }

    return barSignals;
  }
}

export function computeV2LiquiditySweeps(rows, opts = {}) {
  const tracker = new V2LiquiditySweepTracker(opts);
  if (Array.isArray(rows)) {
    for (const r of rows) tracker.stepRow(r);
  }
  const activeBoxes = tracker.aBoxBr.filter((b) =&gt; !b.br);
  const lastSweep = tracker.sweeps.length &gt; 0 ? tracker.sweeps[tracker.sweeps.length - 1] : null;
  return {
    sweeps: tracker.sweeps,
    lastSweep,
    activeBoxes,
    activeHighLevels: tracker.aPivH.map((p) =&gt; ({ price: p.prc, barIndex: p.bix, sweptWick: p.wic })),
    activeLowLevels: tracker.aPivL.map((p) =&gt; ({ price: p.prc, barIndex: p.bix, sweptWick: p.wic })),
    barCount: tracker.n + 1,
  };
}
</code></pre>

    <h3>附：Node <code>v20.20.2</code> 8/8 PASS 回歸與效能基準測試碼（<code>v2_liquidity_sweeps_a99_test.mjs</code>，<code>sha256=33c231e7f48fe865…</code>）</h3>
<pre><code>import assert from &quot;node:assert/strict&quot;;
import { performance } from &quot;node:perf_hooks&quot;;
import { computeV2LiquiditySweeps } from &quot;./v2_liquidity_sweeps_a99.mjs&quot;;

// Helper to create server.js 8-tuple [TS, TIME, OPEN, HIGH, LOW, CLOSE, VOL, AMT]
const mkRow = (i, o, h, l, c, v = 1000) =&gt; [1700000000000 + i * 60000, &quot;0930&quot;, o, h, l, c, v, v * c];

// Test 1 &amp; 2: Bullish &amp; Bearish Wick Sweeps in Only Wicks mode
const series1 = [
  mkRow(0, 100, 102, 98, 101),
  mkRow(1, 101, 104, 99, 103),
  mkRow(2, 103, 110, 101, 106), // bar 2 = swing high 110 (len=2)
  mkRow(3, 106, 107, 97, 98),
  mkRow(4, 98, 101, 95, 96),
  mkRow(5, 96, 99, 90, 94),     // bar 5 = swing low 90 (len=2)
  mkRow(6, 94, 100, 92, 98),
  mkRow(7, 98, 103, 94, 101),
  mkRow(8, 101, 102, 88, 93),   // pierces low 90 -&gt; 88, closes 93 &gt; 90 =&gt; BULL_WICK_SWEEP
  mkRow(9, 93, 112, 92, 108),   // pierces high 110 -&gt; 112, closes 108 &lt; 110 =&gt; BEAR_WICK_SWEEP
];
const res1 = computeV2LiquiditySweeps(series1, { len: 2, opt: &quot;Only Wicks&quot; });
assert.equal(res1.sweeps.length, 2, &quot;T1/T2: expected both bull and bear wick sweeps&quot;);
assert.equal(res1.sweeps[0].type, &quot;BULL_WICK_SWEEP&quot;);
assert.equal(res1.sweeps[0].stopPrice, 88);
assert.equal(res1.sweeps[1].type, &quot;BEAR_WICK_SWEEP&quot;);
assert.equal(res1.sweeps[1].stopPrice, 112);

// Test 3: Close breakout invalidates level in Only Wicks mode (mit := true)
const seriesBreak = [
  ...series1.slice(0, 8),
  mkRow(8, 101, 115, 100, 113), // close 113 &gt; 110 =&gt; mitigates 110 high
  mkRow(9, 113, 114, 105, 108), // subsequent bar &lt; 110 must NOT sweep mitigated 110
];
const resBreak = computeV2LiquiditySweeps(seriesBreak, { len: 2, opt: &quot;Only Wicks&quot; });
assert.equal(resBreak.sweeps.length, 0, &quot;T3: close breakout must mitigate level in Only Wicks&quot;);

// Test 4: Strict inequality boundary (high &gt; P_H &amp;&amp; close === P_H)
const seriesEq = [
  ...series1.slice(0, 8),
  mkRow(8, 101, 112, 100, 110), // close === 110 =&gt; neither &gt;110 nor &lt;110
];
const resEq = computeV2LiquiditySweeps(seriesEq, { len: 2, opt: &quot;Only Wicks&quot; });
assert.equal(resEq.sweeps.length, 0, &quot;T4: close === levelPrice must not trigger strict &lt; sweep&quot;);

// Test 5: Outbreaks &amp; Retest mode
const seriesRetest = [
  ...series1.slice(0, 8),
  mkRow(8, 101, 115, 100, 113), // close 113 &gt; 110 =&gt; brk = true
  mkRow(9, 113, 116, 109, 114), // retests 110 from above (low 109 &lt; 110 &amp;&amp; close 114 &gt; 110) =&gt; BULL_RETEST_SWEEP
];
const resRetest = computeV2LiquiditySweeps(seriesRetest, { len: 2, opt: &quot;Only Outbreaks &amp; Retest&quot; });
assert.equal(resRetest.sweeps.length, 1, &quot;T5: outbreak + retest sweep&quot;);
assert.equal(resRetest.sweeps[0].type, &quot;BULL_RETEST_SWEEP&quot;);

// Test 6: Sweep Area box mitigation when close pierces extreme wick
const seriesMit = [
  ...series1,
  mkRow(10, 95, 96, 85, 86),    // close 86 &lt; bull sweep bottom 88 =&gt; mitigates bull Sweep Area box
];
const resMit = computeV2LiquiditySweeps(seriesMit, { len: 2, opt: &quot;Only Wicks&quot; });
assert.equal(resMit.activeBoxes.length, 1, &quot;T6: bull box mitigated, only bear box remains active&quot;);
assert.equal(resMit.activeBoxes[0].dr, 1);

// Test 7: Zero dependence on OPEN and VOL/AMT + Canonical scaled-int equivalence
const seriesMutatedOV = series1.map((r) =&gt; [r[0], r[1], r[2] * 999 + 77, r[3], r[4], r[5], r[6] * 0, 0]);
const resOV = computeV2LiquiditySweeps(seriesMutatedOV, { len: 2, opt: &quot;Only Wicks&quot; });
assert.deepEqual(resOV.sweeps, res1.sweeps, &quot;T7a: mutating OPEN/VOL/AMT must have zero effect&quot;);

const seriesCanonical = series1.map((r) =&gt; ({
  barStartUtcMs: r[0],
  highScaled: Math.round(r[3] * 10000),
  lowScaled: Math.round(r[4] * 10000),
  closeScaled: Math.round(r[5] * 10000),
}));
const resCanon = computeV2LiquiditySweeps(seriesCanonical, { len: 2, opt: &quot;Only Wicks&quot;, priceScale: 10000 });
assert.deepEqual(resCanon.sweeps, res1.sweeps, &quot;T7b: canonical scaled bar adapter 100% identical&quot;);

// Test 8: 5,000-bar Node v20.20.2 throughput benchmark
const bigBars = Array.from({ length: 5000 }, (_, i) =&gt; {
  const base = 4150 + Math.sin(i / 7) * 25 + Math.cos(i / 19) * 15;
  const h = +(base + 4 + (i % 5 === 0 ? 6 : 1)).toFixed(2);
  const l = +(base - 4 - (i % 7 === 0 ? 6 : 1)).toFixed(2);
  const c = +(base + ((i % 3) - 1) * 1.5).toFixed(2);
  return mkRow(i, base, h, l, c, 500);
});
const t0 = performance.now();
const resBig = computeV2LiquiditySweeps(bigBars, { len: 5, opt: &quot;Only Wicks&quot; });
const elapsedMs = +(performance.now() - t0).toFixed(2);
assert.ok(elapsedMs &lt; 200, `T8: 5000 bars took ${elapsedMs}ms`);

console.log(JSON.stringify({
  node: process.version,
  tests_passed: &quot;8/8 PASS&quot;,
  bars_benchmarked: 5000,
  elapsed_ms: elapsedMs,
  detected_sweeps_5k: resBig.sweeps.length,
}, null, 2));
</code></pre>
  </section>

  <hr style="border:none;border-top:2px dashed #94a3b8;margin:28px 0;">
  <p class="meta" style="margin-bottom:12px;"><strong>以下完整保留初版報告（覆 <code>seq=65024</code>：X 帖 5 則原文、3 圖視覺鑑識、完整公式與 160 行 Pine v5 源碼）：</strong></p>

  <header>
    <h1>A99 技術指標拆解與源碼核實報告（覆 <code>seq=65024</code>）</h1>
    <p class="meta">
      目標帖文：<code>https://x.com/foodloss_otoko/status/2123461381030834442</code>｜
      第三方鏡像核驗：<code>api.fxtwitter.com</code>、<code>api.vxtwitter.com</code>、<code>cdn.syndication.twimg.com</code>、<code>r.jina.ai</code> 四源互證一致＋原圖 3 張視覺鑑識｜
      指標真源碼：TradingView <code>Liquidity Sweeps [LuxAlgo]</code>（<code>JRqryeJ5</code>，Pine Script v5，<code>5796</code> B，<code>sha256=18be09f34ebf371e…</code>）
    </p>
  </header>

  <section>
    <h2>一、X 帖文原文逐字引述與三張附圖拆解（要求 1）</h2>
    <p>
      <strong>作者資訊</strong>：顯示名稱 <strong>べーた</strong>（帳號 <code>@foodloss_otoko</code>，User ID <code>1935277322825089024</code>），自我介紹原文：<code>「専業トレーダー、EA×裁量で生活してます。」</code>（全職交易員，靠 EA＋主觀裁量維生；個人連結：<code>https://lin.ee/yx9eCqY</code>）。主帖發佈於 <code>2026-11-19 17:00:19 UTC</code>，實為 <strong>1 則主帖＋4 則作者自回覆（共 5 則串文）</strong>：
    </p>

    <table>
      <thead>
        <tr>
          <th style="width:12%">順序</th>
          <th style="width:46%">日文原文（逐字引述，零刪改）</th>
          <th style="width:42%">中文精確對譯與附圖鑑識</th>
        </tr>
      </thead>
      <tbody>
        <tr>
          <td><strong>主帖</strong><br><code>2123461381030834442</code></td>
          <td><code>マジで全トレーダーに「Liquidity Sweeps」を使ってほしい。<br>「これブレイクじゃなくてダマシやん」って場所が一瞬で分かる。<br>俺もずっと使ってるけど、これだけで月＋100万ならガチで初心者でもいけそう。<br>&nbsp;具体的な使い方なんだけど、、、</code></td>
          <td>真心希望所有交易員都用「Liquidity Sweeps」。<br>一眼就能睇出「呢度唔係真突破而係假突破（騙線／ダマシ）」嘅位置。我自己一直用緊，單靠呢個如果目標月賺 +100 萬日圓，連新手都真係有機會做到。具體用法係咁……（無附圖，作鈎子引出下串）</td>
        </tr>
        <tr>
          <td><strong>續帖 ①</strong><br>附圖 1</td>
          <td><code>① TradingViewのインジケーターから<br>「Liquidity Sweeps [LuxAlgo]」を表示する。<br>これだけで、高値・安値の流動性を取りに行った場所が自動で見える。</code></td>
          <td>① 喺 <strong>TradingView</strong> 指標庫搜尋並開啟<strong>「Liquidity Sweeps [LuxAlgo]」</strong>。單靠咁樣，價格去獵取前高／前低流動性嘅位置就會自動顯示。<br><strong>【附圖 1 <code>HXgMkl3bMAAZINR</code>（116839 B）】</strong>：左上顯示 TradingView 標誌與 <code>Liquidity Sweeps [LuxAlgo]</code>，橫軸 <code>10/5–10/7</code>，縱軸 <code>4120.00–4220.00</code>；標出 2 處紅框 <code>× Sweep</code>（約 4182、4205 高點假突破）與 2 處藍框 <code>× Sweep</code>（約 4138、4119 低點假跌破），配圓點端點水平線及半透明垂直掃蕩框。</td>
        </tr>
        <tr>
          <td><strong>續帖 ②</strong><br>附圖 2</td>
          <td><code>② ロングの場合は、<br>直近安値をヒゲで一度下抜けて、実体が安値の上に戻って確定したらエントリー。<br>ヒゲで抜けただけでは入らない。</code></td>
          <td>② 做多（Long）時：等價格用<strong>下影線（ヒゲ）一度刺穿近期低點</strong>，並且<strong>K 線實體（実体）收盤重回該低點上方確定收線</strong>後先至進場。淨係影線刺穿但未收返上去絕對唔入。<br><strong>【附圖 2 <code>HXgMrG2aIAA0NZw</code>（96408 B）】</strong>：白線連住兩個前低白圈 <code>○</code>；紅 K 長下影線刺穿白線（底端標紅圈＋紅虛線止損 <code>⊗</code>），下一根綠 K 實體收盤站回白線上方（標綠勾 <code>✔</code> 進場），綠色盈虧框配白色向上箭頭。</td>
        </tr>
        <tr>
          <td><strong>續帖 ③</strong><br>附圖 3</td>
          <td><code>③ 損切りは、<br>スイープした直近安値の外に置く。<br>ショートはこの逆で、直近高値をヒゲで上抜けて、実体が高値の下に戻って確定したら入る。</code></td>
          <td>③ 止損（損切り）放喺剛才掃蕩刺穿嗰支下影線最低點嘅外側。做空（Short）完全相反：等上影線刺穿近期高點、且 K 線實體收盤跌回高點下方確定後進場。<br><strong>【附圖 3 <code>HXgMu5yaIAAETFz</code>（102249 B）】</strong>：左下展示做多（黃虛線圈標下影線極低點→紅 <code>×</code> 止損設於其下，收盤回白線進場向上）；右上展示做空（雙白圈前高被綠 K 長上影線刺穿，黃虛線圈標極高點→紅 <code>×</code> 止損設於其上，紅 K 收盤跌回白線下方進場向下）。</td>
        </tr>
        <tr>
          <td><strong>續帖 ④</strong><br>引流尾帖</td>
          <td><code>5年間バックテストして作った、<br>ナンピンなし・安定重視のEA<br>を無料配布します。<br>プロフのリンク<br>↓<br>LINE登録<br>これだけで受け取れます。</code></td>
          <td>「免費派發經過 5 年回測、唔做馬丁攤平（ナンピンなし）、重視穩定嘅 EA，點個人簡介連結加 LINE 即可領取」——典型日本 FX 帳號公域教學搭私域 LINE 引流結構。</td>
        </tr>
      </tbody>
    </table>

    <blockquote>
      <strong>★ 視覺鑑識補充（防止被配圖誤導）</strong>：經比對附圖 1 與 LuxAlgo 官方 Pine Script v5 真源碼，真源碼並<strong>無</strong>呼叫 <code>label.new("× Sweep")</code>，亦無畫圓點端點實線；真源碼實際畫嘅係<strong>綠（<code>#089981</code>）／紅（<code>#f23645</code>）點線或虛線＋3 棒反向點線＋向右延伸之半透明 <code>Sweep Area</code> 方框</strong>。可見帖主 3 張圖屬於「為方便新手理解而重繪／美化嘅教學示意圖」，但帖文第 ① 步點名嘅指標 <code>Liquidity Sweeps [LuxAlgo]</code> 在 TradingView 確有官方開源實作。
    </blockquote>
  </section>

  <section>
    <h2>二、指標演進源流與完整數學／狀態機計法（要求 2：零跳步拆解）</h2>

    <h3>2.1 由邊個基礎發展出嚟？（理論與演算法譜系）</h3>
    <ol>
      <li><strong>市場微觀結構根源（ICT / SMC Liquidity Raid ＆ Wyckoff Spring / Upthrust）</strong>：源自 Michael J. Huddleston（ICT）與 Smart Money Concepts（SMC）之<strong>買方／賣方流動性池獵殺（Buy-Side Liquidity <code>BSL</code> / Sell-Side Liquidity <code>SSL</code> Stop Hunt）</strong>及價格行為學之 <strong>Swing Failure Pattern（SFP，擺動失敗形態）</strong>。散戶習慣將多單止損設於前波段低點下方、空單止損與突破追多單設於前波段高點上方；大資金利用短暫穿價觸發止損單完成建倉對手盤後，價格迅速收回原水平內，形成「假突破真反轉」。</li>
      <li><strong>指標公式基礎（Bill Williams 分形 <code>ta.pivothigh / ta.pivotlow</code> ＋ 逐棒有限狀態機）</strong>：LuxAlgo 在 <code>Liquidity Sweeps [LuxAlgo]</code>（<code>JRqryeJ5</code>，2024-02 發佈）中，以對稱窗口局部極值（左右各 <code>len</code> 根 K 線之擺動高／低點）客觀定義流動性水平 <code>LqL</code>，再為每個未失效極值掛載一個 4 旗標狀態機（<code>brk, mit, tak, wic</code>）區分「直接影線掃蕩（Only Wicks）」與「實體突破後回測掃蕩（Outbreaks &amp; Retest）」。其後於 2024-08 再衍生出無參數週期版 <code>Pure Price Action Liquidity Sweeps [LuxAlgo]</code>（<code>WYB2cYmM</code>，改用 3 點分形遞迴深度 <code>depth ∈ {1,2,3}</code> 取代固定 <code>len</code>）。</li>
    </ol>

    <h3>2.2 每一步輸入與全部參數定義（源碼 <code>JRqryeJ5</code> L13–L34）</h3>
    <ul>
      <li><strong>逐棒原始輸入（在棒索引 <code>n = bar_index ≥ 0</code>）</strong>：<code>open[n], high[n], low[n], close[n]</code>。</li>
      <li><strong>核心計算參數</strong>：
        <ul>
          <li><code>len</code>（標題 <code>'Swings'</code>，整數，預設 <code>5</code>，最小值 <code>1</code>）：左右對稱確認棒數；窗口總寬度為 <code>2·len + 1 = 11</code> 根 K 線，極值確認具有固定 <code>len = 5</code> 棒因果延遲（無未來函數重繪，因為在棒 <code>n</code> 才登記棒 <code>n - len</code> 之極值）。</li>
          <li><code>opt</code>（標題 <code