OPEN-SOURCE SCRIPT
Telah dikemas kini 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.
Nota Keluaran
bug fixedSkrip sumber terbuka
Dalam semangat TradingView sebenar, pencipta skrip ini telah menjadikannya sumber terbuka, jadi pedagang boleh menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupuan anda boleh menggunakan secara percuma, ingat bahawa penerbitan semula kod ini tertakluk kepada Peraturan Dalaman.
Penafian
Maklumat dan penerbitan adalah tidak bertujuan, dan tidak membentuk, nasihat atau cadangan kewangan, pelaburan, dagangan atau jenis lain yang diberikan atau disahkan oleh TradingView. Baca lebih dalam Terma Penggunaan.
Skrip sumber terbuka
Dalam semangat TradingView sebenar, pencipta skrip ini telah menjadikannya sumber terbuka, jadi pedagang boleh menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupuan anda boleh menggunakan secara percuma, ingat bahawa penerbitan semula kod ini tertakluk kepada Peraturan Dalaman.
Penafian
Maklumat dan penerbitan adalah tidak bertujuan, dan tidak membentuk, nasihat atau cadangan kewangan, pelaburan, dagangan atau jenis lain yang diberikan atau disahkan oleh TradingView. Baca lebih dalam Terma Penggunaan.