All Strategies
Trend FollowingXAUUSD

ATR Trend Follow for XAUUSD (Gold)

Volatility-adjusted trend following — trail stops by ATR multiples.

Indicators

EMA 21, ATR 14

Recommended Timeframes

1h, 4h, 1d

Symbol Volatility

high

Trading Sessions

London, New York (24/5)

Why ATR Trend Follow Works on XAUUSD

A simple EMA trend with ATR-based exits. Stop and trailing stop scale with the asset's realised volatility, so the same code works on quiet EUR/USD and wild Bitcoin. ATR multipliers (typically 2-3×) are the only parameter you need to tune per market.

Gold (XAUUSD) is the most-traded commodity pair in retail forex. Strong directional moves during news, high intraday volatility, and clean trending behavior on H1/H4 — a favourite for trend-following and breakout bots.

Commodities like gold and silver have well-defined fundamental drivers — central bank policy, real yields, USD strength. Combined with the technical setup below, this gives the strategy two independent edges.

Best For

  • • Cross-asset deployment
  • • Volatile markets

Avoid In

  • • Low-ATR ranges

Pine Script Source

Copy this into PineForge — backtest on XAUUSD or any supported symbol, then deploy as a live bot.

atr-trend-follow.pinePine Script v5
//@version=5
strategy("ATR Trend Follow", overlay=true)

ema_len = input.int(21, "EMA Length")
atr_len = input.int(14, "ATR Length")
atr_mult = input.float(2.5, "ATR Multiplier")

ema = ta.ema(close, ema_len)
atr = ta.atr(atr_len)

long_stop = close - atr * atr_mult

if close > ema and close[1] <= ema[1]
    strategy.entry("Long", strategy.long)

if strategy.position_size > 0
    strategy.exit("Trail", from_entry="Long", stop=long_stop)

Backtest ATR Trend Follow on XAUUSD in 30 seconds

Sign up for PineForge, paste this Pine Script, and run a 1-year backtest on real XAUUSD data — no credit card required.

Related Strategies

We use cookies for analytics and ads measurement. See our privacy policy.