PROTECTED SOURCE SCRIPT
Non-Repainting Dynamic EMA System

Dynamic EMA System - Detailed Explanation
Overview
This indicator creates four adaptive Exponential Moving Averages (EMAs) that automatically adjust their periods based on current market conditions. Unlike traditional fixed-period EMAs, these lines dynamically become faster or slower to better match the market's behavior.
Core Components
1. Base EMA Lengths (Starting Points)
EMA 1: Base period of 10 (fastest)
EMA 2: Base period of 20 (fast-medium)
EMA 3: Base period of 30 (medium)
EMA 4: Base period of 200 (trend identifier)
These base values are not fixed—they serve as starting points that get multiplied by various market condition factors.
Market Analysis Features
The indicator analyzes 12 different market characteristics to understand current conditions:
Technical Indicators Used:
RSI (Relative Strength Index)
Measures momentum and overbought/oversold conditions
Normalized to 0-1 scale
ADX (Average Directional Index)
Measures trend strength
Higher values = stronger trends
Bollinger Bands Position
Shows where price sits relative to volatility bands
Indicates potential reversals or breakouts
VWAP (Volume Weighted Average Price)
Institutional trading benchmark
Signals if price is above/below average weighted price
Ichimoku Cloud
Japanese indicator showing support/resistance
Tenkan-Kijun relationship indicates trend direction
TRAMA (Triangular Moving Average)
Advanced adaptive moving average
Responds to genuine price movements
Volume Analysis
Compares current volume to 20-period average
Higher volume = more significant moves
ATR-Based Volatility
Weighted by volume for accuracy
Adjusts EMAs to market speed
Shannon Entropy
Measures market randomness vs. order
High entropy = choppy; Low entropy = trending
Price Correlation (Short-term)
How consistent price movements are
Detects momentum shifts
Price Correlation (Long-term)
Broader trend consistency
Confirms regime stability
Volume Strength
Normalized volume ratio
Validates price movements
How Length Adaptation Works
Market Regimes Identified:
The system identifies 4 distinct market conditions based on the 12 features:
Regime 1 (Green): Calm, ranging market → Shorter EMAs (more responsive)
Regime 2 (Blue): Strong trending market → Medium-length EMAs (balance speed/noise)
Regime 3 (Red): High volatility/choppy → Longer EMAs (filter noise)
Regime 4 (Gray): Transitional/neutral → Moderate EMAs (adaptive middle ground)
Adaptation Formula:
Each EMA length is calculated as:
Final Length = Base Length × Regime Multiplier × Volatility Adjustment × Momentum Adjustment × Entropy Adjustment
Where:
Regime Multiplier: 0.3x to 2.5x depending on market type
Volatility Adjustment: Increases length during high volatility (filters noise)
Momentum Adjustment: Based on RSI - extreme readings adjust sensitivity
Entropy Adjustment: Lower entropy (trending) = tighter EMAs
Key Adaptive Features
1. Volatility Response
When market volatility increases:
EMAs lengthen automatically to avoid whipsaws
Calculated using ATR weighted by volume
2. Volume Integration
Higher volume makes the system:
React faster to price changes
Increase learning rate
Trust the current move more
3. Correlation Analysis
Short-term correlation: Detects immediate momentum
Long-term correlation: Confirms overall trend stability
Adjusts EMA sensitivity accordingly
4. Entropy Monitoring
Measures market "disorder"
Trending markets → Tighter EMAs (follow trend)
Choppy markets → Wider EMAs (reduce noise)
Non-Repainting Design
Critical Safety Features:
Confirmed Data Only
All calculations use close[1], high[1], low[1], etc.
Current bar data is only used if barstate.isconfirmed
Locked Updates
EMA lengths only change when bar closes
Variables prefixed with confirmed_ store locked values
No Look-Ahead
System learns from past bars only
Future data cannot influence current values
Historical Consistency
Once a bar closes, its EMA values never change
Alerts and signals are reliable
Visual Interpretation
Background Colors:
Green: Calm/ranging market (Regime 1)
Blue: Strong trend (Regime 2)
Red: High volatility/choppy (Regime 3)
Gray: Transitional state (Regime 4)
Color transparency indicates confidence:
Solid color = High confidence in regime identification
Faint color = Lower confidence, potential transition
EMA Lines:
Red EMA (fastest): Short-term momentum
Orange EMA: Medium-term trend
Yellow EMA: Intermediate trend confirmation
Blue EMA: Long-term trend direction
Information Dashboard
The top-right table displays:
Metric Purpose
Regime Strength How strongly current conditions match the identified regime (0-1)
Silhouette Score Quality of regime identification (>0.5 = Excellent, >0.2 = Good)
EMA Values & Lengths Current price level and adaptive period for each EMA
Vol Volatility Volume-weighted volatility measure
Entropy Market randomness level (0 = trending, 1 = random)
Volume Strength Current volume relative to average
Learning Rate How quickly the system adapts (higher = faster adaptation)
Trading Applications
Trend Following:
EMAs aligned in order (1 > 2 > 3 > 4) = Strong uptrend
EMAs aligned reversed = Strong downtrend
Use EMA 4 as major trend filter
Entry Signals:
Fast EMA crosses medium EMA in trend direction
Price pullback to EMA 3 in trending regime
All EMAs converging in ranging regime
Exit Signals:
Fast EMA crosses below medium EMA
Regime change (background color shift)
Silhouette score drops (poor quality)
Regime-Based Strategy:
Green Background: Range trading, fade extremes
Blue Background: Trend following, ride momentum
Red Background: Reduce position size, wait for clarity
Gray Background: Cautious, potential regime shift
Advantages Over Standard EMAs
Automatic Adjustment: No manual tweaking needed for different markets
Context Aware: Understands if market is trending, ranging, or volatile
Volume Integration: Respects institutional involvement
Multi-Factor Analysis: Uses 12 indicators, not just price
Quality Metrics: Silhouette score shows when to trust signals
Non-Repainting: Reliable for backtesting and live trading
Best Practices
Do:
Wait for bar close before acting on signals
Check Silhouette score (>0.2 is reliable)
Use regime color as risk filter
Combine with your trading system
Don't:
Trade against EMA 4 in strong trends
Ignore regime changes
Use in extremely low liquidity
Expect perfection in all conditions
Summary
This is an intelligent, self-adjusting EMA system that reads 12 different market characteristics to automatically optimize its speed. It identifies whether the market is trending, ranging, volatile, or transitional, then adjusts all four EMAs accordingly. The non-repainting design ensures historical accuracy, while the quality metrics (Silhouette score, regime strength) tell you when to trust the signals most.
Overview
This indicator creates four adaptive Exponential Moving Averages (EMAs) that automatically adjust their periods based on current market conditions. Unlike traditional fixed-period EMAs, these lines dynamically become faster or slower to better match the market's behavior.
Core Components
1. Base EMA Lengths (Starting Points)
EMA 1: Base period of 10 (fastest)
EMA 2: Base period of 20 (fast-medium)
EMA 3: Base period of 30 (medium)
EMA 4: Base period of 200 (trend identifier)
These base values are not fixed—they serve as starting points that get multiplied by various market condition factors.
Market Analysis Features
The indicator analyzes 12 different market characteristics to understand current conditions:
Technical Indicators Used:
RSI (Relative Strength Index)
Measures momentum and overbought/oversold conditions
Normalized to 0-1 scale
ADX (Average Directional Index)
Measures trend strength
Higher values = stronger trends
Bollinger Bands Position
Shows where price sits relative to volatility bands
Indicates potential reversals or breakouts
VWAP (Volume Weighted Average Price)
Institutional trading benchmark
Signals if price is above/below average weighted price
Ichimoku Cloud
Japanese indicator showing support/resistance
Tenkan-Kijun relationship indicates trend direction
TRAMA (Triangular Moving Average)
Advanced adaptive moving average
Responds to genuine price movements
Volume Analysis
Compares current volume to 20-period average
Higher volume = more significant moves
ATR-Based Volatility
Weighted by volume for accuracy
Adjusts EMAs to market speed
Shannon Entropy
Measures market randomness vs. order
High entropy = choppy; Low entropy = trending
Price Correlation (Short-term)
How consistent price movements are
Detects momentum shifts
Price Correlation (Long-term)
Broader trend consistency
Confirms regime stability
Volume Strength
Normalized volume ratio
Validates price movements
How Length Adaptation Works
Market Regimes Identified:
The system identifies 4 distinct market conditions based on the 12 features:
Regime 1 (Green): Calm, ranging market → Shorter EMAs (more responsive)
Regime 2 (Blue): Strong trending market → Medium-length EMAs (balance speed/noise)
Regime 3 (Red): High volatility/choppy → Longer EMAs (filter noise)
Regime 4 (Gray): Transitional/neutral → Moderate EMAs (adaptive middle ground)
Adaptation Formula:
Each EMA length is calculated as:
Final Length = Base Length × Regime Multiplier × Volatility Adjustment × Momentum Adjustment × Entropy Adjustment
Where:
Regime Multiplier: 0.3x to 2.5x depending on market type
Volatility Adjustment: Increases length during high volatility (filters noise)
Momentum Adjustment: Based on RSI - extreme readings adjust sensitivity
Entropy Adjustment: Lower entropy (trending) = tighter EMAs
Key Adaptive Features
1. Volatility Response
When market volatility increases:
EMAs lengthen automatically to avoid whipsaws
Calculated using ATR weighted by volume
2. Volume Integration
Higher volume makes the system:
React faster to price changes
Increase learning rate
Trust the current move more
3. Correlation Analysis
Short-term correlation: Detects immediate momentum
Long-term correlation: Confirms overall trend stability
Adjusts EMA sensitivity accordingly
4. Entropy Monitoring
Measures market "disorder"
Trending markets → Tighter EMAs (follow trend)
Choppy markets → Wider EMAs (reduce noise)
Non-Repainting Design
Critical Safety Features:
Confirmed Data Only
All calculations use close[1], high[1], low[1], etc.
Current bar data is only used if barstate.isconfirmed
Locked Updates
EMA lengths only change when bar closes
Variables prefixed with confirmed_ store locked values
No Look-Ahead
System learns from past bars only
Future data cannot influence current values
Historical Consistency
Once a bar closes, its EMA values never change
Alerts and signals are reliable
Visual Interpretation
Background Colors:
Green: Calm/ranging market (Regime 1)
Blue: Strong trend (Regime 2)
Red: High volatility/choppy (Regime 3)
Gray: Transitional state (Regime 4)
Color transparency indicates confidence:
Solid color = High confidence in regime identification
Faint color = Lower confidence, potential transition
EMA Lines:
Red EMA (fastest): Short-term momentum
Orange EMA: Medium-term trend
Yellow EMA: Intermediate trend confirmation
Blue EMA: Long-term trend direction
Information Dashboard
The top-right table displays:
Metric Purpose
Regime Strength How strongly current conditions match the identified regime (0-1)
Silhouette Score Quality of regime identification (>0.5 = Excellent, >0.2 = Good)
EMA Values & Lengths Current price level and adaptive period for each EMA
Vol Volatility Volume-weighted volatility measure
Entropy Market randomness level (0 = trending, 1 = random)
Volume Strength Current volume relative to average
Learning Rate How quickly the system adapts (higher = faster adaptation)
Trading Applications
Trend Following:
EMAs aligned in order (1 > 2 > 3 > 4) = Strong uptrend
EMAs aligned reversed = Strong downtrend
Use EMA 4 as major trend filter
Entry Signals:
Fast EMA crosses medium EMA in trend direction
Price pullback to EMA 3 in trending regime
All EMAs converging in ranging regime
Exit Signals:
Fast EMA crosses below medium EMA
Regime change (background color shift)
Silhouette score drops (poor quality)
Regime-Based Strategy:
Green Background: Range trading, fade extremes
Blue Background: Trend following, ride momentum
Red Background: Reduce position size, wait for clarity
Gray Background: Cautious, potential regime shift
Advantages Over Standard EMAs
Automatic Adjustment: No manual tweaking needed for different markets
Context Aware: Understands if market is trending, ranging, or volatile
Volume Integration: Respects institutional involvement
Multi-Factor Analysis: Uses 12 indicators, not just price
Quality Metrics: Silhouette score shows when to trust signals
Non-Repainting: Reliable for backtesting and live trading
Best Practices
Do:
Wait for bar close before acting on signals
Check Silhouette score (>0.2 is reliable)
Use regime color as risk filter
Combine with your trading system
Don't:
Trade against EMA 4 in strong trends
Ignore regime changes
Use in extremely low liquidity
Expect perfection in all conditions
Summary
This is an intelligent, self-adjusting EMA system that reads 12 different market characteristics to automatically optimize its speed. It identifies whether the market is trending, ranging, volatile, or transitional, then adjusts all four EMAs accordingly. The non-repainting design ensures historical accuracy, while the quality metrics (Silhouette score, regime strength) tell you when to trust the signals most.
保護スクリプト
このスクリプトのソースコードは非公開で投稿されています。 ただし、制限なく自由に使用できます – 詳細はこちらでご確認ください。
免責事項
この情報および投稿は、TradingViewが提供または推奨する金融、投資、トレード、その他のアドバイスや推奨を意図するものではなく、それらを構成するものでもありません。詳細は利用規約をご覧ください。
保護スクリプト
このスクリプトのソースコードは非公開で投稿されています。 ただし、制限なく自由に使用できます – 詳細はこちらでご確認ください。
免責事項
この情報および投稿は、TradingViewが提供または推奨する金融、投資、トレード、その他のアドバイスや推奨を意図するものではなく、それらを構成するものでもありません。詳細は利用規約をご覧ください。