Summary: This article presents a mature hedging grid strategy designed for Gold (XAUUSD). It combines trend-following with range-bound adaptation. Includes specific parameters and a code snippet.




Title: Hedging Grid System for Gold: Trend-Following with Range-Bound Compatibility

Most grid systems fail in strong trends or get chopped to death in ranges. This article presents a mature hedging grid logic specifically for XAUUSD that handles both - without using Martingale.

1. Core Philosophy: Balanced Recovery
Unlike traditional grids that rely on directional averaging, this approach uses a "Balanced Recovery" mechanism. When the market moves against your initial position, the system opens a hedging trade on the opposite side rather than doubling down aggressively.

The key is that the hedge is not a loss lock - it is a dynamic offset. The EA continuously calculates the net exposure of the entire basket. If the floating loss exceeds a preset threshold, the hedge activates to cap drawdown while waiting for a pullback.

2. Specific Parameters for XAUUSD
Based on backtest-optimized ranges for Gold's volatility pattern:

| Parameter | Recommended Value | Rationale |
|-----------|-------------------|-----------|
| Base Grid Gap | 400-800 points (40-80 pips) | Gold's average daily range is ~2000 points |
| Initial Lot Size | 0.01 per $2000 account balance | Conservative base |
| Lot Progression | Linear (+0.01 per step) | Avoids Martingale explosion |
| Max Orders Per Side | 4-5 | Hard limit on exposure |
| Hedge Activation DD | 12-15% of equity | Triggers protective opposite order |
| Recovery Target | 0.5% of basket profit | Closes all when in profit |

3. EA Logic Structure (Pseudo-Code)
```python
# Hedging Grid EA Core Logic for XAUUSD
if not is_news_event(): # News filter active
if price >= last_buy_price + grid_gap and buy_orders_count < max_buy_orders:
open_buy( lot_size = base_lot + buy_orders_count * lot_increment )
if price <= last_sell_price - grid_gap and sell_orders_count < max_sell_orders:
open_sell( lot_size = base_lot + sell_orders_count * lot_increment )

# Hedge trigger based on drawdown
current_dd = calculate_equity_drawdown()
if current_dd >= hedge_dd_threshold and not hedge_active:
open_opposite_hedge( lot_size = total_net_lot * 0.6 )
hedge_active = True

# Recovery logic - trim opposite losers
if hedge_active:
if net_profit_of_active_direction >= recovery_target:
close_all_orders()
hedge_active = False
```

4. Trend-Following Adaptation
To make the grid compatible with trending markets, add a dynamic filter:
  • ADX Filter: If ADX > 30, increase grid gap by 50% (wider spacing)

  • EMA Slope: Only add orders in the trend direction when slope > 0 (for uptrend)

  • Partial Take-Profit: In strong trends, close 60% of positions at 1:2 RR, let 40% run with trailing stop


  • 5. Range-Bound Compatibility
    During low volatility (ATR < 20% of 20-period average):
  • Reduce grid gap by 30% (more frequent captures)

  • Activate "double-sided" mode (both buy and sell grids active)

  • Lower recovery target to 0.3% for faster turnover


  • 6. Risk Management Rules
  • Absolute Equity Floor: Stop all new orders at 30% drawdown

  • Correlation Limit: Never exceed 6% of portfolio in correlated Gold exposures

  • Session Control: Pause grid expansion 15 minutes before high-impact news (NFP, CPI, FOMC)


  • Reference:
  • Kaufman, P. J. (2013). *Trading Systems and Methods*. Wiley.

  • EAHub Community. (2025). Grid Recovery XAUUSD EA Documentation.

  • MQL5 Market. (2025). Extractors for XAUUSD Specifications.