Indicator · Pine Script v5 · On the chart

Market Structure (Breakers) [LuxAlgo]

by theonetrade· code credited to LuxAlgo

Market Structure (Breakers) tracks pivot highs and lows to detect bullish and bearish market structure breaks and shifts.

View on GitHub

GitHub stars34on the repository
Pine versionv5runs as is
Lines of code164
Settings7inputs
LicenceMIT
Last update2 weeks ago8 Nov 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

164 lines of Pine Script v5 from assets/indicator/bit-exact/market_structure_breakers_luxalgo_cONRD5q4.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

market_structure_breakers_luxalgo_cONRD5q4.pine
// This work is licensed under a Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) https://creativecommons.org/licenses/by-nc-sa/4.0/
// © LuxAlgo

//@version=5
indicator("Market Structure (Breakers) [LuxAlgo]", overlay = true, max_lines_count = 500, max_labels_count = 500)
//-----------------------------------------------------------------------------}
//Settings
//-----------------------------------------------------------------------------{
length = input.int(20, 'Swings Period', minval = 2)
breaks = input.int(1, 'Maximum Breaks', minval = 1)
maxDuration = input(1000, 'Breaker Maximum Duration')

//Style
bullCss = input(#089981, 'Bullish MS', inline = 'bull', group = 'Style')
bullBreakCss = input(#f23645, 'Breaker', inline = 'bull', group = 'Style')

bearCss = input(#f23645, 'Bearish MS', inline = 'bear', group = 'Style')
bearBreakCss = input(#089981, 'Breaker', inline = 'bear', group = 'Style')

//-----------------------------------------------------------------------------}
//UDT
//-----------------------------------------------------------------------------{
type breaker
    line level
    int  breaks = 0

//-----------------------------------------------------------------------------}
//Bullish Breaker
//-----------------------------------------------------------------------------{
var phx = 0  
var phcross = false
var bullms = array.new<breaker>(0)
var os = 0

n = bar_index
ph = fixnan(ta.pivothigh(length, length))

if ph != ph[1]
    phx := n-length
    phcross := false

//Test for bullish market structure
if close > ph and not phcross
    line.new(phx, ph, n, ph, color = bullCss)
    
    //MS label
    label.new(int(math.avg(phx, n)), ph, os == -1 ? 'MSS' : 'MSB'
      , textcolor = bullCss
      , color = color(na)
      , size = size.small
      , style = label.style_label_down)

    bullms.unshift(breaker.new(line.new(n, ph, n, ph, color = bullBreakCss, style = line.style_dotted)))
    phcross := true

    if bullms.size() > 100
        bullms.pop()
    
    os := 1

//Iterate trough existing bullish structures and test for breaks
break_down = false

if bullms.size() > 0
    for i = bullms.size()-1 to 0
        get = bullms.get(i)
        get.level.set_x2(n)
        
        if close < get.level.get_y2() and open > get.level.get_y2()
            get.breaks += 1

            if get.breaks == breaks
                bullms.remove(i)
                break_down := true

        else if (n - get.level.get_x1()) >= maxDuration
            bullms.remove(i).level.delete()

//Support events
support = false
if bullms.size() > 0
    lvl = bullms.get(0).level.get_y2()

    support := low < lvl and math.min(close, open) > lvl

//-----------------------------------------------------------------------------}
//Bearish Breaker
//-----------------------------------------------------------------------------{
var plx = 0  
var plcross = false
var bearms = array.new<breaker>(0)

pl = fixnan(ta.pivotlow(length, length))

if pl != pl[1]
    plx := n-length
    plcross := false

//Test for bearish market structure
if close < pl and not plcross
    line.new(plx, pl, n, pl, color = bearCss)

    //MS label
    label.new(int(math.avg(plx, n)), pl, os == 1 ? 'MSS' : 'MSB'
      , textcolor = bearCss
      , color = color(na)
      , size = size.small
      , style = label.style_label_up)

    bearms.unshift(breaker.new(line.new(n, pl, n, pl, color = bearBreakCss, style = line.style_dotted)))
    plcross := true

    if bearms.size() > 100
        bearms.pop()
    
    os := -1

//Iterate trough existing bearish structures and test for breaks
break_up = false

if bearms.size() > 0
    for i = bearms.size()-1 to 0
        get = bearms.get(i)
        get.level.set_x2(n)
        
        if close > get.level.get_y2() and open < get.level.get_y2()
            get.breaks += 1

            if get.breaks == breaks
                bearms.remove(i)
                break_up := true
        else if (n - get.level.get_x1()) >= maxDuration
            bearms.remove(i).level.delete()

//Resistance events
resistance = false
if bearms.size() > 0
    lvl = bearms.get(0).level.get_y2()

    resistance := high > lvl and math.max(close, open) < lvl

//-----------------------------------------------------------------------------}
//Plots
//-----------------------------------------------------------------------------{
plotchar(break_up, 'Bull MSB Breakout', '▲', location.belowbar, #089981)
plotchar(break_down, 'Bear MSB Breakout', '▼', location.abovebar, #f23645)

//Support events
plotcandle(high, high, low, low
  , 'Support Events'
  , na
  , na
  , bordercolor = support ? #089981 : na
  , display = display.all - display.status_line)

//Resistance events
plotcandle(high, high, low, low
  , 'Resistance Events'
  , na
  , na
  , bordercolor = resistance ? #f23645 : na
  , display = display.all - display.status_line)

//-----------------------------------------------------------------------------}

Overview

Market Structure (Breakers) [LuxAlgo] plots support and resistance lines directly on the price chart alongside breaker zones, extending dotted lines that track potential breaker levels until they are invalidated by a customizable maximum duration or number of price breaks.

Details

Published by

theonetrade on GitHub

Code credit

LuxAlgo, as written in the script's header

Draws

On the price chart

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Topics

algorithmic-tradingbacktestingbitcoinccxtcrypto-tradingllm-agentoffline-backtestingopen-source-tradingpine-scriptpine-to-pythonpinescriptpynecorepythonquantquantitative-financestrategy-backtestingtechnical-analysistrading-indicatorstrading-strategiestradingview

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
Swings Periodint20length
Maximum Breaksint1breaks
Breaker Maximum Durationint1000maxDuration
Bullish MScolor#089981bullCss
Breakercolor#f23645bullBreakCss
Bearish MScolor#f23645bearCss
Breakercolor#089981bearBreakCss
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.

Similar Pine Scripts

ICT Equal Highs and Lows

by ArunKBhaskar
575 stars

This overlay indicator finds pivot highs and lows on the price chart and compares the last two highs and the last two lows. When the percentage difference between a pair is below the Equal HL threshold, it treats them as equal levels and draws a box. Left and

Indicator v5 SMC / ICT / price actionSupport & resistance
Updated 1 year ago · MPL-2.0 GitHub repository of ICT Equal Highs and Lows

DE-tracker

by Allen1212
302 stars

This indicator plots labels on the TradingView price chart to mark ARK Invest's buy and sell trades for the DE stock. Buy transactions appear in green with X1 or X2 multipliers showing the number of ARK ETFs involved on the same day; sells appear in red. The m

Indicator v4 Support & resistanceSMC / ICT / price action
Updated 3 years ago · None stated GitHub repository of DE-tracker

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

Indicator v4 TrendSupport & resistance

Golden Bullet Strategy

by TradersPost
228 stars

The Golden Bullet Strategy is an overlay signal indicator based on Smart Money Concepts and time-based liquidity models. It identifies liquidity sweeps of a designated reference session range during a specified hunt window. It then confirms Market Structure Sh

Indicator v6 SMC / ICT / price actionSessions & time
Updated 4 months ago · None stated GitHub repository of Golden Bullet Strategy

Open Source Fractal

by cantolab
183 stars

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

Indicator v6 SMC / ICT / price actionSupport & resistance
Updated 3 months ago · MIT GitHub repository of Open Source Fractal

Swing Failure Signals

by Ganador1
154 stars

This indicator calculates pivot highs and pivot lows to detect liquidity sweeps and Swing Failure Patterns. It identifies when price breaks past recent key swing highs or lows within a configurable historical window, then looks for a quick reversal or change i

Indicator v6 SMC / ICT / price actionSupport & resistance
Updated 3 months ago · Apache-2.0 GitHub repository of Swing Failure Signals

More SMC / ICT scripts

Related on ForexR

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers