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
نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.
نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.