OPEN-SOURCE SCRIPT
Machine Learning Adaptive DMI Signals [AlgoAlpha]

🟠 OVERVIEW
The Directional Movement Index (DMI) is commonly calculated using a fixed lookback length. But market conditions change over time, and a length that works well during one period may become less effective during another.
This script builds multiple DMI models across a user-defined range of lengths and continuously evaluates their past performance. Each DMI length acts as an independent expert. As new directional flips occur, the script measures how well each expert performed and updates its internal scoring system.
The result is an adaptive DMI that automatically shifts toward lengths that have recently produced better directional signals while reducing the influence of weaker performers.
🟠 CONCEPTS
🟠 FEATURES
🟠 HOW TO USE
🟠 CONCLUSION
Machine Learning Adaptive DMI [AlgoAlpha] combines traditional DMI calculations with a performance-driven adaptive length selection process. Instead of relying on a fixed lookback period, it continuously evaluates how different DMI lengths have behaved and adjusts accordingly. This provides a dynamic view of directional strength, trend bias, and signal quality that reflects recent market behavior.
The Directional Movement Index (DMI) is commonly calculated using a fixed lookback length. But market conditions change over time, and a length that works well during one period may become less effective during another.
This script builds multiple DMI models across a user-defined range of lengths and continuously evaluates their past performance. Each DMI length acts as an independent expert. As new directional flips occur, the script measures how well each expert performed and updates its internal scoring system.
The result is an adaptive DMI that automatically shifts toward lengths that have recently produced better directional signals while reducing the influence of weaker performers.
🟠 CONCEPTS
- Expert DMI — A DMI calculation running at a specific lookback length within the tested range.
- Directional Flip — A change in trend state when +DI crosses above -DI or when -DI crosses above +DI.
- Reward Score — A performance score assigned to each completed flip based on return, move quality, pullback behavior, or win rate.
- Maximum Favorable Excursion (MFE) — The largest move in the trade's favor before the next directional flip.
- Maximum Adverse Excursion (MAE) — The largest move against the trade before the next directional flip.
- Recency Decay — A weighting system that gradually reduces the influence of older observations so recent market behavior has greater impact.
- Softmax Weighting — A probability-style weighting process that gives greater influence to higher-scoring DMI lengths when estimating the adaptive length.
🟠 FEATURES
- Adaptive +DI and -DI Lines — Displays directional movement using a dynamically selected DMI length that adjusts over time.
- Directional Clouds — Color-filled regions between the DI lines help visualize which side currently has directional control.
- Bullish and Bearish Flip Signals — ▲ and ▼ markers appear when the Adaptive +DI and -DI lines cross.
- ADX Strength Display — Strength squares at the bottom of the pane become more visible as trend strength increases and fade as strength decreases.
- Information Table — Displays the active adaptive length, selected scoring mode, memory count, and current bullish or bearish trend state in a customizable table.
🟠 HOW TO USE
- Watch for bullish flips when Adaptive +DI crosses above Adaptive -DI to identify potential shifts toward upward directional control.
- Watch for bearish flips when Adaptive -DI crosses above Adaptive +DI to identify potential shifts toward downward directional control.
- Use the ADX strength squares to gauge whether directional movement is strengthening or weakening.
- Increase the tested length range when evaluating a wider variety of market conditions.
- Increase Memory and Forget Old Trades values for more stable adaptation and slower length changes.
- Decrease Memory or lower the decay factor when faster adaptation to recent behavior is preferred.
- Experiment with the available scoring methods to determine whether return, trend quality, or consistency is more important for your analysis.
🟠 CONCLUSION
Machine Learning Adaptive DMI [AlgoAlpha] combines traditional DMI calculations with a performance-driven adaptive length selection process. Instead of relying on a fixed lookback period, it continuously evaluates how different DMI lengths have behaved and adjusts accordingly. This provides a dynamic view of directional strength, trend bias, and signal quality that reflects recent market behavior.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
🚨Get premium: algoalpha.io
🛜Get FREE signals: discord.gg/xCmqTVRexz
💡Tutorials: youtube.com/@AlgoAlpha
🛜Get FREE signals: discord.gg/xCmqTVRexz
💡Tutorials: youtube.com/@AlgoAlpha
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.
오픈 소스 스크립트
트레이딩뷰의 진정한 정신에 따라, 이 스크립트의 작성자는 이를 오픈소스로 공개하여 트레이더들이 기능을 검토하고 검증할 수 있도록 했습니다. 작성자에게 찬사를 보냅니다! 이 코드는 무료로 사용할 수 있지만, 코드를 재게시하는 경우 하우스 룰이 적용된다는 점을 기억하세요.
🚨Get premium: algoalpha.io
🛜Get FREE signals: discord.gg/xCmqTVRexz
💡Tutorials: youtube.com/@AlgoAlpha
🛜Get FREE signals: discord.gg/xCmqTVRexz
💡Tutorials: youtube.com/@AlgoAlpha
면책사항
해당 정보와 게시물은 금융, 투자, 트레이딩 또는 기타 유형의 조언이나 권장 사항으로 간주되지 않으며, 트레이딩뷰에서 제공하거나 보증하는 것이 아닙니다. 자세한 내용은 이용 약관을 참조하세요.