OPEN-SOURCE SCRIPT
Decay Min-Max Channel (DECAYCHANNEL)

The Decay Channel is a price envelope that snaps out instantly to new highs and lows, then pulls back smoothly toward the center while price consolidates. It starts from the same raw extremes as a Donchian Channel, but instead of holding an old high until it exits the lookback window and then dropping off a cliff, each band gradually forgets its extreme. Breakouts widen the channel at once; quiet markets narrow it.
HISTORICAL CONTEXT
Richard Donchian's channel (1960s) defines support and resistance as the highest high and lowest low of the last N bars. Its bands move in steps: a high from 99 bars ago carries full weight, then vanishes completely one bar later. Traders do not treat old extremes that way. Their influence fades.
The Decay Channel borrows exponential decay from physics (radioactive decay, Newton's law of cooling) to let band width relax continuously instead of in jumps, while keeping Donchian's rule that a band can never sit outside actual price history.
HOW IT WORKS
Stage 1: Track extremes and their age
- If high ≥ upper band: upper snaps to the high, its age resets to 0.
- Otherwise the age increases by 1. Same logic for the low and lower band.
Stage 2: Decay toward the midpoint
λ = ln(2) / Period
mid = (upper + lower) / 2
rate = 1 − exp(−λ × age)
upper ← upper − rate × (upper − mid)
lower ← lower − rate × (lower − mid)
The rate is applied again every bar and grows with age, so decay starts slowly and accelerates. After n quiet bars the remaining width is about exp(−ln 2 × n(n+1) / (2 × Period)).
Stage 3: Donchian clamp
upper = min(upper, highest high of last Period bars)
lower = max(lower, lowest low of last Period bars)
The bands can never extend beyond real price history.
Decay speed (measured, flat price after a range)
- Period 20: width halves after about 6 bars, down to 10% after 11.
- Period 100: halves after about 14 bars, 10% after 25.
- Rule of thumb: half the width is gone after roughly √(2 × Period) bars.
On random-walk data the channel is typically 30-40% as wide as Donchian.
INPUTS & PARAMETERS
- Period: Sets both the decay rate and the Donchian lookback. Default: 100.
Period selection
- 20-50: Tight channel, bands hug recent swings and contract within a few bars.
- 100: Default. Holds extremes briefly, contracts within about 15-25 quiet bars.
- 200+: Slower release, closer to classic Donchian behavior.
HOW TO USE
Breakouts
- A band that has decayed toward price is easier to break than a full Donchian band. A close beyond a decayed band signals that price is leaving a consolidation, earlier than a Donchian breakout would.
Volatility regime
- Wide channel: recent extremes are fresh, the market is active.
- Narrow channel: no new extremes for a while, compression. Compression often precedes expansion.
Trend reading
- In an uptrend the upper band keeps snapping to new highs while the lower band decays upward toward price. That rising lower band works as a trailing stop that tightens on its own.
LIMITATIONS
- Not a half-life in the strict sense: because the decay rate grows with age and compounds each bar, the width halves after roughly √(2 × Period) bars, not after Period bars.
- More touches, more signals: bands sit much closer to price than Donchian bands, so band breaks happen more often. Filter them before trading.
- Asymmetric midpoint: when one band snaps and the other decays, the midpoint shifts, so the two bands do not contract evenly.
- Cost: each bar scans the full lookback for the Donchian clamp, so very large periods are slower to compute.
- Warmup: until Period bars exist, the clamp uses only the available history.
REFERENCES
- Donchian, R. "High Finance in Copper." Financial Analysts Journal, 1960.
- Newton, I. "Scala Graduum Caloris." Philosophical Transactions, 1701.
- Rutherford, E. Radioactive Substances and their Radiations. Cambridge University Press, 1913.
HISTORICAL CONTEXT
Richard Donchian's channel (1960s) defines support and resistance as the highest high and lowest low of the last N bars. Its bands move in steps: a high from 99 bars ago carries full weight, then vanishes completely one bar later. Traders do not treat old extremes that way. Their influence fades.
The Decay Channel borrows exponential decay from physics (radioactive decay, Newton's law of cooling) to let band width relax continuously instead of in jumps, while keeping Donchian's rule that a band can never sit outside actual price history.
HOW IT WORKS
Stage 1: Track extremes and their age
- If high ≥ upper band: upper snaps to the high, its age resets to 0.
- Otherwise the age increases by 1. Same logic for the low and lower band.
Stage 2: Decay toward the midpoint
λ = ln(2) / Period
mid = (upper + lower) / 2
rate = 1 − exp(−λ × age)
upper ← upper − rate × (upper − mid)
lower ← lower − rate × (lower − mid)
The rate is applied again every bar and grows with age, so decay starts slowly and accelerates. After n quiet bars the remaining width is about exp(−ln 2 × n(n+1) / (2 × Period)).
Stage 3: Donchian clamp
upper = min(upper, highest high of last Period bars)
lower = max(lower, lowest low of last Period bars)
The bands can never extend beyond real price history.
Decay speed (measured, flat price after a range)
- Period 20: width halves after about 6 bars, down to 10% after 11.
- Period 100: halves after about 14 bars, 10% after 25.
- Rule of thumb: half the width is gone after roughly √(2 × Period) bars.
On random-walk data the channel is typically 30-40% as wide as Donchian.
INPUTS & PARAMETERS
- Period: Sets both the decay rate and the Donchian lookback. Default: 100.
Period selection
- 20-50: Tight channel, bands hug recent swings and contract within a few bars.
- 100: Default. Holds extremes briefly, contracts within about 15-25 quiet bars.
- 200+: Slower release, closer to classic Donchian behavior.
HOW TO USE
Breakouts
- A band that has decayed toward price is easier to break than a full Donchian band. A close beyond a decayed band signals that price is leaving a consolidation, earlier than a Donchian breakout would.
Volatility regime
- Wide channel: recent extremes are fresh, the market is active.
- Narrow channel: no new extremes for a while, compression. Compression often precedes expansion.
Trend reading
- In an uptrend the upper band keeps snapping to new highs while the lower band decays upward toward price. That rising lower band works as a trailing stop that tightens on its own.
LIMITATIONS
- Not a half-life in the strict sense: because the decay rate grows with age and compounds each bar, the width halves after roughly √(2 × Period) bars, not after Period bars.
- More touches, more signals: bands sit much closer to price than Donchian bands, so band breaks happen more often. Filter them before trading.
- Asymmetric midpoint: when one band snaps and the other decays, the midpoint shifts, so the two bands do not contract evenly.
- Cost: each bar scans the full lookback for the Donchian clamp, so very large periods are slower to compute.
- Warmup: until Period bars exist, the clamp uses only the available history.
REFERENCES
- Donchian, R. "High Finance in Copper." Financial Analysts Journal, 1960.
- Newton, I. "Scala Graduum Caloris." Philosophical Transactions, 1701.
- Rutherford, E. Radioactive Substances and their Radiations. Cambridge University Press, 1913.
สคริปต์แบบโอเพนซอร์ส
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
Rigorous technical indicators for Pine Script 6 with O(1) streaming, defensible math, and proper initialization. Fully documented, implemented in C#, transcribed to Pine Script, and wrapped for Python.
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน
สคริปต์แบบโอเพนซอร์ส
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
Rigorous technical indicators for Pine Script 6 with O(1) streaming, defensible math, and proper initialization. Fully documented, implemented in C#, transcribed to Pine Script, and wrapped for Python.
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน