OPEN-SOURCE SCRIPT
Adaptive Channel Breakout [MarkitTick]

💡 This script is a trend-following system designed to identify high-probability breakout opportunities while rigorously filtering out market noise. By synthesizing volatility (ATR), trend strength (ADX), and price extremes (Donchian logic), this indicator attempts to solve the classic problem of false breakouts in ranging markets. It features a regime-detection engine that dynamically adjusts the visual feedback and signal generation based on whether the market is trending or consolidating.
✨ Originality and Utility
Most breakout indicators rely solely on price crossing a fixed threshold (like a 20-day High). However, these systems often fail in "choppy" markets where price seeks liquidity above highs before reversing. This script innovates by:
🔬 Methodology and Concepts
The core logic operates on a three-stage pipeline:
1. Market Regime Classification The script utilizes the Directional Movement Index (DMI) and Average Directional Index (ADX) to determine the state of the market.
2. Adaptive Channel Construction The channels are calculated using a modified Donchian/ATR hybrid approach:
3. Signal Generation & Filtering
🎨 Visual Guide
The indicator is designed for immediate visual interpretation through color-coding and dashboard analytics.
● Channel Bands
● Background Fills (Market Regime) The space between the channels is filled to indicate the current market state:
● Signal Shapes
● Dashboard (Top Right) A table displaying real-time metrics:
📖 How to Use
For Trend Following Wait for the background color to transition from Yellow (Range) to Green (Bull) or Red (Bear). This signifies a volatility expansion from a consolidation period. Enter on the corresponding Triangle signal.
For Risk Management
For Crypto/Parabolic Assets Enable the "Use Logarithmic Scale" setting in the inputs. This normalizes the volatility calculations, preventing the bands from becoming too wide during exponential price increases.
⚙️ Inputs and Settings
Adaptive Parameters
Filters & Exits
UI / Dashboard
🔍 Deconstruction of the Underlying Scientific and Academic Framework
1. Outlier Detection Theory The script uses an ATR Multiplier of 3.2. In normal statistical distributions, 3 standard deviations cover 99.7% of data points. While financial markets are leptokurtic (fat-tailed), a multiplier of 3.2 on the ATR effectively acts as an outlier filter. A breach of this band signifies a price movement that is statistically significant relative to recent noise, suggesting a structural shift in supply/demand rather than random variance.
2. Heteroscedasticity Handling By including a Logarithmic option, the script addresses heteroscedasticity—the phenomenon where the variability of a variable is unequal across the range of values. In simpler terms, a $100 move in Bitcoin at $1,000 is different from a $100 move at $60,000. Using log-returns (math.log) ensures the channel width remains proportionally relevant regardless of the asset's absolute price level.
3. Trend Efficiency (ADX) The integration of J. Welles Wilder’s ADX serves as a filter for "Trend Efficiency." Breakout systems suffer drawdown in mean-reverting markets. By mathematically requiring ADX > 25, the model attempts to trade only when the autocorrelation of price changes is positive (trending behavior), thereby increasing the expectancy of the breakout signal.
⚠️ Disclaimer
All provided scripts and indicators are strictly for educational exploration and must not be interpreted as financial advice or a recommendation to execute trades. I expressly disclaim all liability for any financial losses or damages that may result, directly or indirectly, from the reliance on or application of these tools. Market participation carries inherent risk where past performance never guarantees future returns, leaving all investment decisions and due diligence solely at your own discretion.
✨ Originality and Utility
Most breakout indicators rely solely on price crossing a fixed threshold (like a 20-day High). However, these systems often fail in "choppy" markets where price seeks liquidity above highs before reversing. This script innovates by:
- Volatility-Adjusted Bounds: It does not simply track the Highest High or Lowest Low. Instead, it retracts the channel bounds by a multiple of the Average True Range (ATR). This creates a "tightened" breakout requirement—price must not only make a new high but do so with enough momentum to overcome the volatility threshold. Regime Filtering: Integrated ADX/DMI logic categorizes the market into Bull, Bear, or Range. Signals are filtered to align with the dominant regime (e.g., no Longs are permitted if the internal structure is Bearish). Logarithmic Scaling: A unique feature allowing calculations to be performed on Logarithmic price data, making it highly suitable for parabolic assets like Crypto or small-cap stocks where linear percentage moves vary drastically. Time-Based Exits: Recognizes that "stale" trades—those that do not perform immediately—often turn into losses, and provides visual cues to exit if momentum stalls.
🔬 Methodology and Concepts
The core logic operates on a three-stage pipeline:
1. Market Regime Classification The script utilizes the Directional Movement Index (DMI) and Average Directional Index (ADX) to determine the state of the market.
- Trending: Defined as ADX > Threshold (default 25). Range: Defined as ADX < Threshold.
- Direction: Determined by the relationship between DI+ and DI-.
2. Adaptive Channel Construction The channels are calculated using a modified Donchian/ATR hybrid approach:
- Upper Band: Highest High (N) minus (ATR × Multiplier). Lower Band: Lowest Low (N) plus (ATR × Multiplier).
3. Signal Generation & Filtering
- Long Signal: Price crosses over the Upper Band, provided the market is in a Bull or Range regime. Short Signal: Price crosses under the Lower Band, provided the market is in a Bear or Range regime.
- Stale Exit: If a signal is generated but price fails to reverse or progress significantly within a user-defined bar limit (default 10), a "Time Exit" warning is triggered.
🎨 Visual Guide
The indicator is designed for immediate visual interpretation through color-coding and dashboard analytics.
● Channel Bands
- Upper Line: Represents the dynamic resistance/breakout level. Lower Line: Represents the dynamic support/breakout level. Color Logic:
- Gray: Indicates the opposing side of the trend (e.g., Upper band is gray during a downtrend). Green: Active Upper Band during a Bullish phase. Red: Active Lower Band during a Bearish phase.
● Background Fills (Market Regime) The space between the channels is filled to indicate the current market state:
- Green Fill: Bullish Trend (ADX High, DI+ > DI-). Red Fill: Bearish Trend (ADX High, DI- > DI+).
- Yellow Fill: Range/Accumulation (ADX Low). Breakouts from Yellow zones are often the most explosive.
● Signal Shapes
- Green Triangle (Below Bar): Valid Long Breakout Signal. Red Triangle (Above Bar): Valid Short Breakout Signal.
- Orange "X" (Below Bar): Time Exit/Stale Trade. Indicates the trade has not progressed after N bars.
● Dashboard (Top Right) A table displaying real-time metrics:
- Market Regime: Explicitly states TREND (Bull/Bear) or RANGE. Volatility: Displays the current ATR value.
- ADX Strength: Shows the ADX value, highlighting it in white if it is above the trending threshold.
📖 How to Use
For Trend Following Wait for the background color to transition from Yellow (Range) to Green (Bull) or Red (Bear). This signifies a volatility expansion from a consolidation period. Enter on the corresponding Triangle signal.
For Risk Management
- Stop Loss: The script calculates suggested Stop Losses (SL) based on the opposite channel band. Stale Exits: If you see an Orange "X" appear after entering a trade, consider closing the position or tightening stops, as the momentum impulse has faded.
For Crypto/Parabolic Assets Enable the "Use Logarithmic Scale" setting in the inputs. This normalizes the volatility calculations, preventing the bands from becoming too wide during exponential price increases.
⚙️ Inputs and Settings
Adaptive Parameters
- Lookback Length (20): The period for High/Low and ATR calculations. ATR Multiplier (3.2): Determines the width of the channel. Higher values reduce false signals but delay entry. (3.2 is tuned for outlier detection).
- Use Logarithmic Scale: Toggles math.log() calculations for High, Low, and Close.
Filters & Exits
- ADX Threshold (25): The level at which the market is considered "Trending." Time Exit (Bars) (10): The number of bars allowed for a trade to "work" before being flagged as stale.
UI / Dashboard
- Show Analytics Dashboard: Toggles the on-screen information table. Size: Adjusts the text size of the dashboard (Tiny, Small, Normal).
🔍 Deconstruction of the Underlying Scientific and Academic Framework
1. Outlier Detection Theory The script uses an ATR Multiplier of 3.2. In normal statistical distributions, 3 standard deviations cover 99.7% of data points. While financial markets are leptokurtic (fat-tailed), a multiplier of 3.2 on the ATR effectively acts as an outlier filter. A breach of this band signifies a price movement that is statistically significant relative to recent noise, suggesting a structural shift in supply/demand rather than random variance.
2. Heteroscedasticity Handling By including a Logarithmic option, the script addresses heteroscedasticity—the phenomenon where the variability of a variable is unequal across the range of values. In simpler terms, a $100 move in Bitcoin at $1,000 is different from a $100 move at $60,000. Using log-returns (math.log) ensures the channel width remains proportionally relevant regardless of the asset's absolute price level.
3. Trend Efficiency (ADX) The integration of J. Welles Wilder’s ADX serves as a filter for "Trend Efficiency." Breakout systems suffer drawdown in mean-reverting markets. By mathematically requiring ADX > 25, the model attempts to trade only when the autocorrelation of price changes is positive (trending behavior), thereby increasing the expectancy of the breakout signal.
⚠️ Disclaimer
All provided scripts and indicators are strictly for educational exploration and must not be interpreted as financial advice or a recommendation to execute trades. I expressly disclaim all liability for any financial losses or damages that may result, directly or indirectly, from the reliance on or application of these tools. Market participation carries inherent risk where past performance never guarantees future returns, leaving all investment decisions and due diligence solely at your own discretion.
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
Passionate technical analysts crafting unique, proprietary indicators. We deliver fresh insights designed to redefine your understanding of the market. We welcome new ideas—message us with your concept, and we’ll build it for you free of charge.
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
Passionate technical analysts crafting unique, proprietary indicators. We deliver fresh insights designed to redefine your understanding of the market. We welcome new ideas—message us with your concept, and we’ll build it for you free of charge.
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。