Build a Gold (XAUUSD) RSI Mean-Reversion EA for MT5 — No Code
Quick Answer: Gold XAUUSD RSI EA Without Code
Quick answer: Open AlfaTactix Strategy Builder → Step 3 — Signals on H1 for XAUUSD → add RSI with Length 14, Overbought 70, Oversold 30 → Buy: condition Cross, Target Oversold, Direction Up, Value 30 → Sell: Cross, Target Overbought, Direction Down, Value 70 → Step 4: spread filter + market session (London/NY overlap) → Step 5: ATR-based or fixed stop loss per EA Risk Management → Save → export MQL5 from Code Generator → compile once in MetaEditor → backtest with realistic XAUUSD spread in the Strategy Tester.
Disclosure: This tutorial uses AlfaTactix Strategy Builder for a gold-only RSI mean-reversion recipe. For the full six-step platform tour, see Build EA Without Coding. For every RSI condition type (Compare, Cross, Divergence, Failure Swing, Breakout, Pattern, Slope), see RSI Overbought/Oversold EA — No Code. For MA/ATR gold case study (not RSI), see EA for Gold (XAUUSD).
Related guides: RSI Academy · Backtest in Strategy Tester · EA Prop Firm Rules
Why RSI on Gold (XAUUSD)?
Gold (XAUUSD) is one of the most traded symbols on MT5 — high volatility, sharp intraday swings, and mean-reverting behavior during range sessions. The Relative Strength Index (RSI) maps those swings to a 0–100 oscillator: extremes near 70 (overbought) and 30 (oversold) often precede bounce moves when momentum exhausts.
| Why RSI on gold | Detail |
|---|---|
| Clear zones | OB/OS levels give rule-based entries without discretionary chart reading |
| Mean-reversion fit | Gold frequently oscillates in ranges during London/NY liquidity |
| Automation | An EA runs OnTick() logic via exported iRSI() — no hand-written MQL5 |
| Complements other gold EAs | This guide is RSI-only; trend/ATR gold systems live in EA for Gold (XAUUSD) |
Gold-specific cautions: Wider spread, faster moves, and session-dependent liquidity. A forex-tuned RSI EA copied to XAUUSD without Step 4 filters often over-trades or gets stopped out by spread. This guide adds spread + session filters and ATR-aware risk on top of the classic 30/70 Cross recipe.
Not the same as trend-following gold: If you want moving-average entries on gold, use Moving Average Crossover EA — No Code or the Gold XAUUSD MQL5 case study — then optionally layer RSI as a filter later.
Classic Gold RSI Settings
| Setting | Starter (H1 XAUUSD) | Notes for gold |
|---|---|---|
| Length | 14 | Try 9–11 after backtest if signals lag |
| Overbought | 70 | Range 50–100 in builder; 75 = stricter sells |
| Oversold | 30 | Range 0–50; 25 = stricter buys |
| Source | Close | High/Low = more reactive on volatile candles |
| Smoothing | None | Optional SMA/EMA if RSI line is too noisy |
| Timeframe | H1 | M15 = more signals + spread cost; H4 = fewer, cleaner |
| Symbol | XAUUSD (or broker gold symbol) | Match Market Watch name exactly in tester |
Works best: Range or mild trend days during London open through NY overlap — RSI crosses back from extremes after impulse moves.
Struggles in: Strong one-way gold trends (RSI can stay overbought/oversold for hours). Mitigate with Step 4 session filter, Step 5 stop loss, or combine with a trend filter from MA Crossover EA.
For oscillator math, divergence, and chart reading, see the RSI Academy guide.
RSI Parameters and Gold-Specific Filters
RSI parameters (from Strategy Builder UI)
When you add RSI on Step 3 — Signals, the Parameters panel matches rsiConfig:
| Parameter | Range / options | Default | Gold tip |
|---|---|---|---|
| Length | 2 – 100 | 14 | Shorter = faster signals on volatile gold |
| Source | Close, Open, High, Low | Close | Close is standard for H1 mean-reversion |
| Smoothing | None, SMA, EMA, WMA, SMMA, VWMA | None | Add smoothing only if backtest improves stability |
| Smoothing Length | 1 – 100 | 14 | Used when Smoothing ≠ None |
| Overbought | 50 – 100 | 70 | Align with Sell Cross Value |
| Oversold | 0 – 50 | 30 | Align with Buy Cross Value |
| Offset | -50 – 50 | 0 | Leave 0 unless you know you need bar shift |
Core signal recipe (Step 3):
| Tab | Condition | Target | Direction | Value |
|---|---|---|---|---|
| Buy | Cross | Oversold | Up | 30 |
| Sell | Cross | Overbought | Down | 70 |
RSI condition types (brief): The builder exposes Compare, Cross, Divergence, Failure Swing, Breakout, Pattern, and Slope. For mean-reversion gold, start with Cross only. Compare fires while RSI stays in a zone (more entries). Divergence and Failure Swing suit advanced reversal filters. Full field-by-field documentation: RSI Overbought/Oversold EA — No Code.
Gold-specific Step 4 filters
| Filter | Purpose on XAUUSD |
|---|---|
| Spread | Block entries when spread exceeds your cap (gold spread spikes at rollovers and thin sessions) |
| Market session | Trade London and/or NY, or London/NY overlap when liquidity and mean-reversion are strongest |
| Optional ATR filter | Skip ultra-low volatility bars (no room for bounce) or extreme ATR (news spikes) |
Configure these on Step 4 — Filters in Strategy Builder. For multi-timeframe ideas later, see Advanced EA MTF & Filters — this article stays focused on H1 XAUUSD RSI.
Build the Gold RSI EA Step by Step
Workflow: six steps in Strategy Builder demo. Below is the XAUUSD H1 mean-reversion recipe.
Step 1 — Strategy information
- Name: e.g.
Gold RSI Mean Reversion H1 XAUUSD - Description: optional note — RSI 14 / 30 / 70, London/NY session
Step 2 — Timeframes
- Enable H1 as the trading timeframe (matches tf0 on Step 3).
- Optional later: higher timeframe trend filter — not required for this starter EA.
Step 3 — Signals (core)
- Open tab Buy.
- Select timeframe H1.
- Add indicator → RSI (Momentum group).
- Parameters:
- Length: 14
- Source: Close
- Smoothing: None
- Smoothing Length: 14 (ignored when Smoothing = None)
- Overbought: 70
- Oversold: 30
- Offset: 0
- Add condition → Cross:
- Target: Oversold
- Direction: Up
- Value: 30
- Open tab Sell.
- Add RSI (mirror parameters).
- Add condition → Cross:
- Target: Overbought
- Direction: Down
- Value: 70
Stricter alternative: On Buy, Compare RSI <= 30 AND Cross Oversold Up 30 — fewer false starts; see condition details in the RSI EA guide.
Step 4 — Filters (recommended for gold)
- Spread filter: set maximum spread your broker typically offers during target hours (tune after demo observation).
- Market session: enable London and New York, or restrict to overlap window for tighter liquidity.
- Optional: ATR minimum/maximum if your builder build supports it for news avoidance.
Step 5 — Risk management
Gold requires realistic stops — not EURUSD pip counts.
| Setting | Suggestion for XAUUSD |
|---|---|
| Lot / risk % | 0.01 lot demo or 0.5–1% risk per trade |
| Stop Loss | ATR-based (e.g. 1.5–2× ATR) or fixed points sized for your broker |
| Take Profit | Optional; many RSI EAs exit on opposite Cross signal |
| One trade at a time | Reduces overlap risk in fast gold moves |
Full reference: EA Risk Management. Compare with ATR/MA approach in EA for Gold (XAUUSD).
Step 6 — Preview and Save
Review Buy/Sell rules and Step 4/5 settings → Save strategy to your account.
Export, Compile, and Backtest
- Open Code Generator → select your saved gold RSI strategy → MQL5 → download
.mq5. - Copy to
MQL5/Experts, compile (F7) in MetaEditor. - Open Strategy Tester:
- Symbol: XAUUSD (exact broker name)
- Period: H1
- Model: Every tick (or 1 minute OHLC for first pass)
- Spread: use current or fixed realistic gold spread — tight test spreads flatter results
- Date range: 6–12 months minimum
- Forward test on Demo before live.
If OrderSend fails with 10016, see Invalid Stops. Exported code uses standard iRSI().
Reference: MetaTrader 5 Strategy Tester.
Improvements and Prop Firm Notes
| Problem | Builder lever |
|---|---|
| Spread eats edge | Step 4 spread filter; realistic spread in tester |
| Entries outside liquid hours | Step 4 London/NY session |
| Counter-trend losses in gold trends | Tighter OB/OS (75/25); optional MA trend filter (MA Crossover EA) |
| Stops too tight for gold | Step 5 ATR stop; fix 10016 via Invalid Stops guide |
| Prop firm rule breach | Cap daily loss in Step 5; read EA Prop Firm Rules on MT5 |
Prop firm checklist: Confirm XAUUSD is allowed, max lot and drawdown fit your Step 5 settings, and backtest spread matches live account type. Many firms restrict news trading — consider disabling the EA around high-impact USD releases if your rules require it.
Advanced RSI upgrades: Add Failure Swing or Divergence with AND on Step 3 (documented in RSI Overbought/Oversold EA). Do not stack every condition on day one — validate the base Cross 30/70 recipe first.
Next Steps
- RSI Overbought/Oversold EA — No Code — full RSI condition types and generic forex recipe
- EA for Gold (XAUUSD) — MA/ATR gold case study (complement to this RSI guide)
- Build EA Without Coding — complete Strategy Builder walkthrough
- Moving Average Crossover EA — No Code — trend filter alternative
- RSI Academy guide — indicator theory
- EA Prop Firm Rules on MT5 — compliance before funded accounts
Try it: Strategy Builder demo — build the XAUUSD H1 RSI 14 / 30 / 70 EA with spread and session filters, export from Code Generator, and backtest the same week you forward-test on Demo.