OPEN-SOURCE SCRIPT
Dynamic EMA Ribbon System

This Pine Script v6 indicator creates a multi-EMA ribbon that dynamically changes color based on market conditions. It includes 16 EMAs (21 to 66 in 3-period increments) and a thick 200 EMA for long-term trend reference. The indicator automatically detects bullish, bearish, and sideways markets, adjusting the EMA colors accordingly for clear visual interpretation.
Key Features
1. Multi-EMA Ribbon (21 to 66)
16 EMAs plotted distinctly (21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66).
Each EMA is individually visible (not clubbed together).
Adjustable line thickness (1-3 pixels).
2. Dynamic Color System
Green EMAs:
Price is above all EMAs.
EMAs are stacked ascendingly (21 > 24 > 27 > ... > 66).
Red EMAs:
Price is below all EMAs.
EMAs are stacked descendingly (21 < 24 < 27 < ... < 66).
Gray EMAs:
Market is sideways (price range within threshold).
EMAs are not properly stacked (no clear trend).
3. 200 EMA Reference Line
Thick black line (3px width).
Broken line style for better visibility.
Trend confirmation:
"▲ Trend Start" label when price crosses above 200 EMA.
"▼ Trend End" label when price crosses below 200 EMA.
4. Market State Detection
Sideways Market Condition:
Detected when price range is < user-defined threshold (default: 1.5%).
Background turns light gray.
Trending Market Condition:
Bullish: Background turns light green.
Bearish: Background turns light red.
5. Visual Enhancements
Price Position Line:
Blue line showing recent price movement (last 20 bars).
Clear Labels:
Large "Trend Start" / "Trend End" alerts.
No Repainting:
Uses confirmed signals to avoid false alerts.
Input Parameters
Parameter Description Default Range
Show 200 EMA Toggles the 200 EMA reference line true true/false
EMA Line Thickness Adjusts thickness of EMAs (1-3px) 1 1-3
Sideways Threshold (%) Price range % to consider market sideways 1.5% 0.1-10%
Sideways Period Bars analyzed for sideways condition 20 5-100
How to Use in Trading
Bullish Market (Green EMAs)
Entry Signal:
Price above all EMAs + EMAs stacked upward.
Confirmation: Price crosses above 200 EMA ("▲ Trend Start").
Exit Signal:
EMAs turn red or price drops below key EMAs.
Bearish Market (Red EMAs)
Entry Signal:
Price below all EMAs + EMAs stacked downward.
Confirmation: Price crosses below 200 EMA ("▼ Trend End").
Exit Signal:
EMAs turn green or price rises above key EMAs.
Sideways Market (Gray EMAs)
Strategy:
Avoid trend trades.
Look for breakouts (price exits range with EMA color change).
Code Highlights
✔ Optimized Performance – Uses arrays for EMA calculations.
✔ No Repainting – Signals are confirmed before display.
✔ Professional Visuals – Clean labels, dynamic colors, and intuitive design.
Final Notes
This indicator is perfect for:
✅ Trend-following strategies (swing/day trading).
✅ Breakout confirmation (sideways → trending shifts).
✅ Multi-timeframe analysis (works on all timeframes).
Installation:
Copy the Pine Script code.
Paste into TradingView’s Pine Editor.
Apply to any chart.
Key Features
1. Multi-EMA Ribbon (21 to 66)
16 EMAs plotted distinctly (21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66).
Each EMA is individually visible (not clubbed together).
Adjustable line thickness (1-3 pixels).
2. Dynamic Color System
Green EMAs:
Price is above all EMAs.
EMAs are stacked ascendingly (21 > 24 > 27 > ... > 66).
Red EMAs:
Price is below all EMAs.
EMAs are stacked descendingly (21 < 24 < 27 < ... < 66).
Gray EMAs:
Market is sideways (price range within threshold).
EMAs are not properly stacked (no clear trend).
3. 200 EMA Reference Line
Thick black line (3px width).
Broken line style for better visibility.
Trend confirmation:
"▲ Trend Start" label when price crosses above 200 EMA.
"▼ Trend End" label when price crosses below 200 EMA.
4. Market State Detection
Sideways Market Condition:
Detected when price range is < user-defined threshold (default: 1.5%).
Background turns light gray.
Trending Market Condition:
Bullish: Background turns light green.
Bearish: Background turns light red.
5. Visual Enhancements
Price Position Line:
Blue line showing recent price movement (last 20 bars).
Clear Labels:
Large "Trend Start" / "Trend End" alerts.
No Repainting:
Uses confirmed signals to avoid false alerts.
Input Parameters
Parameter Description Default Range
Show 200 EMA Toggles the 200 EMA reference line true true/false
EMA Line Thickness Adjusts thickness of EMAs (1-3px) 1 1-3
Sideways Threshold (%) Price range % to consider market sideways 1.5% 0.1-10%
Sideways Period Bars analyzed for sideways condition 20 5-100
How to Use in Trading
Bullish Market (Green EMAs)
Entry Signal:
Price above all EMAs + EMAs stacked upward.
Confirmation: Price crosses above 200 EMA ("▲ Trend Start").
Exit Signal:
EMAs turn red or price drops below key EMAs.
Bearish Market (Red EMAs)
Entry Signal:
Price below all EMAs + EMAs stacked downward.
Confirmation: Price crosses below 200 EMA ("▼ Trend End").
Exit Signal:
EMAs turn green or price rises above key EMAs.
Sideways Market (Gray EMAs)
Strategy:
Avoid trend trades.
Look for breakouts (price exits range with EMA color change).
Code Highlights
✔ Optimized Performance – Uses arrays for EMA calculations.
✔ No Repainting – Signals are confirmed before display.
✔ Professional Visuals – Clean labels, dynamic colors, and intuitive design.
Final Notes
This indicator is perfect for:
✅ Trend-following strategies (swing/day trading).
✅ Breakout confirmation (sideways → trending shifts).
✅ Multi-timeframe analysis (works on all timeframes).
Installation:
Copy the Pine Script code.
Paste into TradingView’s Pine Editor.
Apply to any chart.
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.
Penafian
Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.
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.
Penafian
Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.