3 EMA Trend Detector with Selectable EMAs & Slope Filter

Overview:
This indicator highlights strong trend conditions using a customizable combination of three exponential moving averages (EMAs). It shades the background green during confirmed uptrends and red during downtrends, providing a clear "go / stop" visual signal on your chart.
The indicator is built for traders who want precision control over which EMAs are used in their trend logic and how strong the trend must be (based on EMA slope). It can be used as a trend confirmation tool, entry filter, or visual market bias gauge.
🧠 How It Works:
Uses three EMAs: default lengths are 12, 48, and 200.
A strong uptrend is confirmed when:
The selected EMAs are aligned (e.g., EMA 12 > EMA 48 > EMA 200)
Each EMA is rising by more than a threshold, defined as a percentage of price
A strong downtrend is confirmed when:
The EMAs are aligned in reverse (e.g., EMA 12 < EMA 48 < EMA 200)
Each EMA is falling by more than the threshold
You can customize the threshold (%) for each EMA to control sensitivity.
⚙️ Features & Customization:
✅ Enable/disable each EMA individually via checkboxes
✅ Custom slope sensitivity per EMA (e.g., EMA 12 reacts faster than EMA 200)
✅ Background shading turns green for uptrend, red for downtrend
✅ Color customization for up/down trends
✅ Hidden trendSignal output (1 = uptrend, -1 = downtrend) for use in alerts
📌 How to Use:
Add the indicator to your chart.
Use the settings to:
Select which EMAs are included in trend detection
Set slope sensitivity for each EMA (as % of price)
Watch the background for:
🟩 Green = strong uptrend (aligned and sloping up)
🟥 Red = strong downtrend (aligned and sloping down)
Optional: use the hidden trendSignal (value of 1 or -1) to set alerts.
🔔 Example Alert Condition:
To alert when a strong uptrend begins:
trendSignal crosses 1
Or when a strong downtrend begins:
trendSignal crosses -1
🔎 Ideal For:
Momentum traders
Trend-followers
Swing traders looking for clean market structure confirmation
Anyone who wants to simplify multi-EMA trend filtering
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
Untuk akses pantas pada carta, tambah skrip ini kepada kegemaran anda — ketahui lebih lanjut di sini.
Penafian
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
Untuk akses pantas pada carta, tambah skrip ini kepada kegemaran anda — ketahui lebih lanjut di sini.