OPEN-SOURCE SCRIPT
Market Structure Pivots Trend

This indicator identifies and visualizes key market structure by plotting confirmed, non-repainting pivot points. It goes beyond simple markers by classifying the pivots, extending dynamic support/resistance lines, and providing a visual representation of the current trend state.
Key Features:
Non-Repainting Pivot Detection:
Uses a standard lookback method (left and right bars) to identify historical pivot points.
Note on Confirmation: Pivots are only confirmed after the Pivot Right Bars input has passed. This is essential for ensuring the signal is non-repainting, but it introduces an inherent lag.
Automatically classifies the sequence of pivots according to Dow Theory: Higher Highs (HH), Higher Lows (HL), Lower Highs (LH), and Lower Lows (LL).
Pivot Classification Filter:
Price Tolerance Filter: A user-defined percentage tolerance filters out insignificant market noise. A pivot is only classified as 'Higher' or 'Lower' if its price exceeds the previous one by more than the set tolerance, leading to more robust signals.
Equal Pivot Detection: The tolerance also enables the detection of Equal Highs (EH) and Equal Lows (EL), highlighting consolidation zones.
Dynamic Support & Resistance Lines:
When enabled, the indicator extends a horizontal line from the most recent confirmed pivot high and low.
These lines update in real-time, providing clear S/R levels.
Lines automatically terminate if the price decisively breaks through them or if a new pivot of the same type is formed.
Trend State Visualization:
A built-in state machine analyzes the sequence of pivots and breaks to determine the current market trend (Uptrend, Downtrend, or Neutral).
Plots a dynamic step-line based on recent highs/lows to visually represent the current trend state.
Full Customization & Alerts:
Display Options: Choose between simple triangles or detailed text labels that show the pivot type, price, and the absolute or relative change from the previous pivot of the same type.
Visual Styling: Full control over colors for all six pivot types (HH, LH, EH, LL, HL, EL) and line styles.
Comprehensive Alerts: Set up alerts for every new pivot formation (e.g., HH, LL), for S/R line breaks, and for changes in the overall trend state (Up, Down, Neutral).
DISCLAIMER
For Informational/Educational Use Only: This indicator is provided for informational and educational purposes only. It does not constitute financial, investment, or trading advice, nor is it a recommendation to buy or sell any asset.
Use at Your Own Risk: All trading decisions you make based on the information or signals generated by this indicator are made solely at your own risk.
No Guarantee of Performance: Past performance is not an indicator of future results. The author makes no guarantee regarding the accuracy of the signals or future profitability.
No Liability: The author shall not be held liable for any financial losses or damages incurred directly or indirectly from the use of this indicator.
Signals Are Not Recommendations: The alerts and visual signals (e.g., crossovers) generated by this tool are not direct recommendations to buy or sell. They are technical observations for your own analysis and consideration.
Key Features:
Non-Repainting Pivot Detection:
Uses a standard lookback method (left and right bars) to identify historical pivot points.
Note on Confirmation: Pivots are only confirmed after the Pivot Right Bars input has passed. This is essential for ensuring the signal is non-repainting, but it introduces an inherent lag.
Automatically classifies the sequence of pivots according to Dow Theory: Higher Highs (HH), Higher Lows (HL), Lower Highs (LH), and Lower Lows (LL).
Pivot Classification Filter:
Price Tolerance Filter: A user-defined percentage tolerance filters out insignificant market noise. A pivot is only classified as 'Higher' or 'Lower' if its price exceeds the previous one by more than the set tolerance, leading to more robust signals.
Equal Pivot Detection: The tolerance also enables the detection of Equal Highs (EH) and Equal Lows (EL), highlighting consolidation zones.
Dynamic Support & Resistance Lines:
When enabled, the indicator extends a horizontal line from the most recent confirmed pivot high and low.
These lines update in real-time, providing clear S/R levels.
Lines automatically terminate if the price decisively breaks through them or if a new pivot of the same type is formed.
Trend State Visualization:
A built-in state machine analyzes the sequence of pivots and breaks to determine the current market trend (Uptrend, Downtrend, or Neutral).
Plots a dynamic step-line based on recent highs/lows to visually represent the current trend state.
Full Customization & Alerts:
Display Options: Choose between simple triangles or detailed text labels that show the pivot type, price, and the absolute or relative change from the previous pivot of the same type.
Visual Styling: Full control over colors for all six pivot types (HH, LH, EH, LL, HL, EL) and line styles.
Comprehensive Alerts: Set up alerts for every new pivot formation (e.g., HH, LL), for S/R line breaks, and for changes in the overall trend state (Up, Down, Neutral).
DISCLAIMER
For Informational/Educational Use Only: This indicator is provided for informational and educational purposes only. It does not constitute financial, investment, or trading advice, nor is it a recommendation to buy or sell any asset.
Use at Your Own Risk: All trading decisions you make based on the information or signals generated by this indicator are made solely at your own risk.
No Guarantee of Performance: Past performance is not an indicator of future results. The author makes no guarantee regarding the accuracy of the signals or future profitability.
No Liability: The author shall not be held liable for any financial losses or damages incurred directly or indirectly from the use of this indicator.
Signals Are Not Recommendations: The alerts and visual signals (e.g., crossovers) generated by this tool are not direct recommendations to buy or sell. They are technical observations for your own analysis and consideration.
สคริปต์โอเพนซอร์ซ
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้มันเป็นโอเพ่นซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันการทำงานของสคริปต์ได้ ขอแสดงความชื่นชมผู้เขียน! แม้ว่าคุณจะสามารถใช้งานได้ฟรี แต่อย่าลืมว่าการเผยแพร่โค้ดซ้ำนั้นจะต้องเป็นไปตามกฎระเบียบการใช้งานของเรา
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมที่ ข้อกำหนดการใช้งาน
สคริปต์โอเพนซอร์ซ
ด้วยเจตนารมณ์หลักของ TradingView ผู้สร้างสคริปต์นี้ได้ทำให้มันเป็นโอเพ่นซอร์ส เพื่อให้เทรดเดอร์สามารถตรวจสอบและยืนยันการทำงานของสคริปต์ได้ ขอแสดงความชื่นชมผู้เขียน! แม้ว่าคุณจะสามารถใช้งานได้ฟรี แต่อย่าลืมว่าการเผยแพร่โค้ดซ้ำนั้นจะต้องเป็นไปตามกฎระเบียบการใช้งานของเรา
คำจำกัดสิทธิ์ความรับผิดชอบ
ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมที่ ข้อกำหนดการใช้งาน