OPEN-SOURCE SCRIPT
SuperTrend Engine [Quantum Algo]

SuperTrend Engine [Quantum Algo]
====================================================
🔶 OVERVIEW
SuperTrend Engine is a volatility-adaptive SuperTrend indicator built on one idea: every SuperTrend gives you signals — this one shows you the whipsaws it saved you from, tells you its real win rate on your chart, and admits when it is wrong.
The engine self-tunes its factor with a fully transparent formula, confirms flips through a Whipsaw Shield that absorbs fake-outs and marks every one it absorbed, stamps every buy and sell flip with its live, honestly-computed win rate on the current symbol, settles every marker into its real outcome ten bars later, and draws the trade geometry — entry, trailing stop, one-R and two-R references — the moment a flip confirms.
🔶 WHAT IS A SUPERTREND?
A SuperTrend is a trailing stop built from the Average True Range: a band placed a volatility-scaled distance from price that ratchets in the trend's favor and never retreats. While price holds above the band, the trend is up and the band trails below as a stop; a close through the band flips the state. It is one of the most followed trend-following tools in retail trading — and its famous weakness is the whipsaw: sideways markets flip it back and forth, and a fixed factor that survives chop is too slow in trends. This engine is built specifically against that weakness.
🔶 WHY THIS SCRIPT IS ORIGINAL
1. The Whipsaw Shield — visible absorbed fake-outs. A flip only confirms when the close clears the opposite band by a volatility margin. When the raw trail flips and reverses before clearing it, the engine holds its direction and prints a small ghost marker where the whipsaw died, with a running Whipsaws Shielded counter in the dashboard. Other tools try to reduce whipsaws quietly; to our knowledge, none renders the failures it absorbed. Here the evidence is on the chart.
2. Honest per-symbol flip statistics. Every flip is stamped with its live win rate on this exact symbol and timeframe — shrinkage-adjusted so thin history cannot show fake confidence, with a Wilson confidence bound and sample count in the hover tooltip. The indicator audits itself in public instead of asserting signals.
3. Markers that settle into their outcome. Each buy and sell marker resolves ten bars later: the trend color if the flip delivered, faded gray if it failed. Scroll any chart and read the engine's true track record directly off the markers — including the losses.
4. Transparent adaptation, not a black box. The factor self-tunes between your two bounds using Perry Kaufman's Efficiency Ratio — tight when price moves cleanly, wide in chop — and the dashboard shows the live factor and efficiency reading every bar. The adaptation can be verified with a calculator; nothing asks for trust.
5. A trade plan, not just a line. On every confirmed flip the engine draws the entry, the trailing stop, and one-R and two-R reference levels, and the dashboard tracks the open signal's running R-multiple live.
6. A breathing chart. The glow between price and trail intensifies with trend distance and fades as price returns to the stop, grade-A flips (volume, efficiency, and a decisive break together) print in the accent color, and the whole layer stays capped and clean.
🔶 HOW IT WORKS
Adaptive trail: Classic ratcheting SuperTrend bands are computed from the Average True Range, with the factor interpolated between the trend bound and the chop bound by the Efficiency Ratio — the ratio of net price movement to total path length over the lookback.
Whipsaw Shield: The raw band flip is treated as a candidate, not a signal. Only a close beyond the opposite band plus the margin confirms the flip; a raw flip that reverses first is counted, marked as a ghost, and absorbed.
Statistics: Each confirmed flip records what price did ten and thirty bars later, in the flip's direction, into capped first-in-first-out databases. Win rates are pulled toward fifty percent by pseudo-samples and carry Wilson lower bounds. Until the minimum sample is met, markers read "collecting history" instead of inventing a number.
Outcome settlement: Every marker stores its flip price and recolors by the realized ten-bar outcome, then joins the capped history.
Grading: Volume z-score, efficiency level, and break decisiveness combine into an A, B, C grade on every flip.
Non-repainting: Flips, shields, grades, statistics, and settlement are all evaluated on closed bars. Once printed, nothing moves.
🔶 HOW TO USE IT
1. Works on any market — cryptocurrency, forex, gold, indices, stocks, futures — and any timeframe. Trending instruments suit tighter trend bounds; choppy ones benefit from a wider chop bound and a larger shield margin.
2. Treat the flip as regime information and the trail as the stop: the line is the invalidation, and the one-R and two-R references scale targets to the risk the stop defines.
3. Read the ghost markers as the tool working: a cluster of × marks in a range is the chop a fixed-factor SuperTrend would have traded.
4. Judge fresh flips against the settled history and the statistics rows — a symbol whose markers keep settling gray is telling you trend-following struggles there, and that is information worth having before the next flip.
5. Use the grade for position confidence: an A-grade flip with volume, high efficiency, and a decisive break is a different event from a drift-through.
6. Watch the live factor and efficiency in the dashboard to see the adaptation reasoning in real time.
🔶 SETTINGS
- Adaptive trail: Average True Range length, factor in strong trend, factor in chop, Efficiency Ratio length.
- Whipsaw Shield: flip margin and ghost marker toggle.
- Statistics: sample cap, minimum samples to grade, shrinkage strength, Wilson z-score, markers to keep.
- Trade plan toggle and plans to keep.
- Visuals: all colors, glow fill, candle tinting.
- Themeable dashboard: position, four text sizes, title band, background, frame, grid, and three text colors.
🔶 ALERTS
- Buy Flip / Sell Flip — the adaptive trail flipped with the confirmation margin cleared.
- Whipsaw Shielded — a raw flip reversed before confirming; the engine held its direction.
- Grade A Flip — full quality confluence: volume, efficiency, and a decisive break.
🔶 FREQUENTLY ASKED QUESTIONS
Does the indicator repaint? No. Every flip, shield event, grade, statistic, and marker settlement is evaluated at bar close. Once printed, nothing moves.
How is this different from other adaptive or machine-learning SuperTrends? Adaptation itself is not the claim — several tools adapt the factor. The differences are transparency and honesty: the adaptation here is one verifiable formula shown live on the dashboard, the whipsaws it absorbs are rendered instead of hidden, every signal carries its real statistics with confidence bounds, and every marker settles into its true outcome.
What does a ghost × marker mean? The raw SuperTrend flipped there and reversed before clearing the confirmation margin. The engine held its direction and counted the whipsaw it absorbed.
Why does a marker turn gray? The flip failed: ten bars later, price had not moved in its direction. Gray markers are the audit trail working — an honest tool must be able to show its losses.
Why do the win rates hover near fifty percent on some symbols? Because that is the truth of trend-flip performance there. The shrinkage and confidence bounds are designed to display small honest numbers rather than large misleading ones.
🔶 CREDITS
The SuperTrend trailing stop was created by Olivier Seban; the Average True Range is by J. Welles Wilder Jr. (1978); the Efficiency Ratio is by Perry J. Kaufman; the Wilson score interval is by Edwin B. Wilson (1927). This script gratefully acknowledges all four. The Whipsaw Shield, the transparent adaptive-factor design, the per-symbol statistical engine, the outcome-settling markers, the trade plan layer, and all code in this script are original work — no third-party or open-source script code was reused.
🔶 LIMITATIONS
Trend-following flips underperform by nature in prolonged ranges; the shield reduces but cannot eliminate that cost, and shielded entries confirm slightly later than raw ones — the margin trades earliness for reliability. Statistics need history to mature and are honest about being thin early. Volume grading is less meaningful on symbols with unreliable volume reporting. No indicator replaces independent analysis.
🔶 DISCLAIMER
This script is provided strictly for educational and informational purposes. It is not financial advice, an investment recommendation, or a solicitation to buy or sell any financial instrument. Past behavior of any flip, statistic, or grade does not guarantee future results. Trading involves substantial risk. Always do your own research and manage risk independently.
====================================================
🔶 OVERVIEW
SuperTrend Engine is a volatility-adaptive SuperTrend indicator built on one idea: every SuperTrend gives you signals — this one shows you the whipsaws it saved you from, tells you its real win rate on your chart, and admits when it is wrong.
The engine self-tunes its factor with a fully transparent formula, confirms flips through a Whipsaw Shield that absorbs fake-outs and marks every one it absorbed, stamps every buy and sell flip with its live, honestly-computed win rate on the current symbol, settles every marker into its real outcome ten bars later, and draws the trade geometry — entry, trailing stop, one-R and two-R references — the moment a flip confirms.
🔶 WHAT IS A SUPERTREND?
A SuperTrend is a trailing stop built from the Average True Range: a band placed a volatility-scaled distance from price that ratchets in the trend's favor and never retreats. While price holds above the band, the trend is up and the band trails below as a stop; a close through the band flips the state. It is one of the most followed trend-following tools in retail trading — and its famous weakness is the whipsaw: sideways markets flip it back and forth, and a fixed factor that survives chop is too slow in trends. This engine is built specifically against that weakness.
🔶 WHY THIS SCRIPT IS ORIGINAL
1. The Whipsaw Shield — visible absorbed fake-outs. A flip only confirms when the close clears the opposite band by a volatility margin. When the raw trail flips and reverses before clearing it, the engine holds its direction and prints a small ghost marker where the whipsaw died, with a running Whipsaws Shielded counter in the dashboard. Other tools try to reduce whipsaws quietly; to our knowledge, none renders the failures it absorbed. Here the evidence is on the chart.
2. Honest per-symbol flip statistics. Every flip is stamped with its live win rate on this exact symbol and timeframe — shrinkage-adjusted so thin history cannot show fake confidence, with a Wilson confidence bound and sample count in the hover tooltip. The indicator audits itself in public instead of asserting signals.
3. Markers that settle into their outcome. Each buy and sell marker resolves ten bars later: the trend color if the flip delivered, faded gray if it failed. Scroll any chart and read the engine's true track record directly off the markers — including the losses.
4. Transparent adaptation, not a black box. The factor self-tunes between your two bounds using Perry Kaufman's Efficiency Ratio — tight when price moves cleanly, wide in chop — and the dashboard shows the live factor and efficiency reading every bar. The adaptation can be verified with a calculator; nothing asks for trust.
5. A trade plan, not just a line. On every confirmed flip the engine draws the entry, the trailing stop, and one-R and two-R reference levels, and the dashboard tracks the open signal's running R-multiple live.
6. A breathing chart. The glow between price and trail intensifies with trend distance and fades as price returns to the stop, grade-A flips (volume, efficiency, and a decisive break together) print in the accent color, and the whole layer stays capped and clean.
🔶 HOW IT WORKS
Adaptive trail: Classic ratcheting SuperTrend bands are computed from the Average True Range, with the factor interpolated between the trend bound and the chop bound by the Efficiency Ratio — the ratio of net price movement to total path length over the lookback.
Whipsaw Shield: The raw band flip is treated as a candidate, not a signal. Only a close beyond the opposite band plus the margin confirms the flip; a raw flip that reverses first is counted, marked as a ghost, and absorbed.
Statistics: Each confirmed flip records what price did ten and thirty bars later, in the flip's direction, into capped first-in-first-out databases. Win rates are pulled toward fifty percent by pseudo-samples and carry Wilson lower bounds. Until the minimum sample is met, markers read "collecting history" instead of inventing a number.
Outcome settlement: Every marker stores its flip price and recolors by the realized ten-bar outcome, then joins the capped history.
Grading: Volume z-score, efficiency level, and break decisiveness combine into an A, B, C grade on every flip.
Non-repainting: Flips, shields, grades, statistics, and settlement are all evaluated on closed bars. Once printed, nothing moves.
🔶 HOW TO USE IT
1. Works on any market — cryptocurrency, forex, gold, indices, stocks, futures — and any timeframe. Trending instruments suit tighter trend bounds; choppy ones benefit from a wider chop bound and a larger shield margin.
2. Treat the flip as regime information and the trail as the stop: the line is the invalidation, and the one-R and two-R references scale targets to the risk the stop defines.
3. Read the ghost markers as the tool working: a cluster of × marks in a range is the chop a fixed-factor SuperTrend would have traded.
4. Judge fresh flips against the settled history and the statistics rows — a symbol whose markers keep settling gray is telling you trend-following struggles there, and that is information worth having before the next flip.
5. Use the grade for position confidence: an A-grade flip with volume, high efficiency, and a decisive break is a different event from a drift-through.
6. Watch the live factor and efficiency in the dashboard to see the adaptation reasoning in real time.
🔶 SETTINGS
- Adaptive trail: Average True Range length, factor in strong trend, factor in chop, Efficiency Ratio length.
- Whipsaw Shield: flip margin and ghost marker toggle.
- Statistics: sample cap, minimum samples to grade, shrinkage strength, Wilson z-score, markers to keep.
- Trade plan toggle and plans to keep.
- Visuals: all colors, glow fill, candle tinting.
- Themeable dashboard: position, four text sizes, title band, background, frame, grid, and three text colors.
🔶 ALERTS
- Buy Flip / Sell Flip — the adaptive trail flipped with the confirmation margin cleared.
- Whipsaw Shielded — a raw flip reversed before confirming; the engine held its direction.
- Grade A Flip — full quality confluence: volume, efficiency, and a decisive break.
🔶 FREQUENTLY ASKED QUESTIONS
Does the indicator repaint? No. Every flip, shield event, grade, statistic, and marker settlement is evaluated at bar close. Once printed, nothing moves.
How is this different from other adaptive or machine-learning SuperTrends? Adaptation itself is not the claim — several tools adapt the factor. The differences are transparency and honesty: the adaptation here is one verifiable formula shown live on the dashboard, the whipsaws it absorbs are rendered instead of hidden, every signal carries its real statistics with confidence bounds, and every marker settles into its true outcome.
What does a ghost × marker mean? The raw SuperTrend flipped there and reversed before clearing the confirmation margin. The engine held its direction and counted the whipsaw it absorbed.
Why does a marker turn gray? The flip failed: ten bars later, price had not moved in its direction. Gray markers are the audit trail working — an honest tool must be able to show its losses.
Why do the win rates hover near fifty percent on some symbols? Because that is the truth of trend-flip performance there. The shrinkage and confidence bounds are designed to display small honest numbers rather than large misleading ones.
🔶 CREDITS
The SuperTrend trailing stop was created by Olivier Seban; the Average True Range is by J. Welles Wilder Jr. (1978); the Efficiency Ratio is by Perry J. Kaufman; the Wilson score interval is by Edwin B. Wilson (1927). This script gratefully acknowledges all four. The Whipsaw Shield, the transparent adaptive-factor design, the per-symbol statistical engine, the outcome-settling markers, the trade plan layer, and all code in this script are original work — no third-party or open-source script code was reused.
🔶 LIMITATIONS
Trend-following flips underperform by nature in prolonged ranges; the shield reduces but cannot eliminate that cost, and shielded entries confirm slightly later than raw ones — the margin trades earliness for reliability. Statistics need history to mature and are honest about being thin early. Volume grading is less meaningful on symbols with unreliable volume reporting. No indicator replaces independent analysis.
🔶 DISCLAIMER
This script is provided strictly for educational and informational purposes. It is not financial advice, an investment recommendation, or a solicitation to buy or sell any financial instrument. Past behavior of any flip, statistic, or grade does not guarantee future results. Trading involves substantial risk. Always do your own research and manage risk independently.
Script open-source
Dans l'esprit TradingView, le créateur de ce script l'a rendu open source afin que les traders puissent examiner et vérifier ses fonctionnalités. Bravo à l'auteur! Bien que vous puissiez l'utiliser gratuitement, n'oubliez pas que la republication du code est soumise à nos Règles.
The institutional Edge: Indicators, Strategies & a Free Academy. quantum-algo.com
Clause de non-responsabilité
Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.
Script open-source
Dans l'esprit TradingView, le créateur de ce script l'a rendu open source afin que les traders puissent examiner et vérifier ses fonctionnalités. Bravo à l'auteur! Bien que vous puissiez l'utiliser gratuitement, n'oubliez pas que la republication du code est soumise à nos Règles.
The institutional Edge: Indicators, Strategies & a Free Academy. quantum-algo.com
Clause de non-responsabilité
Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.