Crossover XAU
- エキスパート
- Ricardo Barnard
- バージョン: 2.7
- アクティベーション: 5
Crossover XAU – Optimized 9/21 EMA Crossover EA for XAUUSD
This Expert Advisor is a robust automated trading system based on the classic 9-period and 21-period EMA crossover strategy on the M5 timeframe. It is strictly optimized for XAUUSD (Gold) with special focus on safe volume calculation to prevent "Not enough money" or margin errors on this high-margin symbol.
Key Features:
- EMA Crossover Logic: Opens a single main trade (Buy when fast EMA crosses above slow EMA, Sell on the opposite crossover).
- Advanced Margin Protection: Uses OrderCalcMargin() with a 10% safety buffer and final free margin validation — significantly reduces the risk of order rejection due to insufficient margin on XAUUSD.
- Dynamic Lot Sizing: Automatically reduces lot size if the requested volume would exceed available free margin.
- Trailing Stop: Optional intelligent trailing stop (default 339 points) to lock in profits.
- Hedge Recovery System (optional): On hedging accounts only, opens a counter-trade (hedge) when the main position moves against it by the HedgeTrigger distance. The hedge closes automatically when it reaches the set profit target.
- Daily Trade Limit: Configurable maximum trades per day to control exposure.
- Safe SL/TP Handling: Respects broker stop levels and normalizes prices correctly.
- Clean Code: Uses MQL5's modern CTrade class, proper position handling, and detailed logging.
Important: This EA must be used on XAUUSD (Gold). While it may technically run on other symbols, it is strictly optimized and intended exclusively for XAUUSD on the M5 timeframe.
Important Risk Disclaimer:
We do not guarantee any profits. Past performance is not indicative of future results. Trading in financial markets, especially with leverage on XAUUSD (Gold), involves substantial risk of loss and may not be suitable for all investors.
We strongly recommend testing this EA thoroughly on a demo account first for at least several weeks (or months) before using it on a live account. Understand the strategy, monitor its behavior in different market conditions, and only risk capital you can afford to lose.
Backtesting & Personal Use:
This EA was backtested from 2018 to 2025 on high-quality historical data for XAUUSD. We personally use this exact same version (v2.07) in our own trading.
Recommended Settings:
- Attach the EA exclusively to the XAUUSD chart on M5 timeframe.
- Default parameters are already optimized for XAUUSD.
- Adjust Lots, HedgePercent, and risk-related inputs according to your account size and risk tolerance.
Account Type:
- Works on both Netting and Hedging accounts.
- Hedge recovery functions are active only on hedging accounts.
Attach the EA to the XAUUSD 1H chart, enable AutoTrading, and let it work.
Always combine automated trading with your own market understanding and proper risk management.
