1Copy the scriptPress Copy script above, or the copy button on the code below.
2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.
Source Code
374 lines of Pine Script v5 from indicators/market_structure_sr.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.
Using configurable swing lengths, it identifies swing highs and lows to classify higher highs, higher lows, lower highs, and lower lows. It aggregates pivot touches within a user-defined percentage tolerance to construct dynamic support and resistance levels, highlighting breakouts when price breaches them. Settings allow customizing lookback periods, minimum touch counts, zone limits, and line extensions.
Swing high and low pivot detection
Market structure classification with HH and LL labels
Automated support and resistance zones based on touch counts
Support and resistance break signaling
Optional trend line display and rightward zone extensions
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
Swing Detection Length
int
5
swing_length
Show Swing Points
bool
true
show_swings
Show HH/LL Labels
bool
true
show_structure_labels
Show Trend Lines
bool
true
show_trendlines
S/R Lookback Period
int
100
sr_lookback
Touch Tolerance %
float
0.5
sr_touch_tolerance
Max S/R Zones
int
5
max_sr_zones
Min Touches
int
2
sr_strength_min
Show S/R Zones
bool
true
show_sr_zones
Show S/R Breaks
bool
true
show_sr_breaks
Extend Zones Right
bool
true
zone_extend
Swing High
color
color.new(color.red, 0)
swing_high_color
Show all 16 settings
Setting
Type
Default
Variable
Swing Low
color
color.new(color.green, 0)
swing_low_color
Resistance Zone
color
color.new(color.red, 80)
resistance_color
Support Zone
color
color.new(color.green, 80)
support_color
Break Signal
color
color.new(color.orange, 0)
break_color
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.
This indicator detects equal highs and lows by comparing prices within user-defined left and right bars using a tolerance percentage. It plots horizontal lines on the price chart for equal highs in one color and lows in another. A screener allows input of mult
This Pine Script indicator plots a ZigZag on the price chart. It identifies reversal points when price moves more than a set percentage from the last pivot. The script calculates forecasts using zigzag data and labels detected geometric patterns including harm
This indicator plots market structure on the price chart by identifying swing highs and lows. It connects these points with lines to visualize trend direction and detect Break of Structure (BOS) when price breaks a prior swing in the current trend. Change of C
This indicator implements the Fractal Model concept to plot market structure shifts, liquidity sweeps, and Change in State of Delivery (CISD) levels. It overlays custom higher-timeframe candle previews, open prices, and time markers directly on the price chart
BigBeluga Smart Money Concepts identifies and overlays market structure and volumetric order blocks directly on the price chart. It analyzes market swings, trend sweeps, and mapping structure using customizable pivot lengths and calculation modes. The indicato
Apex Trend & Liquidity Master calculates a trend cloud using customizable moving averages expanded by a volatility multiplier directly on the main price chart. It identifies dynamic support and resistance liquidity zones from swing high and low pivots, extendi