trend system algo [skyeye]

Core Features & Calculation Logic
1. Market Structure Identification (The Backbone)
Algorithm: Utilizes a filtered ZigZag algorithm. Unlike standard ZigZags, this script incorporates a Min Swing % filter and a Min Bars duration filter.
Logic: It identifies valid Higher Highs (HH) and Lower Lows (LL) only when price moves exceed a specific volatility threshold. This effectively filters out market noise.
Visuals:
Green Background: Indicates a Bullish Structure phase.
Red Background: Indicates a Bearish Structure phase.
2. Zero-Lag Momentum Layer (The Trigger)
Algorithm: A Two-Pole Gaussian Filter.
Logic: Gaussian filters offer superior smoothness compared to Simple or Exponential Moving Averages (SMA/EMA) while significantly reducing lag. This allows for faster reaction to trend reversals without the "whipsaw" effect of noisy moving averages.
MTF Dashboard: The table in the bottom-right corner monitors the Gaussian momentum across 5 timeframes (5m to 4h) in real-time, helping traders align with the dominant trend.
3. Quantitative Risk Engine (The Execution)
Auto-Calculation: When a valid trend reversal signal occurs (Structure Flip + Momentum Cross), the script automatically projects a trade setup.
Dynamic Stop Loss (SL): Calculated using the Average True Range (ATR). This ensures the stop loss adapts to the current market volatility (wider stops in volatile markets, tighter stops in calm markets).
Take Profit (TP) Targets: Automatically projects three fixed Reward-to-Risk (R:R) targets:
TP1: 1:1 R:R
TP2: 1:1.5 R:R
TP3: 1:2 R:R
Visuals: Draws colored boxes and dashed lines on the chart to visualize the potential PnL zones immediately upon signal generation.
Strategy Guide: The "Quant Nexus" Method
Step 1: Structural Bias Observe the background color.
Trade Long only when the background is Green.
Trade Short only when the background is Red.
Step 2: Trend Alignment Check the MTF Dashboard. Ideally, the H1 and H4 timeframes should match the color of your intended trade direction (Green for Long, Purple for Short).
Step 3: Signal Execution Wait for the entry signal (indicated by the Risk/Reward boxes appearing).
Entry: At the close of the signal candle.
Stop Loss: Place your SL at the level indicated by the "Stop Loss" label (based on ATR).
Take Profit: Scale out positions at TP1, TP2, and TP3 levels.
Settings Customization
ZigZag Config: Adjust Depth and Min Swing % to tune the sensitivity of market structure.
MTF Trends: Customize the Alpha to adjust the smoothness of the Gaussian line.
Quant Risk: Toggle Use ATR SL or adjust SL Multiplier to fit your risk appetite.
Disclaimer: This tool is for educational purposes only. Automated signals should always be verified with your own analysis.
(Chinese Translation / 中文說明)
系統概述 Structural Trend & Fibo Nexus [Quant] 是一套綜合交易系統,旨在縮小主觀技術分析與量化風險管理之間的差距。它將市場結構識別、多週期 (MTF) 動能和自動風險/回報計算整合到單一圖表介面中。
核心功能與計算邏輯
1. 市場結構識別 (骨幹)
演算法: 使用經過過濾的 ZigZag 演算法。與標準 ZigZag 不同,本腳本結合了「最小波動百分比」和「最小 K 線數」過濾器。
邏輯: 僅當價格變動超過特定的波動率閾值時,才會識別有效的更高高點 (HH) 和更低低點 (LL)。這有效地過濾了市場雜訊。
視覺效果:
綠色背景: 表示看漲結構階段。
紅色背景: 表示看跌結構階段。
2. 零延遲動能層 (觸發器)
演算法: 雙極高斯濾波器 (Two-Pole Gaussian Filter)。
邏輯: 與簡單或指數移動平均線 (SMA/EMA) 相比,高斯濾波器提供了卓越的平滑度,同時顯著減少了延遲。這允許對趨勢反轉做出更快的反應,而不會產生嘈雜均線的「假突破」效應。
MTF 儀表板: 右下角的表格即時監控 5 個時間週期 (5m 至 4h) 的高斯動能,幫助交易者與主趨勢保持一致。
3. 量化風控引擎 (執行)
自動計算: 當有效的趨勢反轉信號出現(結構翻轉 + 動能交叉)時,腳本會自動投射交易計畫。
動態止損 (SL): 使用 平均真實波幅 (ATR) 計算。這確保止損能適應當前的市場波動(波動大時止損較寬,平靜時止損較窄)。
止盈 (TP) 目標: 自動投射三個固定的風險回報比 (R:R) 目標:
TP1: 1:1 盈虧比
TP2: 1:1.5 盈虧比
TP3: 1:2 盈虧比
視覺效果: 在信號產生時,立即在圖表上繪製彩色方框和虛線,以視覺化潛在的盈虧區域。
策略指南:量化共振法
第一步:結構偏差 觀察背景顏色。
背景為 綠色 時,僅考慮做多。
背景為 紅色 時,僅考慮做空。
第二步:趨勢對齊 檢查 MTF 儀表板。理想情況下,H1 和 H4 時間週期應與您的預期交易方向顏色相符(做多為綠色,做空為紫色)。
第三步:信號執行 等待進場信號(由出現的風險/回報框指示)。
進場: 在信號 K 線收盤時。
止損: 將止損設置在「Stop Loss」標籤指示的位置(基於 ATR)。
止盈: 在 TP1、TP2 和 TP3 水平分批獲利了結。
設定自定義
ZigZag 設置: 調整 Depth 和 Min Swing % 以微調市場結構的靈敏度。
MTF 趨勢: 自定義 Alpha 以調整高斯線的平滑度。
量化風控: 切換 Use ATR SL 或調整 SL Multiplier 以符合您的風險偏好。
免責聲明:本工具僅供教育用途。自動信號應始終通過您自己的分析進行驗證。
Added Fibonacci settings
Added high/low point judgment line
手機版本算力不足問題
增加斐波設置
增加高低點判斷線
Added `max_bars_back=5000` to line 2 - Forces backtracking of 5000 candlesticks, reducing device-to-device differences.
Improved `calc_gaussian` - Uses safer initialization and historical value access.
Created the `calc_mtf_trend` helper function - Unifies MTF request parameters, added `ignore_invalid_symbol=true`.
Improved ZigZag filtering - Added NA value checks to ensure consistent filtering logic.
Enhanced array security checks - Checks size and index before access.
Safety checks: Add `is_valid_zz_point` to process only valid data.
Initialization logic: Set the initial value at the first valid ZigZag point, instead of relying on historical data.
Filtering conditions: Apply filtering only after initialization to avoid inconsistencies in the initial stage.
Zero division prevention: Use `math.max(last_valid_px, 0.0001)` to prevent division by zero errors.
Final direction: Use the `zz_initialized` flag to determine whether to use the filtered direction.
Add `can_generate_signal` flag - Generate a signal only when the following conditions are met:
Sufficient number of bars
ZigZag is initialized
All trend values are valid.
Improved `final_dir` calculation - Added a safety check to ensure valid values.
Improved signal logic - Use `prev_final_dir` to ensure historical values are valid before comparison.
Core Concepts & Logic:
Multi-Timeframe Gaussian Trend: The indicator calculates a Gaussian Filter (low-lag smoothing) on the current chart plus 4 higher timeframes (e.g., if you are on 5m, it checks 15m, 30m, 1H, 4H).
The "MTF Dashboard" in the bottom right corner visualizes the alignment of these trends.
A trade signal is filtered based on how many timeframes are aligned (Trend Strength).
ZigZag Market Structure: Using the DevLucem ZigZag library, the script identifies Swing Highs and Swing Lows.
Structure Flips: It detects when price breaks a valid swing point (Change of Character).
Fibonacci Retracements: Automatically draws Fib levels on the most recent valid ZigZag leg to find pullback entries (0.618, 0.5, etc.).
Adaptive Signal Logic: The script offers different modes based on your trading style:
Standard: Best for scalping (≤5m). Focuses on fast structure flips.
High Timeframe: Requires stricter MTF alignment (at least 3 TFs matching).
Trend Following: Purely follows the dominant Gaussian trend direction.
Auto-Adaptive: Automatically switches logic based on the chart timeframe.
Risk Management (TP/SL): When a signal is confirmed, the script draws a visual Risk/Reward box.
SL: Based on ATR (Average True Range) to account for volatility.
TP: Fixed Reward-to-Risk ratios (1:1, 1:1.5, 1:2).
⚠️ Important Disclosure regarding Repainting: This script utilizes ZigZag calculations. By definition, the ZigZag indicator is a "repainting" tool because it looks for pivot points that can only be confirmed after price has moved a certain percentage.
The Trend Line (Gaussian): Does NOT repaint (uses confirmed bars).
The ZigZag Lines & Fibo: The last segment will update as new highs/lows are formed.
Historical Signals: The script includes a confirmation delay setting to minimize noise, but traders should wait for the candle close before acting on ZigZag-based signals.
Settings:
ZigZag: Adjust Depth and Deviation to filter noise.
MTF: Customize which timeframes are tracked in the dashboard.
Winrate Optimization: Enable "Volume Confirmation" or "Trend Strength Filter" to reduce false signals in ranging markets.
[Chinese / 中文]
簡介: Pro AI Algo [SkyEye] 是一套結合市場結構 (ZigZag) 與 多週期趨勢 (MTF) 的綜合交易系統。本指標不單純依賴均線交叉,而是利用高斯濾波器 (Gaussian Filters) 同時監控 5 個不同的時間週期來判斷市場主趨勢,並結合 ZigZag 理論來識別結構翻轉(HH/LL)。
核心邏輯與功能:
多週期高斯趨勢 (MTF Trend): 指標會計算當前圖表及 4 個更高時間週期的高斯平滑曲線。
右下角的「儀表板」顯示了各週期的趨勢方向。
信號會根據多週期的共振程度(趨勢強度)進行過濾,避免逆勢操作。
ZigZag 市場結構: 利用 ZigZag 算法識別波段高低點。
結構翻轉: 偵測價格是否突破有效的前高或前低 (BOS/CHoCH)。
斐波那契回撤: 自動在最新的 ZigZag 波段上繪製 Fibo 線 (0.618, 0.5 等),輔助尋找回調入場點。
自適應信號模式:
標準信號: 適合 ≤5分鐘圖表,反應靈敏,側重結構突破。
高時間框架: 要求更嚴格的 MTF 共振(至少 3 個週期方向一致)。
趨勢追蹤: 專注於大趨勢方向,過濾短期雜訊。
自動適配: 根據當前圖表時間自動切換上述模式。
風控系統 (TP/SL): 信號觸發時,系統會自動繪製盈虧比方框。
止損 (SL): 基於 ATR (平均真實波幅) 動態計算。
止盈 (TP): 預設風險回報比 (RR) 目標。
⚠️ 關於重繪 (Repainting) 的重要說明: 本腳本包含 ZigZag 組件。ZigZag 本質上是具有重繪特性的,因為它需要價格反轉一定幅度後才能確認頂底。
趨勢線 (高斯): 不會重繪。
ZigZag 連線與 Fibo: 最後一根連線會隨著新高/新低的產生而更新。
操作建議: 建議等待 K 線收盤確認信號,並利用內建的過濾器(如成交量確認)來提高勝率。
สคริปต์แบบเฉพาะผู้ได้รับเชิญเท่านั้น
เฉพาะผู้ใช้งานที่ผู้เขียนอนุมัตเท่านั้นจึงจะสามารถเข้าถึงสคริปต์นี้ได้ คุณจะต้องขอและได้รับอนุญาตก่อนใช้งาน ซึ่งโดยทั่วไปจะได้รับอนุญาตหลังจากชำระเงินแล้ว สำหรับรายละเอียดเพิ่มเติม โปรดทำตามคำแนะนำของผู้เขียนด้านล่าง หรือติดต่อ Sky_Eye โดยตรง
TradingView ไม่แนะนำให้จ่ายเงินหรือใช้สคริปต์ เว้นแต่คุณจะเชื่อถือผู้เขียนและเข้าใจวิธีการทำงานของสคริปต์นั้นอย่างถ่องแท้ คุณยังสามารถหาทางเลือกแบบโอเพนซอร์สฟรีได้ใน สคริปต์ชุมชนของเรา
คำแนะนำของผู้เขียน
คำจำกัดสิทธิ์ความรับผิดชอบ
สคริปต์แบบเฉพาะผู้ได้รับเชิญเท่านั้น
เฉพาะผู้ใช้งานที่ผู้เขียนอนุมัตเท่านั้นจึงจะสามารถเข้าถึงสคริปต์นี้ได้ คุณจะต้องขอและได้รับอนุญาตก่อนใช้งาน ซึ่งโดยทั่วไปจะได้รับอนุญาตหลังจากชำระเงินแล้ว สำหรับรายละเอียดเพิ่มเติม โปรดทำตามคำแนะนำของผู้เขียนด้านล่าง หรือติดต่อ Sky_Eye โดยตรง
TradingView ไม่แนะนำให้จ่ายเงินหรือใช้สคริปต์ เว้นแต่คุณจะเชื่อถือผู้เขียนและเข้าใจวิธีการทำงานของสคริปต์นั้นอย่างถ่องแท้ คุณยังสามารถหาทางเลือกแบบโอเพนซอร์สฟรีได้ใน สคริปต์ชุมชนของเรา