OPEN-SOURCE SCRIPT
AI-Enhanced MSS Hunter

AI-Enhanced MSS Hunter [Kill Zones & Golden Zone]
This indicator is a hybrid trading system that merges Mechanical Price Action (ICT Concepts) with Statistical Machine Learning (K-Nearest Neighbors). It is designed to assist traders in identifying high-probability reversals after liquidity sweeps, as well as trend-continuation entries during specific "Kill Zone" sessions.
How It Works
The script operates on a strict 3-step validation process to filter out false signals during choppy market conditions.
1. Liquidity Sweep (The Trigger) The system automatically plots the Previous Day High (PDH) and Previous Day Low (PDL).
The logic begins only when price "sweeps" (breaks) one of these key levels.
State Persistence: Once a level is swept, the system remembers this event for the remainder of the session (or until a signal fires), waiting for the market to reverse.
2. Market Structure Shift (The Setup) After a sweep, the indicator hunts for a Market Structure Shift (MSS).
It tracks dynamic Swing Highs and Swing Lows.
A signal is prepared only if price breaks a recent structural swing point in the opposite direction of the sweep (e.g., Sweep PDL -> Break Swing High).
3. AI / Machine Learning Filter (The Confirmation) To reduce false positives, the signal must be confirmed by a K-Nearest Neighbors (KNN) algorithm.
The Logic: The script analyzes the current values of RSI (14), CCI (14), and ROC (10).
The Comparison: It looks back at the last ~1,000 bars of history to find similar market conditions (neighbors).
The Prediction: If the majority of those historical "neighbors" resulted in a favorable move, the AI confirms the trade. If historical data suggests chop or reversal, the signal is blocked.
Key Features
🎯 Primary Reversal Signals (Circles)
Green Circle: Price swept PDL + Bullish MSS + AI Confirmation.
Red Circle: Price swept PDH + Bearish MSS + AI Confirmation.
♻️ Golden Zone Re-Entries (Triangles) Once a Primary Signal is active, the script tracks the new trend leg.
It automatically draws a dynamic Golden Zone (0.5 – 0.618 Fibonacci Retracement).
If price pulls back into this zone and forms a new MSS, a Re-Entry Triangle is plotted.
Invalidation: If the pullback breaks the original setup's low/high, the zone is removed to prevent bad trades.
⏰ Kill Zone Time Filters Signals are filtered by time to ensure you are trading during high-volume sessions.
Default AM Session: 08:30 – 10:00 (New York Time)
Default PM Session: 14:00 – 15:00 (New York Time)
Fully customizable in settings.
Settings Guide
Key Levels: Toggle PDH/PDL lines and customize colors.
Kill Zones: Enable/Disable time filtering and highlight background colors.
AI Settings:
K-Nearest Neighbors (k): Number of historical neighbors to compare (Default: 5).
Training Window: How far back the AI looks for patterns (Default: 1000 bars).
Visuals: Turn on/off the Golden Zone fib clouds or text labels.
Disclaimer
This tool is for educational purposes only. The "AI" component is a statistical classification algorithm based on historical momentum and does not guarantee future results. Always manage risk and use this indicator as part of a comprehensive trading plan.
This indicator is a hybrid trading system that merges Mechanical Price Action (ICT Concepts) with Statistical Machine Learning (K-Nearest Neighbors). It is designed to assist traders in identifying high-probability reversals after liquidity sweeps, as well as trend-continuation entries during specific "Kill Zone" sessions.
How It Works
The script operates on a strict 3-step validation process to filter out false signals during choppy market conditions.
1. Liquidity Sweep (The Trigger) The system automatically plots the Previous Day High (PDH) and Previous Day Low (PDL).
The logic begins only when price "sweeps" (breaks) one of these key levels.
State Persistence: Once a level is swept, the system remembers this event for the remainder of the session (or until a signal fires), waiting for the market to reverse.
2. Market Structure Shift (The Setup) After a sweep, the indicator hunts for a Market Structure Shift (MSS).
It tracks dynamic Swing Highs and Swing Lows.
A signal is prepared only if price breaks a recent structural swing point in the opposite direction of the sweep (e.g., Sweep PDL -> Break Swing High).
3. AI / Machine Learning Filter (The Confirmation) To reduce false positives, the signal must be confirmed by a K-Nearest Neighbors (KNN) algorithm.
The Logic: The script analyzes the current values of RSI (14), CCI (14), and ROC (10).
The Comparison: It looks back at the last ~1,000 bars of history to find similar market conditions (neighbors).
The Prediction: If the majority of those historical "neighbors" resulted in a favorable move, the AI confirms the trade. If historical data suggests chop or reversal, the signal is blocked.
Key Features
🎯 Primary Reversal Signals (Circles)
Green Circle: Price swept PDL + Bullish MSS + AI Confirmation.
Red Circle: Price swept PDH + Bearish MSS + AI Confirmation.
♻️ Golden Zone Re-Entries (Triangles) Once a Primary Signal is active, the script tracks the new trend leg.
It automatically draws a dynamic Golden Zone (0.5 – 0.618 Fibonacci Retracement).
If price pulls back into this zone and forms a new MSS, a Re-Entry Triangle is plotted.
Invalidation: If the pullback breaks the original setup's low/high, the zone is removed to prevent bad trades.
⏰ Kill Zone Time Filters Signals are filtered by time to ensure you are trading during high-volume sessions.
Default AM Session: 08:30 – 10:00 (New York Time)
Default PM Session: 14:00 – 15:00 (New York Time)
Fully customizable in settings.
Settings Guide
Key Levels: Toggle PDH/PDL lines and customize colors.
Kill Zones: Enable/Disable time filtering and highlight background colors.
AI Settings:
K-Nearest Neighbors (k): Number of historical neighbors to compare (Default: 5).
Training Window: How far back the AI looks for patterns (Default: 1000 bars).
Visuals: Turn on/off the Golden Zone fib clouds or text labels.
Disclaimer
This tool is for educational purposes only. The "AI" component is a statistical classification algorithm based on historical momentum and does not guarantee future results. Always manage risk and use this indicator as part of a comprehensive trading plan.
สคริปต์โอเพนซอร์ซ
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน
สคริปต์โอเพนซอร์ซ
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน