OPEN-SOURCE SCRIPT
Bear Market Highlighter — Peak→Final Trough

📌 Bear Market Highlighter — Peak → Final Trough (Summary)
Purpose:
This TradingView indicator automatically identifies and shades bear markets. A bear market is defined as a drawdown greater than 20% (customizable) from the last peak to the eventual trough.
🔑 Key Features
Automatic Detection: Detects market peaks and measures drawdowns until they exceed the user-defined threshold.
Shading: Highlights the entire bear phase (peak → trough) with a colored box plus live background shading.
Labels: Marks Bear Start at the peak and Bear End at the trough.
Configurable End Condition:
End on New High = true: Bear ends only when price fully recovers above the prior peak (keeps long declines like 2008 as one continuous bear).
End on New High = false: Bear ends sooner when drawdown shrinks below the threshold.
Customizable Inputs:
Threshold % (default: 20%)
Use Low or Close prices for drawdown
Shade color and opacity
⚙️ Inputs Explained
Bear threshold (%) → Minimum drop from peak to trigger a bear (default 20%).
Use low for drawdown → If true, calculation uses low prices (intraday depth), else close.
End on new high → Keeps long multi-leg declines as one bear until market exceeds old peak.
Shade color & opacity → Customize how the bear phase appears visually.
📈 How It Works
Track Peak: While not in a bear, the indicator keeps updating the highest point.
Trigger Bear: When drawdown > threshold, it marks the bear start.
Update Trough: While in bear, it tracks the lowest price reached.
End Bear:
Either when price recovers above old peak (End on new high = true),
Or when drawdown shrinks below threshold (End on new high = false).
Visualize: Shades the full peak-to-trough area and places start/end labels.
👉 Best Use Case: Long-term charts (weekly/monthly) for visualizing historic bear markets — helps compare severity & duration of downturns at a glance.
Purpose:
This TradingView indicator automatically identifies and shades bear markets. A bear market is defined as a drawdown greater than 20% (customizable) from the last peak to the eventual trough.
🔑 Key Features
Automatic Detection: Detects market peaks and measures drawdowns until they exceed the user-defined threshold.
Shading: Highlights the entire bear phase (peak → trough) with a colored box plus live background shading.
Labels: Marks Bear Start at the peak and Bear End at the trough.
Configurable End Condition:
End on New High = true: Bear ends only when price fully recovers above the prior peak (keeps long declines like 2008 as one continuous bear).
End on New High = false: Bear ends sooner when drawdown shrinks below the threshold.
Customizable Inputs:
Threshold % (default: 20%)
Use Low or Close prices for drawdown
Shade color and opacity
⚙️ Inputs Explained
Bear threshold (%) → Minimum drop from peak to trigger a bear (default 20%).
Use low for drawdown → If true, calculation uses low prices (intraday depth), else close.
End on new high → Keeps long multi-leg declines as one bear until market exceeds old peak.
Shade color & opacity → Customize how the bear phase appears visually.
📈 How It Works
Track Peak: While not in a bear, the indicator keeps updating the highest point.
Trigger Bear: When drawdown > threshold, it marks the bear start.
Update Trough: While in bear, it tracks the lowest price reached.
End Bear:
Either when price recovers above old peak (End on new high = true),
Or when drawdown shrinks below threshold (End on new high = false).
Visualize: Shades the full peak-to-trough area and places start/end labels.
👉 Best Use Case: Long-term charts (weekly/monthly) for visualizing historic bear markets — helps compare severity & duration of downturns at a glance.
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
Penafian
Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.
Skrip sumber terbuka
Dalam semangat sebenar TradingView, pencipta skrip ini telah menjadikannya sumber terbuka supaya pedagang dapat menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupun anda boleh menggunakannya secara percuma, ingat bahawa menerbitkan semula kod ini adalah tertakluk kepada Peraturan Dalaman kami.
Penafian
Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.