OPEN-SOURCE SCRIPT
Deadband Hysteresis Supertrend [BackQuant]

Deadband Hysteresis Supertrend [BackQuant]
A two-stage trend tool that first filters price with a deadband baseline, then runs a Supertrend around that baseline with optional flip hysteresis and ATR-based adverse exits.
What this is
A hybrid of two ideas:
The goal is fewer whipsaws in chop and clearer regime identification during trends.
How it works (high level)
If you would like to check out the filter by itself:
What it plots
Inputs that matter
How to read it
Use cases
Tuning guidance
Included alerts
Strengths
Putting it together
Think of this tool as two decisions layered into one view. The deadband baseline answers “does this move even count,” then the Supertrend wrapped around that baseline answers “if it counts, which side should I be on and where do I flip.” When both parts agree you tend to stay on the correct side of a trend for longer, and when they disagree you get an early warning that conditions are changing.
Final thoughts
Deadband Hysteresis Supertrend is best read as a regime lens. The baseline defines your tolerance for noise, the bands define your trailing structure, and the flip offset plus adverse ATR stop define how forgiving or strict you want to be at the boundary. On strong trends it helps you hold through shallow shakeouts. In choppy conditions it encourages patience until price does something meaningful. Start with settings that reflect the cadence of your market, observe how often flips occur, then nudge the deadband and flip offset until the tool spends most of its time describing the move you care about rather than the noise in between.
A two-stage trend tool that first filters price with a deadband baseline, then runs a Supertrend around that baseline with optional flip hysteresis and ATR-based adverse exits.
What this is
A hybrid of two ideas:
- Deadband Hysteresis Baseline that only advances when price pulls far enough from the baseline to matter. This suppresses micro noise and gives you a stable centerline.
- Supertrend bands wrapped around that baseline instead of raw price. Flips are further gated by an extra margin so side changes are more deliberate.
The goal is fewer whipsaws in chop and clearer regime identification during trends.
How it works (high level)
- Deadband step — compute a per-bar “deadband” size from one of four modes: ATR, Percent of price, Ticks, or Points. If price deviates from the baseline by more than this amount, move the baseline forward by a fraction of the excess. If not, hold the line.
- Centered Supertrend — build upper and lower bands around the baseline using ATR and a user factor. Track the usual trailing logic that tightens a band while price moves in its favor.
- Flip hysteresis — require price to exceed the active band by an extra flip offset × ATR before switching sides. This adds stickiness at the boundary.
- Adverse exit — once a side is taken, trigger an exit if price moves against the entry by K × ATR.
If you would like to check out the filter by itself:
![Deadband Hysteresis Filter [BackQuant]](https://s3.tradingview.com/t/TPvNyPwv_mid.png)
What it plots
- DBHF baseline (optional) as a smooth centerline.
- DBHF Supertrend as the active trailing band.
- Candle coloring by trend side for quick read.
- Signal markers 𝕃 and 𝕊 at flips plus ✖ on adverse exits.
Inputs that matter
- Price Source — series being filtered. Close is typical. HL2 or HLC3 can be steadier.
- Deadband mode — ATR, Percent, Ticks, or Points. This defines the “it’s big enough to matter” zone.
- ATR Length / Mult (DBHF) — only used when mode = ATR. Larger values widen the do-nothing zone.
- Percent / Ticks / Points — alternatives to ATR; pick what fits your market’s convention.
- Enter Mult — scales the deadband you must clear before the baseline moves. Increase to filter more noise.
- Response — fraction of the excess applied to baseline movement. Higher responds faster; lower is smoother.
- Supertrend ATR Period & Factor — traditional band size controls; higher factor widens and flips less often.
- Flip Offset ATR — extra ATR buffer required to flip. Useful in choppy regimes.
- Adverse Stop K·ATR — per-trade danger brake that forces an exit if price moves K×ATR against entry.
- UI — toggle baseline, supertrend, signals, and bar painting; choose long and short colors.
How to read it
- Green regime — candles painted long and the Supertrend running below price. Pullbacks toward the baseline that fail to breach the opposite band often resume higher.
- Red regime — candles painted short and the Supertrend running above price. Rallies that cannot reclaim the band may roll over.
- Frequent side swaps — reduce sensitivity by increasing Enter Mult, using ATR mode, raising the Supertrend factor, or adding Flip Offset ATR.
Use cases
- Bias filter — allow entries only in the direction of the current side. Use your preferred triggers inside that bias.
- Trailing logic — treat the active band as a dynamic stop. If the side flips or an adverse K·ATR exit prints, reduce or close exposure.
- Regime map — on higher timeframes, the combination baseline + band produces a clean up vs down template for allocation decisions.
Tuning guidance
- Fast markets — ATR deadband, modest Enter Mult (0.8–1.2), response 0.2–0.35, Supertrend factor 1.7–2.2, small Flip Offset (0.2–0.5 ATR).
- Choppy ranges — widen deadband or raise Enter Mult, lower response, and add more Flip Offset so flips require stronger evidence.
- Slow trends — longer ATR periods and higher Supertrend factor to keep you on side longer; use a conservative adverse K.
Included alerts
- DBHF ST Long — side flips to long.
- DBHF ST Short — side flips to short.
- Adverse Exit Long / Short — K·ATR stop triggers against the current side.
Strengths
- Deadbanded baseline reduces micro whipsaws before Supertrend logic even begins.
- Flip hysteresis adds a second layer of confirmation at the boundary.
- Optional adverse ATR stop provides a uniform risk cut across assets and regimes.
- Clear visuals and minimal parameters to adjust for symbol behavior.
Putting it together
Think of this tool as two decisions layered into one view. The deadband baseline answers “does this move even count,” then the Supertrend wrapped around that baseline answers “if it counts, which side should I be on and where do I flip.” When both parts agree you tend to stay on the correct side of a trend for longer, and when they disagree you get an early warning that conditions are changing.
- When the baseline bends and price cannot reclaim the opposite band, momentum is usually continuing. Pullbacks into the baseline that stall before the far band often resolve in trend.
- When the baseline flattens and the bands compress, expect indecision. Use the Flip Offset ATR to avoid reacting to the first feint. Wait for a clean band breach with follow through.
- When an adverse K·ATR exit prints while the side has not flipped, treat it as a risk event rather than a full regime change. Many users cut size, re-enter only if the side reasserts, and let the next flip confirm a new trend.
Final thoughts
Deadband Hysteresis Supertrend is best read as a regime lens. The baseline defines your tolerance for noise, the bands define your trailing structure, and the flip offset plus adverse ATR stop define how forgiving or strict you want to be at the boundary. On strong trends it helps you hold through shallow shakeouts. In choppy conditions it encourages patience until price does something meaningful. Start with settings that reflect the cadence of your market, observe how often flips occur, then nudge the deadband and flip offset until the tool spends most of its time describing the move you care about rather than the noise in between.
Скрипт с открытым кодом
В истинном духе TradingView автор этого скрипта опубликовал его с открытым исходным кодом, чтобы трейдеры могли понять, как он работает, и проверить на практике. Вы можете воспользоваться им бесплатно, но повторное использование этого кода в публикации регулируется Правилами поведения.
Check out whop.com/signals-suite for Access to Invite Only Scripts!
Отказ от ответственности
Все виды контента, которые вы можете увидеть на TradingView, не являются финансовыми, инвестиционными, торговыми или любыми другими рекомендациями. Мы не предоставляем советы по покупке и продаже активов. Подробнее — в Условиях использования TradingView.
Скрипт с открытым кодом
В истинном духе TradingView автор этого скрипта опубликовал его с открытым исходным кодом, чтобы трейдеры могли понять, как он работает, и проверить на практике. Вы можете воспользоваться им бесплатно, но повторное использование этого кода в публикации регулируется Правилами поведения.
Check out whop.com/signals-suite for Access to Invite Only Scripts!
Отказ от ответственности
Все виды контента, которые вы можете увидеть на TradingView, не являются финансовыми, инвестиционными, торговыми или любыми другими рекомендациями. Мы не предоставляем советы по покупке и продаже активов. Подробнее — в Условиях использования TradingView.