OPEN-SOURCE SCRIPT
ที่อัปเดต: Dept Zones

Dept Zones visualizes dynamic overbought and oversold zones directly on the price chart. Unlike fixed-threshold oscillators (RSI, Stochastic), this envelope automatically adapts to each instrument's volatility regime, eliminating the need to manually adjust settings when switching between assets or timeframes.
How it works
The indicator constructs an adaptive price envelope using Ehlers-based two-pole smoothing applied to log-transformed price data. The envelope width is scaled by a smoothed true range, which means the zones expand during high volatility and contract during low volatility — automatically.
Two zones are drawn:
Overbought zone (red) — the area between the inner and outer upper bands. When price enters this zone, it has reached a statistically extreme level relative to its recent volatility-adjusted range. This signals elevated probability of a pullback or reversal.
Oversold zone (green) — the mirror zone below price. Entry into this zone signals that price is stretched to the downside and a bounce or reversal becomes more likely.
A subtle background highlight appears when price is currently inside either zone.
Why log-price and adaptive smoothing matter
Traditional Bollinger Bands use linear price and simple standard deviation, which creates asymmetric zones (the upper band is always wider than the lower on an uptrend). By applying the envelope to log-transformed price, zones remain symmetrical in percentage terms regardless of price level. The Ehlers two-pole smoother provides significantly less lag than a simple moving average of the same period, allowing the envelope to track structural price changes more responsively while still filtering noise.
How to use
Dept Zones is designed as a companion to signal-based indicators like Dept Fractals. The zones provide context — they show WHEN price is in an extreme area. A reversal signal that occurs inside a zone carries significantly more weight than one that occurs in the neutral area between zones.
The indicator can also be used standalone to identify areas where trend-following entries become risky (price deep in the overbought zone = dangerous to go long) and where mean-reversion setups become attractive.
Settings
Source: Price input for the envelope calculation (default: hlc3).
Lookback: Smoothing period. Higher values produce smoother, slower-reacting zones. Default 200.
Inner Band: Amplitude multiplier for the inner boundary. Lower = wider zone, more frequent entries. Default 4.0.
Outer Band: Amplitude multiplier for the outer boundary. Represents the extreme. Default 7.0.
Alerts
Overbought — fires when price touches or exceeds the inner upper band.
Oversold — fires when price touches or breaches the inner lower band.
What makes this different from standard Bollinger Bands or Keltner Channels
Standard envelopes use linear price math and simple moving averages, creating lag and asymmetric zones. Dept Zones uses log-price transformation for symmetrical percentage-based zones, Ehlers adaptive smoothing for minimal lag, and true range scaling for automatic volatility adjustment. The result is an envelope that works consistently across crypto, forex, commodities, and equities without parameter changes.
How it works
The indicator constructs an adaptive price envelope using Ehlers-based two-pole smoothing applied to log-transformed price data. The envelope width is scaled by a smoothed true range, which means the zones expand during high volatility and contract during low volatility — automatically.
Two zones are drawn:
Overbought zone (red) — the area between the inner and outer upper bands. When price enters this zone, it has reached a statistically extreme level relative to its recent volatility-adjusted range. This signals elevated probability of a pullback or reversal.
Oversold zone (green) — the mirror zone below price. Entry into this zone signals that price is stretched to the downside and a bounce or reversal becomes more likely.
A subtle background highlight appears when price is currently inside either zone.
Why log-price and adaptive smoothing matter
Traditional Bollinger Bands use linear price and simple standard deviation, which creates asymmetric zones (the upper band is always wider than the lower on an uptrend). By applying the envelope to log-transformed price, zones remain symmetrical in percentage terms regardless of price level. The Ehlers two-pole smoother provides significantly less lag than a simple moving average of the same period, allowing the envelope to track structural price changes more responsively while still filtering noise.
How to use
Dept Zones is designed as a companion to signal-based indicators like Dept Fractals. The zones provide context — they show WHEN price is in an extreme area. A reversal signal that occurs inside a zone carries significantly more weight than one that occurs in the neutral area between zones.
The indicator can also be used standalone to identify areas where trend-following entries become risky (price deep in the overbought zone = dangerous to go long) and where mean-reversion setups become attractive.
Settings
Source: Price input for the envelope calculation (default: hlc3).
Lookback: Smoothing period. Higher values produce smoother, slower-reacting zones. Default 200.
Inner Band: Amplitude multiplier for the inner boundary. Lower = wider zone, more frequent entries. Default 4.0.
Outer Band: Amplitude multiplier for the outer boundary. Represents the extreme. Default 7.0.
Alerts
Overbought — fires when price touches or exceeds the inner upper band.
Oversold — fires when price touches or breaches the inner lower band.
What makes this different from standard Bollinger Bands or Keltner Channels
Standard envelopes use linear price math and simple moving averages, creating lag and asymmetric zones. Dept Zones uses log-price transformation for symmetrical percentage-based zones, Ehlers adaptive smoothing for minimal lag, and true range scaling for automatic volatility adjustment. The result is an envelope that works consistently across crypto, forex, commodities, and equities without parameter changes.
Release Note
Dept Zones builds adaptive overbought/oversold envelopes using a log-price framework and an Ehlers two-pole super smoother — a causal digital filter from John Ehlers' signal processing research. Instead of fixed percentage offsets, the bands scale dynamically with a smoothed true range computed in log space, so the zones self-adjust to current volatility on any instrument and any timeframe from 1 minute to monthly.─── HOW IT WORKS ───
Log-space computation
All prices and ranges are transformed into logarithmic space before smoothing. This makes percentage moves symmetric — a +10% rally and a −10% drop are equidistant — so the envelope width is proportional rather than additive.
Two-pole Ehlers super smoother
The smoothed midline and smoothed true range are produced by John Ehlers' two-pole super smoother (Cybernetic Analysis for Stocks and Futures, 2004). This IIR filter suppresses Nyquist-frequency noise and aliasing while preserving trend curvature better than a simple moving average at equivalent lag. The implementation is fully self-contained — no external libraries are required.
Adaptive true range
Volatility is measured as the log-space true range: max(log H−log L, |log H−log prev.C|, |log L−log prev.C|), then smoothed with the same filter. Band width reacts to real volatility expansion and contraction rather than a static multiplier.
Adaptive lookback by timeframe
When "Auto Lookback" is enabled, the filter period scales automatically so the indicator covers approximately the same real-world time window across resolutions:
• 1 min → 500 bars (cap)
• 15 min → 384 bars
• 1 hour → 96 bars
• 4 hour → 30 bars
• Daily → 200 bars
• Weekly → 29 bars
─── ZONES AND VISUALS ───
• Midline — smoothed log-price mean (blue, 80% transparency)
• Inner band — zone entry threshold, default 4× smoothed ATR (red/teal)
• Outer band — extreme boundary, default 7× smoothed ATR
• Shaded fill between inner and outer bands highlights OB/OS zones
• Background colour activates when candle high/low touches the inner boundary
─── INPUTS ───
Source — price input for the midline (default HLC3)
Lookback — manual filter period (used when Auto Lookback is off)
Auto Lookback — scales period automatically to chart timeframe (default: on)
Inner Band — ATR multiplier for the zone entry edge (lower = wider zone)
Outer Band — ATR multiplier for the extreme boundary
─── ALERTS ───
Two alert conditions:
• Overbought — high ≥ upper inner band
• Oversold — low ≤ lower inner band
Both carry {{ticker}} and {{interval}} tokens in the alert message.
สคริปต์แบบโอเพนซอร์ส
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน
สคริปต์แบบโอเพนซอร์ส
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน