Liquidity Sweeps 技術指標完整計法拆解與核實報告

版本:Rev 3 定版歸檔(保留 Rev 2/Rev 1 於下方) 日期:2026-11-20 來源指令:Relay seq=65024 + seq=65033 + seq=65053 (dj_host1, sha12=93fefc5d9251) 席位:A93 (A932756|3號組) 改動摘要:Rev 3 定版歸檔 V2 指標(新增零依賴 Node.js 1:1 實作 computeLiquiditySweepsV2 並經 Node v20.20.2 實跑 6/6 測試 PASS;收口停議)

【Rev 3 定版歸檔|應 seq=65053 定調=V2 指標】算法+完整編碼保存(Pine v6 + Node.js 1:1 模組)

定調狀態:依主持 seq=65053(sha12=93fefc5d9251)定調,本指標歸檔為 V2 指標;本單一自包含 HTML 已完整保存:(1)原帖驗證、(2)逐行數學算法與狀態機、(3)輸入欄位全量審計(純 H/L/C + bar_index)、(4)官方 Pine Script v6 160 行原碼、(5)可直接接入 market-engine-server.js 之零依賴 Node.js 參考實作。收口封存,待日後改程式階段再行整合。

歸檔組件實測驗證結果
Node.js 參考模組v2_liquidity_sweeps.js(computeLiquiditySweepsV2(bars, options),sha256=e005c6e8ce59…),1:1 對應 LuxAlgo Pine v6 L1–L160(含 ta.pivothigh/low 左右嚴格/非嚴格比較、三種 opt 模式、2000 根過期、Sweep Area 延伸+maxB=300+Mitigation 終止)。
本機實測結果Node v20.20.2 單元測試 6/6 PASS(Test 1 看跌影線掃蕩+Mitigation、Test 2 看漲影線掃蕩、Test 3 實體上破+看漲回測兼驗 Only Wicks 淘汰、Test 4 看跌回測、Test 5 maxB 上限停止延伸、Test 6 close === pivotPrice 嚴格不等式邊界)。

V2 指標 Node.js 1:1 參考實作與 6 項單元測試(v2_liquidity_sweeps.js)

'use strict';

/**
 * V2 Indicator: Liquidity Sweeps (1:1 JS port of Liquidity Sweeps [LuxAlgo] Pine Script v6, 160 lines)
 * Inputs: bars = [{ high, low, close }, ...] (pure H/L/C + array index; no open, no volume, no external data)
 * Options:
 *   len    (int, default 5, >= 1): symmetric pivot lookback left=right=len
 *   opt    ('Only Wicks' | 'Only Outbreaks & Retest' | 'Wicks + Outbreaks & Retest', default 'Only Wicks')
 *   extend (bool, default true): extend sweep area boxes up to maxB bars or until mitigated
 *   maxB   (int, default 300, 1..5000): maximum extension bars for sweep area
 */
function computeLiquiditySweepsV2(bars, options = {}) {
  const len = Math.max(1, Number.isInteger(options.len) ? options.len : 5);
  const opt = options.opt || 'Only Wicks';
  const extend = options.extend !== undefined ? Boolean(options.extend) : true;
  const maxB = Math.min(5000, Math.max(1, Number.isInteger(options.maxB) ? options.maxB : 300));

  const oW = opt === 'Only Wicks';
  const oO = opt === 'Only Outbreaks & Retest';

  // Pine ta.pivothigh(high, len, len) at bar n:
  // checks pivot candidate at idx = n - len against [idx - len .. idx - 1] (>=) and [idx + 1 .. idx + len] (>)
  function pivotHighAt(n) {
    if (n < 2 * len) return null;
    const idx = n - len;
    const cand = bars[idx].high;
    if (!Number.isFinite(cand)) return null;
    for (let k = idx - len; k < idx; k++) {
      if (!(cand >= bars[k].high)) return null;
    }
    for (let k = idx + 1; k <= idx + len; k++) {
      if (!(cand > bars[k].high)) return null;
    }
    return cand;
  }

  function pivotLowAt(n) {
    if (n < 2 * len) return null;
    const idx = n - len;
    const cand = bars[idx].low;
    if (!Number.isFinite(cand)) return null;
    for (let k = idx - len; k < idx; k++) {
      if (!(cand <= bars[k].low)) return null;
    }
    for (let k = idx + 1; k <= idx + len; k++) {
      if (!(cand < bars[k].low)) return null;
    }
    return cand;
  }

  const aPivH = []; // newest first (unshift)
  const aPivL = [];
  const boxes = []; // { dir: +1 bear | -1 bull, kind: 'wick'|'retest', left, right, top, bottom, triggerBar, pivotBar, pivotPrice, triggerLineY, triggerLineEnd, mitigated, mitigatedAt }
  const events = [];

  function addSweep(piv, dir, kind, n, bar) {
    const top = dir === 1 ? bar.high : piv.prc;
    const bottom = dir === 1 ? piv.prc : bar.low;
    const triggerLineY = dir === 1 ? bar.low : bar.high;
    const box = {
      dir,
      side: dir === 1 ? 'BEAR' : 'BULL',
      kind, // 'wick' (dotted) or 'retest' (dashed)
      lineStyle: kind === 'wick' ? 'dotted' : 'dashed',
      pivotBar: piv.bix,
      pivotPrice: piv.prc,
      triggerBar: n,
      left: n - 1,
      right: n + 1,
      top,
      bottom,
      triggerLineY,
      triggerLineEnd: n + 3,
      mitigated: false,
      mitigatedAt: null,
    };
    boxes.unshift(box);
    events.push(box);
  }

  for (let n = 0; n < bars.length; n++) {
    const bar = bars[n];
    const ph = pivotHighAt(n);
    const pl = pivotLowAt(n);

    if (ph !== null) {
      aPivH.unshift({ prc: ph, bix: n - len, brk: false, mit: false, tak: false, wic: false });
    }
    if (pl !== null) {
      aPivL.unshift({ prc: pl, bix: n - len, brk: false, mit: false, tak: false, wic: false });
    }

    // Active Pivot Highs (BSL)
    for (let i = aPivH.length - 1; i >= 0; i--) {
      const p = aPivH[i];
      if (!p.mit) {
        if (!p.brk) {
          if (bar.close > p.prc) {
            if (!oW) p.brk = true;
            else p.mit = true;
          }
          if (!oO && !p.wic) {
            if (bar.high > p.prc && bar.close < p.prc) {
              addSweep(p, 1, 'wick', n, bar);
              p.wic = true;
            }
          }
        } else {
          if (bar.close < p.prc) p.mit = true;
          if (!oW && bar.low < p.prc && bar.close > p.prc) {
            addSweep(p, -1, 'retest', n, bar);
            p.tak = true;
          }
        }
      }
      if (n - p.bix > 2000 || p.mit || p.tak) {
        aPivH.splice(i, 1);
      }
    }

    // Active Pivot Lows (SSL)
    for (let i = aPivL.length - 1; i >= 0; i--) {
      const p = aPivL[i];
      if (!p.mit) {
        if (!p.brk) {
          if (bar.close < p.prc) {
            if (!oW) p.brk = true;
            else p.mit = true;
          }
          if (!oO && !p.wic) {
            if (bar.low < p.prc && bar.close > p.prc) {
              addSweep(p, -1, 'wick', n, bar);
              p.wic = true;
            }
          }
        } else {
          if (bar.close > p.prc) p.mit = true;
          if (!oW && bar.high > p.prc && bar.close < p.prc) {
            addSweep(p, 1, 'retest', n, bar);
            p.tak = true;
          }
        }
      }
      if (n - p.bix > 2000 || p.mit || p.tak) {
        aPivL.splice(i, 1);
      }
    }

    // Sweep Area extension & mitigation (Pine L151-158)
    if (extend) {
      for (const bx of boxes) {
        if (!bx.mitigated && n - bx.left - 1 <= maxB) {
          bx.right = n;
          if (bx.dir === -1 && bar.close < bx.bottom) {
            bx.mitigated = true;
            bx.mitigatedAt = n;
          }
          if (bx.dir === 1 && bar.close > bx.top) {
            bx.mitigated = true;
            bx.mitigatedAt = n;
          }
        }
      }
    }
  }

  return { events, activePivotHighs: aPivH, activePivotLows: aPivL };
}

module.exports = { computeLiquiditySweepsV2 };

if (require.main === module) {
  const assert = require('assert');

  // Test 1: Bearish Wick Sweep on Pivot High (len=2) + Mitigation on close > top
  const bars1 = [
    { high: 10, low: 8, close: 9 },
    { high: 11, low: 9, close: 10 },
    { high: 15, low: 10, close: 14 }, // idx 2: pivot high = 15, confirmed at n=4
    { high: 13, low: 11, close: 12 },
    { high: 12, low: 10, close: 11 }, // n=4: pivot 15 enters aPivH
    { high: 16.5, low: 11.5, close: 14.2 }, // n=5: high>15 & close<15 => Bearish wick sweep [15, 16.5]
    { high: 15.8, low: 13, close: 14.5 },   // n=6: inside box, extends right=6
    { high: 17.2, low: 14, close: 17.0 },   // n=7: close>16.5 => mitigated
    { high: 18, low: 16, close: 17.5 },     // n=8: box stays right=7
  ];
  const r1 = computeLiquiditySweepsV2(bars1, { len: 2, opt: 'Only Wicks', extend: true, maxB: 300 });
  assert.strictEqual(r1.events.length, 1);
  assert.strictEqual(r1.events[0].side, 'BEAR');
  assert.strictEqual(r1.events[0].kind, 'wick');
  assert.strictEqual(r1.events[0].pivotBar, 2);
  assert.strictEqual(r1.events[0].triggerBar, 5);
  assert.strictEqual(r1.events[0].top, 16.5);
  assert.strictEqual(r1.events[0].bottom, 15);
  assert.strictEqual(r1.events[0].mitigated, true);
  assert.strictEqual(r1.events[0].mitigatedAt, 7);
  assert.strictEqual(r1.events[0].right, 7);

  // Test 2: Bullish Wick Sweep on Pivot Low (len=2)
  const bars2 = [
    { high: 20, low: 18, close: 19 },
    { high: 19, low: 17, close: 18 },
    { high: 17, low: 12, close: 15 }, // idx 2: pivot low = 12, confirmed at n=4
    { high: 16, low: 14, close: 15 },
    { high: 17, low: 15, close: 16 },
    { high: 15.5, low: 11.2, close: 13.0 }, // n=5: low<12 & close>12 => Bullish wick sweep [11.2, 12]
  ];
  const r2 = computeLiquiditySweepsV2(bars2, { len: 2, opt: 'Only Wicks' });
  assert.strictEqual(r2.events.length, 1);
  assert.strictEqual(r2.events[0].side, 'BULL');
  assert.strictEqual(r2.events[0].top, 12);
  assert.strictEqual(r2.events[0].bottom, 11.2);

  // Test 3: Outbreak & Retest (Bullish retest of broken Pivot High)
  const bars3 = [
    { high: 10, low: 8, close: 9 },
    { high: 11, low: 9, close: 10 },
    { high: 15, low: 10, close: 14 }, // idx 2: pivot high = 15
    { high: 13, low: 11, close: 12 },
    { high: 12, low: 10, close: 11 }, // n=4 confirmed
    { high: 17, low: 13, close: 16 }, // n=5 close>15 => brk=true (in Only Wicks, retired!)
    { high: 16.5, low: 14.5, close: 15.8 }, // n=6 low<15 & close>15 => Bullish retest sweep!
  ];
  const r3_ow = computeLiquiditySweepsV2(bars3, { len: 2, opt: 'Only Wicks' });
  assert.strictEqual(r3_ow.events.length, 0);
  const r3_oo = computeLiquiditySweepsV2(bars3, { len: 2, opt: 'Only Outbreaks & Retest' });
  assert.strictEqual(r3_oo.events.length, 1);
  assert.strictEqual(r3_oo.events[0].side, 'BULL');
  assert.strictEqual(r3_oo.events[0].kind, 'retest');
  assert.strictEqual(r3_oo.events[0].top, 15);
  assert.strictEqual(r3_oo.events[0].bottom, 14.5);

  // Test 4: Bearish Outbreak & Retest on broken Pivot Low
  const bars4 = [
    { high: 20, low: 18, close: 19 },
    { high: 19, low: 17, close: 18 },
    { high: 17, low: 12, close: 15 }, // idx 2: pivot low = 12
    { high: 16, low: 14, close: 15 },
    { high: 17, low: 15, close: 16 }, // n=4 confirmed
    { high: 14, low: 10, close: 11 }, // n=5 close<12 => brk=true
    { high: 12.6, low: 10.5, close: 11.4 }, // n=6 high>12 & close<12 => Bearish retest sweep!
  ];
  const r4 = computeLiquiditySweepsV2(bars4, { len: 2, opt: 'Wicks + Outbreaks & Retest' });
  assert.strictEqual(r4.events.length, 1);
  assert.strictEqual(r4.events[0].side, 'BEAR');
  assert.strictEqual(r4.events[0].kind, 'retest');
  assert.strictEqual(r4.events[0].top, 12.6);
  assert.strictEqual(r4.events[0].bottom, 12);

  // Test 5: maxB cap stops box extension cleanly (n - left - 1 <= maxB => n <= triggerBar + maxB)
  const bars5 = bars1.slice(0, 6).concat([
    { high: 15, low: 13, close: 14 }, // n=6 (age 1)
    { high: 15, low: 13, close: 14 }, // n=7 (age 2)
    { high: 15, low: 13, close: 14 }, // n=8 (age 3 > maxB=2)
  ]);
  const r5 = computeLiquiditySweepsV2(bars5, { len: 2, opt: 'Only Wicks', extend: true, maxB: 2 });
  assert.strictEqual(r5.events[0].right, 7);
  assert.strictEqual(r5.events[0].mitigated, false);

  // Test 6: Exact close == pivotPrice triggers neither break nor sweep (strict inequality)
  const bars6 = bars1.slice(0, 5).concat([
    { high: 16, low: 14, close: 15 }, // close == 15
  ]);
  const r6 = computeLiquiditySweepsV2(bars6, { len: 2, opt: 'Only Wicks' });
  assert.strictEqual(r6.events.length, 0);
  assert.strictEqual(r6.activePivotHighs.length, 1);

  console.log('ALL_6_TESTS_PASS (V2 Liquidity Sweeps JS 1:1 Pine v6 port)');
}

【Rev 2 新增|應 seq=65033 追問】輸入數據逐項全量掃描(0 猜測)

結論:係——100% 純 K 線數據即可完全複現,而且甚至唔需要 open 同 volume,唔需要任何盤口(L2/Order Book)、Tick、跨週期(request.security)或外部資金/清算數據。只需當前週期普通 K 線嘅 high、low、close、bar_index 四項即可 100% 獨立算出。

輸入欄位數據來源原碼引用次數與行號(luxalgo_liquidity_sweeps.pine)實際用途
high當前週期 K 線最高價5 次(L75, L111, L120, L138, L143)+ L92 ta.pivothigh(len,len) 隱式預設 source擺動高點 LqL 偵測、上破影線判定、看跌 Sweep Area 上界、3-bar 觸發線
low當前週期 K 線最低價5 次(L76, L113, L118, L136, L145)+ L93 ta.pivotlow(len,len) 隱式預設 source擺動低點 LqL 偵測、下破影線判定、看漲 Sweep Area 下界、3-bar 觸發線
close當前週期 K 線收盤價10 次(L105, L111, L116, L118, L130, L136, L141, L143, L155, L157)收盤突破判定、收回區間確認、水平失效、Sweep Area Mitigation 終止
bar_index (n)當前週期 K 線序號(0,1,2…)2 次(L33, L154)計算 Pivot 位置 n-len、2000 根自動過期、方框延伸上限 maxB=300
open / volume / time(未引用)0 次原版 LuxAlgo 腳本完全唔讀開盤價、成交量、時間戳
外部數據(盤口 L2 / Tick / 跨週期 request.security / 訂單流)(未引用)0 次無任何真實止損盤或交易所深度接口;「流動性位」係由歷史高/低點價位推斷嘅純 OHLC 代理指標

補充說明(誠實邊界):原帖回覆串(3 則)仍受 X 登入牆未能拉取,若作者私下改用第三方衍生版(如加成交量過濾之版本)則會多用 volume 一個普通 K 線欄位,依然唔需盤口數據。

一、原帖實核內容(多鏡像交叉驗證,無憑印象補寫)

欄位實測驗證結果
目標連結https://x.com/foodloss_otoko/status/2123461381030834442
驗證鏡像api.fxtwitter.com、cdn.syndication.twimg.com、publish.twitter.com/oembed、fetch_page(四處原文 100% 一致)
作者資訊顯示名:べーた|帳號:@foodloss_otoko(ID 1935277322825089024)|簡介:専業トレーダー、EA×裁量で生活してます。|個人網站:https://lin.ee/yx9eCqY
發布時間與互動2026-11-19T17:00:19Z(HKT 2026-11-20 01:00:19)|瀏覽 36,445|讚 279|轉推 28|書籤 451|回覆數 3
主帖附圖/媒體主帖本身無附圖(FxTwitter media: null,is_note_tweet: false,長度 123 字元)。
回覆串核實邊界未驗證:主帖句尾「具体的な使い方なんだけど、、、」且顯示 replies=3,屬後續回覆串;因 X 登入牆限制,公開鏡像未能讀取該 3 則回覆正文及其可能附帶嘅圖表截圖,故不作猜測或補寫。

主帖全文(逐字引用)

マジで全トレーダーに「Liquidity Sweeps」を使ってほしい。 「これブレイクじゃなくてダマシやん」って場所が一瞬で分かる。 俺もずっと使ってるけど、これだけで月+100万ならガチで初心者でもいけそう。 具体的な使い方なんだけど、、、

中文直譯:真心希望所有交易員都用「Liquidity Sweeps」。一眼就睇得出「呢度唔係真突破,係假突破(ダマシ)」。我自己一直都用緊,淨係靠呢個就算新手都好似真係可以月賺+100 萬日圓。講下具體用法呢……

二、指標起源與完整數學計法(基於官方開源 160 行 Pine Script v6,不跳步)

1. 發展基礎與版本定位

2. 輸入數據與全部參數(L15–L33)

符號/參數類型與預設值範圍/選項用途
high, low, close, bar_index (n)K 線序列OHLC(唔用 open,亦唔用 volume)所有計算僅依賴最高價、最低價、收盤價與 K 線序號 n
len (Swings)int = 5minval = 1對稱擺動高低點回望週期(左 len 根+右 len 根)
opt (options)string = 'Only Wicks''Only Wicks' (oW) / 'Only Outbreaks & Retest' (oO) / 'Wicks + Outbreaks & Retest' (WO)控制偵測「純影線假突破」定「實體突破後回測反抽」,或兩者皆測
extend (Extend)bool = truetrue / false是否將 Sweep Area 區間方框向右延伸
maxB (Max bars)int = 3001 .. 5000Sweep Area 方框最多向右延伸嘅 K 線根數
硬編過期上限(L123/L148)常數 2000固定當 n - get.bix > 2000 時自動淘汰舊流動性位

3. 逐步驟公式與狀態機(L92–L158)

  1. Step 1|確認擺動高低點=流動性位 LqL(L92–L99)
    每根 K 線 n 計算 ph = ta.pivothigh(high, len, len)、pl = ta.pivotlow(low, len, len):
    • 若 high[n - len] ≥ high[k](對所有 k ∈ [n - 2·len, n - len - 1])且 high[n - len] > high[k](對所有 k ∈ [n - len + 1, n]),則在 n 根確認一個 Pivot High,寫入陣列 aPivH:{prc = high[n-len], bix = n - len, brk = false, mit = false, tak = false, wic = false}。
    • 對稱地,low[n - len] 為左右各 len 根內最低值時,確認一個 Pivot Low,寫入 aPivL。
    • 確認滯後:位於 t 根嘅高低點要等到 t + len 根先會入池(預設滯後 5 根 K 線)。
  2. Step 2|掃描所有活躍 Pivot High P = get.prc(買方流動性 BSL,L101–L124)
    對陣列 aPivH 逆序遍歷每個未失效(not get.mit)水平:
    • 狀態 A:未實體突破(not get.brk)
      • 收盤突破判定(L105–L109):若 close > P:若允許 Outbreak(not oW)則置 get.brk := true(轉入等待回測態);否則(Only Wicks 模式)置 get.mit := true(真突破,直接淘汰、唔出掃蕩訊號)。
      • 看跌影線掃蕩 Bearish Wick Sweep(L110–L114):若 (not oO) and (not get.wic) 且 high > P and close < P:
        • 畫 Bearish Sweep Area(方向 d = +1):上界 y1 = high、下界 y2 = P、水平範圍 [n-1, n+1];於 n 根畫 width=3 粗紅豎線;由 (get.bix, P) 至 (n, P) 畫點線(dotted);於當根最低價 low 向右畫 3 根點線觸發參考線 (n, low)→(n+3, low)。
        • 置 get.wic := true(每個水平最多觸發一次影線掃蕩;注意 WO 模式下未設 mit,該水平之後仍可被實體突破轉入狀態 B)。
    • 狀態 B:已實體上破待回測(get.brk == true,L115–L121)
      • 回落失效(L116–L117):若 close < P 則置 get.mit := true(突破失敗,淘汰)。
      • 看漲回測掃蕩 Bullish Retest Sweep(L118–L121):若 not oW 且 low < P and close > P(回踩跌穿 P 後收回 P 上方):
        • 畫 Bullish Sweep Area(方向 d = -1):上界 y1 = P、下界 y2 = low;由 (get.bix, P) 至 (n, P) 畫虛線(dashed);於 high 畫 3 根點線參考線。
        • 置 get.tak := true(已完成回測,淘汰該水平)。
    • 淘汰條件(L123–L124):當 n - get.bix > 2000 或 get.mit 或 get.tak,自 aPivH 移除。
  3. Step 3|鏡像掃描所有活躍 Pivot Low P = get.prc(賣方流動性 SSL,L126–L149)
    完全鏡像對稱:
    • not get.brk 且 close < P → 若 not oW 置 get.brk := true,否則 get.mit := true。
    • 看漲影線掃蕩 Bullish Wick Sweep(L135–L139):(not oO) and (not get.wic) 且 low < P and close > P → 建 Bullish Sweep Area(d = -1,區間 [low, P])、點線 LqL、high 處 3 根點線,置 get.wic := true。
    • get.brk == true 且 close > P → 置 get.mit := true。
    • 看跌回測掃蕩 Bearish Retest Sweep(L143–L146):not oW 且 high > P and close < P → 建 Bearish Sweep Area(d = +1,區間 [P, high])、虛線 LqL、low 處 3 根點線,置 get.tak := true。
  4. Step 4|Sweep Area 延伸與 Mitigation 終止(L151–L158)
    當 extend == true,對每個未終止(not bx.br)嘅方框:
    • 只要 n - bx.bx.get_left() - 1 ≤ maxB(因建立時 left = trigger_n - 1,等價於 n - trigger_n ≤ maxB),將方框右緣更新為 bar_index。
    • Mitigation 終止:若看漲框(dr == -1)出現 close < box_bottom(跌破掃蕩影線極低點),或看跌框(dr == +1)出現 close > box_top(升破掃蕩影線極高點),即置 bx.br := true 停止延伸。

4. 源碼級細節備註(審計發現)

模式 1:Wick Sweep(點線 LqL|高破低收=Bearish) Pivot High P (bix = n-len) Sweep Area [P, high] 條件:high > P 且 close < P → 紅框 [P, high] + low 處 3-bar 點線 模式 2:Outbreak & Retest(虛線 LqL|上破回踩=Bullish) 先 close > P (brk=true),後回測 low < P 且 close > P Sweep Area [low, P] 條件:brk=true 且 low < P 且 close > P → 綠框 [low, P] + high 處 3-bar 點線

三、核實:「code 可以去 TeamViewer 攞」係咪真?

核實項目結論與證據
是否 TeamViewer?否(名稱混淆/口誤)。TeamViewer 係遠端桌面控制軟件,唔提供技術指標源碼庫;真正提供 Liquidity Sweeps 開源代碼嘅係圖表平台 TradingView(讀音/拼寫同 TeamViewer 易混淆)。
官方免費取碼路徑 1已實測驗證:TradingView 公開頁 https://www.tradingview.com/script/JRqryeJ5-Liquidity-Sweeps-LuxAlgo/(標示 OPEN-SOURCE SCRIPT,免費帳號都可喺圖表 Indicators 搜尋 Liquidity Sweeps 直接套用,或點 Source code 展開完整 Pine Script 代碼)。
官方免費取碼路徑 2已實測驗證:LuxAlgo 官方 Library https://www.luxalgo.com/library/indicator/liquidity-sweeps/(直接內嵌完整 160 行 CC BY-NC-SA 4.0 Pine Script v6 源碼,本席已實測提取驗證)。
作者回覆串/LINE 分發未驗證:作者 @foodloss_otoko 個人頁掛有 LINE 連結 https://lin.ee/yx9eCqY,主帖 3 則回覆受 X 登入牆未能拉取;帖內回覆有否寫錯成 TeamViewer 或要求經 LINE 領取個人改版/參數,特此註明未驗證。

四、附錄:已驗證官方原碼(Liquidity Sweeps [LuxAlgo], Pine Script v6, 160 行)

// 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=6
indicator( 'Liquidity Sweeps'
         , '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 

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