支持中心 帮助文档 联系我们
📱 微信: 18391752892 | 💬 QQ: 3313198376 | ✈️ Telegram | 📧 fishfx123@gmail.com
EURUSD 1.0856 +0.12% GBPUSD 1.2678 +0.08% USDJPY 149.23 -0.15% XAUUSD 2034.56 +0.34% EURUSD 1.0856 +0.12% GBPUSD 1.2678 +0.08% USDJPY 149.23 -0.15% XAUUSD 2034.56 +0.34%

Pairs Trading Z Score Optimized

👤 作者: Ledi Haryadi

1.0 分

¥280.00

📌 版本: v8.0
📥 下载: 0
⭐ 评分: 1.0

📝 产品详情

Pairs Trading Z Score Optimized

作者Ledi Haryadi
版本v8.0
更新2025-04-30T05:11:10
激活数5
原价$40 USD

Pairs Trading Z-Score Optimized is a custom indicator for the MetaTrader 4 (MT4) platform, designed to support pairs trading by analyzing the spread between two currency pairs using Z-Score calculations and stationarity testing. It operates on a single pair (the chart’s symbol and a user-defined second symbol) and displays Z-Score values, threshold bands, and trading signals in a subwindow, with optional arrows on the main chart. The indicator incorporates the Augmented Dickey-Fuller (ADF) test for spread stationarity and provides customizable settings for signal generation and visualization.

Key Features

  1. Z-Score Analysis:
    • Calculates the Z-Score of the spread between two currency pairs (Pair1: chart symbol, Pair2: user-defined, default: GBPUSD) to identify potential trading signals.
    • Uses a configurable lookback period (default: 100 bars) and Z-Score threshold (default: 2.0) to determine signal triggers.
    • Displays Z-Score as a line in a subwindow, with upper and lower threshold bands (default: ±2.0).
  2. Stationarity Testing:
    • Supports the Augmented Dickey-Fuller (ADF) test to assess spread stationarity, with options for no transformation, first differencing, or logarithmic transformation (default: none).
    • Configurable ADF test parameters include lags (default: 1), critical value (default: -2.86 for 5% significance), and test interval (default: 60 seconds).
    • Allows users to require stationary spreads for signal generation (default: enabled).
  3. Signal Generation and Visualization:
    • Generates "LONG" (buy Pair1, sell Pair2) or "SHORT" (sell Pair1, buy Pair2) signals when the Z-Score exceeds the threshold (above +2.0 for SHORT, below -2.0 for LONG).
    • Displays signals as arrows in the subwindow, main chart, or both (configurable via ArrowDisplayMode).
    • Differentiates between stationary (lime arrows, default Wingdings codes: 233/234) and non-stationary (orange arrows, default Wingdings codes: 225/226) signals, with options to enable/disable each (ShowStationaryArrows, ShowNonStationaryArrows).
  4. Hedge Ratio Calculation:
    • Computes the hedge ratio between pairs using linearSy linear regression to determine the spread (Pair1 - hedgeRatio * Pair2).
    • Displays the hedge ratio in the subwindow for transparency.
  5. Alerts:
    • Provides optional alerts for new stationary or non-stationary signals (default: disabled), with messages indicating the signal type and Z-Score (e.g., "[Stationary Signal] SHORT on EURUSD, LONG on GBPUSD (Z-Score=2.50)").
    • Prevents repeated alerts by tracking the last signal state.
  6. Data Handling:
    • Implements robust price data retrieval with retry attempts (default: 3) and timeouts (default: 500ms for data, 1000ms for ADF test) to handle connectivity issues.
    • Ensures data integrity for accurate Z-Score and ADF calculations.
  7. User Interface:
    • Displays key information in the subwindow, including pair names, ADF test status (stationary/non-stationary), and hedge ratio, with customizable label positions (default: X=10, Y=30 pixels).
    • Supports customizable arrow positions on the main chart (default: X=10, Y=10 pixels from the selected corner) and arrow codes for visual distinction.
  8. Customization:
    • Offers extensive input parameters for adjusting lookback period, Z-Score threshold, ADF test settings, stationarity method, and visualization options (arrow display, colors, positions).
    • Allows users to enable/disable features like ADF testing, stationary signal requirements, and alerts.

Usage

  • Initialization: Validates both currency pairs in Market Watch, sets up buffers, and performs an initial ADF test if enabled. Creates subwindow labels for pair, ADF status, and hedge ratio.
  • Operation: Calculates Z-Scores and signals for each bar, updating threshold bands and arrows based on stationarity and Z-Score conditions. Periodically runs ADF tests (every 60 seconds) for the latest bar.
  • Visualization: Plots Z-Score and bands in the subwindow, places arrows on the subwindow or main chart, and updates labels with real-time data.
  • Deinitialization: Removes all labels and arrow objects, resetting signal states.

Notes

  • Requires sufficient historical data (minimum: lookback period + 10 bars)
  • When using Pair Trading Strategy Based on Spearman , make sure to limit the bars in the Max bars in chart option to below 2000, for example 500.
  • Optimized for performance with configurable timeouts and retry mechanisms.
  • The indicator focuses solely on Z-Score-based signals, without additional technical filters like MA or RSI, unlike related indicators.


Detailed Explanation and Reading Guide for the Pairs Trading Z-Score Optimized Indicator in the User Manual

 

安全须知

本产品仅通过 MQL5.com 官方渠道获取。其他渠道版本可能缺少完整功能和技术支持。

EA 配置

交易品种XAUUSD
时间框架H1 (推荐)
推荐经纪商IC Markets, IC Trading
最低存款$300 / 0.01手

📸 截图预览