OPEN-SOURCE SCRIPT
ที่อัปเดต: Triangle Pattern Detection [Dots3Red]

Triangle Pattern Detection Indicator detects and draws triangle chart patterns in real time. The indicator identifies pivot highs and lows, validates converging trendlines, calculates the mathematical apex, and classifies each pattern by type.
How it works
The indicator scans for pivot highs and pivot lows using a configurable lookback length. Once two valid pivot highs and two valid pivot lows are found, it verifies that:
If all conditions pass, the apex is calculated mathematically as the exact intersection point of the two trendlines, and the full triangle is drawn from the shared start bar to the apex.
Pattern Types Detected
Visuals
Info Table (top right)
Keeps a record of the last 5 detected triangles showing:
Column - Description
The Status column updates on every bar so you can see in real time whether price has broken out of any recent pattern.
Settings
Notes
Example on BTC 🪙 chart

How it works
The indicator scans for pivot highs and pivot lows using a configurable lookback length. Once two valid pivot highs and two valid pivot lows are found, it verifies that:
- The trendlines are genuinely converging (spread shrinks from left to right)
- No bar between the pivots violates the trendline boundary
- The upper and lower patterns are aligned in time
- The pattern meets minimum and maximum width requirements
If all conditions pass, the apex is calculated mathematically as the exact intersection point of the two trendlines, and the full triangle is drawn from the shared start bar to the apex.
Pattern Types Detected
- Symmetrical Triangle — both lines converging toward each other
- Ascending Triangle — flat upper resistance, rising lower support
- Descending Triangle — declining upper resistance, flat lower support
- Rectangle — both lines near horizontal
Visuals
- 🟡 Electric glow triangle
- ▼ / ▲ Pivot markers at pattern boundaries (commented out in the code)
- 🔵 Bullish breakout signal / 🔴 Bearish breakout signal with glow effect and stem line
- Number label at each triangle's start for cross-referencing with the info table
Info Table (top right)
Keeps a record of the last 5 detected triangles showing:
Column - Description
- ID - Triangle number
- Type- Pattern classification
- Width - Pattern width in bars
- BO date - The day the price broke out from the triangle pattern
- Status - Live breakout status — Bull / Bear / Inside
The Status column updates on every bar so you can see in real time whether price has broken out of any recent pattern.
Settings
- Pivot Length - Sensitivity of pivot detection (1–10). Lower = more patterns
- Max Pattern Width - Maximum bars between first and second pivots
- Start Bar Alignment Tolerance - Max distance between the start of the upper and lower pivots of the triangle's sides
- Max Apex Distance - How far ahead the apex can project
- Min Pattern Width - Filters out patterns that are too narrow to be meaningful
- Breakout Threshold % - How far the price must close beyond the trendline to confirm a breakout
Notes
- All triangles are drawn on the last bar only, avoiding repainting of historical patterns
- Breakout detection scans from the leftmost bar of the pattern to the apex, firing on the first confirmed close beyond the boundary
Example on BTC 🪙 chart
Release Note
minor changesRelease Note
...สคริปต์โอเพนซอร์ซ
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
Connect the dots to elevate your trading.
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน
สคริปต์โอเพนซอร์ซ
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้เป็นโอเพนซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันฟังก์ชันการทำงานของมันได้ ขอชื่นชมผู้เขียน! แม้ว่าคุณจะใช้งานได้ฟรี แต่โปรดจำไว้ว่าการเผยแพร่โค้ดซ้ำจะต้องเป็นไปตาม กฎระเบียบการใช้งาน ของเรา
Connect the dots to elevate your trading.
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน