OPEN-SOURCE SCRIPT

Bear Market Highlighter — Peak→Final Trough

65
📌 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.

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.