【第 1 次修正新增|覆 seq=65033 + seq=65053 定調封存】V2 指標輸入逐項核實、算法規格與 Node 20 可掛載編碼

定調歸屬:V2 指標(Liquidity Sweeps [LuxAlgo])| Node 模組:v2_liquidity_sweeps_a99.mjs(8883 B,sha256=117854910ba48b01…)| 實測驗收:Node v20.20.2 8/8 PASS(5,000 棒耗時 30 ms,檢出 248 次掃蕩)| 依 65053 交付歸檔後即停止討論,留待後續改 server.js 時直接掛載。

【覆 65033】輸入數據來源逐項精確核實(160 行 Pine v5 全檔掃描,零猜測)

核心結論:100% 純由單一週期普通 K 線數據算出,完全唔需要任何外部數據(無 OrderBook 訂單簿、無 L2 深度、無逐筆 Tick、無跨品種/跨週期 request.security);而且喺普通 K 線「開/高/低/收/量」五欄入面,只用到 high、low、close 三項價格再加整數棒序號 bar_index——連開盤價 open(0 次)同成交量 volume(0 次)都完全冇讀!

輸入欄位 源碼讀取次數 JRqryeJ5(160 行)精確行號 用途與對應 market-engine-server.js 欄位來源
high(最高價) 顯式 5 處+隱式 1 處 顯式:L75, L111, L120, L138, L143
隱式:L92 ta.pivothigh(len, len)
確認擺動前高 PH、判定上影線刺穿(high > PH)、設定空頭 Sweep Area 頂界與多頭輔助 3 棒點線。
對應 server.js:row[IDX.HIGH](row[3])或 bar.highScaled / 10000。
low(最低價) 顯式 5 處+隱式 1 處 顯式:L76, L113, L118, L136, L145
隱式:L93 ta.pivotlow(len, len)
確認擺動前低 PL、判定下影線刺穿(low < PL)、設定多頭 Sweep Area 底界與空頭輔助 3 棒點線。
對應 server.js:row[IDX.LOW](row[4])或 bar.lowScaled / 10000。
close(收盤價) 顯式 10 處 L105, L111, L116, L118, L130, L136, L141, L143, L155, L157 判定影線刺穿後是否收盤拉回(close < PH/close > PL)、真突破作廢(mit := true)及 Sweep Area 方框被實體貫穿失效(bx.br := true)。
對應 server.js:row[IDX.CLOSE](row[5])或 bar.closeScaled / 10000。
bar_index(棒序號) 顯式 2 處 L33 (n = bar_index), L154 記錄極值誕生位置 n - len、超過 2000 棒回收,以及限制方框延伸上限 maxB = 300。
對應 server.js:陣列迭代整數索引 0, 1, 2, …。
open/volume/time 全部 0 次(完全不用) [](全檔 0 命中;本席測試 T7a 將 OPEN/VOL/AMT 乘 999 或清零,輸出 100% 不變) 指標完全不看陰陽棒開盤價與成交量,亦不讀掛單簿/L2/Tick。
用戶可調設定參數 4 項邏輯參數 L14 len=5、L15 opt='Only Wicks'、L23 extend=true、L24 maxB=300 全部為純常數配置(另有 6 項純顏色 input.color 不影響任何數值計算)。

【覆 65053】V2 指標生產級 Node.js 編碼保存(直通 market-engine-server.js IDX 雙介面)

以下零依賴模組 v2_liquidity_sweeps_a99.mjs 直接對齊 market-engine-server.js(L407)之 IDX = { TS:0, TIME:1, OPEN:2, HIGH:3, LOW:4, CLOSE:5, VOL:6, AMT:7 } 陣列格式(例如 entry["1m"|"3m"|"15m"|"60m"])以及 Canonical PRICE_SCALE = 10000 整數物件格式,同時提供批次函數 computeV2LiquiditySweeps(rows, opts) 與增量狀態機 V2LiquiditySweepTracker,日後改 server.js 時可直接掛入 ensureVipScored/attachV2Fields:

/**
 * v2_liquidity_sweeps_a99.mjs
 * Zero-dependency Node.js (v20+) 1:1 port of TradingView "Liquidity Sweeps [LuxAlgo]" (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] === "number" ? 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 && typeof row === "object") {
    if (typeof row.highScaled === "number") {
      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("Unsupported bar row format");
}

export class V2LiquiditySweepTracker {
  constructor(opts = {}) {
    this.len = Math.max(1, opts.len ?? 5);
    this.opt = opts.opt ?? "Only Wicks";
    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 === "Only Wicks";
    this.oO = this.opt === "Only Outbreaks & Retest";

    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 > 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 > right [L+1..2L] and >= 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 <= L; j++) {
        if (!(candH > this.winH[L + j] && candH >= 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 <= L; j++) {
        if (!(candL < this.winL[L + j] && candL <= 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 >= 0; i--) {
      const g = this.aPivH[i];
      if (!g.mit) {
        if (!g.brk) {
          if (close > g.prc) {
            if (!this.oW) g.brk = true;
            else g.mit = true;
          }
          if (!this.oO && !g.wic) {
            if (high > g.prc && close < 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: "WICK",
              };
              this.aBoxBr.unshift(bx);
              if (this.aBoxBr.length > 500) this.aBoxBr.pop();
              g.wic = true;
              const sig = {
                type: "BEAR_WICK_SWEEP", 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 < g.prc) g.mit = true;
          if (!this.oW && low < g.prc && close > 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: "RETEST",
            };
            this.aBoxBr.unshift(bx);
            if (this.aBoxBr.length > 500) this.aBoxBr.pop();
            g.tak = true;
            const sig = {
              type: "BULL_RETEST_SWEEP", 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 > 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 >= 0; i--) {
      const g = this.aPivL[i];
      if (!g.mit) {
        if (!g.brk) {
          if (close < g.prc) {
            if (!this.oW) g.brk = true;
            else g.mit = true;
          }
          if (!this.oO && !g.wic) {
            if (low < g.prc && close > 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: "WICK",
              };
              this.aBoxBr.unshift(bx);
              if (this.aBoxBr.length > 500) this.aBoxBr.pop();
              g.wic = true;
              const sig = {
                type: "BULL_WICK_SWEEP", 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 > g.prc) g.mit = true;
          if (!this.oW && high > g.prc && close < 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: "RETEST",
            };
            this.aBoxBr.unshift(bx);
            if (this.aBoxBr.length > 500) this.aBoxBr.pop();
            g.tak = true;
            const sig = {
              type: "BEAR_RETEST_SWEEP", 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 > this.maxPivotAge || g.mit || g.tak) {
        this.aPivL.splice(i, 1);
      }
    }

    // Step 4: Sweep Area box extension & mitigation
    if (this.extend) {
      for (const bx of this.aBoxBr) {
        if (!bx.br && (n - bx.left - 1) <= this.maxB) {
          bx.right = n;
          if (bx.dr === -1 && close < bx.bottom) bx.br = true;
          if (bx.dr === 1 && close > 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) => !b.br);
  const lastSweep = tracker.sweeps.length > 0 ? tracker.sweeps[tracker.sweeps.length - 1] : null;
  return {
    sweeps: tracker.sweeps,
    lastSweep,
    activeBoxes,
    activeHighLevels: tracker.aPivH.map((p) => ({ price: p.prc, barIndex: p.bix, sweptWick: p.wic })),
    activeLowLevels: tracker.aPivL.map((p) => ({ price: p.prc, barIndex: p.bix, sweptWick: p.wic })),
    barCount: tracker.n + 1,
  };
}

附:Node v20.20.2 8/8 PASS 回歸與效能基準測試碼(v2_liquidity_sweeps_a99_test.mjs,sha256=33c231e7f48fe865…)

import assert from "node:assert/strict";
import { performance } from "node:perf_hooks";
import { computeV2LiquiditySweeps } from "./v2_liquidity_sweeps_a99.mjs";

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

// Test 1 & 2: Bullish & 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 -> 88, closes 93 > 90 => BULL_WICK_SWEEP
  mkRow(9, 93, 112, 92, 108),   // pierces high 110 -> 112, closes 108 < 110 => BEAR_WICK_SWEEP
];
const res1 = computeV2LiquiditySweeps(series1, { len: 2, opt: "Only Wicks" });
assert.equal(res1.sweeps.length, 2, "T1/T2: expected both bull and bear wick sweeps");
assert.equal(res1.sweeps[0].type, "BULL_WICK_SWEEP");
assert.equal(res1.sweeps[0].stopPrice, 88);
assert.equal(res1.sweeps[1].type, "BEAR_WICK_SWEEP");
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 > 110 => mitigates 110 high
  mkRow(9, 113, 114, 105, 108), // subsequent bar < 110 must NOT sweep mitigated 110
];
const resBreak = computeV2LiquiditySweeps(seriesBreak, { len: 2, opt: "Only Wicks" });
assert.equal(resBreak.sweeps.length, 0, "T3: close breakout must mitigate level in Only Wicks");

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

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

// Test 6: Sweep Area box mitigation when close pierces extreme wick
const seriesMit = [
  ...series1,
  mkRow(10, 95, 96, 85, 86),    // close 86 < bull sweep bottom 88 => mitigates bull Sweep Area box
];
const resMit = computeV2LiquiditySweeps(seriesMit, { len: 2, opt: "Only Wicks" });
assert.equal(resMit.activeBoxes.length, 1, "T6: bull box mitigated, only bear box remains active");
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) => [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: "Only Wicks" });
assert.deepEqual(resOV.sweeps, res1.sweeps, "T7a: mutating OPEN/VOL/AMT must have zero effect");

const seriesCanonical = series1.map((r) => ({
  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: "Only Wicks", priceScale: 10000 });
assert.deepEqual(resCanon.sweeps, res1.sweeps, "T7b: canonical scaled bar adapter 100% identical");

// Test 8: 5,000-bar Node v20.20.2 throughput benchmark
const bigBars = Array.from({ length: 5000 }, (_, i) => {
  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: "Only Wicks" });
const elapsedMs = +(performance.now() - t0).toFixed(2);
assert.ok(elapsedMs < 200, `T8: 5000 bars took ${elapsedMs}ms`);

console.log(JSON.stringify({
  node: process.version,
  tests_passed: "8/8 PASS",
  bars_benchmarked: 5000,
  elapsed_ms: elapsedMs,
  detected_sweeps_5k: resBig.sweeps.length,
}, null, 2));

以下完整保留初版報告(覆 seq=65024:X 帖 5 則原文、3 圖視覺鑑識、完整公式與 160 行 Pine v5 源碼):

A99 技術指標拆解與源碼核實報告(覆 seq=65024)

目標帖文:https://x.com/foodloss_otoko/status/2123461381030834442| 第三方鏡像核驗:api.fxtwitter.com、api.vxtwitter.com、cdn.syndication.twimg.com、r.jina.ai 四源互證一致+原圖 3 張視覺鑑識| 指標真源碼:TradingView Liquidity Sweeps [LuxAlgo](JRqryeJ5,Pine Script v5,5796 B,sha256=18be09f34ebf371e…)

一、X 帖文原文逐字引述與三張附圖拆解(要求 1)

作者資訊:顯示名稱 べーた(帳號 @foodloss_otoko,User ID 1935277322825089024),自我介紹原文:「専業トレーダー、EA×裁量で生活してます。」(全職交易員,靠 EA+主觀裁量維生;個人連結:https://lin.ee/yx9eCqY)。主帖發佈於 2026-11-19 17:00:19 UTC,實為 1 則主帖+4 則作者自回覆(共 5 則串文):

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

二、指標演進源流與完整數學/狀態機計法(要求 2:零跳步拆解)

2.1 由邊個基礎發展出嚟?(理論與演算法譜系)

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

2.2 每一步輸入與全部參數定義(源碼 JRqryeJ5 L13–L34)

2.3 逐棒完整公式與狀態轉移(Step 1 ~ Step 5,與 Pine v5 源碼 L89–L156 嚴格一對一)

【Step 1】局部極值(流動性池水平 LqL)確認與入列(源碼 L89–L96)
在每根收線棒 n ≥ 2·len,令候選基準棒索引 k = n - len,計算 ph = ta.pivothigh(len, len) 與 pl = ta.pivotlow(len, len)(TradingView 標準定義:右側嚴格不等於、左側大於等於/小於等於,避免平頂重複觸發):

ph(n) = high[k]   當且僅當  ∀j ∈ {1..len}: high[k] > high[k + j]  且  high[k] >= high[k - j]  (否則為 na)
pl(n) = low[k]    當且僅當  ∀j ∈ {1..len}: low[k]  < low[k + j]   且  low[k]  <= low[k - j]   (否則為 na)

若 not na(ph),將高點物件 H = { prc: ph, bix: n - len, brk: false, mit: false, tak: false, wic: false } 插入陣列 aPivH 頭部;若 not na(pl),將低點物件 L = { prc: pl, bix: n - len, brk: false, mit: false, tak: false, wic: false } 插入陣列 aPivL 頭部。

【Step 2】買方流動性池 aPivH(前高阻力 PH = H.prc)掃蕩與突破判定(源碼 L98–L122)
由舊至新(索引 i = aPivH.size() - 1 遞減至 0)遍歷每個 H.mit == false 之高點:

  1. 情況 2A:尚未發生收盤突破(H.brk == false):
    • 收盤真突破檢查:若 close[n] > PH:
      • 在預設 'Only Wicks'(oW == true)下:設 H.mit := true(視為真突破,該高點失效並於本棒尾刪除);
      • 在非 oW 模式下:設 H.brk := true(轉入「已突破、等待回測」狀態)。
    • 模式① 空頭影線掃蕩公式(Bearish Wick Sweep,當 not oO and not H.wic):
      BearWickSweep(n, H)  <=>  (high[n] > P_H)  AND  (close[n] < P_H)
      一旦成立:① 建立空頭 Sweep Area 方框(頂 y1 = high[n],底 y2 = PH,左 n - 1,右 n + 1,方向 dr = +1)及棒 n 寬度 3 之垂直實線 [PH, high[n]];② 畫點線連接 (H.bix, PH) → (n, PH);③ 自當根棒最低點畫 3 棒短點線 (n, low[n]) → (n + 3, low[n]);④ 設 H.wic := true(防止同一 PH 重複發出影線掃蕩,但保留 PH 直至日後 close > PH 或逾時)。註:邊界情況 high[n] > PH ∧ close[n] == PH 因兩側皆用嚴格不等號,當棒既不標 mit 亦不觸發 Sweep。
  2. 情況 2B:已收盤突破後之回測掃蕩(H.brk == true,僅在 'Only Outbreaks & Retest' 或 'Wicks + Outbreaks & Retest' 生效):
    • 若 close[n] < PH:收盤跌回前高之下,回測失敗,設 H.mit := true;
    • 若 not oW 且滿足多頭回測掃蕩公式 (low[n] < P_H) AND (close[n] > P_H)(前高被突破轉為支撐後,下影線刺穿 PH 再收於 PH 之上):建立多頭方框 [y1 = PH, y2 = low[n], dr = -1]、畫水平虛線(dashed)及頂部 3 棒短點線,設 H.tak := true。
  3. 情況 2C:高點回收條件(L121–L122):若 (n - H.bix > 2000) ∨ H.mit ∨ H.tak,自 aPivH 移除該高點。

【Step 3】賣方流動性池 aPivL(前低支撐 PL = L.prc)對稱掃蕩判定(源碼 L124–L148)
遍歷每個 L.mit == false 之低點:

  1. 情況 3A:尚未收盤跌破(L.brk == false):
    • 若 close[n] < PL:oW 時設 L.mit := true(真跌破失效);否則設 L.brk := true。
    • 模式① 多頭影線掃蕩公式(Bullish Wick Sweep,即 X 帖第 ② 步做多條件,當 not oO and not L.wic):
      BullWickSweep(n, L)  <=>  (low[n] < P_L)  AND  (close[n] > P_L)
      成立時建立多頭 Sweep Area 方框(頂 y1 = PL,底 y2 = low[n],方向 dr = -1)、水平點線 (L.bix, PL) → (n, PL)、頂部 3 棒短點線 (n, high[n]) → (n + 3, high[n]),設 L.wic := true。
  2. 情況 3B:已收盤跌破後之回測做空掃蕩(L.brk == true):若 close[n] > PL 設 L.mit := true;若 not oW 且 (high[n] > P_L) AND (close[n] < P_L),建立空頭方框 [y1 = high[n], y2 = PL, dr = +1]、水平虛線及底部 3 棒短點線,設 L.tak := true。
  3. 情況 3C:低點回收條件(L147–L148):若 (n - L.bix > 2000) ∨ L.mit ∨ L.tak,自 aPivL 移除。

【Step 4】Sweep Area 方框延伸與跌穿止損失效公式(源碼 L150–L156)
當 extend == true,對每個活躍方框 bx(左邊界 left = nsweep - 1):若 not bx.br 且 n - left - 1 ≤ maxB(預設 300 棒),將右邊界推至 n;並檢查區間是否被實體貫穿(恰對應 X 帖第 ③ 步止損位被收盤擊穿):

多頭框失效(dr == -1): close[n] < bx.bottom (= low[n_sweep])   => bx.br := true
空頭框失效(dr == +1): close[n] > bx.top    (= high[n_sweep])  => bx.br := true

【Step 5】衍生版對照(Pure Price Action Liquidity Sweeps [LuxAlgo],WYB2cYmM)
若不欲設定固定 len = 5,LuxAlgo 衍生版改將每根 K 線推入長度 3 之滑動視窗 v[0..2]:第 0 層當中間點 v[1].y == max(v[0].y, v[1].y, v[2].y) 時提取為 1 階擺動高點並送入第 1 層,遞迴 depth 層(Short=1、Intermediate=2、Long=3)後得到無週期參數之結構高/低點,再用完全相同之 high > prc and close < prc/low < prc and close > prc 判定掃蕩。

三、「去 TeamViewer 攞 Code」真偽核實(要求 3:已驗證 vs 未驗證分欄)

核實項目 驗證狀態 實證結論與確切取得方式
「去 TeamViewer 攞 code」說法 名稱誤傳(實為 TradingView) 原文全串 5 則帖文從未提及遠端桌面軟件 TeamViewer;續帖 ① 原文寫明係圖表平台 TradingView(「TradingViewのインジケーターから『Liquidity Sweeps [LuxAlgo]』を表示する」)。「TeamViewer」屬轉述時對「TradingView」之聽誤/筆誤。
Liquidity Sweeps [LuxAlgo] 指標原始碼是否公開可取? 已親手驗證:100% 真(開源 Pine v5) 喺邊度攞:
1. TradingView 公開腳本頁:https://www.tradingview.com/script/JRqryeJ5-Liquidity-Sweeps-LuxAlgo/(衍生版:https://www.tradingview.com/script/WYB2cYmM-Pure-Price-Action-Liquidity-Sweeps-LuxAlgo/)
2. TradingView 官方公開源碼 API 直連:https://pine-facade.tradingview.com/pine-facade/get/PUB%3B26391b932d3145879b67deca62305c9a/last
咩形式:完全開源(Open-source)Pine Script® v5 純文字源碼(CC BY-NC-SA 4.0 授權,共 160 行、5796 bytes,官方 digest 7e613fc5618c1070784779330ff05f138a9d5824,完整附於下節)。喺 TradingView 圖表搜尋該指標並點擊 {}(Source code)即可免付費直接查閱與複製。
帖尾提及之「5 年回測免費 EA」 未驗證(LINE 私域閉源引流) 續帖 ④ 稱須點擊作者個人簡介連結(https://lin.ee/yx9eCqY)加 LINE 領取免費 EA。該 EA 並非 TradingView 公開源碼,屬私域行銷引流物;本席嚴守安全邊界未加外部 LINE,明確標示為「未驗證」。

四、附錄:本席實抓驗證之 Liquidity Sweeps [LuxAlgo] 完整開源 Pine Script v5 源碼(160 行)

SHA-256 = 18be09f34ebf371e4cc8997ba77c29cc1ada4612a5529a79994694ec9b6ba12d(本機沙盒另以 Python 等價狀態機驗算雙向掃蕩斷言 PASS)

// This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) https://creativecommons.org/licenses/by-nc-sa/4.0/
// © LuxAlgo

//@version=5
indicator( 'Liquidity Sweeps [LuxAlgo]'
         , 'LuxAlgo - Liquidity Sweeps'
         ,  max_lines_count=500
         ,  max_boxes_count=500
         ,  overlay=true
         )

//------------------------------------------------------------------------------
//Settings
//-----------------------------------------------------------------------------{
len    = input.int(5, 'Swings', minval=1, group='Liquidity Sweeps')
opt    = input.string('Only Wicks', 'options'
       , options=['Only Wicks', 'Only Outbreaks & Retest', 'Wicks + Outbreaks & Retest'], group='Liquidity Sweeps')

colBl  = input.color(#089981, 'Bull ', group='Liquidity Sweeps', inline='c1')
colBr  = input.color(#f23645, 'Bear' , group='Liquidity Sweeps', inline='c2')
colBl2 = input.color(#08998180,  ''  , group='Liquidity Sweeps', inline='c1')
colBr2 = input.color(#f2364580,  ''  , group='Liquidity Sweeps', inline='c2')

extend = input.bool(true, 'Extend', group='Sweep Area') 
maxB   = input.int(300, 'Max bars', minval=1, maxval=5000, group='Sweep Area')
colBl3 = input.color(#08998141, 'Bull ', group='Sweep Area')
colBr3 = input.color(#f2364541, 'Bear' , group='Sweep Area')

oW = opt == 'Only Wicks'
oO = opt == 'Only Outbreaks & Retest'
WO = opt == 'Wicks + Outbreaks & Retest'

n = bar_index 

//-----------------------------------------------------------------------------}      
//UDT's
//-----------------------------------------------------------------------------{
type piv
    float prc // price
    int   bix // bar_index
    bool  brk // broken
    bool  mit // mitigated
    bool  tak // taken
    bool  wic // wick
    line  lin 

type boxBr 
    box  bx 
    line ln
    bool br
    int  dr

//-----------------------------------------------------------------------------}      
//Variables
//-----------------------------------------------------------------------------{
var array< piv >aPivH  = array.new< piv >(1, piv.new  ())
var array< piv >aPivL  = array.new< piv >(1, piv.new  ())
var array<boxBr>aBoxBr = array.new<boxBr>(1, boxBr.new())

//-----------------------------------------------------------------------------}      
//Methods - functions
//-----------------------------------------------------------------------------{
method n(float piv) => bool out = not na(piv)

method p(piv piv, float val) => float out = (100 / piv.prc * val) - 100

method l(piv get, color c, string s='sd') => 
    style = switch s 
        'dt' => line.style_dotted
        'ds' => line.style_dashed
        =>      line.style_solid 
    line.new(get.bix, get.prc, n, get.prc, color=c, style = style)

method br(piv get, color c3, color c, int d) =>
    y1 = d == 1 ? high : get.prc
    y2 = d == 1 ? get.prc : low
    boxBr.new( 
     box.new(n -1, y1, n +1, y2
     , border_color
     = color.new(
       na, na   )
     , bgcolor=c3)
     , line.new(n , y1, n, y2, color=c, width=3)
     , false
     , d)

lnDot(y, c) => line.new(n, y, n+3, y, color=c, style=line.style_dotted)

//-----------------------------------------------------------------------------}      
//Execution
//-----------------------------------------------------------------------------{
ph = ta.pivothigh(len, len)
pl = ta.pivotlow (len, len)

if ph.n() 
    aPivH.unshift(piv.new(ph, n -len, false, false, false, false))

if pl.n() 
    aPivL.unshift(piv.new(pl, n -len, false, false, false, false)) 

for i = aPivH.size() -1 to 0
    get = aPivH.get(i)
    if not get.mit
        if not get.brk
            if close > get.prc 
                if not oW
                    get.brk := true
                else 
                    get.mit := true
            if not oO and not get.wic 
                if high > get.prc and close < get.prc                   
                    aBoxBr.unshift(get.br(colBr3, colBr, 1))       
                    get.l(colBr2, 'dt'), lnDot(low, colBr)
                    get.wic := true  
        else 
            if close < get.prc 
                get.mit := true
            if not oW and low < get.prc and close > get.prc                    
                aBoxBr.unshift(get.br(colBl3, colBl, -1))    
                get.l(colBl2, 'ds'), lnDot(high, colBl)
                get.tak := true 

    if n - get.bix > 2000 or get.mit or get.tak 
        aPivH.remove(i).lin.delete()

for i = aPivL.size() -1 to 0
    get = aPivL.get(i)
    if not get.mit
        if not get.brk
            if close < get.prc 
                if not oW
                    get.brk := true
                else 
                    get.mit := true
            if not oO and not get.wic 
                if low < get.prc and close > get.prc                              
                    aBoxBr.unshift(get.br(colBl3, colBl, -1))     
                    get.l(colBl2, 'dt'), lnDot(high, colBl)
                    get.wic := true 
        else 
            if close > get.prc 
                get.mit := true
            if not oW and high > get.prc and close < get.prc                     
                aBoxBr.unshift(get.br(colBr3, colBr, 1))    
                get.l(colBr2, 'ds'), lnDot(low, colBr)
                get.tak := true  

    if n - get.bix > 2000 or get.mit or get.tak 
        aPivL.remove(i).lin.delete()

if extend
    for bx in aBoxBr 
        if not bx.br and n - bx.bx.get_left() -1 <= maxB 
            bx.bx.set_right(bar_index)
            if bx.dr == -1 and close < bx.bx.get_bottom() 
                bx.br := true 
            if bx.dr ==  1 and close > bx.bx.get_top   () 
                bx.br := true 

//-----------------------------------------------------------------------------}