PROTECTED SOURCE SCRIPT

Support and Resistance Price Action [sma]

36
Overview
This indicator identifies and visualizes key support and resistance levels based on price action analysis. It automatically detects significant pivot points and displays them as zones or lines on your chart, helping traders identify potential areas of price reversal or continuation.
Key Features
Dynamic Level Detection

Automatically identifies support and resistance levels based on confirmed pivot highs and lows
Uses a configurable pivot length to ensure reliability of detected levels
Filters levels based on historical price touches for validation

Visual Representation

Zone Display: Shows support/resistance as semi-transparent boxes (default)
Line Display: Alternative option to display levels as horizontal lines
Pivot Markers: Highlights recent confirmed pivot points
Customizable colors for all visual elements

Intelligent Level Management

Removes duplicate levels that are too close together (within 0.5% by default)
Automatically removes broken levels when price crosses through them (optional)
Limits the maximum number of displayed levels to avoid chart clutter
Only shows levels relevant to current price action (within 0.5% of current price)

How It Works
Pivot Detection
The indicator scans historical bars to identify valid pivot highs and lows. A pivot high is confirmed when the high of a candle is higher than surrounding candles on both sides. The same logic applies inversely for pivot lows. The number of bars required for confirmation is adjustable.
Level Strength Calculation
Each detected level is assigned a strength value based on how many times price has touched or approached that level in the past. Levels with higher strength (more touches) are considered more significant and can be displayed with thicker lines.
Zone Width
Support and resistance zones have an adjustable width (default 0.5% of price), recognizing that these levels often act as areas rather than exact price points. This tolerance helps account for wicks, spreads, and normal price volatility.
Break Detection
When enabled, the indicator removes levels once price closes beyond them, keeping your chart clean and focused on currently relevant levels. A resistance level is considered broken when price closes above it, and a support level is broken when price closes below it.
Input Parameters
Pivot Length (3-20, default 7): Number of bars on each side required to confirm a pivot point. Higher values produce fewer but more reliable pivots.
Maximum S/R Levels (5-20, default 10): Maximum number of support and resistance levels to display simultaneously.
Minimum Strength (1-5, default 2): Minimum number of historical touches required for a level to be displayed.
Zone Width % (0.1-2.0, default 0.5): Width of support/resistance zones as a percentage of price.
Show Zones: Toggle between zone boxes or simple lines.
Mark Breaks: Automatically remove levels when price breaks through them.
Show Pivots: Display lines marking recent confirmed pivot points.
Pivot Lines to Display (3-15, default 6): Number of recent pivot points to mark on the chart.
Use Cases

Breakout Trading: Identify key levels where price might break out with momentum
Range Trading: Spot potential reversal zones within established ranges
Entry/Exit Planning: Use levels to plan strategic entry and exit points
Stop Loss Placement: Position stops beyond significant support/resistance levels

Important Notes

This indicator is designed for educational and informational purposes
Past performance of support and resistance levels does not guarantee future results
Always combine with other forms of analysis and risk management
The indicator works on all timeframes and instruments
Results may vary based on input settings and market conditions

Technical Details

Maximum 500 lines and 500 boxes can be displayed (TradingView limitation)
Compatible with TradingView Pine Script version 6
Overlay indicator (displays directly on price chart)
Updates in real-time as new bars form


This indicator does not provide financial advice. All trading decisions are the responsibility of the user. Always practice proper risk management and never risk more than you can afford to lose.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.