OPEN-SOURCE SCRIPT

EMA 20/50/200 - Warning Note Before Cross

28
EMA 20/50/200 - Smart Cross Detection with Customizable Alerts

A clean and minimalistic indicator that tracks three key Exponential Moving Averages (20, 50, and 200) with intelligent near-cross detection and customizable warning system.

═══════════════════════════════════════════════════════════════════

📊 KEY FEATURES

✓ Triple EMA System
• EMA 20 (Red) - Fast/Short-term trend
• EMA 50 (Yellow) - Medium/Intermediate trend
• EMA 200 (Green) - Slow/Long-term trend & major support/resistance

✓ Smart Near-Cross Detection
• Get warned BEFORE crosses happen (not after)
• Adjustable threshold percentage (how close is "close")
• Automatic hiding after cross to prevent false signals
• Configurable lookback period

✓ Dual Warning System
• Price Label: Appears directly on chart near EMAs
• Info Table: Positioned anywhere on your chart
• Both show distance percentage and direction
• Dynamic positioning to avoid blocking candles

✓ Color-Coded Alerts
• GREEN warning = Bullish cross approaching (EMA 20 crossing UP through EMA 50)
• RED warning = Bearish cross approaching (EMA 20 crossing DOWN through EMA 50)

✓ Cross Signal Detection
• Golden Cross (EMA 50 crosses above EMA 200)
• Death Cross (EMA 50 crosses below EMA 200)
• Fast crosses (EMA 20 and EMA 50)

═══════════════════════════════════════════════════════════════════

⚙️ CUSTOMIZATION OPTIONS

Warning Settings:
• Custom warning text for bull/bear signals
• Adjustable opacity for better visibility
• Toggle distance and direction display
• Flexible table positioning (9 positions available)
• 5 text size options

Alert Settings:
• Golden/Death Cross alerts
• Fast cross alerts (20/50)
• Near-cross warnings (before it happens)
• All alerts are non-repainting

Display Options:
• Show/hide each EMA individually
• Toggle all signals on/off
• Adjustable threshold sensitivity
• Dynamic label positioning

═══════════════════════════════════════════════════════════════════

🎯 HOW TO USE

1. ADD TO CHART
Simply add the indicator to any chart and timeframe

2. ADJUST THRESHOLD
Default is 0.5% - increase for less frequent warnings, decrease for earlier warnings

3. SET UP ALERTS
Create alerts for:
• Near-cross warnings (get notified before the cross)
• Actual crosses (when EMA 20 crosses EMA 50)
• Golden/Death crosses (major trend changes)

4. CUSTOMIZE APPEARANCE
• Change warning text to your language
• Adjust opacity for your chart theme
• Position table where it's most convenient
• Choose label size for visibility

═══════════════════════════════════════════════════════════════════

💡 TRADING TIPS

- Use the near-cross warning to prepare entries/exits BEFORE the cross happens
- Green warning = Prepare for potential long position
- Red warning = Prepare for potential short position
- Combine with other indicators for confirmation
- Higher timeframes = more reliable signals
- Warning disappears after cross to avoid confusion

═══════════════════════════════════════════════════════════════════

🔧 TECHNICAL DETAILS

- Pine Script v6
- Non-repainting (all signals confirm on bar close)
- Works on all timeframes
- Works on all instruments (stocks, crypto, forex, futures)
- Lightweight and efficient
- No external data sources required

═══════════════════════════════════════════════════════════════════

📝 SETTINGS GUIDE

Near Cross Settings:
• Threshold %: How close EMAs must be to trigger warning (default 0.5%)
• Lookback Bars: Hide warning for X bars after a cross (default 3)

Warning Note Style:
• Text Size: Tiny to Huge
• Colors: Customize bull/bear warning colors
• Position: Place table anywhere on chart
• Opacity: 0 (solid) to 90 (very transparent)

Price Label:
• Size: Tiny to Large
• Opacity: Control transparency
• Auto-positioning: Moves to avoid blocking candles

Custom Text:
• Bull/Bear warning messages
• Toggle distance display
• Toggle direction display

═══════════════════════════════════════════════════════════════════

⚠️ IMPORTANT NOTES

- Warnings only appear BEFORE crosses, not after
- After a cross happens, warning is hidden for the lookback period
- Adjust threshold if you're getting too many/too few warnings
- This is a trend-following indicator - best used with confirmation
- Always use proper risk management

═══════════════════════════════════════════════════════════════════

Happy Trading! 📈📉

If you find this indicator useful, please give it a boost and leave a comment!
For questions or suggestions, feel free to reach out.

Declinazione di responsabilità

Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.