Indicator · Pine Script v5 · On the chart

Flux Lab SMC

by darup67

A smart money concepts overlay that marks swing-based break of structure and change of character, order blocks that are removed once broken, fair value gaps above a minimum ATR size, equal highs and lows within a tolerance, and a premium and discount equilibrium.

View on GitHub

GitHub stars1on the repository
Pine versionv5runs as is
Lines of code135
Settings11inputs
LicenceMIT
Last update3 weeks ago7 Oct 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

135 lines of Pine Script v5 from pine/flux_smc.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

flux_smc.pine
//@version=5
// Flux Lab SMC — FluxCharts-style Smart Money Concepts suite
// Structure (BOS / CHoCH), order blocks, fair value gaps, equal highs/lows,
// premium/discount zones and confluence buy/sell signals.
indicator("Flux Lab SMC", overlay = true, max_boxes_count = 200, max_lines_count = 200, max_labels_count = 200)

swingLen   = input.int(5, "Swing length", minval = 2)
showOB     = input.bool(true, "Order blocks")
obMax      = input.int(5, "Max active order blocks", minval = 1)
showFVG    = input.bool(true, "Fair value gaps")
fvgMinAtr  = input.float(0.2, "Min FVG size (x ATR)", step = 0.05)
showEQ     = input.bool(true, "Equal highs / lows")
eqTolAtr   = input.float(0.1, "EQH/EQL tolerance (x ATR)", step = 0.05)
showPD     = input.bool(true, "Premium / discount")
showSig    = input.bool(true, "Buy / sell signals")
bullCol    = input.color(color.new(#089981, 0), "Bull color")
bearCol    = input.color(color.new(#f23645, 0), "Bear color")

atr = ta.atr(14)

// ---------- swings & structure ----------
ph = ta.pivothigh(high, swingLen, swingLen)
pl = ta.pivotlow(low, swingLen, swingLen)

var float lastHigh = na
var float lastLow  = na
var int   lastHighBar = na
var int   lastLowBar  = na
var bool  hiBroken = true
var bool  loBroken = true
var int   trend = 0   // 1 bull, -1 bear
var float prevHigh = na
var float prevLow  = na

if not na(ph)
    prevHigh := lastHigh
    lastHigh := ph
    lastHighBar := bar_index - swingLen
    hiBroken := false
    if showEQ and not na(prevHigh) and math.abs(ph - prevHigh) <= eqTolAtr * atr
        label.new(lastHighBar, ph, "EQH", style = label.style_label_down, color = color.new(bearCol, 80), textcolor = bearCol, size = size.tiny)
if not na(pl)
    prevLow := lastLow
    lastLow := pl
    lastLowBar := bar_index - swingLen
    loBroken := false
    if showEQ and not na(prevLow) and math.abs(pl - prevLow) <= eqTolAtr * atr
        label.new(lastLowBar, pl, "EQL", style = label.style_label_up, color = color.new(bullCol, 80), textcolor = bullCol, size = size.tiny)

bullBreak = not hiBroken and not na(lastHigh) and close > lastHigh
bearBreak = not loBroken and not na(lastLow)  and close < lastLow

// ---------- order blocks ----------
var array<box> bullOBs = array.new<box>()
var array<box> bearOBs = array.new<box>()

f_lastCandle(bool wantBear, int fromBar) =>
    // most recent opposite-colored candle between the swing and now
    int idx = na
    for i = 1 to math.max(1, bar_index - fromBar)
        if wantBear ? close[i] < open[i] : close[i] > open[i]
            idx := i
            break
    idx

if bullBreak
    label.new(bar_index, lastHigh, trend == -1 ? "CHoCH" : "BOS", style = label.style_label_down, color = color.new(bullCol, 100), textcolor = bullCol, size = size.small)
    line.new(lastHighBar, lastHigh, bar_index, lastHigh, color = bullCol, style = line.style_dashed)
    trend := 1
    hiBroken := true
    if showOB
        i = f_lastCandle(true, lastHighBar)
        if not na(i)
            array.push(bullOBs, box.new(bar_index - i, high[i], bar_index + 20, low[i], border_color = bullCol, bgcolor = color.new(bullCol, 85), extend = extend.right))
            if array.size(bullOBs) > obMax
                box.delete(array.shift(bullOBs))

if bearBreak
    label.new(bar_index, lastLow, trend == 1 ? "CHoCH" : "BOS", style = label.style_label_up, color = color.new(bearCol, 100), textcolor = bearCol, size = size.small)
    line.new(lastLowBar, lastLow, bar_index, lastLow, color = bearCol, style = line.style_dashed)
    trend := -1
    loBroken := true
    if showOB
        i = f_lastCandle(false, lastLowBar)
        if not na(i)
            array.push(bearOBs, box.new(bar_index - i, high[i], bar_index + 20, low[i], border_color = bearCol, bgcolor = color.new(bearCol, 85), extend = extend.right))
            if array.size(bearOBs) > obMax
                box.delete(array.shift(bearOBs))

// mitigate (remove) invalidated blocks; detect retests
bool obBullTouch = false
bool obBearTouch = false
if array.size(bullOBs) > 0
    for j = array.size(bullOBs) - 1 to 0
        b = array.get(bullOBs, j)
        if close < box.get_bottom(b)
            box.delete(b)
            array.remove(bullOBs, j)
        else if low <= box.get_top(b) and close > box.get_bottom(b)
            obBullTouch := true
if array.size(bearOBs) > 0
    for j = array.size(bearOBs) - 1 to 0
        b = array.get(bearOBs, j)
        if close > box.get_top(b)
            box.delete(b)
            array.remove(bearOBs, j)
        else if high >= box.get_bottom(b) and close < box.get_top(b)
            obBearTouch := true

// ---------- fair value gaps ----------
bullFVG = low > high[2] and (low - high[2]) >= fvgMinAtr * atr
bearFVG = high < low[2] and (low[2] - high) >= fvgMinAtr * atr
if showFVG and bullFVG
    box.new(bar_index - 2, low, bar_index + 10, high[2], border_color = na, bgcolor = color.new(bullCol, 80), text = "FVG", text_color = bullCol, text_size = size.tiny)
if showFVG and bearFVG
    box.new(bar_index - 2, low[2], bar_index + 10, high, border_color = na, bgcolor = color.new(bearCol, 80), text = "FVG", text_color = bearCol, text_size = size.tiny)

// ---------- premium / discount ----------
rangeHi = ta.highest(high, 100)
rangeLo = ta.lowest(low, 100)
eq = (rangeHi + rangeLo) / 2
plot(showPD ? eq : na, "Equilibrium", color = color.new(color.gray, 40), style = plot.style_linebr)
inDiscount = close < eq
inPremium  = close > eq

// ---------- signals: trend + OB retest + zone ----------
buySig  = showSig and trend == 1  and obBullTouch and inDiscount and close > open
sellSig = showSig and trend == -1 and obBearTouch and inPremium  and close < open
plotshape(buySig,  "Buy",  shape.labelup,   location.belowbar, bullCol, text = "BUY",  textcolor = color.white, size = size.small)
plotshape(sellSig, "Sell", shape.labeldown, location.abovebar, bearCol, text = "SELL", textcolor = color.white, size = size.small)

alertcondition(bullBreak, "Bullish BOS/CHoCH", "Flux Lab: bullish structure break on {{ticker}}")
alertcondition(bearBreak, "Bearish BOS/CHoCH", "Flux Lab: bearish structure break on {{ticker}}")
alertcondition(buySig,  "Flux Buy",  "Flux Lab BUY {{ticker}} @ {{close}}")
alertcondition(sellSig, "Flux Sell", "Flux Lab SELL {{ticker}} @ {{close}}")

Overview

Buy and sell signals appear when trend, an order block retest, the discount or premium zone and a confirming candle agree. Swing length, limits and colors are adjustable, and alerts are included.

Details

Published by

darup67 on GitHub

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.

Settings

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

SettingTypeDefaultVariable
Swing lengthint5swingLen
Order blocksbooltrueshowOB
Max active order blocksint5obMax
Fair value gapsbooltrueshowFVG
Min FVG size (x ATR)float0.2fvgMinAtr
Equal highs / lowsbooltrueshowEQ
EQH/EQL tolerance (x ATR)float0.1eqTolAtr
Premium / discountbooltrueshowPD
Buy / sell signalsbooltrueshowSig
Bull colorcolorcolor.new(#089981, 0)bullCol
Bear colorcolorcolor.new(#f23645, 0)bearCol
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
303 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 2 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 3 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 2 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 2 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