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
Skrip sumber terbuka
Dalam semangat TradingView sebenar, pencipta skrip ini telah menjadikannya sumber terbuka, jadi pedagang boleh menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupuan anda boleh menggunakan secara percuma, ingat bahawa penerbitan semula kod ini tertakluk kepada Peraturan Dalaman.
Penafian
Maklumat dan penerbitan adalah tidak bertujuan, dan tidak membentuk, nasihat atau cadangan kewangan, pelaburan, dagangan atau jenis lain yang diberikan atau disahkan oleh TradingView. Baca lebih dalam Terma Penggunaan.
Skrip sumber terbuka
Dalam semangat TradingView sebenar, pencipta skrip ini telah menjadikannya sumber terbuka, jadi pedagang boleh menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupuan anda boleh menggunakan secara percuma, ingat bahawa penerbitan semula kod ini tertakluk kepada Peraturan Dalaman.
Penafian
Maklumat dan penerbitan adalah tidak bertujuan, dan tidak membentuk, nasihat atau cadangan kewangan, pelaburan, dagangan atau jenis lain yang diberikan atau disahkan oleh TradingView. Baca lebih dalam Terma Penggunaan.