Indicator · Pine Script v6 · On the chart

Apex Trend & Liquidity Master (SMC)

by app-builder-sketch· code credited to DarkPoolCrypto

Apex Trend & Liquidity Master (SMC) is an overlay indicator that combines trend-following filters with Smart Money Concepts market structure and liquidity tools.

View on GitHub

GitHub stars1on the repository
Pine versionv6current
Lines of code246
Settings21inputs
LicenceGPL-3.0
Last update10 months ago26 Dec 2025

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

246 lines of Pine Script v6 from Apex Series/Apex Trend & Liquidity Master (SMC)/Apex Trend & Liquidity Master (SMC)v7.2.pine, published under GPL-3.0. Keep the author's credit and licence lines when you reuse it.

Apex Trend & Liquidity Master (SMC)v7.2.pine

// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © DarkPoolCrypto

//@version=6
indicator("Apex Trend & Liquidity Master (SMC)v7.2", overlay=true, max_boxes_count=500, max_lines_count=500, max_labels_count=500)

// ════════════════════════════════════════════════════════════════════════════
// 1. SYSTEM CONFIGURATION
// ════════════════════════════════════════════════════════════════════════════

// --- Trend & Signals ---
grp_sig   = "🌊 Trend & Signals (Original)"
// DEFAULT: ON (Ready to trade)
show_sig  = input.bool(true, "Show Buy/Sell Signals", group=grp_sig, tooltip="Restored: Momentum-based entry signals.")
// DEFAULT: ON (Ready to trade)
show_sl   = input.bool(true, "Show Trailing Stop", group=grp_sig, tooltip="Restored: ATR-based trailing stop line.")
ma_type   = input.string("HMA", "Trend Algorithm", options=["EMA", "SMA", "HMA", "RMA"], group=grp_sig, tooltip="Selects baseline formula.")
len_main  = input.int(55, "Trend Length", minval=10, group=grp_sig, tooltip="Lookback period for the main trend.")
mult      = input.float(1.5, "Volatility Multiplier", step=0.1, group=grp_sig, tooltip="Controls cloud width. Higher = Conservative.")
src       = input.source(close, "Source", group=grp_sig, tooltip="Price source.")

// --- Classic Supply & Demand ---
grp_sd    = "🧱 Classic Supply & Demand"
show_sd   = input.bool(true, "Show Swing S/D Zones", group=grp_sd, tooltip="Restored: Original pivot-based liquidity zones.")
liq_len   = input.int(10, "Pivot Lookback", group=grp_sd, tooltip="Sensitivity of pivots.")
sd_ext    = input.int(20, "Extension", group=grp_sd, tooltip="Bars to extend swing zones.")

// --- Smart Money Concepts (SMC) ---
grp_smc   = "🏛️ Smart Money Concepts (New)"
show_bos  = input.bool(true, "Show BOS/CHoCH", group=grp_smc, tooltip="Market Structure Breaks (High Contrast).")
show_ob   = input.bool(true, "Show Order Blocks", group=grp_smc, tooltip="Specific institutional candles (Ghost Mode).")
show_fvg  = input.bool(true, "Show FVG", group=grp_smc, tooltip="Fair Value Gaps (Ghost Mode).")
fvg_mit   = input.bool(true, "Auto-Delete Mitigated", group=grp_smc, tooltip="Cleans up chart by removing tested zones.")

// --- Visual Palette (Distinct Shades) ---
grp_vis   = "🎨 Distinct Color Palette"

// 1. Trend Colors (Deep/Dark)
c_tr_bull = input.color(#00695C, "Trend: Bullish (Deep Teal)", group=grp_vis, tooltip="Used for the Cloud and Bar Colors.")
c_tr_bear = input.color(#B71C1C, "Trend: Bearish (Maroon)", group=grp_vis, tooltip="Used for the Cloud and Bar Colors.")

// 2. Signal/Structure Colors (Bright/Neon)
c_sig_bull = input.color(#00E676, "Action: Bullish (Neon Green)", group=grp_vis, tooltip="Used for Buy Signals, BOS, and Trailing Stop.")
c_sig_bear = input.color(#FF1744, "Action: Bearish (Neon Red)", group=grp_vis, tooltip="Used for Sell Signals, BOS, and Trailing Stop.")

// 3. Classic S/D Colors (Standard)
c_sd_bull = input.color(#43A047, "Classic Demand (Forest)", group=grp_vis, tooltip="Used for Pivot-based Demand Zones.")
c_sd_bear = input.color(#E53935, "Classic Supply (Brick)", group=grp_vis, tooltip="Used for Pivot-based Supply Zones.")

// 4. SMC Colors (Pale/Ghost)
c_smc_bull = input.color(#B9F6CA, "SMC Demand (Pale Mint)", group=grp_vis, tooltip="Used for Order Blocks & FVGs (High Transparency).")
c_smc_bear = input.color(#FFCDD2, "SMC Supply (Pale Rose)", group=grp_vis, tooltip="Used for Order Blocks & FVGs (High Transparency).")


// ════════════════════════════════════════════════════════════════════════════
// 2. TREND & SIGNALS ENGINE
// ════════════════════════════════════════════════════════════════════════════

// --- Dynamic MA ---
get_ma(t, s, l) =>
    t == "SMA" ? ta.sma(s, l) : t == "EMA" ? ta.ema(s, l) : t == "HMA" ? ta.hma(s, l) : ta.rma(s, l)

baseline = get_ma(ma_type, src, len_main)
atr      = ta.atr(len_main)
upper    = baseline + (atr * mult)
lower    = baseline - (atr * mult)

var int trend = 0
if close > upper
    trend := 1
else if close < lower
    trend := -1

// --- Signal Filters (ADX + Momentum) ---
[di_plus, di_minus, adx] = ta.dmi(14, 14)
adx_ok = adx > 20

// WaveTrend Calculation
ap = hlc3, esa = ta.ema(ap, 10), d = ta.ema(math.abs(ap - esa), 10)
ci = (ap - esa) / (0.015 * d), tci = ta.ema(ci, 21)
mom_buy = tci < 60
mom_sell = tci > -60

// Volume Filter
vol_avg = ta.sma(volume, 20)
vol_ok = volume > vol_avg

// Signal Logic
sig_buy  = trend == 1 and trend[1] != 1 and vol_ok and mom_buy and adx_ok
sig_sell = trend == -1 and trend[1] != -1 and vol_ok and mom_sell and adx_ok

// --- Trailing Stop ---
var float trail_stop = na
trail_atr = ta.atr(14) * 2.0
if trend == 1
    trail_stop := math.max(nz(trail_stop, close), close - trail_atr)
    if trend[1] == -1 
        trail_stop := close - trail_atr
else if trend == -1
    trail_stop := math.min(nz(trail_stop, close), close + trail_atr)
    if trend[1] == 1 
        trail_stop := close + trail_atr

// ════════════════════════════════════════════════════════════════════════════
// 3. CLASSIC SUPPLY & DEMAND (PIVOTS)
// ════════════════════════════════════════════════════════════════════════════

ph = ta.pivothigh(high, liq_len, liq_len)
pl = ta.pivotlow(low, liq_len, liq_len)

var box[] sd_zones = array.new_box()
manage_zones(arr, lim) =>
    if array.size(arr) > lim
        box.delete(array.shift(arr))

if not na(ph) and show_sd
    // Classic Supply: Solid Standard Colors
    b = box.new(bar_index - liq_len, high[liq_len], bar_index + sd_ext, math.max(open[liq_len], close[liq_len]), 
         border_color=color.new(c_sd_bear, 50), bgcolor=color.new(c_sd_bear, 70), 
         text="Supply", text_color=color.new(color.white, 20), text_size=size.tiny)
    array.push(sd_zones, b)
    manage_zones(sd_zones, 10)

if not na(pl) and show_sd
    // Classic Demand: Solid Standard Colors
    b = box.new(bar_index - liq_len, low[liq_len], bar_index + sd_ext, math.min(open[liq_len], close[liq_len]), 
         border_color=color.new(c_sd_bull, 50), bgcolor=color.new(c_sd_bull, 70), 
         text="Demand", text_color=color.new(color.white, 20), text_size=size.tiny)
    array.push(sd_zones, b)
    manage_zones(sd_zones, 10)

// ════════════════════════════════════════════════════════════════════════════
// 4. SMC LOGIC (BOS / CHoCH / OB / FVG)
// ════════════════════════════════════════════════════════════════════════════

// --- Active Structure Tracking ---
var float last_ph = na
var float last_pl = na
var float lower_high = na
var float higher_low = na

if not na(ph)
    last_ph := high[liq_len]
    if trend == -1
        lower_high := last_ph
if not na(pl)
    last_pl := low[liq_len]
    if trend == 1
        higher_low := last_pl

x_ph = ta.crossover(close, last_ph)
x_pl = ta.crossunder(close, last_pl)
x_lh = ta.crossover(close, lower_high)
x_hl = ta.crossunder(close, higher_low)

// --- Visualizing BOS & CHoCH (Uses Neon Signal Colors) ---
if show_bos
    if trend == 1 and x_ph
        line.new(bar_index - 10, last_ph, bar_index, last_ph, color=c_sig_bull, style=line.style_solid, width=2)
        label.new(bar_index, last_ph, "BOS", color=color(na), textcolor=c_sig_bull, style=label.style_none, size=size.normal)
    if trend == -1 and x_pl
        line.new(bar_index - 10, last_pl, bar_index, last_pl, color=c_sig_bear, style=line.style_solid, width=2)
        label.new(bar_index, last_pl, "BOS", color=color(na), textcolor=c_sig_bear, style=label.style_none, size=size.normal)
    if trend == -1 and x_lh
        line.new(bar_index - 10, lower_high, bar_index, lower_high, color=c_sig_bull, style=line.style_solid, width=2)
        label.new(bar_index, lower_high, "CHoCH", color=color(na), textcolor=c_sig_bull, style=label.style_none, size=size.normal)
        higher_low := low 
    if trend == 1 and x_hl
        line.new(bar_index - 10, higher_low, bar_index, higher_low, color=c_sig_bear, style=line.style_solid, width=2)
        label.new(bar_index, higher_low, "CHoCH", color=color(na), textcolor=c_sig_bear, style=label.style_none, size=size.normal)
        lower_high := high 

// --- Order Blocks & FVGs (Uses Pale SMC Colors) ---
var box[] ob_zones = array.new_box()
var box[] fvg_zones = array.new_box()

// OB Logic
if trend == 1 and x_ph and show_ob
    for i = 1 to 20
        if close[i] < open[i]
            array.push(ob_zones, box.new(bar_index[i], high[i], bar_index + sd_ext, low[i], border_color=na, bgcolor=color.new(c_smc_bull, 80)))
            manage_zones(ob_zones, 5)
            break
if trend == -1 and x_pl and show_ob
    for i = 1 to 20
        if close[i] > open[i]
            array.push(ob_zones, box.new(bar_index[i], high[i], bar_index + sd_ext, low[i], border_color=na, bgcolor=color.new(c_smc_bear, 80)))
            manage_zones(ob_zones, 5)
            break

// FVG Logic
atr_c = ta.atr(14)
fvg_b = (low > high[2]) and (low - high[2] > atr_c * 0.5)
fvg_s = (high < low[2]) and (low[2] - high > atr_c * 0.5)

if show_fvg
    if fvg_b
        array.push(fvg_zones, box.new(bar_index[2], high[2], bar_index + sd_ext, low, border_color=na, bgcolor=color.new(c_smc_bull, 80)))
    if fvg_s
        array.push(fvg_zones, box.new(bar_index[2], low[2], bar_index + sd_ext, high, border_color=na, bgcolor=color.new(c_smc_bear, 80)))
    manage_zones(fvg_zones, 10)

// Mitigation
if fvg_mit
    if array.size(ob_zones) > 0
        for i = array.size(ob_zones) - 1 to 0
            b = array.get(ob_zones, i), bt = box.get_top(b), bb = box.get_bottom(b)
            if (close > bt and bt > bb) or (close < bb and bb < bt)
                box.delete(b), array.remove(ob_zones, i)
            else
                box.set_right(b, bar_index + 5)
    if array.size(fvg_zones) > 0
        for i = array.size(fvg_zones) - 1 to 0
            b = array.get(fvg_zones, i), bt = box.get_top(b), bb = box.get_bottom(b)
            if (close > bt and bt > bb) or (close < bb and bb < bt)
                box.delete(b), array.remove(fvg_zones, i)
            else
                box.set_right(b, bar_index + 5)

// ════════════════════════════════════════════════════════════════════════════
// 5. PLOTTING
// ════════════════════════════════════════════════════════════════════════════

// Trend Cloud (Deep Context Colors - Dynamic)
p1 = plot(upper, display=display.none)
p2 = plot(lower, display=display.none)
// FIXED: Cloud color switches fully based on Trend
c_cloud_fill = trend == 1 ? color.new(c_tr_bull, 85) : color.new(c_tr_bear, 85)
fill(p1, p2, color=c_cloud_fill, title="Trend Cloud")

// Trailing Stop (Neon Action Colors)
plot(show_sl ? trail_stop : na, "Trailing Stop", color=trend==1?c_sig_bull:c_sig_bear, style=plot.style_linebr, linewidth=2)

// Signals (Neon Action Colors)
if show_sig and sig_buy
    label.new(bar_index, low, "BUY", color=c_sig_bull, textcolor=color.white, style=label.style_label_up, size=size.small)
if show_sig and sig_sell
    label.new(bar_index, high, "SELL", color=c_sig_bear, textcolor=color.white, style=label.style_label_down, size=size.small)

// Bar Color (Deep Context Colors)
barcolor(trend == 1 ? c_tr_bull : trend == -1 ? c_tr_bear : na)

// Alerts
alertcondition(sig_buy, "Apex Buy Signal", "Trend Following Buy Signal")
alertcondition(sig_sell, "Apex Sell Signal", "Trend Following Sell Signal")

Overview

Apex Trend & Liquidity Master (SMC) calculates baseline trend clouds using moving averages such as HMA, EMA, SMA, or RMA alongside volatility bands, providing momentum-based buy and sell signals with an ATR trailing stop. It also maps classic pivot supply and demand zones, break of structure (BOS), change of character (CHoCH), order blocks, and fair value gaps with auto-mitigation cleanup.

Details

Published by

app-builder-sketch on GitHub

Code credit

DarkPoolCrypto, as written in the script's header

Type

Indicator, Pine Script v6

Draws

On the price chart

Category

SMC / ICT / price action, Trend, Support & resistance, Moving averages

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
Show Buy/Sell Signalsbooltrueshow_sig
Show Trailing Stopbooltrueshow_sl
Trend AlgorithmstringHMAma_type
Trend Lengthint55len_main
Volatility Multiplierfloat1.5mult
Sourcesourceclosesrc
Show Swing S/D Zonesbooltrueshow_sd
Pivot Lookbackint10liq_len
Extensionint20sd_ext
Show BOS/CHoCHbooltrueshow_bos
Show Order Blocksbooltrueshow_ob
Show FVGbooltrueshow_fvg
Show all 21 settings
SettingTypeDefaultVariable
Auto-Delete Mitigatedbooltruefvg_mit
Trend: Bullish (Deep Teal)color#00695Cc_tr_bull
Trend: Bearish (Maroon)color#B71C1Cc_tr_bear
Action: Bullish (Neon Green)color#00E676c_sig_bull
Action: Bearish (Neon Red)color#FF1744c_sig_bear
Classic Demand (Forest)color#43A047c_sd_bull
Classic Supply (Brick)color#E53935c_sd_bear
SMC Demand (Pale Mint)color#B9F6CAc_smc_bull
SMC Supply (Pale Rose)color#FFCDD2c_smc_bear
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

HH-LL Buy/Sell + EMA

by vinitpatil519
5 stars

This overlay indicator classifies market structure with an ATR-based ZigZag that marks higher highs, higher lows, lower highs, and lower lows. A state machine plots buy and sell labels on the confirmation bar, not on the earlier pivot, and by default waits for

Indicator v5 TrendSupport & resistance
Updated 2 months ago · None stated GitHub repository of HH-LL Buy/Sell + EMA
4 stars

This indicator computes the Watchtower Axis as a 257-period weighted moving average of closing prices to establish the main trend baseline. It defines volatility gates using the highest high and lowest low over 463 periods, along with a 377-period exponential

Indicator v6 TrendMoving averages
Updated 10 months ago · MIT GitHub repository of Miela Labs | John Dee's Watchtower

This indicator identifies Smart Money Concepts structure alongside a four-line moving average ribbon on the price chart. It detects swing highs and lows across a user-defined lookback period, generating price action labels such as higher highs, lower highs, hi

Indicator v5 SMC / ICT / price actionSupport & resistance
Updated 1 year ago · None stated GitHub repository of FluidTrades - SMC Lite + Moving Average Ribbon

GODMODE Dashboard

by EricMohlathe
2 stars

This indicator visualises multiple smart money concepts and technical analysis modules directly on the price chart. It plots trend EMAs, VWAP bands with standard deviations, market structure breaks and changes of character, Fair Value Gaps, Order Blocks, suppl

Indicator v5 SMC / ICT / price actionSupport & resistance Repaints
Updated 2 months ago · None stated GitHub repository of GODMODE Dashboard

EMA + Trend + Liquidity

by kvmafthab-pixel
1 stars

This overlay plots a four-length exponential moving average ribbon and classifies trend on the price chart. It marks strong bullish when the 21-period average is above the 50 and 200 with a positive short slope, strong bearish when that stack is reversed, and

Indicator v5 TrendMoving averages
Updated 5 months ago · Custom licence GitHub repository of EMA + Trend + Liquidity
575 stars

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

Indicator v5 Support & resistanceTrend
Updated 1 year ago · MPL-2.0 GitHub repository of ICT Equal Highs and Lows with Screener

More indicators

Trade Your Charts With a Regulated Broker

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

Compare brokers