OPEN-SOURCE SCRIPT
Atualizado Dynamic Volatility Bull/Bear Threshold

Overview
This indicator builds on Anton Kreil's (POTM) "drawdown-from-high" bull/bear framework and upgrades it into a volatility-adaptive version. It anchors to the rolling high (HH) and derives a dynamic bear level from annualized volatility (σ) and a multiple N: a close below it signals bear; reclaiming it while above the long-term MA signals bull.
Core logic
Rolling High HH: the highest high over the past lookback (default 252) bars — the anchor for every level.
Dynamic Bear Level: HH × (1 − N×σ). The drawdown threshold tightens when volatility is low and loosens when it is high (clamped to 5%~60%), so high-vol instruments never end up with a useless "dead line."
Fixed 20% Line: HH × 0.8, i.e. 20% below the high — the original course definition of a bear market, shown for comparison.
Confirm MA: the maLen (default 200) SMA of close, used to confirm trend recovery.
Signals & colors
🔻 Red triangle: close just broke below the dynamic bear level → Bear (Dynamic)
🟠 Orange circle: close just broke 20% below the rolling high → 20% Line Alert (course bear early-warning)
🟢 Green triangle: close reclaimed the dynamic level and crossed above the confirm MA → Bull Confirm
Background: Red = Bear, Green = Bull, Yellow = Recovering
Inputs
Lookback (default 252): window for σ and the rolling high
Vol multiple N (default 1.2): larger N = deeper bear threshold; 0.81.0 more sensitive, 1.82.0 only on crashes
Bull-confirm MA period (default 200)
Overlay fixed 20% line / Show confirm MA: toggles
How to use
Watch the red dynamic bear line as the primary signal; for the strict course rule "20% below high = bear," watch the orange circle. The yellow "Recovering" zone is often a good watch area for option positioning. This is a trend state machine, not a short-term entry signal.
Disclaimer
For research and education only. Not investment advice. Past performance does not guarantee future results.
This indicator builds on Anton Kreil's (POTM) "drawdown-from-high" bull/bear framework and upgrades it into a volatility-adaptive version. It anchors to the rolling high (HH) and derives a dynamic bear level from annualized volatility (σ) and a multiple N: a close below it signals bear; reclaiming it while above the long-term MA signals bull.
Core logic
Rolling High HH: the highest high over the past lookback (default 252) bars — the anchor for every level.
Dynamic Bear Level: HH × (1 − N×σ). The drawdown threshold tightens when volatility is low and loosens when it is high (clamped to 5%~60%), so high-vol instruments never end up with a useless "dead line."
Fixed 20% Line: HH × 0.8, i.e. 20% below the high — the original course definition of a bear market, shown for comparison.
Confirm MA: the maLen (default 200) SMA of close, used to confirm trend recovery.
Signals & colors
🔻 Red triangle: close just broke below the dynamic bear level → Bear (Dynamic)
🟠 Orange circle: close just broke 20% below the rolling high → 20% Line Alert (course bear early-warning)
🟢 Green triangle: close reclaimed the dynamic level and crossed above the confirm MA → Bull Confirm
Background: Red = Bear, Green = Bull, Yellow = Recovering
Inputs
Lookback (default 252): window for σ and the rolling high
Vol multiple N (default 1.2): larger N = deeper bear threshold; 0.81.0 more sensitive, 1.82.0 only on crashes
Bull-confirm MA period (default 200)
Overlay fixed 20% line / Show confirm MA: toggles
How to use
Watch the red dynamic bear line as the primary signal; for the strict course rule "20% below high = bear," watch the orange circle. The yellow "Recovering" zone is often a good watch area for option positioning. This is a trend state machine, not a short-term entry signal.
Disclaimer
For research and education only. Not investment advice. Past performance does not guarantee future results.
Notas de Lançamento
bug fixedScript de código aberto
Em verdadeiro espírito do TradingView, o criador deste script o tornou de código aberto, para que os traders possam revisar e verificar sua funcionalidade. Parabéns ao autor! Embora você possa usá-lo gratuitamente, lembre-se de que a republicação do código está sujeita às nossas Regras da Casa.
Aviso legal
As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.
Script de código aberto
Em verdadeiro espírito do TradingView, o criador deste script o tornou de código aberto, para que os traders possam revisar e verificar sua funcionalidade. Parabéns ao autor! Embora você possa usá-lo gratuitamente, lembre-se de que a republicação do código está sujeita às nossas Regras da Casa.
Aviso legal
As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.