OPEN-SOURCE SCRIPT
Jamallo Channels

🔹Intro
For decades, technical traders have relied on conventional channel models, each burdened by fundamental mathematical limitations:
- Bollinger Bands rely on simple moving averages (SMA) and raw price standard deviation. When strong directional trends emerge, raw variance conflates trend slope with volatility, causing the bands to artificially flare open ("volatility bulge") and produce severe lag and frequent false mean-reversion signals.
- Keltner Channels utilize exponential moving averages (EMA) wrapped with Average True Range (ATR). While smoother, the EMA introduces continuous phase delay, and the bands drift constantly with price, failing to provide stable, horizontal support and resistance benchmarks during consolidation.
- Donchian Channels plot rolling highest highs and lowest lows over an N-bar window. However, they are exceptionally vulnerable to single-bar outlier wicks and sudden step jumps that distort the true statistical distribution without accounting for underlying volatility dynamics.
Jamallo Channels resolves these structural flaws through a novel mathematical synthesis:
1. It replaces lagging moving averages with a multi-resolution Maximal Overlap Discrete Wavelet Transform (MODWT) Haar filter bank coupled with an energy-calibrated deadband step-hold state machine. The baseline remains strictly stationary during consolidation and snaps instantaneously to new price levels upon statistically significant drift.
2. It decouples trend from volatility by computing standard deviation strictly on the detrended high-frequency wavelet residual, filtered through a rolling linear-interpolation median to eliminate spike distortion.
3. It locks the volatility corridor at the exact moment a new regime step triggers—producing pristine, step-synchronized horizontal channels and mathematically robust exhaustion zones.
🔹Break down
1. Multi-Resolution Haar Wavelet MODWT Engine:
- Undecimated Dyadic Decomposition: Deconstructs raw price action across up to 5 dyadic scale levels (Level 1 = 2-bar, Level 2 = 4-bar, Level 3 = 8-bar, Level 4 = 16-bar, Level 5 = 32-bar) into orthogonal approximation (trend) and detail (high-frequency noise) coefficients without phase distortion or downsampling loss.
- Scale-Adaptive Smoothing: Isolates the true low-frequency structural trend from intraday churn and microstructure noise at the selected dyadic decomposition level.
- Dynamic Detail Energy Tracking: Measures the real-time volatility intensity of the high-frequency detail spectrum by computing a rolling Simple Moving Average of absolute detail coefficients over a calibrated lookback window.
2. Energy-Calibrated Deadband Step-Hold Mechanism:
- Statistical Innovation Filtering: Establishes an adaptive deadband threshold scaled directly by the product of the detail energy and a deadband multiplier.
- Zero-Drift Piecewise Step-Holding: The smooth wavelet baseline is held strictly horizontal until price innovation definitively breaches the dynamic detail deadband threshold. Once breached, the baseline snaps instantaneously to the new equilibrium price level, eliminating baseline drifting during consolidation phases.
- Clean Regime Direction State: Evaluates the direction of every confirmed step, immediately classifying the market into Bullish (Teal) or Bearish (Maroon) regime states.
3. Detrended Residual Volatility & Frozen Sigma Bands:
- Trend-Decoupled Dispersion Measurement: Unlike standard deviation calculated around lagging moving averages—which artificially inflates during strong trends—Jamallo Channels isolates the high-frequency wavelet residual (Price minus Wavelet Mid) before computing variance, capturing genuine localized volatility.
- Median Filter Outlier Rejection: Applies a rolling linear-interpolation median filter (50th percentile over a 100-bar window) to the raw residual standard deviation, immunizing the channel against one-off spike anomalies and erratic expansion.
- Step-Locked Volatility Corridors: Volatility is sampled and frozen precisely at the moment a new Haar baseline step triggers. The frozen sigma remains constant throughout the entire regime life cycle, producing stable, non-wiggling horizontal channels.
4. Multi-Tier Volatility Corridors & Exhaustion Envelopes:
- Inner Expansion Zone (1.0σ): Defines the immediate high-probability operational boundary around the stepped trend baseline.
- Mid Dispersion Boundary (2.0σ): Represents standard 2-sigma statistical bounds where normal trending impulse legs oscillate.
- Outer Exhaustion & Mean-Reversion Zone (3.0σ): The extreme channel boundary (2.0σ to 3.0σ highlighted by shaded backgrounds) marks statistical overextension where price is prime for momentum exhaustion and mean-reverting retests back to the Haar stepped baseline.
🔹How to use: Trend Following & Risk Management
Jamallo Channels provides clear, objective mathematical parameters for both momentum trend riders and mean-reversion scalpers across all timeframes.
Regime Trend Trading:
- Setup & Execution: Enter in the direction of a newly confirmed Haar baseline step (when the baseline shifts color to Teal for Longs or Maroon for Shorts) or upon a sustained price breakout above/below the baseline following volatility compression.
- Stop Loss Placement: Anchor stop loss orders directly behind the most recent stepped Haar baseline level or just outside the opposite inner/mid channel boundary.
- Trailing & Letting Winners Run: Trail stop loss orders systematically step-by-step as new horizontal baseline rungs are confirmed, protecting capital while letting winners ride the macro expansion.
Mean-Reversion & Exhaustion Scalping:
- Exhaustion Rejection: When price enters the extreme 2.0σ–3.0σ outer band corridor (upper red fill or lower teal fill) and forms rejection wicks or structural exhaustion patterns, execute counter-trend mean-reversion setups.
- Take-Profit Targets: Target the inner channel (1.0σ) for partial profits and the primary Haar stepped baseline (0σ mean) for final profit harvesting.
- Invalidation / Stop Loss: Place tight stop losses just beyond the outer 3.0σ boundary line.
🔹Settings Parameters
Haar Wavelet Basis:
- Basis Level (1 - 5): Selects the dyadic wavelet decomposition scale (1 = 2-bar, 2 = 4-bar, 3 = 8-bar, 4 = 16-bar, 5 = 32-bar). Higher levels smooth out larger macro trends, while lower levels capture high-frequency swings.
- Deadband Multiplier (0.1 - 10.0): Scaling coefficient applied to the detail energy. Higher values widen the deadband, requiring larger directional thrusts to trigger a new step and producing wider, noise-immune steps.
- Detail Energy Lookback (5 - 200): The rolling lookback window used to calculate the average magnitude of wavelet detail coefficients.
Stdev Bands:
- Stdev Length (min 2): Lookback period for measuring the standard deviation of the detrended wavelet residual.
- Inner Multiplier (0.1 - 10.0): Standard deviation multiplier for the inner channel envelope (default: 1.0σ).
- Mid Multiplier (0.1 - 10.0): Standard deviation multiplier for the middle channel envelope (default: 2.0σ).
- Outer Multiplier (0.1 - 10.0): Standard deviation multiplier for the extreme exhaustion envelope (default: 3.0σ).
Display Settings:
- Basis Up Color: Custom color for the stepped baseline during bullish regime states (default: Teal).
- Basis Down Color: Custom color for the stepped baseline during bearish regime states (default: Maroon).
- Upper Color: Accent color for the upper channel bands and exhaustion fills (default: Red).
- Lower Color: Accent color for the lower channel bands and exhaustion fills (default: Teal).
- Show Fill: Toggles background shading for the inner and outer volatility corridors.
For decades, technical traders have relied on conventional channel models, each burdened by fundamental mathematical limitations:
- Bollinger Bands rely on simple moving averages (SMA) and raw price standard deviation. When strong directional trends emerge, raw variance conflates trend slope with volatility, causing the bands to artificially flare open ("volatility bulge") and produce severe lag and frequent false mean-reversion signals.
- Keltner Channels utilize exponential moving averages (EMA) wrapped with Average True Range (ATR). While smoother, the EMA introduces continuous phase delay, and the bands drift constantly with price, failing to provide stable, horizontal support and resistance benchmarks during consolidation.
- Donchian Channels plot rolling highest highs and lowest lows over an N-bar window. However, they are exceptionally vulnerable to single-bar outlier wicks and sudden step jumps that distort the true statistical distribution without accounting for underlying volatility dynamics.
Jamallo Channels resolves these structural flaws through a novel mathematical synthesis:
1. It replaces lagging moving averages with a multi-resolution Maximal Overlap Discrete Wavelet Transform (MODWT) Haar filter bank coupled with an energy-calibrated deadband step-hold state machine. The baseline remains strictly stationary during consolidation and snaps instantaneously to new price levels upon statistically significant drift.
2. It decouples trend from volatility by computing standard deviation strictly on the detrended high-frequency wavelet residual, filtered through a rolling linear-interpolation median to eliminate spike distortion.
3. It locks the volatility corridor at the exact moment a new regime step triggers—producing pristine, step-synchronized horizontal channels and mathematically robust exhaustion zones.
🔹Break down
1. Multi-Resolution Haar Wavelet MODWT Engine:
- Undecimated Dyadic Decomposition: Deconstructs raw price action across up to 5 dyadic scale levels (Level 1 = 2-bar, Level 2 = 4-bar, Level 3 = 8-bar, Level 4 = 16-bar, Level 5 = 32-bar) into orthogonal approximation (trend) and detail (high-frequency noise) coefficients without phase distortion or downsampling loss.
- Scale-Adaptive Smoothing: Isolates the true low-frequency structural trend from intraday churn and microstructure noise at the selected dyadic decomposition level.
- Dynamic Detail Energy Tracking: Measures the real-time volatility intensity of the high-frequency detail spectrum by computing a rolling Simple Moving Average of absolute detail coefficients over a calibrated lookback window.
2. Energy-Calibrated Deadband Step-Hold Mechanism:
- Statistical Innovation Filtering: Establishes an adaptive deadband threshold scaled directly by the product of the detail energy and a deadband multiplier.
- Zero-Drift Piecewise Step-Holding: The smooth wavelet baseline is held strictly horizontal until price innovation definitively breaches the dynamic detail deadband threshold. Once breached, the baseline snaps instantaneously to the new equilibrium price level, eliminating baseline drifting during consolidation phases.
- Clean Regime Direction State: Evaluates the direction of every confirmed step, immediately classifying the market into Bullish (Teal) or Bearish (Maroon) regime states.
3. Detrended Residual Volatility & Frozen Sigma Bands:
- Trend-Decoupled Dispersion Measurement: Unlike standard deviation calculated around lagging moving averages—which artificially inflates during strong trends—Jamallo Channels isolates the high-frequency wavelet residual (Price minus Wavelet Mid) before computing variance, capturing genuine localized volatility.
- Median Filter Outlier Rejection: Applies a rolling linear-interpolation median filter (50th percentile over a 100-bar window) to the raw residual standard deviation, immunizing the channel against one-off spike anomalies and erratic expansion.
- Step-Locked Volatility Corridors: Volatility is sampled and frozen precisely at the moment a new Haar baseline step triggers. The frozen sigma remains constant throughout the entire regime life cycle, producing stable, non-wiggling horizontal channels.
4. Multi-Tier Volatility Corridors & Exhaustion Envelopes:
- Inner Expansion Zone (1.0σ): Defines the immediate high-probability operational boundary around the stepped trend baseline.
- Mid Dispersion Boundary (2.0σ): Represents standard 2-sigma statistical bounds where normal trending impulse legs oscillate.
- Outer Exhaustion & Mean-Reversion Zone (3.0σ): The extreme channel boundary (2.0σ to 3.0σ highlighted by shaded backgrounds) marks statistical overextension where price is prime for momentum exhaustion and mean-reverting retests back to the Haar stepped baseline.
🔹How to use: Trend Following & Risk Management
Jamallo Channels provides clear, objective mathematical parameters for both momentum trend riders and mean-reversion scalpers across all timeframes.
Regime Trend Trading:
- Setup & Execution: Enter in the direction of a newly confirmed Haar baseline step (when the baseline shifts color to Teal for Longs or Maroon for Shorts) or upon a sustained price breakout above/below the baseline following volatility compression.
- Stop Loss Placement: Anchor stop loss orders directly behind the most recent stepped Haar baseline level or just outside the opposite inner/mid channel boundary.
- Trailing & Letting Winners Run: Trail stop loss orders systematically step-by-step as new horizontal baseline rungs are confirmed, protecting capital while letting winners ride the macro expansion.
Mean-Reversion & Exhaustion Scalping:
- Exhaustion Rejection: When price enters the extreme 2.0σ–3.0σ outer band corridor (upper red fill or lower teal fill) and forms rejection wicks or structural exhaustion patterns, execute counter-trend mean-reversion setups.
- Take-Profit Targets: Target the inner channel (1.0σ) for partial profits and the primary Haar stepped baseline (0σ mean) for final profit harvesting.
- Invalidation / Stop Loss: Place tight stop losses just beyond the outer 3.0σ boundary line.
🔹Settings Parameters
Haar Wavelet Basis:
- Basis Level (1 - 5): Selects the dyadic wavelet decomposition scale (1 = 2-bar, 2 = 4-bar, 3 = 8-bar, 4 = 16-bar, 5 = 32-bar). Higher levels smooth out larger macro trends, while lower levels capture high-frequency swings.
- Deadband Multiplier (0.1 - 10.0): Scaling coefficient applied to the detail energy. Higher values widen the deadband, requiring larger directional thrusts to trigger a new step and producing wider, noise-immune steps.
- Detail Energy Lookback (5 - 200): The rolling lookback window used to calculate the average magnitude of wavelet detail coefficients.
Stdev Bands:
- Stdev Length (min 2): Lookback period for measuring the standard deviation of the detrended wavelet residual.
- Inner Multiplier (0.1 - 10.0): Standard deviation multiplier for the inner channel envelope (default: 1.0σ).
- Mid Multiplier (0.1 - 10.0): Standard deviation multiplier for the middle channel envelope (default: 2.0σ).
- Outer Multiplier (0.1 - 10.0): Standard deviation multiplier for the extreme exhaustion envelope (default: 3.0σ).
Display Settings:
- Basis Up Color: Custom color for the stepped baseline during bullish regime states (default: Teal).
- Basis Down Color: Custom color for the stepped baseline during bearish regime states (default: Maroon).
- Upper Color: Accent color for the upper channel bands and exhaustion fills (default: Red).
- Lower Color: Accent color for the lower channel bands and exhaustion fills (default: Teal).
- Show Fill: Toggles background shading for the inner and outer volatility corridors.
สคริปต์แบบโอเพนซอร์ส
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
Join the Growing (Econophysics Trading) Community! ⚛️
discord.com/invite/qb4RKFdwYJ
Trade the physics of price.
discord.com/invite/qb4RKFdwYJ
Trade the physics of price.
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน
สคริปต์แบบโอเพนซอร์ส
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
Join the Growing (Econophysics Trading) Community! ⚛️
discord.com/invite/qb4RKFdwYJ
Trade the physics of price.
discord.com/invite/qb4RKFdwYJ
Trade the physics of price.
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน