PROTECTED SOURCE SCRIPT
MACD + 200 EMA + Chandelier + ML Optimizer

Neural MACD Trend Strategy [ML + Chandelier + ADX]
This script modernizes a classic high-probability trend strategy by integrating Machine Learning and dynamic risk management. It is built on the foundation of the 9, 21, and 200 EMAs with MACD execution, designed to automate the workflow of trend traders.
Key Features:
1. Core Logic: Trades are executed on MACD crosses, but only when aligned with the long-term trend (200 EMA). An optional setting enforces a simultaneous 9/21 EMA cross for high-momentum confirmation.
2. Machine Learning Optimizer: A K-Nearest Neighbors (KNN) algorithm runs in the background, analyzing RSI, CCI, and ROC. It compares the current setup to the last 1,000 bars of history; if the historical probability is negative, the ML blocks the trade to save capital.
3. Range Filter: Uses ADX to detect choppy markets. If the market is ranging (ADX < 20), the background turns gray and trading is paused.
4. Advanced Exits: Automatically calculates Stop Losses based on recent Swing Highs/Lows. Includes a Chandelier Exit (ATR Trailing Stop) to lock in profits dynamically. You can choose between fixed Reward-to-Risk targets (e.g., 1.5x) or disable targets to ride the trend until the trailing stop is hit.
This script modernizes a classic high-probability trend strategy by integrating Machine Learning and dynamic risk management. It is built on the foundation of the 9, 21, and 200 EMAs with MACD execution, designed to automate the workflow of trend traders.
Key Features:
1. Core Logic: Trades are executed on MACD crosses, but only when aligned with the long-term trend (200 EMA). An optional setting enforces a simultaneous 9/21 EMA cross for high-momentum confirmation.
2. Machine Learning Optimizer: A K-Nearest Neighbors (KNN) algorithm runs in the background, analyzing RSI, CCI, and ROC. It compares the current setup to the last 1,000 bars of history; if the historical probability is negative, the ML blocks the trade to save capital.
3. Range Filter: Uses ADX to detect choppy markets. If the market is ranging (ADX < 20), the background turns gray and trading is paused.
4. Advanced Exits: Automatically calculates Stop Losses based on recent Swing Highs/Lows. Includes a Chandelier Exit (ATR Trailing Stop) to lock in profits dynamically. You can choose between fixed Reward-to-Risk targets (e.g., 1.5x) or disable targets to ride the trend until the trailing stop is hit.
نص برمجي محمي
تم نشر هذا النص البرمجي كمصدر مغلق. ومع ذلك، يمكنك استخدامه بحرية ودون أي قيود - تعرف على المزيد هنا.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.
نص برمجي محمي
تم نشر هذا النص البرمجي كمصدر مغلق. ومع ذلك، يمكنك استخدامه بحرية ودون أي قيود - تعرف على المزيد هنا.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.