Xauusd Averaging
- Experts
- Versão: 1.0
- Ativações: 5
XAUUSD Averaging EA is an automated grid trading system designed specifically for XAUUSD (Gold) trading on the MetaTrader 5 platform. This Expert Advisor implements a professional averaging strategy with martingale position sizing, utilizing dynamic spacing based on market volatility through ATR (Average True Range) analysis.
The system combines multiple grid modes with technical filters including Moving Average crossover signals, RSI confirmation, and ADX trend strength filtering. It features advanced basket risk management with trailing stops, daily limits, and an adaptive failure counter that progressively increases profit targets after consecutive losses.
This EA is built for traders seeking a systematic grid-based approach to XAUUSD with robust risk controls and volatility adaptation.
Core Features
-
Three Grid Spacing Modes – Static, ATR-dynamic, and Hybrid (ATR with min/max limits)
-
Martingale Position Sizing – Configurable lot multiplier with maximum lot protection
-
ATR-Adaptive Stop Loss & Take Profit – Dynamic SL/TP based on market volatility
-
Basket Trailing Stop – Activates at specified profit level with retracement-based closure
-
Technical Entry Filters – MA crossover signals with optional RSI and ADX confirmation
-
Daily Profit/Loss Limits – Automatic trading pause when daily targets are met
-
Failure Counter System – Increases profit targets after consecutive failed cycles
-
Weekend Position Closure – Automatic close before market weekend
-
Spread Protection – Maximum spread filter to avoid unfavorable entry conditions
-
Force Entry Mode – Testing feature for immediate position opening on startup
Grid Spacing Modes
Static Grid
Fixed point spacing between averaged positions:
-
Buy Grid: 300 points default
-
Sell Grid: 500 points default
-
Tiered spacing option with 1.8x multiplier per level
Dynamic Grid (ATR-Based)
Spacing adapts to current market volatility:
-
Uses ATR (14-period, H4 timeframe) for measurement
-
Separate multipliers for buy and sell directions
-
No fixed limits applied
Hybrid Grid
ATR-based spacing with user-defined boundaries:
-
Minimum spacing: 300 points
-
Maximum spacing: 1000 points
-
Combines volatility adaptation with safety limits
Entry Signals & Filters
Primary Signal: Moving Average Crossover
-
5-period SMA on close price
-
Buy Signal: Price closes above MA after being below
-
Sell Signal: Price closes below MA after being above
RSI Filter (Optional)
-
14-period RSI on close price
-
Buy: RSI below 30 (oversold)
-
Sell: RSI above 70 (overbought)
ADX Trend Filter (Optional)
-
14-period ADX on H4 timeframe
-
Minimum threshold: 25.0
-
Buy: ADX > 25 and +DI > -DI
-
Sell: ADX > 25 and -DI > +DI
Position Sizing & Martingale
| Parameter | Default | Description |
|---|---|---|
| Starting Lot | 0.01 | Initial position size |
| Lot Multiplier | 1.5 | Multiplier after each averaging level |
| Max Lot | 0.50 | Absolute maximum lot size safety limit |
| Max Positions | 20 | Maximum positions per cycle |
Minimum Distance Protection
-
Automatically respects broker minimum stop levels
-
Adds 50-point buffer above minimum requirements
Daily Limits & Session Control
Daily Profit Limit
-
Percentage of balance as daily profit target
-
Stops new entries when reached
-
Can close all positions automatically
Daily Loss Limit
-
Percentage of balance as daily loss limit
-
Stops trading when reached
-
Can close all positions automatically
Weekend Control
-
Automatic position closure before weekend
-
Prevents weekend gap exposure
-
Market closure detection based on Friday 22:00
Setup Instructions
-
Install the EA – Place XAU_Averaging_EA_V1.0.mq5 in the MQL5/Experts folder
-
Compile – Ensure no compilation errors
-
Attach to Chart – Attach to XAUUSD chart (any timeframe)
-
Configure Inputs – Adjust grid mode, lot size, and risk parameters
-
Enable Auto-Trading – Click the green AutoTrading button
-
Monitor – Observe first entry and averaging behavior
Recommended Settings
| Parameter | Recommendation |
|---|---|
| Timeframe | H1 or H4 for stable signals |
| Grid Mode | Hybrid for volatility adaptation |
| Starting Lot | 0.01 for $1000 account |
| Max Positions | 10-15 for moderate risk |
| Max Lot | 0.20-0.50 based on account size |
| Trailing Trigger | Adjust to account size (5-20% of balance) |
Important Notes
-
Risk Warning: Grid/martingale strategies carry significant risk
-
Account Requirement: Minimum $500 recommended for 0.01 lot
-
Broker Compatibility: Ensure broker supports hedging and market execution
-
Slippage: Trading during high volatility may cause order slippage
-
Margin: Monitor margin levels closely during averaging phases
-
Backtesting: Use MultiTester for reliable strategy validation
-
Demo First: Always test on demo account before live trading
Error Handling
The EA includes robust error handling for:
-
Insufficient margin (logs warning, skips averaging)
-
Spread exceeding limits (skips entry)
-
Auto-trading disabled (continuous monitoring)
-
Broker stop level constraints (auto-adjusts SL/TP)
-
Order placement failures (retry up to 3 times)
Disclaimer
Trading XAUUSD (Gold) carries significant risk. Grid and martingale strategies can amplify losses during adverse market conditions. This EA is a trading tool and does not guarantee profits.
Users should:
-
Understand the strategy mechanics before deployment
-
Apply appropriate risk management
-
Monitor trading activity regularly
-
Use only risk capital
-
Adjust parameters based on current market volatility
Past performance does not guarantee future results. All settings should be validated on demo accounts before live implementation.
