Alibaba Gold
- Experts
- Version: 1.0
- Activations: 11
Alibaba Gold is a MetaTrader 5 Expert Advisor that trades EURUSD and gold together using a statistical mean-reversion strategy.
The EA monitors the relationship between the two instruments, calculates a hedge ratio and spread z-score, and looks for deviations that meet its entry conditions. Each trading basket contains two opposing positions: one instrument is bought while the other is sold.
Although gold is part of the strategy, Alibaba Gold is a two-instrument trading system.
Main features
-
Automatic detection of broker EURUSD and gold symbols, including common prefixes, suffixes, and GOLD naming.
-
Z-score entry and exit conditions.
-
Adjustable correlation filter and hedge-ratio smoothing.
-
Separate lot settings for each instrument.
-
Combined margin checks before opening a basket, followed by individual order checks.
-
Broker trading-session checks and deferred close retries.
-
Configurable basket profit and loss thresholds.
-
Trading schedules, Friday controls, and path-memory filtering.
-
Dashboard showing operating status, open trading instruments, basket profit/loss, and model statistics.
-
Dashboard drawing is disabled automatically during non-visual backtests.
Setup
-
Make sure your broker offers both EURUSD and gold against USD.
-
Attach one instance to an EURUSD or gold chart. M15 is the recommended display timeframe.
-
Leave both instrument overrides blank for automatic detection.
-
Select lot sizes appropriate for your account balance, leverage, and broker contract specifications.
-
Enable Algo Trading.
The EA calculates its signals using M1 data internally, independently of the attached chart timeframe. Both instruments require sufficient historical data.
Avoid running multiple instances on the same instruments with the same magic number.
Input parameters
Symbols and position sizing:
-
FirstLegOverride — Optional exact broker symbol for EURUSD. Leave blank for automatic detection.
-
SecondLegOverride — Optional exact broker symbol for gold against USD. Leave blank for automatic detection.
-
LotsAset — Base lot size for EURUSD.
-
LotsBset — Base lot size for gold.
-
XBalance — Set to zero for fixed lots. A positive value enables stepped lot multiplication based on account balance.
-
showPanel — Show or hide the chart dashboard.
Entry and exit settings:
-
EntryThreshold — Absolute z-score required for an entry.
-
ExitThreshold — Z-score reversion level used to close a basket.
-
smoothing — Hedge-ratio smoothing factor.
Correlation settings:
-
CorrThreshold — Minimum correlation required for entry.
-
CorrOnReturns — Calculate correlation from candle price changes instead of price levels.
-
UseAbsCorr — Use absolute correlation, allowing strongly inverse relationships to meet the filter.
Risk and trade management:
-
magicNumber — Identifier for positions managed by this EA.
-
closeTarget — Profit threshold for an additional signal-based basket exit. Zero disables this condition.
-
closeTargetProfit — Basket profit threshold for requesting closure. Zero disables it.
-
closeTargetLoss — Basket loss threshold for requesting closure. Zero disables it.
-
minWaitAfterClose / minWaitAfterClose2 — Combined entry cooldown. The current release interprets these values in seconds.
Trading schedules:
-
TradeStartHour / TradeStartMinute / TradeEndHour / TradeEndMinute — Allowed entry window in broker server time.
-
TradeStartHourC / TradeStartMinuteC / TradeEndHourC / TradeEndMinuteC — Allowed normal exit window in broker server time. Basket loss protection can request closure outside this window.
-
fridayStopHour — Friday entry cutoff hour. Zero disables the cutoff.
-
closeAllOnFriday — Request closure of managed positions after the enabled Friday cutoff.
Path-memory settings:
-
PathMemoryEnable — Enable additional filtering of repeated spread excursions.
-
PathMemoryWindowMinutes — Lookback window following a basket close.
-
PathMemoryMinPriorBars — Minimum excursion age used by the filter.
-
PathMemoryResetDepth — Z-score reset level used to clear path-memory blocking.
Trading considerations
Opposing positions in different instruments do not eliminate market risk. Their relationship can change, and either or both positions can lose money.
Basket thresholds are managed by the EA rather than guaranteed execution prices. If a market is closed or an order cannot be executed, closure must wait until trading becomes available.
Test the settings using your broker’s data and a demo account before live use. Historical results do not guarantee future performance.
