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.
Script de código aberto
Em verdadeiro espírito do TradingView, o criador deste script o tornou de código aberto, para que os traders possam revisar e verificar sua funcionalidade. Parabéns ao autor! Embora você possa usá-lo gratuitamente, lembre-se de que a republicação do código está sujeita às nossas Regras da Casa.
Aviso legal
As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.
Script de código aberto
Em verdadeiro espírito do TradingView, o criador deste script o tornou de código aberto, para que os traders possam revisar e verificar sua funcionalidade. Parabéns ao autor! Embora você possa usá-lo gratuitamente, lembre-se de que a republicação do código está sujeita às nossas Regras da Casa.
Aviso legal
As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.