OPEN-SOURCE SCRIPT
Quantum Pulse AI

High-Level Overview
This script is a hybrid trading system that combines traditional trend-following indicators with a k-Nearest Neighbors (k-NN) Machine Learning engine. Instead of relying solely on hardcoded crossovers, it looks at the current market conditions, searches its historical memory for similar moments, and predicts the next move based on what happened in the past.
1. The Technical Foundation (Base Features)
Before the AI even kicks in, the script tracks a robust baseline of institutional-grade metrics:
Moving Averages: Two customizable MAs (SMA/EMA/VWMA) determine short-term momentum.
VWAP & Bands: Anchored daily VWAP with up to 3 standard deviation bands to judge institutional value and overbought/oversold extremes.
Trend Smoothing: Hull Moving Average (HMA) and Supertrend dictate the broader directional bias.
Momentum Filters: ADX ensures the market is actually trending (ignoring chop), while relative volume tracks participation.
2. The AI k-NN Classification Engine
This is the "brain" of the script. It uses a mathematical algorithm to predict price direction based on Euclidean geometry.
Feature Vectors: It takes 4 real-time data points (MA spread, Price vs. VWAP, HMA slope, and Relative Volume) and normalizes them into a 4-dimensional spatial grid.
Historical Scanning: The script looks back in time (e.g., 2,000 bars) and calculates the exact geometric distance between the current market conditions and historical market conditions.
Voting System: It isolates the k closest historical matches (e.g., the 8 most similar moments in the past). It then looks at what price actually did next in those historical moments (went up or went down). Those neighbors "vote" on the current probability, generating a Bull/Bear Confidence Percentage.
3. Signal Filtering & State Tracking (Anti-Flicker)
The script includes strict logic to prevent chart clutter and false signals:
Convergence: A signal will only fire if the AI probability is above your defined threshold (e.g., 70%), the ADX shows a strong trend, and price is structurally on the correct side of the VWAP.
State Tracker: A built-in memory state (currentTradeState) forces strict alternation. Once an "AI BUY" fires, the system locks into a Long state. It will ignore any duplicate bullish spikes and will only fire again when an "AI SELL" conditions are met.
4. Dashboards & UI
Core Dashboard: A bottom-center panel that gives a rapid visual summary of all traditional metrics (Price, VWAP, MA, HMA, ST, ADX, Volume).
ML Ensemble Panel: A top-right heads-up display showing the AI's exact live confidence percentages, its grading scale (A+, A, B, C), and the current active forecast.
Day Trading Extras: Automatically plots Previous Day High/Low/Close, daily Pivot points, Support/Resistance levels, and the critical First 15-Minute High/Low breakout zones.
This script is a hybrid trading system that combines traditional trend-following indicators with a k-Nearest Neighbors (k-NN) Machine Learning engine. Instead of relying solely on hardcoded crossovers, it looks at the current market conditions, searches its historical memory for similar moments, and predicts the next move based on what happened in the past.
1. The Technical Foundation (Base Features)
Before the AI even kicks in, the script tracks a robust baseline of institutional-grade metrics:
Moving Averages: Two customizable MAs (SMA/EMA/VWMA) determine short-term momentum.
VWAP & Bands: Anchored daily VWAP with up to 3 standard deviation bands to judge institutional value and overbought/oversold extremes.
Trend Smoothing: Hull Moving Average (HMA) and Supertrend dictate the broader directional bias.
Momentum Filters: ADX ensures the market is actually trending (ignoring chop), while relative volume tracks participation.
2. The AI k-NN Classification Engine
This is the "brain" of the script. It uses a mathematical algorithm to predict price direction based on Euclidean geometry.
Feature Vectors: It takes 4 real-time data points (MA spread, Price vs. VWAP, HMA slope, and Relative Volume) and normalizes them into a 4-dimensional spatial grid.
Historical Scanning: The script looks back in time (e.g., 2,000 bars) and calculates the exact geometric distance between the current market conditions and historical market conditions.
Voting System: It isolates the k closest historical matches (e.g., the 8 most similar moments in the past). It then looks at what price actually did next in those historical moments (went up or went down). Those neighbors "vote" on the current probability, generating a Bull/Bear Confidence Percentage.
3. Signal Filtering & State Tracking (Anti-Flicker)
The script includes strict logic to prevent chart clutter and false signals:
Convergence: A signal will only fire if the AI probability is above your defined threshold (e.g., 70%), the ADX shows a strong trend, and price is structurally on the correct side of the VWAP.
State Tracker: A built-in memory state (currentTradeState) forces strict alternation. Once an "AI BUY" fires, the system locks into a Long state. It will ignore any duplicate bullish spikes and will only fire again when an "AI SELL" conditions are met.
4. Dashboards & UI
Core Dashboard: A bottom-center panel that gives a rapid visual summary of all traditional metrics (Price, VWAP, MA, HMA, ST, ADX, Volume).
ML Ensemble Panel: A top-right heads-up display showing the AI's exact live confidence percentages, its grading scale (A+, A, B, C), and the current active forecast.
Day Trading Extras: Automatically plots Previous Day High/Low/Close, daily Pivot points, Support/Resistance levels, and the critical First 15-Minute High/Low breakout zones.
Скрипт с открытым кодом
В истинном духе TradingView, создатель этого скрипта сделал его открытым исходным кодом, чтобы трейдеры могли проверить и убедиться в его функциональности. Браво автору! Вы можете использовать его бесплатно, но помните, что перепубликация кода подчиняется нашим Правилам поведения.
Отказ от ответственности
Информация и публикации не предназначены для предоставления и не являются финансовыми, инвестиционными, торговыми или другими видами советов или рекомендаций, предоставленных или одобренных TradingView. Подробнее читайте в Условиях использования.
Скрипт с открытым кодом
В истинном духе TradingView, создатель этого скрипта сделал его открытым исходным кодом, чтобы трейдеры могли проверить и убедиться в его функциональности. Браво автору! Вы можете использовать его бесплатно, но помните, что перепубликация кода подчиняется нашим Правилам поведения.
Отказ от ответственности
Информация и публикации не предназначены для предоставления и не являются финансовыми, инвестиционными, торговыми или другими видами советов или рекомендаций, предоставленных или одобренных TradingView. Подробнее читайте в Условиях использования.