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.
สคริปต์โอเพนซอร์ซ
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้มันเป็นโอเพ่นซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันการทำงานของสคริปต์ได้ ขอแสดงความชื่นชมผู้เขียน! แม้ว่าคุณจะสามารถใช้งานได้ฟรี แต่อย่าลืมว่าการเผยแพร่โค้ดซ้ำนั้นจะต้องเป็นไปตามกฎระเบียบการใช้งานของเรา
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมที่ ข้อกำหนดการใช้งาน
สคริปต์โอเพนซอร์ซ
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้มันเป็นโอเพ่นซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันการทำงานของสคริปต์ได้ ขอแสดงความชื่นชมผู้เขียน! แม้ว่าคุณจะสามารถใช้งานได้ฟรี แต่อย่าลืมว่าการเผยแพร่โค้ดซ้ำนั้นจะต้องเป็นไปตามกฎระเบียบการใช้งานของเรา
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมที่ ข้อกำหนดการใช้งาน