OPEN-SOURCE SCRIPT
Clean MA Signal - XAUUSD [5m]

Clean MA Signal — XAUUSD
A trend-following signal indicator built specifically for XAUUSD on the 5-minute chart. Combines EMA stack alignment, higher timeframe trend filtering, and multiple quality filters to surface only high-probability entries — and stay out of the noise gold is famous for.
How it works
Signals trigger when the fast EMA crosses or breaks through the slow EMA with momentum, while all three EMAs (9 / 21 / 50) are in full alignment. A 1-hour HTF filter ensures you're only trading in the direction of the larger trend.
Filters applied to every signal
EMA stack: all three EMAs must be fully stacked (bull or bear)
1H trend bias: fast and slow EMA must agree on the 1-hour chart
ADX ≥ 20: only trades trending conditions — skips gold's choppy consolidation phases
RSI range: avoids overbought/oversold extremes
Body ratio ≥ 0.45: requires a decisive candle — filters out wick-heavy indecision bars
Volatility spike filter: rejects candles more than 2.5× the average ATR — avoids news spike traps
Exhaustion filter: skips entries after 3 consecutive same-direction closes
Cooldown: minimum 8 bars between signals to prevent signal stacking
Stop loss & take profit
SL is placed below/above the 8-bar swing low/high plus an ATR buffer — respects actual price structure rather than a fixed distance. Three TP levels are projected using ATR multiples (1.2 / 2.5 / 4.5). TP and SL hit events are marked directly on the chart.
Works on
5-minute chart (primary). Also functional on 3m and 15m with minor input adjustments.
For educational purposes only. Past performance does not guarantee future results
Script de código aberto
Em verdadeiro espírito do TradingView, o criador deste script o tornou de código aberto, para que os traders possam revisar e verificar sua funcionalidade. Parabéns ao autor! Embora você possa usá-lo gratuitamente, lembre-se de que a republicação do código está sujeita às nossas Regras da Casa.
Aviso legal
As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.
Script de código aberto
Em verdadeiro espírito do TradingView, o criador deste script o tornou de código aberto, para que os traders possam revisar e verificar sua funcionalidade. Parabéns ao autor! Embora você possa usá-lo gratuitamente, lembre-se de que a republicação do código está sujeita às nossas Regras da Casa.
Aviso legal
As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.