PROTECTED SOURCE SCRIPT

Dynamic Adaptive Moving Average [Alpha Extract]

178
Dynamic Adaptive Moving Average (DAMA) 📊

The Dynamic Adaptive Moving Average (DAMA) indicator is an adaptive technical tool that automatically discovers the optimal moving average period based on forward-looking price behavior. Unlike traditional fixed-length moving averages, this indicator continuously evaluates multiple timeframes to identify which MA length most accurately predicts future price movement, creating a responsive trend line that adapts to changing market conditions.

🔶 CALCULATION

The indicator employs a dynamic optimization algorithm to select the most effective moving average:
• Period Testing: Evaluates MA lengths from 5 to 100 periods to find the optimal timeframe
• Predictive Error: Measures each MA's accuracy by comparing it to the actual price 5 bars in the future
• Trend Weighting: Incorporates Rate of Change (ROC) to give higher priority to trend-following capabilities
• Error Minimization: Selects the MA length with the lowest weighted predictive error
• Smoothing: Applies an exponential smoothing factor (0.2) to prevent erratic changes in the trend line


🔶 DETAILS

Visual Features:
• Adaptive Trend Line: A yellow line representing the smoothed optimal moving average that dynamically adjusts its period
• Color-Coded Fills: Green areas when price is above the optimal MA (bullish), red when price is below (bearish)
• Opacity Gradient: Fill transparency provides visual context for the relationship between price and the trend line
• Real-Time Optimization Display: A table in the top-right corner shows the current optimal MA length

Interpretation:
• Bullish Signal: Price above the yellow DAMA line with green fill indicates upward momentum
• Bearish Signal: Price below the yellow DAMA line with red fill suggests downward pressure
• Trend Changes: Watch for crossovers between price and the DAMA for potential trend shifts
• Optimal Length Changes: Shorter optimal lengths may indicate trending markets, while longer lengths often appear in ranging conditions

🔶 EXAMPLES

The indicator demonstrates:
• Trend Identification: The DAMA hugs price more closely during trends while maintaining enough distance to filter noise
snapshot

• Dynamic Adaptation: The MA length automatically adjusts shorter during strong trends and longer during consolidations
snapshot

• Forward-Looking: By optimizing based on future price projection (5 bars), the indicator anticipates price movements better than traditional MAs

• Smooth Transitions: The smoothing algorithm prevents whipsaws while still allowing the MA to adapt to changing conditions

🔶 SETTINGS

Customization Options:
• Min/Max Length: Define the range of MA periods to test (default: 5-100)
• Step Size: Set the increment for testing different MA lengths (default: 1)
• Lookahead: Adjust the number of bars to project ahead for optimization (default: 5)
• Smoothing Factor: Control how quickly the MA adapts to new optimal lengths (default: 0.2)

The Dynamic Adaptive Moving Average (DAMA) indicator offers traders a sophisticated yet intuitive trend-following tool that eliminates the need to manually select MA periods.
Its self-optimizing algorithm continuously identifies the most effective moving average length based on actual price prediction accuracy, making it valuable for various trading strategies across different market environments and timeframes.

Aviso legal

As informações e publicações não devem ser e não constituem conselhos ou recomendações financeiras, de investimento, de negociação ou de qualquer outro tipo, fornecidas ou endossadas pela TradingView. Leia mais em Termos de uso.