OPEN-SOURCE SCRIPT
Automatic Support & Resistance

1. Overview
This is an automatic Support and Resistance (S/R) level detector for TradingView. It identifies significant price pivots (peaks and troughs) based on user-defined settings and plots up to 8 dynamic levels on your chart.
The script is intended for educational and informational purposes to demonstrate automatic S/R detection using pivot points and to help traders identify potential areas of interest.
2. Key Logic & Features
A. Pivot Detection
The script detects price pivots (local highs and lows) using ta.pivothigh() and ta.pivotlow().
Two detection speeds:
Regular Pivots: Use the Right Bars setting to define the confirmation period.
Quick Pivots: Use the Quick Right setting for more sensitive, faster-moving levels.
Source Selection: Choose between using Close price or High/Low values for detection.
B. Level Hierarchy
The script plots eight levels, organized as:
Resistance Levels (Red/Green): Levels 1, 3, 5, 7 (top 4 lines).
Support Levels (Red/Green): Levels 2, 4, 6, 8 (bottom 4 lines).
C. Visual Customization (NEW)
Line Styles: Independently set the style for Resistance and Support lines:
Solid (default for both)
Dotted (uses plot.style_circles)
Dashed (uses plot.style_stepline)
Color Logic: Each level dynamically changes color:
Green: Current close price is above the level (bullish context).
Red: Current close price is below the level (bearish context).
D. Additional Features
show_last=1: Only the most recent segment of each level is shown, keeping the chart clean.
trackprice=true: Extends the line horizontally to the right edge of the chart for easy reference.
3. User Inputs (Customization)
Input Description Default
Left Bars Number of bars to the left of a pivot. 50
Right Bars Number of bars to the right of a pivot (confirmation). 25
Quick Right Faster confirmation period for quick pivots. 5
Source Use Close or High/Low for pivot detection. Close
Resistance Line Style Style for top (resistance) levels. Solid
Support Line Style Style for bottom (support) levels. Solid
4. How to Use
Add the script to any chart.
Adjust Pivot Sensitivity:
Increase Left Bars and Right Bars for longer-term, stronger S/R levels.
Decrease them for more, shorter-term levels.
Use Quick Right to add a more sensitive, faster-responding layer.
Interpret the Levels:
Resistance (top lines): Price may face selling pressure when approaching these levels from below.
Support (bottom lines): Price may find buying pressure when approaching these levels from above.
Green level: Price is currently trading above that level (potentially acting as support).
Red level: Price is currently trading below that level (potentially acting as resistance).
Combine with other tools: Use this as one component of a complete trading strategy, alongside trend indicators, candlestick patterns, or volume analysis.
5. Compliance & Transparency
No Financial Advice: This script is strictly for educational and informational purposes. It does not provide financial advice, trading recommendations, or guaranteed results. All trading decisions are your own responsibility.
Original Work: The code is the original work of the author, based on standard Pine Script pivot functions (ta.pivothigh, ta.pivotlow). It is published under the Mozilla Public License 2.0.
No Guarantee: The accuracy, reliability, or profitability of the detected S/R levels is not guaranteed. Different market conditions may require different parameter adjustments.
6. Technical Notes & Limitations
Version: Converted to Pine Script v6 for optimal performance and future compatibility.
Repainting: Pivot-based levels are non-repainting by nature (ta.pivothigh/low only confirms after the right bars have passed). However, the dynamic coloring reacts to each new bar's close.
Performance: The script is lightweight and runs efficiently on most charts.
7. Credits & Open Source
This script is published under the Mozilla Public License 2.0. You are free to use, modify, and share this code for non-commercial purposes, provided you retain the original license and attribution. No private keys, external dependencies, or hidden functions are included.
This is an automatic Support and Resistance (S/R) level detector for TradingView. It identifies significant price pivots (peaks and troughs) based on user-defined settings and plots up to 8 dynamic levels on your chart.
The script is intended for educational and informational purposes to demonstrate automatic S/R detection using pivot points and to help traders identify potential areas of interest.
2. Key Logic & Features
A. Pivot Detection
The script detects price pivots (local highs and lows) using ta.pivothigh() and ta.pivotlow().
Two detection speeds:
Regular Pivots: Use the Right Bars setting to define the confirmation period.
Quick Pivots: Use the Quick Right setting for more sensitive, faster-moving levels.
Source Selection: Choose between using Close price or High/Low values for detection.
B. Level Hierarchy
The script plots eight levels, organized as:
Resistance Levels (Red/Green): Levels 1, 3, 5, 7 (top 4 lines).
Support Levels (Red/Green): Levels 2, 4, 6, 8 (bottom 4 lines).
C. Visual Customization (NEW)
Line Styles: Independently set the style for Resistance and Support lines:
Solid (default for both)
Dotted (uses plot.style_circles)
Dashed (uses plot.style_stepline)
Color Logic: Each level dynamically changes color:
Green: Current close price is above the level (bullish context).
Red: Current close price is below the level (bearish context).
D. Additional Features
show_last=1: Only the most recent segment of each level is shown, keeping the chart clean.
trackprice=true: Extends the line horizontally to the right edge of the chart for easy reference.
3. User Inputs (Customization)
Input Description Default
Left Bars Number of bars to the left of a pivot. 50
Right Bars Number of bars to the right of a pivot (confirmation). 25
Quick Right Faster confirmation period for quick pivots. 5
Source Use Close or High/Low for pivot detection. Close
Resistance Line Style Style for top (resistance) levels. Solid
Support Line Style Style for bottom (support) levels. Solid
4. How to Use
Add the script to any chart.
Adjust Pivot Sensitivity:
Increase Left Bars and Right Bars for longer-term, stronger S/R levels.
Decrease them for more, shorter-term levels.
Use Quick Right to add a more sensitive, faster-responding layer.
Interpret the Levels:
Resistance (top lines): Price may face selling pressure when approaching these levels from below.
Support (bottom lines): Price may find buying pressure when approaching these levels from above.
Green level: Price is currently trading above that level (potentially acting as support).
Red level: Price is currently trading below that level (potentially acting as resistance).
Combine with other tools: Use this as one component of a complete trading strategy, alongside trend indicators, candlestick patterns, or volume analysis.
5. Compliance & Transparency
No Financial Advice: This script is strictly for educational and informational purposes. It does not provide financial advice, trading recommendations, or guaranteed results. All trading decisions are your own responsibility.
Original Work: The code is the original work of the author, based on standard Pine Script pivot functions (ta.pivothigh, ta.pivotlow). It is published under the Mozilla Public License 2.0.
No Guarantee: The accuracy, reliability, or profitability of the detected S/R levels is not guaranteed. Different market conditions may require different parameter adjustments.
6. Technical Notes & Limitations
Version: Converted to Pine Script v6 for optimal performance and future compatibility.
Repainting: Pivot-based levels are non-repainting by nature (ta.pivothigh/low only confirms after the right bars have passed). However, the dynamic coloring reacts to each new bar's close.
Performance: The script is lightweight and runs efficiently on most charts.
7. Credits & Open Source
This script is published under the Mozilla Public License 2.0. You are free to use, modify, and share this code for non-commercial purposes, provided you retain the original license and attribution. No private keys, external dependencies, or hidden functions are included.
نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
Site: nasalgotrading.com
Youtube: youtube.com/@NasAlgo
Twitter: x.com/NASAlgo
Group: facebook.com/groups/514453124166240
Discord: discord.com/invite/e2BKh6NcRF
t.me/FreeCryptoMoneyEarning
Youtube: youtube.com/@NasAlgo
Twitter: x.com/NASAlgo
Group: facebook.com/groups/514453124166240
Discord: discord.com/invite/e2BKh6NcRF
t.me/FreeCryptoMoneyEarning
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.
نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
Site: nasalgotrading.com
Youtube: youtube.com/@NasAlgo
Twitter: x.com/NASAlgo
Group: facebook.com/groups/514453124166240
Discord: discord.com/invite/e2BKh6NcRF
t.me/FreeCryptoMoneyEarning
Youtube: youtube.com/@NasAlgo
Twitter: x.com/NASAlgo
Group: facebook.com/groups/514453124166240
Discord: discord.com/invite/e2BKh6NcRF
t.me/FreeCryptoMoneyEarning
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.