OPEN-SOURCE SCRIPT
Diupdate AI SuperTrend Strength Forecasting Engine [TraderZen]

The question that matters most in real time: "How confident should I be in this setup right now?"
The ML Trend Strength Forecasting Engine was built to answer that question directly. Instead of drawing lines on a chart and leaving interpretation to the trader, it computes a numerical confidence score for every potential bull and bear setup as it forms. It evaluates the quality of the setup context, the strength of the trigger bar, the state of the broader market regime, and whether similar setups in the recent past actually worked. The output is a percentage — how likely is this signal to follow through.
The indicator does not generate buy or sell signals in the traditional sense. It provides a calibrated confidence reading that helps the trader decide whether to act, wait, or pass entirely.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Key Differences and Advantages
How It Works
The engine runs five interconnected layers, each feeding into a final confidence score.
Layer 1 — The Anchor Cluster
Seven moving averages are computed simultaneously: VWAP, VWMA, EMA, SMA, RMA, HMA, and the Donchian midpoint. These are grouped into four families:
The high, low, and midpoint of this entire cluster define where the market's center of gravity sits. A bullish candidate is detected when price crosses above the cluster midpoint from below. A bearish candidate is detected when price crosses below from above. The crossing is the trigger event. Everything else evaluates the quality of that cross.
Layer 2 — Context Scoring
Before the cross happens, the engine has been watching:
These components combine into a context score that answers: "Was the setup that led to this cross a good one?"
Context scoring is weighted — side positioning and slope carry the most influence, followed by compression and clearance, with duration and excursion providing secondary confirmation.
Layer 3 — Trigger Scoring
The crossing bar itself is evaluated for quality. A strong trigger bar:
Each dimension is scored and blended into a trigger score.
Layer 4 — Regime and Features
The broader environment is assessed through Kalman-filtered features: relative volume versus its baseline, relative ATR versus its baseline, ADX trend strength, and price distance from the trend moving average. These are smoothed to reduce noise while preserving directional shifts.
Volatility regime awareness scales key thresholds automatically. In low-volatility environments, the engine tightens its excursion and distance requirements. In high-volatility environments, it loosens them. This prevents the indicator from being too sensitive in calm markets and too restrictive in active ones.
Layer 5 — Adaptive Analog Memory (KNN)
This is the differentiator. Every time a candidate signal is generated, the engine stores its five feature values (context, trigger, volume, ADX, trend distance) along with what actually happened over the following evaluation window. Did price hold above the cluster? Did it expand meaningfully? The outcome is recorded as a success or failure.
When a new candidate appears, the engine searches its memory for the most similar historical setups using a k-nearest-neighbors algorithm. Key details:
The memory requires a warmup period. Until enough resolved candidates have been recorded, the engine relies solely on the base scoring.
Putting It Together
The final confidence score blends the base score (context, trigger, regime, trend alignment) with the KNN analog prediction. The result is displayed as a percentage for both the bull and bear side. When confidence exceeds the threshold and beats the opposite side by a directional edge, a signal label appears on the price chart.
If a signal later fails to hold or expand, a small rejection marker ("x") appears on the chart — providing direct visual accountability.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
How To Use It
Reading the Pane
The indicator occupies its own pane below the price chart. Five elements are displayed:
Reading the Chart Labels
Higher percentages indicate stronger setups. Every signal is eventually graded pass or fail.
Reading the Dashboard
The dashboard in the bottom-right corner shows:
The win rate is the most important dashboard metric. Above 60% = well-calibrated. Below 45% = thresholds may need adjustment.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Important Settings
Confidence Threshold (default: 65%)
The minimum confidence required for a signal label to appear. This is the primary sensitivity control. Lower = more signals with weaker setups. Higher = fewer, more selective signals.
Armed Threshold (default: 45%)
Minimum confidence for the ribbon to show an armed state (aqua/fuchsia). Acts as a pre-signal alert — when the ribbon transitions from watch to armed, a signal may be imminent.
Watch Threshold (default: 45%)
Minimum context score to enter watch mode (yellow/purple). Lower values start tracking setups earlier.
Directional Edge (default: 5.0)
Minimum gap between bull and bear confidence required for a signal. Prevents signals in ambiguous conditions where both sides score similarly.
Resolution Bars (default: 8)
How many bars after a signal the engine waits before grading it pass or fail. Shorter = more responsive grading. Longer = more forgiving.
Hold Outcome Ratio (default: 0.60)
Fraction of resolution bars price must stay on the correct side for a success grade. At 0.60 with 8 bars, price must hold for at least 5 of 8 bars.
Expansion Outcome Target (default: 1.00 ATR)
Minimum price expansion required for an alternative success grade. A signal can succeed by either holding position or expanding sufficiently.
Memory Decay Rate (default: 0.005)
How quickly older memory samples lose influence. Higher = more recency-biased. At default, recent samples carry roughly 2x the weight of samples from 140 bars ago.
History Size (default: 120)
Maximum resolved samples in analog memory. Larger = more context but more computation.
Session Settings
Configure to match the instrument's primary trading session. Default is 0930-1600 America/New_York (US equities and futures).
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
What This Indicator Is Not
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Disclaimer
This indicator is provided for educational and informational purposes only. It is not financial advice, and it does not constitute a recommendation to buy, sell, or hold any financial instrument.
All trading involves risk. Past performance of any signal, scoring system, or pattern recognition mechanism does not guarantee future results. The confidence percentages represent a statistical assessment based on the scoring model and historical analogs available within the loaded chart data. They are not predictions and should not be treated as certainties.
The adaptive analog memory learns from the chart data currently loaded in TradingView. Its effectiveness depends on having sufficient resolved samples, and its learned patterns may not generalize to future market conditions, different instruments, or different timeframes.
The win rate displayed in the dashboard reflects performance on the loaded chart history only and is subject to survivorship bias, lookback bias, and data limitations inherent to backtesting on historical bars.
No indicator, algorithm, or model can account for all market variables including liquidity events, news-driven gaps, exchange outages, or sudden regime changes. Traders should always use independent risk management, position sizing, and their own judgment before entering any trade.
By using this indicator, you acknowledge that you are solely responsible for your own trading decisions and that the authors accept no liability for any losses incurred.
The ML Trend Strength Forecasting Engine was built to answer that question directly. Instead of drawing lines on a chart and leaving interpretation to the trader, it computes a numerical confidence score for every potential bull and bear setup as it forms. It evaluates the quality of the setup context, the strength of the trigger bar, the state of the broader market regime, and whether similar setups in the recent past actually worked. The output is a percentage — how likely is this signal to follow through.
The indicator does not generate buy or sell signals in the traditional sense. It provides a calibrated confidence reading that helps the trader decide whether to act, wait, or pass entirely.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Key Differences and Advantages
- What KNN Predicts
Generally: "Will the trend direction be right?"
This Indicator: "Will this setup hold or expand?" - Training Labels
Generally: Past indicator directions (circular — predicting itself)
This Indicator: Actual price outcomes (self-validating — did the trade work?) - Signal Source
Generally: Single trend line or oscillator
This Indicator: 7-anchor cluster consensus (VWAP, VWMA, EMA, SMA, RMA, HMA, Donchian) - Features
Generally: RSI + MA deviation at multiple timeframes
This Indicator: Context + Trigger + Volume + ADX + Trend Distance — Kalman-filtered - Confidence Meaning
Generally: "How similar to past indicator wins"
This Indicator: "How likely to follow through based on setup quality + historical analogs" - Accountability
Generally: No rejection tracking, no performance feedback
This Indicator: Rejection markers on failed signals + live win rate dashboard - Adaptivity
Generally: Fixed normalization window, static thresholds
This Indicator: Adaptive ceilings, vol regime scaling, running stats, memory decay
How It Works
The engine runs five interconnected layers, each feeding into a final confidence score.
Layer 1 — The Anchor Cluster
Seven moving averages are computed simultaneously: VWAP, VWMA, EMA, SMA, RMA, HMA, and the Donchian midpoint. These are grouped into four families:
- Institutional — VWAP and VWMA
- Trend — EMA, SMA, RMA
- Fast — HMA
- Structural — Donchian midpoint
The high, low, and midpoint of this entire cluster define where the market's center of gravity sits. A bullish candidate is detected when price crosses above the cluster midpoint from below. A bearish candidate is detected when price crosses below from above. The crossing is the trigger event. Everything else evaluates the quality of that cross.
Layer 2 — Context Scoring
Before the cross happens, the engine has been watching:
- How long price spent on the other side (duration)
- How far it traveled away from the cluster (excursion)
- How tightly the anchors are compressed (compression)
- How much slope agreement exists across anchor families (coherence)
- Where price sits relative to the cluster edges (clearance)
These components combine into a context score that answers: "Was the setup that led to this cross a good one?"
Context scoring is weighted — side positioning and slope carry the most influence, followed by compression and clearance, with duration and excursion providing secondary confirmation.
Layer 3 — Trigger Scoring
The crossing bar itself is evaluated for quality. A strong trigger bar:
- Has a solid body (not a doji)
- Closes near the directional extreme (close near the high for bulls, near the low for bears)
- Shows force momentum aligned in the right direction
- Has meaningful distance from the cluster
- Represents a genuine cross rather than a wick touch
Each dimension is scored and blended into a trigger score.
Layer 4 — Regime and Features
The broader environment is assessed through Kalman-filtered features: relative volume versus its baseline, relative ATR versus its baseline, ADX trend strength, and price distance from the trend moving average. These are smoothed to reduce noise while preserving directional shifts.
Volatility regime awareness scales key thresholds automatically. In low-volatility environments, the engine tightens its excursion and distance requirements. In high-volatility environments, it loosens them. This prevents the indicator from being too sensitive in calm markets and too restrictive in active ones.
Layer 5 — Adaptive Analog Memory (KNN)
This is the differentiator. Every time a candidate signal is generated, the engine stores its five feature values (context, trigger, volume, ADX, trend distance) along with what actually happened over the following evaluation window. Did price hold above the cluster? Did it expand meaningfully? The outcome is recorded as a success or failure.
When a new candidate appears, the engine searches its memory for the most similar historical setups using a k-nearest-neighbors algorithm. Key details:
- Features are normalized to equal scales using running statistics
- Older samples receive exponentially decaying weights so the memory adapts as market behavior shifts
- The KNN prediction is blended with the base confidence score
- The memory learns and improves as it accumulates data on the specific instrument and timeframe
The memory requires a warmup period. Until enough resolved candidates have been recorded, the engine relies solely on the base scoring.
Putting It Together
The final confidence score blends the base score (context, trigger, regime, trend alignment) with the KNN analog prediction. The result is displayed as a percentage for both the bull and bear side. When confidence exceeds the threshold and beats the opposite side by a directional edge, a signal label appears on the price chart.
If a signal later fails to hold or expand, a small rejection marker ("x") appears on the chart — providing direct visual accountability.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
How To Use It
Reading the Pane
The indicator occupies its own pane below the price chart. Five elements are displayed:
- Ribbon (top bar) — shows current state by color:
Gray = idle, Yellow = watching bull, Purple = watching bear, Aqua = armed bull, Fuchsia = armed bear, Green = bull signal, Red = bear signal - Dominant confidence line (thicker) — tracks the higher of the two side scores. When it rises above the confidence threshold line, a signal is likely imminent.
- Bull and bear confidence lines (thinner) — show each side independently. Watching these diverge helps anticipate which direction will win.
- Bias line — oscillates around 50. Above 50 = bull dominant. Below 50 = bear dominant.
Reading the Chart Labels
- Green label with % — bull signal fired with confidence above threshold
- Red label with % — bear signal fired
- Dimmed green "x" — a bull signal was rejected (failed to hold or expand)
- Dimmed red "x" — a bear signal was rejected
Higher percentages indicate stronger setups. Every signal is eventually graded pass or fail.
Reading the Dashboard
The dashboard in the bottom-right corner shows:
- Bull and bear signal counts and win rates
- Memory status (warming up or active with sample counts)
- Current volatility regime (low, normal, or high)
- Session status and bar count
- Context and trigger score breakdown
- Family coherence percentage
- Force momentum direction
The win rate is the most important dashboard metric. Above 60% = well-calibrated. Below 45% = thresholds may need adjustment.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Important Settings
Confidence Threshold (default: 65%)
The minimum confidence required for a signal label to appear. This is the primary sensitivity control. Lower = more signals with weaker setups. Higher = fewer, more selective signals.
Armed Threshold (default: 45%)
Minimum confidence for the ribbon to show an armed state (aqua/fuchsia). Acts as a pre-signal alert — when the ribbon transitions from watch to armed, a signal may be imminent.
Watch Threshold (default: 45%)
Minimum context score to enter watch mode (yellow/purple). Lower values start tracking setups earlier.
Directional Edge (default: 5.0)
Minimum gap between bull and bear confidence required for a signal. Prevents signals in ambiguous conditions where both sides score similarly.
Resolution Bars (default: 8)
How many bars after a signal the engine waits before grading it pass or fail. Shorter = more responsive grading. Longer = more forgiving.
Hold Outcome Ratio (default: 0.60)
Fraction of resolution bars price must stay on the correct side for a success grade. At 0.60 with 8 bars, price must hold for at least 5 of 8 bars.
Expansion Outcome Target (default: 1.00 ATR)
Minimum price expansion required for an alternative success grade. A signal can succeed by either holding position or expanding sufficiently.
Memory Decay Rate (default: 0.005)
How quickly older memory samples lose influence. Higher = more recency-biased. At default, recent samples carry roughly 2x the weight of samples from 140 bars ago.
History Size (default: 120)
Maximum resolved samples in analog memory. Larger = more context but more computation.
Session Settings
Configure to match the instrument's primary trading session. Default is 0930-1600 America/New_York (US equities and futures).
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
What This Indicator Is Not
- It does not predict price direction. It evaluates setup quality and follow-through probability.
- It does not replace risk management. A 75% confidence signal can and will fail. The rejection markers exist to make this visible.
- It does not work equally on all instruments without adjustment. The adaptive mechanisms handle much of the calibration automatically, but the confidence threshold may need tuning. The dashboard win rate provides the feedback loop.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Disclaimer
This indicator is provided for educational and informational purposes only. It is not financial advice, and it does not constitute a recommendation to buy, sell, or hold any financial instrument.
All trading involves risk. Past performance of any signal, scoring system, or pattern recognition mechanism does not guarantee future results. The confidence percentages represent a statistical assessment based on the scoring model and historical analogs available within the loaded chart data. They are not predictions and should not be treated as certainties.
The adaptive analog memory learns from the chart data currently loaded in TradingView. Its effectiveness depends on having sufficient resolved samples, and its learned patterns may not generalize to future market conditions, different instruments, or different timeframes.
The win rate displayed in the dashboard reflects performance on the loaded chart history only and is subject to survivorship bias, lookback bias, and data limitations inherent to backtesting on historical bars.
No indicator, algorithm, or model can account for all market variables including liquidity events, news-driven gaps, exchange outages, or sudden regime changes. Traders should always use independent risk management, position sizing, and their own judgment before entering any trade.
By using this indicator, you acknowledge that you are solely responsible for your own trading decisions and that the authors accept no liability for any losses incurred.
Catatan Rilis
Updates Color fill for regime change.
Catatan Rilis
Update User can adjust the label font size.
Skrip open-source
Dengan semangat TradingView yang sesungguhnya, pembuat skrip ini telah menjadikannya sebagai sumber terbuka, sehingga para trader dapat meninjau dan memverifikasi fungsinya. Salut untuk penulisnya! Meskipun Anda dapat menggunakannya secara gratis, perlu diingat bahwa penerbitan ulang kode ini tunduk pada Tata Tertib kami.
Pernyataan Penyangkalan
Informasi dan publikasi ini tidak dimaksudkan, dan bukan merupakan, saran atau rekomendasi keuangan, investasi, trading, atau jenis lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Ketentuan Penggunaan.
Skrip open-source
Dengan semangat TradingView yang sesungguhnya, pembuat skrip ini telah menjadikannya sebagai sumber terbuka, sehingga para trader dapat meninjau dan memverifikasi fungsinya. Salut untuk penulisnya! Meskipun Anda dapat menggunakannya secara gratis, perlu diingat bahwa penerbitan ulang kode ini tunduk pada Tata Tertib kami.
Pernyataan Penyangkalan
Informasi dan publikasi ini tidak dimaksudkan, dan bukan merupakan, saran atau rekomendasi keuangan, investasi, trading, atau jenis lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Ketentuan Penggunaan.