Gold Trend only
- Experts
- Eslam Mohamed Hassanein Hassan Aly
- Versione: 2.0
- Attivazioni: 5
Overview
This is a professional Expert Advisor (trading bot) for MetaTrader 5 that implements a multi-timeframe trend-following strategy based on MACD crossovers. The bot is specifically optimized for Gold (XAUUSD) trading but works on any Forex pair.
How It Works
The strategy uses 3 timeframes to filter signals:
| Timeframe | Role |
|---|---|
| Higher Timeframe | Determines the primary trend direction |
| Middle Timeframe | Confirms the trend direction |
| Entry Timeframe | Executes the trade when a new crossover occurs |
Entry Logic
-
BUY Signal: Higher and Middle timeframes show bullish trend + Entry timeframe gives a new bullish MACD crossover
-
SELL Signal: Higher and Middle timeframes show bearish trend + Entry timeframe gives a new bearish MACD crossover
Important: The bot only enters after the candle closes (no false signals during candle formation). Only one position at a time is allowed.
Key Features
1. Multi-Timeframe Confirmation
-
Higher TF → Trend direction
-
Middle TF → Trend confirmation
-
Entry TF → Entry signal execution
2. Advanced Money Management (3 Modes)
| Mode | Description |
|---|---|
| Fixed Lot | Trade with a constant lot size |
| Per 100$ Balance | Automatically adjusts lot size based on account balance (e.g., 0.01 lot per 100$ balance) |
| Risk Percentage | Calculates lot size based on risk % per trade (e.g., 2% risk = lot calculated automatically) |
3. Position Management
-
Partial Close: Automatically closes a percentage of the position when reaching partial profit (e.g., close 50% at 50% of TP)
-
Break Even: Moves Stop Loss to entry price after partial profit target is reached
-
Trailing Stop: Optional trailing stop to lock in profits as price moves favorably
4. Spread Filter
Prevents trading during high spread conditions to avoid unnecessary losses.
5. Netting Account Support
Fully compatible with Netting accounts (one position per symbol).
Recommended Settings for Gold (XAUUSD)
| Parameter | Recommended Value | Explanation |
|---|---|---|
| Higher Timeframe | H1 or H4 | Determines overall trend |
| Middle Timeframe | M15 | Confirms the trend |
| Entry Timeframe | M5 | Entry signals |
| Take Profit | 300-500 Pips | Gold moves 2000-5000 pips daily |
| Stop Loss | 100-200 Pips | Reasonable stop for gold |
| Max Spread | 30-50 Pips | Gold spread is 15-30 pips normally |
| Lot Method | PER100 or RISK | Recommended for proper money management |
| Lot per 100$ | 0.01 | Safe lot size for gold |
| Risk Percent | 0.5-1.0% | Conservative risk management |
Important Notes for Gold Trading:
-
1 Pip on XAUUSD = 10 Points (the bot handles this automatically)
-
Gold spread can spike to 50-100 pips during news events → Enable spread filter!
-
Gold is more volatile than Forex → Use smaller lot sizes (start with 0.01 lot)
-
Minimum account balance recommended: $500 for 0.01 lot
Input Parameters Explained
Timeframes
-
Higher_Timeframe = H1 (Trend)
-
Middle_Timeframe = M15 (Confirmation)
-
Entry_Timeframe = M5 (Entry)
MACD Settings
-
FastEMA = 12
-
SlowEMA = 26
-
SignalSMA = 9
Money Management
-
LotMethod = PER100 or RISK or FIXED
-
FixedLot = 0.01 (if using FIXED mode)
-
LotPer100 = 0.01 (if using PER100 mode)
-
RiskPercent = 1.0 (if using RISK mode)
-
MaxLotAllowed = 0.1 (safety limit)
Trade Settings (in PIPS)
-
TakeProfitPips = 300-500 pips
-
StopLossPips = 100-200 pips
-
MagicNumber = Unique identifier for this EA
Spread Filter
-
EnableSpreadFilter = true
-
MaxSpreadPips = 30-50 pips
Position Management
-
EnablePartialClose = true/false (optional)
-
EnableBreakEven = true (recommended)
-
PartialClosePercent = 50.0
-
EnableTrailingStop = false (optional)
-
TrailingStopPips = 50 (if enabled)
Installation Instructions
-
Copy the .mq5 file to MQL5/Experts/ folder
-
Compile the file in MetaEditor (F7)
-
Attach the EA to a Gold chart (XAUUSD)
-
Adjust settings according to your risk preference
-
Run on Demo account first for at least 1 month
-
After consistent results, move to Live account with small capital
Backtest Results Summary
Tested on XAUUSD with conservative settings:
-
Period: 2021-2025 (post-COVID)
-
Initial Deposit: $500
-
Profit Factor: 2.65
-
Win Rate: 94.65%
-
Max Drawdown: 49.60%
⚠️ Warning: Past performance does not guarantee future results. Always test on demo first!
Risk Warning
Trading Gold (XAUUSD) involves significant risk due to:
-
High volatility
-
Spread spikes during news events
-
Gap risks over weekends
Never risk more than 1-2% of your account per trade.
Support
For questions or support, refer to the source code comments or contact your trading community.
Version: 2.00
Compatible with: MetaTrader 5 (Netting & Hedging accounts)
Symbols: XAUUSD (Gold), Forex pairs
Timeframes: Any (recommended: H1/M15/M5)
