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.
Open-source Skript
Ganz im Sinne von TradingView hat dieser Autor sein/ihr Script als Open-Source veröffentlicht. Auf diese Weise können nun auch andere Trader das Script rezensieren und die Funktionalität überprüfen. Vielen Dank an den Autor! Sie können das Script kostenlos verwenden, aber eine Wiederveröffentlichung des Codes unterliegt unseren Hausregeln.
🚨Get premium: algoalpha.io
🛜Get FREE signals: discord.gg/xCmqTVRexz
💡Tutorials: youtube.com/@AlgoAlpha
🛜Get FREE signals: discord.gg/xCmqTVRexz
💡Tutorials: youtube.com/@AlgoAlpha
Haftungsausschluss
Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.
Open-source Skript
Ganz im Sinne von TradingView hat dieser Autor sein/ihr Script als Open-Source veröffentlicht. Auf diese Weise können nun auch andere Trader das Script rezensieren und die Funktionalität überprüfen. Vielen Dank an den Autor! Sie können das Script kostenlos verwenden, aber eine Wiederveröffentlichung des Codes unterliegt unseren Hausregeln.
🚨Get premium: algoalpha.io
🛜Get FREE signals: discord.gg/xCmqTVRexz
💡Tutorials: youtube.com/@AlgoAlpha
🛜Get FREE signals: discord.gg/xCmqTVRexz
💡Tutorials: youtube.com/@AlgoAlpha
Haftungsausschluss
Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.