Indicator · Pine Script v6 · On the chart

Apex Trend & Liquidity Master

by Ahmed-GoCode· code credited to Ahmed - Quant-Edge Indicators

Apex Trend & Liquidity Master calculates a trend cloud using customizable moving averages expanded by a volatility multiplier directly on the main price chart.

View on GitHub

GitHub stars53on the repository
Pine versionv6current
Lines of code220
Settings18inputs
LicenceMPL-2.0
Last update2 months ago17 Aug 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

220 lines of Pine Script v6 from Quant-Edge-Indicators/Smart Money & Liquidity/Apex Trend.pinescript, published under MPL-2.0. Keep the author's credit and licence lines when you reuse it.

Apex Trend.pinescript
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Ahmed - Quant-Edge Indicators
//@version=6
indicator("Apex Trend & Liquidity Master ", overlay=true, max_boxes_count=50, max_lines_count=50)

// ════════════════════════════════════════════════════════════════════════════
// 1. SYSTEM CONFIGURATION & INPUTS
// ════════════════════════════════════════════════════════════════════════════

// --- Trend Engine Settings ---
grp_trend = "🌊 Trend Architecture"
ma_type   = input.string("HMA", "Trend Algorithm", options=["EMA", "SMA", "HMA", "RMA"], group=grp_trend)
len_main  = input.int(55, "Trend Length", minval=10, group=grp_trend)
mult      = input.float(1.5, "Volatility Multiplier", step=0.1, group=grp_trend, tooltip="Expands/contracts the cloud based on market volatility.")
src       = input.source(close, "Source", group=grp_trend)

// --- Liquidity & Structure ---
grp_liq   = "🧱 Liquidity & Structure"
show_liq  = input.bool(true, "Show Smart Liquidity Zones", group=grp_liq)
liq_len   = input.int(10, "Pivot Lookback", group=grp_liq, tooltip="Sensitivity for finding Swing Highs/Lows.")
zone_ext  = input.int(5, "Zone Extension", group=grp_liq)

// --- Filter Logic ---
grp_filt  = "🛡️ Signal Filters"
use_vol   = input.bool(true, "Volume Filter", group=grp_filt, tooltip="Only show signals when volume is above average.")
use_rsi   = input.bool(false, "RSI Filter", group=grp_filt, tooltip="Filter out Buy signals in Overbought areas and Sell in Oversold.")

// --- Visual Customization ---
grp_vis   = "🎨 Visual Interface"
c_bull    = input.color(#00E676, "Bullish Color", group=grp_vis)
c_bear    = input.color(#FF1744, "Bearish Color", group=grp_vis)
c_neu     = input.color(#78909C, "Neutral/Chop Color", group=grp_vis)
c_text    = input.color(#FFFFFF, "Text Color", group=grp_vis)
show_bar  = input.bool(true, "Color Candles", group=grp_vis)

// --- Dashboard (HUD) ---
grp_hud   = "🖥️ Dashboard Styling"
show_hud  = input.bool(true, "Show HUD", group=grp_hud)
hud_pos   = input.string("Top Right", "Position", options=["Top Right", "Bottom Right", "Top Left", "Bottom Left"], group=grp_hud)
hud_bg    = input.color(color.new(#000000, 30), "Background", group=grp_hud)
hud_sz    = input.string("Small", "Size", options=["Tiny", "Small", "Normal"], group=grp_hud)

// ════════════════════════════════════════════════════════════════════════════
// 2. CORE CALCULATIONS
// ════════════════════════════════════════════════════════════════════════════

// --- Helper Function: Dynamic MA Calculation ---
get_ma(type, source, length) =>
    switch type
        "SMA" => ta.sma(source, length)
        "EMA" => ta.ema(source, length)
        "HMA" => ta.hma(source, length)
        "RMA" => ta.rma(source, length)
        => ta.ema(source, length)

// --- Trend Cloud Logic ---
// We calculate a baseline MA and add ATR bands to create a "Cloud"
baseline = get_ma(ma_type, src, len_main)
atr      = ta.atr(len_main)
upper    = baseline + (atr * mult)
lower    = baseline - (atr * mult)

// Trend State Determination
var int trend = 0
if close > upper
    trend := 1 // Bullish
else if close < lower
    trend := -1 // Bearish
else
    trend := trend // Maintain previous state (filter chop)

// Trend Strength (for Visualization)
is_strong_bull = trend == 1 and close > upper
is_strong_bear = trend == -1 and close < lower

// --- Volume & Momentum Logic ---
vol_ma    = ta.sma(volume, 20)
high_vol  = volume > vol_ma
rsi_val   = ta.rsi(close, 14)
rsi_ok_buy = not use_rsi or rsi_val < 70
rsi_ok_sell = not use_rsi or rsi_val > 30

// ════════════════════════════════════════════════════════════════════════════
// 3. SMART LIQUIDITY ENGINE
// ════════════════════════════════════════════════════════════════════════════

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

// Arrays to manage drawing liquidity blocks
var box[] supply_zones = array.new_box()
var box[] demand_zones = array.new_box()

// Function to keep array size managed (Performance)
manage_zones(arr) =>
    if array.size(arr) > 5
        box.delete(array.shift(arr))

// Supply (Resistance) Creation
if not na(ph) and show_liq
    // Top of box = Pivot High, Bottom = Highest Body in range
    float box_top = high[liq_len]
    float box_bot = math.max(open[liq_len], close[liq_len])
    
    b = box.new(bar_index - liq_len, box_top, bar_index + zone_ext, box_bot, 
         border_color=color.new(c_bear, 60), bgcolor=color.new(c_bear, 85), 
         text="Supply", text_color=color.new(c_text, 50), text_size=size.tiny)
    array.push(supply_zones, b)
    manage_zones(supply_zones)

// Demand (Support) Creation
if not na(pl) and show_liq
    // Bottom of box = Pivot Low, Top = Lowest Body in range
    float box_bot = low[liq_len]
    float box_top = math.min(open[liq_len], close[liq_len])
    
    b = box.new(bar_index - liq_len, box_top, bar_index + zone_ext, box_bot, 
         border_color=color.new(c_bull, 60), bgcolor=color.new(c_bull, 85), 
         text="Demand", text_color=color.new(c_text, 50), text_size=size.tiny)
    array.push(demand_zones, b)
    manage_zones(demand_zones)

// Active Zone Management (Extend or Mitigate)
if barstate.islast
    // Manage Supply
    if array.size(supply_zones) > 0
        for i = array.size(supply_zones) - 1 to 0
            b = array.get(supply_zones, i)
            // If price closes above the zone, delete it (Mitigated)
            if close > box.get_bottom(b)
                box.delete(b)
                array.remove(supply_zones, i)
            else
                box.set_right(b, bar_index + 10)
    
    // Manage Demand
    if array.size(demand_zones) > 0
        for i = array.size(demand_zones) - 1 to 0
            b = array.get(demand_zones, i)
            // If price closes below the zone, delete it (Mitigated)
            if close < box.get_top(b)
                box.delete(b)
                array.remove(demand_zones, i)
            else
                box.set_right(b, bar_index + 10)

// ════════════════════════════════════════════════════════════════════════════
// 4. SIGNAL GENERATION & PLOTTING
// ════════════════════════════════════════════════════════════════════════════

// Filter Conditions
cond_vol = not use_vol or high_vol

// Entry Signals
sig_buy = trend == 1 and trend[1] != 1 and cond_vol and rsi_ok_buy
sig_sell = trend == -1 and trend[1] != -1 and cond_vol and rsi_ok_sell

// Plot Trend Cloud
col_fill = trend == 1 ? c_bull : c_bear
p1 = plot(upper, "Upper Band", color=color.new(col_fill, 100))
p2 = plot(lower, "Lower Band", color=color.new(col_fill, 100))
fill(p1, p2, color=color.new(col_fill, 80), title="Trend Cloud")

// Plot Signals
plotshape(sig_buy, "Buy Signal", shape.labelup, location.belowbar, c_bull, 0, "BUY", c_text, size=size.small)
plotshape(sig_sell, "Sell Signal", shape.labeldown, location.abovebar, c_bear, 0, "SELL", c_text, size=size.small)

// Candle Coloring
bar_col = trend == 1 ? c_bull : trend == -1 ? c_bear : c_neu
barcolor(show_bar ? bar_col : na)

// ════════════════════════════════════════════════════════════════════════════
// 5. PROFESSIONAL DASHBOARD (HUD)
// ════════════════════════════════════════════════════════════════════════════

if show_hud
    var table hud = table.new(
         hud_pos == "Top Right" ? position.top_right : hud_pos == "Top Left" ? position.top_left : hud_pos == "Bottom Right" ? position.bottom_right : position.bottom_left, 
         2, 4, 
         bgcolor=hud_bg, 
         border_width=1, 
         border_color=color.new(c_neu, 60))

    if barstate.islast
        // Determine Text Size
        t_size = hud_sz == "Tiny" ? size.tiny : hud_sz == "Small" ? size.small : size.normal
        
        // Header
        table.cell(hud, 0, 0, "APEX MASTER", text_color=c_text, bgcolor=color.new(col_fill, 20), text_size=t_size, text_halign=text.align_left)
        table.cell(hud, 1, 0, "LIVE", text_color=c_text, bgcolor=color.new(col_fill, 20), text_size=t_size, text_halign=text.align_right)

        // Trend Status
        t_txt = trend == 1 ? "BULLISH" : "BEARISH"
        table.cell(hud, 0, 1, "Trend Bias", text_color=c_text, text_size=t_size, text_halign=text.align_left)
        table.cell(hud, 1, 1, t_txt, text_color=col_fill, text_size=t_size, text_halign=text.align_right)

        // Momentum (RSI)
        mom_txt = rsi_val > 60 ? "STRONG" : rsi_val < 40 ? "WEAK" : "NEUTRAL"
        mom_col = rsi_val > 60 ? c_bull : rsi_val < 40 ? c_bear : c_neu
        table.cell(hud, 0, 2, "Momentum", text_color=c_text, text_size=t_size, text_halign=text.align_left)
        table.cell(hud, 1, 2, mom_txt, text_color=mom_col, text_size=t_size, text_halign=text.align_right)

        // Volume State
        vol_txt = high_vol ? "HIGH" : "LOW"
        vol_col = high_vol ? c_bull : c_neu
        table.cell(hud, 0, 3, "Volume", text_color=c_text, text_size=t_size, text_halign=text.align_left)
        table.cell(hud, 1, 3, vol_txt, text_color=vol_col, text_size=t_size, text_halign=text.align_right)

// ════════════════════════════════════════════════════════════════════════════
// 6. ALERTS
// ════════════════════════════════════════════════════════════════════════════

alertcondition(sig_buy, "Apex Buy Alert", "Long Entry Signal Detected on {{ticker}}")
alertcondition(sig_sell, "Apex Sell Alert", "Short Entry Signal Detected on {{ticker}}")
// === Dashboard with Telegram Link ===
var table myTable = table.new(position.top_center, 1, 1, border_width=1, frame_color=color.black, bgcolor=color.white)

// Add Telegram Message to Dashboard
table.cell(myTable, 0, 0, "Join Telegram @freeindicatores", bgcolor=color.blue, text_color=color.white, text_size=size.normal)

Overview

Apex Trend & Liquidity Master identifies dynamic support and resistance liquidity zones from swing high and low pivots, extending them across recent bars. The script includes optional volume and RSI filters to confirm market conditions. Additionally, it highlights market structure by coloring price candles according to trend state and displays an on-screen HUD dashboard with real-time status telemetry.

Details

Published by

Ahmed-GoCode on GitHub

Code credit

Ahmed - Quant-Edge Indicators, as written in the script's header

Type

Indicator, Pine Script v6

Draws

On the price chart

Category

Trend, Support & resistance, SMC / ICT / price action, Screeners & dashboards

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

fair-value-gapfibonaccimarket-structurepine-scriptrsi-strategysmart-money-conceptstechnical-analysistradingviewalgorithmic-tradingcrypto-trading

Settings

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

SettingTypeDefaultVariable
Trend AlgorithmstringHMAma_type
Trend Lengthint55len_main
Volatility Multiplierfloat1.5mult
Sourcesourceclosesrc
Show Smart Liquidity Zonesbooltrueshow_liq
Pivot Lookbackint10liq_len
Zone Extensionint5zone_ext
Volume Filterbooltrueuse_vol
RSI Filterboolfalseuse_rsi
Bullish Colorcolor#00E676c_bull
Bearish Colorcolor#FF1744c_bear
Neutral/Chop Colorcolor#78909Cc_neu
Show all 18 settings
SettingTypeDefaultVariable
Text Colorcolor#FFFFFFc_text
Color Candlesbooltrueshow_bar
Show HUDbooltrueshow_hud
PositionstringTop Righthud_pos
Backgroundcolorcolor.new(#000000, 30)hud_bg
SizestringSmallhud_sz
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

Quantum Structure | jjart

by MeridianAlgo
9 stars

This indicator analyzes market structure and identifies key swing highs, swing lows, and consolidation ranges across multiple timeframes. It automatically adapts swing lengths and consolidation thresholds according to chosen profiles for scalping, intraday, or

Indicator v6 SMC / ICT / price actionSupport & resistance
Updated 4 months ago · MIT GitHub repository of Quantum Structure | jjart

Vein Execution 15m is an execution and timing overlay designed to complement higher-timeframe context. It monitors lower-timeframe micro structure shifts, liquidity sweeps, rejection candles, engulfing patterns, and follow-through momentum. The script calculat

Indicator v6 TrendSMC / ICT / price action
Updated yesterday · MIT GitHub repository of Vein: Execution 15m [WavesUnchained]
7 stars

Smart Krypto Futures Daytrade Suite is an all-in-one technical indicator tailored for intraday cryptocurrency trading. It plots higher-timeframe supply and demand zones, Fair Value Gaps with optional mitigation filtering, session VWAP, dynamic moving averages,

Indicator v6 SMC / ICT / price actionSupport & resistance
Updated 3 months ago · None stated GitHub repository of Smart Krypto Futures Daytrade Suite
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

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

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