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.
Script de código aberto
No verdadeiro espirito do TradingView, o autor desse script o publicou como código aberto, para que os traders possam entendê-lo e verificá-lo. Parabéns ao autor Você pode usá-lo gratuitamente, mas a reutilização desse código em publicações e regida pelas Regras da Casa.
Aviso legal
As informações e publicações não devem ser e não constituem conselhos ou recomendações financeiras, de investimento, de negociação ou de qualquer outro tipo, fornecidas ou endossadas pela TradingView. Leia mais em Termos de uso.
Script de código aberto
No verdadeiro espirito do TradingView, o autor desse script o publicou como código aberto, para que os traders possam entendê-lo e verificá-lo. Parabéns ao autor Você pode usá-lo gratuitamente, mas a reutilização desse código em publicações e regida pelas Regras da Casa.
Aviso legal
As informações e publicações não devem ser e não constituem conselhos ou recomendações financeiras, de investimento, de negociação ou de qualquer outro tipo, fornecidas ou endossadas pela TradingView. Leia mais em Termos de uso.