← Back to Home

XAU Mean Reversion EA v1.30

Complete setup guide, configuration reference, and troubleshooting.

1. System Requirements

  • Platform: MetaTrader 4 (MT4) — build 1300 or later recommended
  • Instrument: XAUUSD (Gold vs US Dollar)
  • Timeframe: M15 (15-minute chart)
  • Minimum Deposit: $500 recommended (micro lots at 0.01)
  • Broker: ECN / low-spread broker with max spread under 50 points on XAUUSD
  • VPS: Recommended for 24/5 uninterrupted operation — low-latency connection to your broker
  • Operating System: Windows 7 or later (or Linux via Wine)

2. Installation

  1. Download the EA file — After purchase you will receive a .ex4 compiled expert advisor file.
  2. Open your MT4 Data Folder — In MetaTrader 4 go to File → Open Data Folder.
  3. Copy the file — Navigate to MQL4 → Experts and paste the .ex4 file there.
  4. Restart MT4 — Close and reopen MetaTrader 4 completely so the EA appears in the Navigator panel.
  5. Attach to chart — Open a XAUUSD M15 chart, then drag the EA from the Navigator panel onto the chart.
  6. Enable live trading — In the EA properties dialog, check "Allow live trading". Also ensure the AutoTrading button on the MT4 toolbar is enabled (green icon).
  7. Configure parameters — Adjust the input parameters as needed (see section 3 below), then click OK.

Tip: Always test on a demo account first. Run the EA for at least 1–2 weeks on demo before going live to confirm it matches your expectations.

3. Recommended Settings & Parameters

Below is the complete list of input parameters with their default values. You can adjust these in the EA properties dialog (Inputs tab).

Lot Size & Risk Management

ParameterDefaultDescription
InpLotSize0.01Fixed lot size when dynamic lots are disabled
InpUseDynamicLotsfalseEnable automatic lot sizing based on account balance and risk percent
InpRiskPercent1.0Percentage of account balance to risk per trade (used when dynamic lots are enabled)

Stop Loss & Trailing Stop

ParameterDefaultDescription
InpInitialSL2.00Initial stop loss distance in dollars from entry price
InpTrailingDistance2.00Trailing stop distance in dollars — how far behind price the stop follows
InpTrailingStep0.50Minimum price movement in dollars before trailing stop updates
InpUseATRStopLosstrueUse ATR-based dynamic stop loss instead of fixed initial SL
InpATRPeriod14Period for ATR indicator used in dynamic stop loss calculation
InpATRMultiplier1.5Multiplier applied to ATR value to determine stop loss distance

Partial Close

ParameterDefaultDescription
InpUsePartialClosetrueEnable closing a portion of the position at a profit target
InpPartialClosePercent50Percentage of position to close when partial close target is hit
InpPartialClosePips2.0Profit distance in dollars at which partial close triggers

Trading Session (Hong Kong Time)

ParameterDefaultDescription
InpHKTStartHour8Trading session start hour in Hong Kong Time (HKT, UTC+8)
InpHKTEndHour19Trading session end hour in Hong Kong Time (HKT, UTC+8)
InpServerOffset5Hours to add to server time to convert to HKT (see broker config section)

Signal Indicators (EMA & RSI)

ParameterDefaultDescription
InpEMAFast9Fast EMA period — detects short-term price direction
InpEMASlow25Slow EMA period — establishes the mean reversion baseline
InpMinEMAGap1.50Minimum gap in dollars between fast and slow EMA to confirm divergence
InpConfirmBars5Number of consecutive bars the EMA crossover must persist before entry
InpRSIPeriod14RSI indicator period
InpRSIMidline50.0RSI midline — values above indicate bullish, below indicate bearish
InpSmoothedRSIPeriod7Smoothing period applied to RSI to reduce noise

Trade Filters & Safety

ParameterDefaultDescription
InpCooldownBars40Minimum bars to wait after a trade closes before opening a new one
InpMaxConsecutiveLosses2Maximum consecutive losses allowed before the EA pauses trading
InpMaxSpread0.50Maximum allowed spread in dollars — trades are skipped if spread exceeds this
InpUseNewsFiltertrueEnable news filter to avoid trading around high-impact news events
InpNewsMinutesBefore30Minutes before a news event to stop opening new trades
InpNewsMinutesAfter30Minutes after a news event to resume trading

4. Broker Configuration & Server Offset

The EA uses Hong Kong Time (HKT, UTC+8) internally to define the trading session. Because different brokers run their MT4 servers in different timezones, you need to set the InpServerOffset parameter so the EA can convert server time to HKT correctly.

How to Calculate Server Offset

The formula is: ServerOffset = 8 - BrokerUTCOffset

Where 8 is the UTC offset for Hong Kong Time, and BrokerUTCOffsetis your broker's server timezone offset from UTC.

BrokerServer TimezoneCalculationInpServerOffset
IC MarketsUTC+28 - 2 = 66
PepperstoneUTC+38 - 3 = 55
ExnessUTC+08 - 0 = 88

Note on Daylight Saving Time (DST): Many brokers shift their server time by 1 hour during DST transitions (typically in March and November). When your broker switches between summer and winter time, you may need to adjust InpServerOffsetby +1 or -1 accordingly. Check your broker's announcements for DST schedule changes.

How to Verify Your Offset

  1. Open the Market Watch window in MT4 and note the server time shown at the bottom.
  2. Compare it to the current Hong Kong Time (search "HKT time now" online).
  3. The difference in hours is your InpServerOffset value.
  4. For example, if server time shows 12:00 and HKT is 17:00, the offset is 5.

5. Troubleshooting

EA does not appear in Navigator panel

  • Ensure the .ex4 file is placed in the correct folder: MQL4/Experts
  • Restart MT4 completely (close and reopen)
  • Right-click in the Navigator panel and select "Refresh"

EA shows a sad face icon on the chart

  • Click the AutoTrading button on the toolbar to enable it (icon should turn green)
  • Open EA properties → Common tab → ensure "Allow live trading" is checked
  • Go to Tools → Options → Expert Advisors → check "Allow automated trading"

EA is active but not opening trades

  • Check the Experts tab (bottom of MT4) for log messages — the EA prints reasons for skipping trades
  • Verify you are on a XAUUSD M15 chart
  • Confirm the current time falls within the trading session (HKT 8:00–19:00 by default)
  • Ensure spread is below InpMaxSpread (default $0.50)
  • Check if the cooldown period is active — after a trade closes the EA waits InpCooldownBars bars (default 40) before the next entry
  • If you hit InpMaxConsecutiveLosses (default 2), the EA pauses until the next trading session
  • The news filter may be blocking trades — check if a high-impact event is within the configured window

Trades open at wrong hours

  • Your InpServerOffset is likely incorrect — see the Broker Configuration section above to recalculate
  • Check if your broker recently switched between summer/winter time (DST change)

Stop loss is too tight / too wide

  • If InpUseATRStopLoss is true, the SL adapts to market volatility via ATR
  • Increase InpATRMultiplier for wider stops or decrease it for tighter stops
  • Alternatively, set InpUseATRStopLoss=false to use the fixed InpInitialSL value instead

"OrderSend Error 130" in Experts log

  • Error 130 means the stop loss or take profit is too close to the current price
  • Increase InpInitialSL or InpATRMultiplier to set a wider stop
  • Check your broker's minimum stop level for XAUUSD

High spread warnings in the log

  • The EA skips trades when spread exceeds InpMaxSpread
  • If this happens frequently, consider switching to an ECN account or a broker with tighter gold spreads
  • You can increase InpMaxSpread but be aware that wider spreads reduce profitability

Need more help? Reach out via the contact form on the homepage.