Auto Harmonic Patterns [Trader-Alex])

Whether you are a scalper or a swing trader, this tool streamlines the complex process of measuring Fibonacci ratios, allowing you to focus on execution rather than manual drawing.
Key Features
Multi-Scale Scanning Engine: The indicator runs 5 independent scanning groups simultaneously. This allows it to detect patterns across different market distinct market cycles (micro-structures to macro-trends) within a single timeframe.
Comprehensive Pattern Support: Automatically recognizes a wide range of classic and modern harmonic patterns, including:
- Gartley
- Bat & Alt Bat
- Butterfly
- Crab & Deep Crab
- Shark
- Cypher
Predictive PRZ Technology (Potential Patterns): Unlike standard indicators that only show completed patterns, this tool projects "Potential Patterns" in real-time. It calculates the Potential Reversal Zone (PRZ) based on converging Fibonacci projections, giving you a clear visual of where the D-point (Entry) is likely to form before price arrives.
Smart Filtering & Optimization: To maintain a clean chart, the indicator includes an intelligent filtering system. If multiple patterns are detected in the same area, it automatically evaluates the geometry and risk-to-reward ratio to display only the most optimal setup.
Integrated Trade Management: For every valid pattern, the indicator automatically plots:
- Entry Level: The optimal completion point.
- Stop Loss (SL): Calculated based on invalidation structures.
- Take Profit (TP1 & TP2): Based on standard harmonic retracement targets.
Visual Clarity: Distinguishes between Bullish (Green/Blue tones) and Bearish (Red/Orange tones) setups. Successful historical patterns and currently developing patterns are visually distinct for easy back-testing and live trading.
Disclaimer This tool is for educational and informational purposes only. Trading financial markets involves risk. Past performance of harmonic patterns does not guarantee future results. Always use proper risk management.
-------------------------------------------------------------------------------------
此指標是一套高階的技術分析工具,專為自動化識別金融市場中的「諧波型態 (Harmonic Patterns)」而設計。透過多層次的掃描引擎,它能精準偵測價格行為中的幾何結構,協助交易者快速鎖定高勝率的潛在反轉區 (PRZ)。
無論您是短線交易者還是波段交易者,此工具都能簡化繁瑣的費波那契比例測量過程,讓您能專注於交易決策而非手動繪圖。
核心功能
多維度掃描引擎: 指標內建 5 組獨立的掃描運算邏輯,能夠同時運行。這意味著它能在單一圖表時間週期內,同時捕捉從小級別結構到大級別趨勢的各種型態。
支援多種經典型態: 自動識別市場上主流的諧波結構,包含:
- 加特利 (Gartley)
- 蝙蝠與變種蝙蝠 (Bat & Alt Bat)
- 蝴蝶 (Butterfly)
- 螃蟹與深海螃蟹 (Crab & Deep Crab)
- 鯊魚 (Shark)
- 賽福 (Cypher)
預測性 PRZ 技術 (潛在型態): 不同於一般指標僅顯示「已完成」的歷史型態,本工具具備即時預測功能。它能根據費波那契數列的匯聚點,計算出潛在反轉區 (PRZ),在價格到達前提前標示出預期的 D 點 (入場點)。
智能篩選與優化: 為了保持圖表整潔,指標內建智能過濾系統。當同一區域偵測到多個重疊型態時,系統會自動評估幾何結構與盈虧比,僅顯示條件最優異的一個交易機會。
整合式交易管理: 針對每一個有效型態,指標會自動計算並繪製:
- 入場價 (Entry): 型態完成的最佳價位。
- 止損位 (SL): 基於結構失效點的防守位置。
- 止盈位 (TP1 & TP2): 基於諧波回撤比例的標準獲利目標。
視覺化清晰呈現: 清楚區分看漲 (綠/藍色系) 與看跌 (紅/橙色系) 架構。歷史勝率回測線圖與正在發展中的潛在型態均有不同的視覺樣式,方便用戶進行複盤與實盤操作。
免責聲明 本工具僅供教學與輔助分析使用。金融市場交易具有風險,諧波型態的歷史表現不代表未來獲利保證。請務必做好個人風險管理。
This update brings a significant overhaul to the visual customization and user interface of the Auto Harmonic Patterns indicator. Designed for traders who require precise control over their chart aesthetics, this version allows for full color customization and improved visibility across different chart themes.
Key Features & Updates:
1. 🎨 Individual Pattern Customization You now have granular control over every harmonic pattern.
Toggle Visibility: Independently enable or disable specific patterns (e.g., show only Gartley and Bat, hide others).
Custom Colors: Assign a unique color to each pattern type. For example, set Gartley to Green, Shark to Cyan, and Crab to Purple to easily distinguish them at a glance.
2. 🌓 Dark & Light Mode Support Fixed visibility issues for entry labels on different backgrounds.
Dark Mode: Sets Entry text to White (optimized for dark backgrounds).
Light Mode: Sets Entry text to Black (optimized for light/white backgrounds).
Select your preference in the "Style Settings".
3. 🎯 Custom TP & SL Colors
You are no longer restricted to the default green/red for Take Profit and Stop Loss lines.
Customize the TP Line Color and SL Line Color directly in the settings to match your personal charting theme.
How to Use:
Add the indicator to your chart.
Open Settings (Inputs tab).
Scroll to "Pattern Visibility & Colors" to toggle patterns and set their specific colors.
Scroll to "Style Settings" to select your Chart Mode (Dark/Light) and set custom TP/SL line colors.
-----------------------------------------------------------------------------------------------------
自動諧波型態識別 (Auto Harmonic Patterns) - 自定義顏色與介面更新
本次更新大幅提升了指標的視覺客製化功能與使用者介面體驗。專為需要精確控制圖表美學的交易者設計,此版本允許完全自定義顏色,並優化了在不同圖表主題下的顯示效果。
主要功能與更新:
1. 🎨 獨立型態客製化 您現在可以對每一個諧波型態進行細緻的控制。
獨立開關: 單獨啟用或關閉特定型態(例如:只顯示 Gartley 和 Bat,隱藏其他型態)。
自定義顏色: 為每一種型態指定獨立的顏色。例如,您可以將 Gartley 設為綠色,Shark 設為青色,Crab 設為紫色,以便一眼區分不同架構。
2. 🌓 支援日間與夜間模式 (Dark/Light Mode) 解決了進場價格 (Entry) 文字在不同背景顏色下看不清楚的問題。
Dark Mode (夜間模式): 將 Entry 文字設為 白色(適用於深色背景)。
Light Mode (日間模式): 將 Entry 文字設為 黑色(適用於淺色/白色背景)。
請在「樣式設定 (Style Settings)」中選擇您的偏好。
3. 🎯 自定義 TP 與 SL 顏色
止盈 (TP) 與止損 (SL) 線條不再侷限於預設的紅綠色。
您可以在設定中直接自定義 TP Line Color 與 SL Line Color,使其完美融入您的個人圖表配色。
使用說明:
將指標加入圖表。
打開 設定 (Settings)。
前往 "Pattern Visibility & Colors" 區塊,開關特定型態並設定其專屬顏色。
前往 "Style Settings" 區塊,選擇圖表模式 (Dark/Light) 並設定喜歡的 TP/SL 線條顏色。
This major update introduces a robust statistical analysis tool and significantly improves the pattern recognition engine to ensure the most accurate harmonic detections.
Key Updates:
1. 📊 Real-Time Win Rate Statistics Table A new dashboard has been added to the chart (customizable position) to track the historical performance of every pattern.
Metrics: Displays Total patterns found, TP1 Hit %, TP2 Hit %, and SL Hit %.
Break-Even Logic: The statistics use smart tracking. If a pattern hits TP1, it is considered a "winning" or "break-even" trade. If price subsequently reverses to hit the Stop Loss, it is not recorded as a loss in the SL% column, providing a more realistic view of trade management.
2. 🧠 Enhanced Pattern Recognition (Best Fit Algorithm) We have overhauled the detection logic to solve overlapping pattern conflicts.
Shark vs. Cypher Fix: Previously, some Shark patterns were incorrectly identified as Cyphers due to similar B-point ratios. The new "Best Fit" algorithm compares the geometric error score of both patterns and selects the one that is mathematically closer to the ideal definition.
Dual Shark Targets: The indicator now distinguishes between the 0.886 Shark and the 1.13 Shark. It automatically detects which D-point projection matches the price action better and adjusts the Entry, SL, and Targets accordingly.
----------------------------------------------------------------------------
自動諧波型態識別 [邏輯修復與勝率統計]
本次更新引入了強大的統計分析工具,並大幅改進了型態識別引擎,以確保提供最精確的諧波交易訊號。
主要更新內容:
1. 📊 即時勝率統計表格 (Statistics Table) 圖表上新增了一個數據儀表板(位置可自定義),用於追蹤歷史型態的表現。
數據指標: 顯示已發現的 型態總數 (Total)、TP1 命中率、TP2 命中率 以及 止損率 (SL %)。
保本邏輯 (Break-Even Logic): 統計採用更貼近實戰的邏輯。如果價格先觸發了 TP1,該交易即被視為獲利或保本。若價格隨後反轉觸碰止損,不會被計入 SL% 的敗場中,這能提供更具參考價值的風險評估。
2. 🧠 強化識別邏輯 (最佳匹配算法) 我們全面修正了檢測邏輯,解決了型態重疊時的衝突問題。
修復 Shark 與 Cypher 衝突: 過去部分鯊魚型態 (Shark) 因 B 點比例相近而被誤判為賽弗 (Cypher)。新的「最佳匹配 (Best Fit)」演算法會計算幾何誤差值,自動選擇數學比例上最完美的型態進行標記。
雙重鯊魚目標: 指標現在能自動區分 0.886 Shark 與 1.13 Shark。程式會自動判斷價格行為更符合哪一種 D 點延伸,並據此調整進場點、止損位與獲利目標。
Key Features & Updates:
1. 🌐 Bilingual Settings Interface (English & Chinese) To make the indicator more accessible, all input parameters and setting menus have been updated to a dual-language format: English (Chinese).
Traders can now easily understand complex harmonic parameters (like "Tolerance" or "Scan Period") without language barriers.
Example: Length is now displayed as Length (長度).
2. ↔️ Customizable PRZ Width (Padding) Standard harmonic calculations can sometimes result in a Potential Reversal Zone (PRZ) that is too narrow, leading to valid trades being visually "stopped out" by small wicks.
New Feature: Added a "PRZ Padding %" setting.
How it works: You can manually expand the upper and lower boundaries of the PRZ box by a specific percentage. This allows you to create a wider "kill zone" to accommodate market volatility and price spikes, ensuring you don't miss entries due to tight calculations.
----------------------------------------------------------------------------------------
本次更新致力於提升使用者的操作體驗,並為交易者提供更靈活的反轉區 (PRZ) 定義功能。
主要功能與更新:
1. 🌐 全面雙語設定介面 (中英對照) 為了讓指標更易於上手,我們將所有的參數輸入與設定選單全面更新為 英文 (中文) 對照格式。
使用者現在可以直觀地理解各種諧波參數(如「容錯率」或「掃描週期」),不再受語言隔閡影響。
例如:Length 選項現在顯示為 Length (長度)。
2. ↔️ 自定義 PRZ 寬度 (緩衝區調整) 標準的諧波計算有時會產生非常狹窄的潛在反轉區 (PRZ),導致有效的交易機會因為 K 線的輕微插針而在視覺上看似失效。
新功能: 新增 "PRZ Padding % (PRZ 寬度擴張 %)" 設定。
操作方式: 您可以設定一個百分比,手動將 PRZ 方框的上下邊界向外擴張。這能幫助您建立一個更寬裕的「狙擊區」,以容納市場的正常波動與插針行情,避免因計算過於嚴格而錯失進場機會。
Key Feature: Active A & C Point Optimization
The Problem: Standard pivot detection (Pivot High/Low) often misses the true local high or low due to strict "left/right bars" requirements. This can cause patterns to connect to a lower high (or higher low) instead of the actual peak, making the A or C points look "floating" or inaccurate.
The Solution: The indicator now performs a secondary scan between the legs of the pattern:
- For Point A: Scans between X and B.
- For Point C: Scans between B and D.
If a better (more extreme) price point is found within these ranges, the indicator automatically replaces the original A and C points with the true swing high/low.
The Result: Pattern legs now snap perfectly to the wicks of the candles. This results in significantly more accurate Fibonacci ratio calculations for the pattern structure and PRZ.
(Note: Point B is intentionally anchored to its original pivot to preserve the core classification of the harmonic pattern, e.g., distinguishing Gartley from Bat.)
自動諧波型態識別 [智能波段優化]
本次更新引入了先進的 「智能波段 (Smart Swing)」演算法,旨在修復諧波檢測中常見的視覺與計算誤差,確保型態能完美貼合市場的真實價格行為。
核心功能:主動式 A 點與 C 點優化
問題痛點: 傳統的 Pivot(轉折點)偵測常因嚴格的「左右 K 線數量」限制,而錯過真正的局部最高或最低點。這會導致畫出的型態 A 點或 C 點沒有連在最高的影線上,而是連在旁邊較低的次高點,造成視覺上的「懸空」或不精確。
解決方案: 指標現在會對型態的區間進行二次掃描:
- 針對 A 點:
- 針對 C 點:
如果在這些區間內發現了比原本偵測到的 Pivot 更極端的價格,程式會自動將 A 點與 C 點 替換 為真正的市場轉折高/低點。
更新成效: 型態連線現在會完美吸附在 K 線的影線尖端。這不僅讓圖表更乾淨,更大幅提升了斐波那契比例計算與反轉區 (PRZ) 的精確度。
(註:B 點維持原有的 Pivot 定義不變,以確保諧波架構的核心分類——如區分 Gartley 與 Bat——不會被破壞。)
Key Features & Updates:
- 🦈 Shark vs. Cypher Logic Upgrade : We have implemented a strict "XD-Ratio Lock" algorithm. Previously, Shark and Cypher patterns could be confused due to similar B-point retracements. The new logic now rigorously calculates the X-to-D extension. A pattern is only classified as a Cypher if the D-point aligns perfectly with the XC 0.786 projection, ensuring 100% accurate classification between these two complex structures.
- ⚡ Zero-Latency PRZ Activation: Fixed a visual lag issue where potential patterns would wait for a candle close to appear. Now, the detection is Real-Time. As soon as the price action touches the Potential Reversal Zone (PRZ), the potential D-point and trade setup are displayed instantly, allowing for sniper-like entries without delay.
- 🎯 Multi-PRZ Simultaneous Display: The indicator is no longer limited to showing a single potential setup. It can now project multiple Potential Reversal Zones (PRZs) simultaneously. This is crucial for identifying "Pattern clusters" (e.g., a small Gartley forming inside a larger Deep Crab), giving you a stronger confluence for reversal.
- 📉 Full Bi-Directional Generation: The scanning engine has been optimized to handle Bullish and Bearish patterns simultaneously without conflict. Whether the market is trending up or down, the indicator will successfully generate and plot valid setups for all supported pattern types in both directions.
- 📐 Advanced XABC Geometry Validation: We introduced a new "Time-Price Geometry Check". This strictly enforces that points X, A, B, and C follow a correct chronological order and price swing logic (High/Low sequence). This update eliminates invalid "twisted" patterns that could previously appear during extreme volatility or consolidation.
------------------------------------------------------------------------------------------------------
本次更新代表了運算精確度與執行速度的重大飛躍。我們重寫了核心幾何引擎,確保零延遲的偵測能力,並徹底消除了相似型態之間的識別誤判。
主要功能與更新:
- 🦈 鯊魚 (Shark) 與賽福 (Cypher) 判定升級: 我們實裝了嚴格的**「XD 比例鎖定」**演算法。過去由於 B 點回撤比例相近,鯊魚與賽福容易混淆。新的邏輯現在會嚴格計算 X 到 D 的延伸比率。只有當 D 點精準對齊 XC 0.786 投射位時,才會被歸類為賽福,確保這兩種複雜結構的分類 100% 準確。
- ⚡ 零延遲 PRZ 顯示技術: 修復了潛在型態需等待 K 線收盤才顯示的視覺延遲問題。現在的偵測是即時 (Real-Time) 的。一旦價格行為觸碰到潛在反轉區 (PRZ),潛在 D 點與交易計畫會「瞬間」顯示,讓您不再錯過插針行情的入場機會。
- 🎯 同時顯示多個 PRZ: 指標不再侷限於一次只顯示一個潛在型態。現在它可以同時在圖表上投射多個潛在反轉區 (PRZ)。這對於識別「型態共振」至關重要(例如:在大級別的深海螃蟹中,同時出現一個小級別的加特利),提供更強的反轉訊號依據。
- 📉 全方位多空順利生成: 掃描引擎經過全面優化,能夠在無衝突的情況下同時處理看漲與看跌型態。無論市場是上漲還是下跌趨勢,指標都能針對所有支援的型態類型,順利且完整地生成雙向的有效架構。
- 📐 XABC 點位幾何驗證升級: 我們引入了全新的**「時空幾何驗證 (Time-Price Geometry Check)」**。這項功能強制確保 X、A、B、C 四點嚴格遵守正確的時間順序與高低點波段邏輯,徹底杜絕了在劇烈波動或盤整行情中,可能出現的「扭曲」或無效型態。
- Trigger Logic: Alerts are now triggered immediately when price touches the PRZ (Potential Reversal Zone) of a potential pattern.
- Anti-Spam Mechanism: Implemented a unique ID system for every pattern structure. The alert fires only once per valid pattern structure to prevent repetitive signals. A new alert will only trigger if the pattern name changes due to market structure shifts.
- Rich Message: The alert message now includes the full Pattern Name, Direction, Entry Price, TP1, TP2, and SL.
2. Optimized Pattern Priority Logic
- Butterfly vs. Deep Crab: Fixed an issue where Deep Crab (1.618) would sometimes override Butterfly (1.272) due to overlapping tolerance zones. The logic now prioritizes Butterfly when both are valid, ensuring the nearer 1.272 reversal point is identified first.
3. Enhanced Color & Visual Customization
- Bull/Bear Separation: Removed the generic Dark/Light mode. You can now independently customize colors for Bullish and Bearish signals (Entry, TP, SL lines).
- Unified Visibility Control: The "Show TP/SL Lines" option now correctly toggles the Entry Line as well.
- Detailed Labels: Text labels on lines now display the full context, e.g., [Bullish] Gartley instead of just [Gartley].
4. UX Improvements
- Line Length Control: Added a multiplier setting to adjust the length of Entry/TP/SL lines.
中文更新日誌 (v4)
1. 新增智能警報系統 (Smart Alert System) 🔔
- 觸發機制: 當價格接觸到潛在型態的 PRZ (潛在反轉區) 時立即觸發警報。
- 防重複機制: 導入了基於型態結構的唯一 ID 識別。針對同一個型態結構,警報僅會觸發一次,防止訊號重複轟炸。只有當行情變化導致「型態名稱改變」時,才會視為新訊號再次通知。
- 完整訊息: 警報內容包含完整資訊:型態名稱、多空方向、進場價 (Entry)、止盈 (TP1/TP2) 與止損 (SL)。
2. 型態優先權邏輯優化
- 蝴蝶 vs 深海螃蟹: 修正了 Deep Crab (1.618) 因公差範圍重疊而覆蓋 Butterfly (1.272) 的問題。現在當兩者同時成立時,系統會優先判定為 Butterfly,確保您能優先捕捉到較近的 1.272 反轉點。
3. 視覺與顏色自定義增強
- 多空顏色分離: 移除了舊版的深淺色模式,改為完全自定義。您現在可以獨立設定 多頭 (Bullish) 與 空頭 (Bearish) 的 Entry、TP、SL 線條顏色。
- 統一顯示開關: 「顯示 TP/SL 線」的選項現在會同步控制 Entry (進場線) 的顯示與隱藏。
- 完整標籤顯示: 線條上的文字標籤現在會顯示完整方向,例如 [Bullish] Gartley,而非僅顯示型態名稱。
4. 使用者體驗優化
- 線條長度控制: 新增了線條長度倍數設定,可自由調整 TP/SL 線在圖表上的延伸長度。
Key Updates on PRZ & Historical Display:
1. "Deep Scan" Stability Engine
The Problem: In standard harmonic scripts, valid patterns often disappear or flicker when a new, minor pivot forms (the "conveyor belt" effect), causing the X point to drop out of calculation range.
The Solution: This script now employs a multi-layer Deep Scan mechanism. It simultaneously evaluates both the most recent pivot combination and the previous structure. This ensures that a solid XABC pattern remains visible and valid even if minor price fluctuations create insignificant new pivots, significantly reducing false invalidations.
2. Smart History Transition
Active vs. History: Patterns remain in "Potential Mode" (Dashed lines + PRZ Box) while testing the zone.
Auto-Lock: As soon as price enters the PRZ and subsequently hits either Take Profit 1 or Stop Loss, the pattern is instantly converted to "History Mode" (Solid lines).
Logic: The script performs a full historical lookback from the moment of entry to the current bar to ensure the status (Win/Loss) is accurate.
3. Precision D-Point Snapping
Visual Accuracy: When a pattern converts to history, the D-Point (Entry) no longer floats at the theoretical harmonic ratio. Instead, it automatically snaps to the actual extreme price (Lowest Low for Bullish / Highest High for Bearish) that occurred within the PRZ. This visualizes exactly where the reversal or failure happened.
4. Clean Chart Aesthetics
PRZ Box: The colored PRZ box is automatically removed for completed patterns to prevent chart clutter.
Extended Analysis Lines: Entry, TP, and SL lines remain fully extended even for historical patterns, allowing traders to perform post-trade analysis on how price respected these levels over time.
--------------------------------------------------------------------------------------------------
本次更新針對潛在反轉區 (PRZ) 的計算與歷史歸檔邏輯進行了核心重構。新的演算法能精準區分「進行中的機會」與「已完成的歷史型態」,為交易者提供更穩定、乾淨且專業的圖表體驗。
關於 PRZ 與歷史顯示的關鍵更新:
1. 「深度掃描」穩定性引擎 (Deep Scan)
問題解決: 傳統諧波腳本常因市場產生微小的雜訊 Pivot,導致舊有的 X 點被擠出計算範圍,造成原本有效的型態瞬間消失或閃爍。
解決方案: 本策略引入多層 深度掃描 機制,同時計算最新與前一組的 Pivot 結構。這意味著即使出現微小的新高低點,原本穩固的大級別 XABC 結構依然會被鎖定並保留,大幅提升型態的可信度與穩定性。
2. 智慧歷史狀態切換 (Smart History)
即時狀態區分: 當價格正在測試區域時,圖形保持為「潛在模式」(虛線 + PRZ 色塊)。
自動鎖定: 一旦價格確認進入 PRZ,並隨後觸發 止盈 (TP1) 或 止損 (SL),程式會立即將該型態轉換為「歷史模式」(實線)。
邏輯嚴謹: 系統會執行全歷史回溯檢查,從進場的那一刻掃描至當前 K 線,確保勝負判定準確無誤。
3. D 點精準吸附 (Snap to Extremum)
還原真實走勢: 當型態轉為歷史狀態時,圖表上的 D 點 (進場點) 不再只是顯示理論的數學比率位置,而是會 自動吸附到 PRZ 區間內實際發生的極值(多頭吸附最低點 / 空頭吸附最高點)。這能讓您清楚看到反轉或止損實際發生的確切位置。
4. 圖表視覺優化
自動移除色塊: 已完成(止盈或止損)的歷史型態,PRZ 色塊將自動消失,保持圖面整潔。
保留分析線條: 歷史型態的 Entry、TP 與 SL 水平線將保持完整延伸長度,方便交易者進行覆盤分析,觀察後續價格對這些關鍵位階的反應。
2. Fixed the issue where potential TP/SL lines were not removed after the TP or SL was triggered.
1. 修正上一版本TL、SL線條格式
2. 修正TP/SL後,潛在TP、SL未移除問題
已回溯至 12/24 版本;今日的更新發現了 Bug。
Invite-only script
Only users approved by the author can access this script. You'll need to request and get permission to use it. This is typically granted after payment. For more details, follow the author's instructions below or contact Trader-Alex directly.
TradingView does NOT recommend paying for or using a script unless you fully trust its author and understand how it works. You may also find free, open-source alternatives in our community scripts.
Author's instructions
交易所註冊連結|>
BingX |>
bingx.com/invite/VBXORPQC
Disclaimer
Invite-only script
Only users approved by the author can access this script. You'll need to request and get permission to use it. This is typically granted after payment. For more details, follow the author's instructions below or contact Trader-Alex directly.
TradingView does NOT recommend paying for or using a script unless you fully trust its author and understand how it works. You may also find free, open-source alternatives in our community scripts.
Author's instructions
交易所註冊連結|>
BingX |>
bingx.com/invite/VBXORPQC