OPEN-SOURCE SCRIPT
Swing High/Low Extensions

Swing High/Low — Extensions (2 Plots + Drawings + Touch Signal)
What it does
This indicator finds Swing Highs/Lows using a symmetric length (same bars left & right), then creates horizontal extension levels that run to the right and stop at the first price touch (“extend until future intersection”).
It outputs:
Two plots showing the most recent active High/Low extension (great for alerts & strategy logic).
Line drawings for every detected swing (historical levels stay on the chart and end at the touch bar).
A hidden TouchSignal used to color bars and trigger alerts without distorting the price scale.
The design mirrors Sierra Chart’s “Swing High and Low” with “Extend Swings Until Future Intersection”, but implemented natively in Pine.
How it determines swings
Uses ta.pivothigh() / ta.pivotlow() with length bars left and right.
A swing is confirmed only after there are length bars to the right of the center.
How extensions/lines end
High extensions end when High ≥ level.
Low extensions end when Low ≤ level.
The corresponding line drawing is frozen on the touch bar; the most recent active line continues to extend each new bar.
Inputs
Swing Strength (Bars Left = Right) – symmetric pivot length.
Offset as Percentage – 1 = +1%; positive values push levels outward (High up / Low down), negative pull them inward.
Draw “Extend…Until Future Intersection” Lines – toggle line drawings on/off.
Line Width (Plots + Drawings) – thickness for plots and drawings.
HighExt Color / LowExt Color – colors for the two plots and drawings.
Touch Color – color to paint bars on the touch bar (doesn’t affect scale).
HighExt/LowExt Line Style – choose line style (Solid/Dashed/Dotted) for drawings.
Color Bars on Touch? – enable/disable bar coloring.
Bar Color on High Touch / Low Touch – separate bar colors for each side.
Bar Color Transparency (0..100) – opacity for the bar painting.
Plots
HighExt – latest active high extension only.
LowExt – latest active low extension only.
(Internally there is also a hidden “TouchSignal” plot used for bar coloring & alerts; it’s not displayed to keep the chart scale clean.)
Alerts
Three built-in alertconditions:
Any Extension Touched — triggers when either side is hit.
High Extension Touched — only high level touch.
Low Extension Touched — only low level touch.
Create alerts from the indicator’s “More” (⋯) menu → Add alert → choose one of the conditions.
Styling
Drawings use your selected style (Solid/Dashed/Dotted), color, and width.
Existing historical lines adopt new styles when the script recalculates.
Bar coloring highlights the exact touch candle; disable it if you prefer clean candles.
Notes & tips
Scale-safe: the TouchSignal is hidden (display=none), so it won’t distort the Y-axis.
Performance: TradingView limits scripts to ~500 line objects; this script uses max_lines_count=500. If you hit the cap on long histories, either increase timeframe or disable drawings and rely on the two plots + alerts.
Works on any symbol/timeframe; levels are rounded to the instrument’s minimum tick.
Intended use
For discretionary levels, alerting, and rule-based entries that react to first touch of recent swing extensions. Not financial advice—use at your own risk.
What it does
This indicator finds Swing Highs/Lows using a symmetric length (same bars left & right), then creates horizontal extension levels that run to the right and stop at the first price touch (“extend until future intersection”).
It outputs:
Two plots showing the most recent active High/Low extension (great for alerts & strategy logic).
Line drawings for every detected swing (historical levels stay on the chart and end at the touch bar).
A hidden TouchSignal used to color bars and trigger alerts without distorting the price scale.
The design mirrors Sierra Chart’s “Swing High and Low” with “Extend Swings Until Future Intersection”, but implemented natively in Pine.
How it determines swings
Uses ta.pivothigh() / ta.pivotlow() with length bars left and right.
A swing is confirmed only after there are length bars to the right of the center.
How extensions/lines end
High extensions end when High ≥ level.
Low extensions end when Low ≤ level.
The corresponding line drawing is frozen on the touch bar; the most recent active line continues to extend each new bar.
Inputs
Swing Strength (Bars Left = Right) – symmetric pivot length.
Offset as Percentage – 1 = +1%; positive values push levels outward (High up / Low down), negative pull them inward.
Draw “Extend…Until Future Intersection” Lines – toggle line drawings on/off.
Line Width (Plots + Drawings) – thickness for plots and drawings.
HighExt Color / LowExt Color – colors for the two plots and drawings.
Touch Color – color to paint bars on the touch bar (doesn’t affect scale).
HighExt/LowExt Line Style – choose line style (Solid/Dashed/Dotted) for drawings.
Color Bars on Touch? – enable/disable bar coloring.
Bar Color on High Touch / Low Touch – separate bar colors for each side.
Bar Color Transparency (0..100) – opacity for the bar painting.
Plots
HighExt – latest active high extension only.
LowExt – latest active low extension only.
(Internally there is also a hidden “TouchSignal” plot used for bar coloring & alerts; it’s not displayed to keep the chart scale clean.)
Alerts
Three built-in alertconditions:
Any Extension Touched — triggers when either side is hit.
High Extension Touched — only high level touch.
Low Extension Touched — only low level touch.
Create alerts from the indicator’s “More” (⋯) menu → Add alert → choose one of the conditions.
Styling
Drawings use your selected style (Solid/Dashed/Dotted), color, and width.
Existing historical lines adopt new styles when the script recalculates.
Bar coloring highlights the exact touch candle; disable it if you prefer clean candles.
Notes & tips
Scale-safe: the TouchSignal is hidden (display=none), so it won’t distort the Y-axis.
Performance: TradingView limits scripts to ~500 line objects; this script uses max_lines_count=500. If you hit the cap on long histories, either increase timeframe or disable drawings and rely on the two plots + alerts.
Works on any symbol/timeframe; levels are rounded to the instrument’s minimum tick.
Intended use
For discretionary levels, alerting, and rule-based entries that react to first touch of recent swing extensions. Not financial advice—use at your own risk.
نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.
نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.