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.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.