This architecture is stripped of retail noise (no lagging moving averages or arbitrary oscillators). It is engineered strictly for raw price action, tracking Asian accumulation, London expansion, and NY sweeps.
It calculates the statistical exhaustion of the daily range using ADR Z-Scores and actively flags structural liquidity sweeps if NY attempts to run London's stops and fails.
Code: Select all
//@version=5
indicator("Institutional Liquidity Matrix & Z-Score [PA]", overlay=true, max_lines_count=100, max_boxes_count=100, max_labels_count=50)
// ==============================================================================
// PARAMETERS & MACROS
// ==============================================================================
grp_time = "Market Microstructure (Exchange Time)"
sess_asia = input.session("1800-0300", title="Asian Accumulation", group=grp_time)
sess_lon = input.session("0300-0800", title="London Expansion", group=grp_time)
sess_ny = input.session("0800-1200", title="NY Liquidity/Overlap", group=grp_time)
grp_quant = "Quantitative Exhaustion"
adr_len = input.int(20, title="ADR Length", group=grp_quant)
z_thresh = input.float(1.0, title="Exhaustion Z-Score (Range/ADR)", step=0.1, group=grp_quant)
grp_ui = "Architecture & Visuals"
col_asia = input.color(color.new(#808080, 90), title="Asia Box", group=grp_ui)
col_lon = input.color(color.new(#2962ff, 85), title="London Box", group=grp_ui)
col_ny = input.color(color.new(#d50000, 85), title="NY Box", group=grp_ui)
col_sweep = input.color(color.new(#ffaa00, 0), title="Sweep Marker", group=grp_ui)
// ==============================================================================
// TIME SERIES STATE
// ==============================================================================
in_asia = time(timeframe.period, sess_asia)
in_lon = time(timeframe.period, sess_lon)
in_ny = time(timeframe.period, sess_ny)
var float asia_h = na, var float asia_l = na, var box box_asia = na
var float lon_h = na, var float lon_l = na, var box box_lon = na
var float ny_h = na, var float ny_l = na, var box box_ny = na
var line line_lh = na, var line line_ll = na, var line line_lm = na
// ==============================================================================
// VOLATILITY & STATISTICAL METRICS
// ==============================================================================
float d_range = request.security(syminfo.tickerid, "D", high[1] - low[1])
float adr = ta.sma(d_range, adr_len)
float current_range = ta.highest(high, 100) - ta.lowest(low, 100) // Approximated intraday range
float z_score = current_range / adr // Ratio of current expansion vs average
// ==============================================================================
// SESSION LOGIC & STRUCTURAL MAPPING
// ==============================================================================
// Asia (Accumulation)
if in_asia
if not in_asia[1]
asia_h := high, asia_l := low
box_asia := box.new(bar_index, asia_h, bar_index, asia_l, border_color=na, bgcolor=col_asia)
else
asia_h := math.max(asia_h, high), asia_l := math.min(asia_l, low)
box.set_top(box_asia, asia_h), box.set_bottom(box_asia, asia_l), box.set_right(box_asia, bar_index)
// London (Expansion / Manipulation)
if in_lon
if not in_lon[1]
lon_h := high, lon_l := low
box_lon := box.new(bar_index, lon_h, bar_index, lon_l, border_color=na, bgcolor=col_lon)
else
lon_h := math.max(lon_h, high), lon_l := math.min(lon_l, low)
box.set_top(box_lon, lon_h), box.set_bottom(box_lon, lon_l), box.set_right(box_lon, bar_index)
current_range := lon_h - (na(asia_l) ? lon_l : math.min(asia_l, lon_l))
// NY (Mitigation / Sweep / Continuation)
var bool bear_sweep = false
var bool bull_sweep = false
if in_ny
if not in_ny[1]
ny_h := high, ny_l := low
box_ny := box.new(bar_index, ny_h, bar_index, ny_l, border_color=na, bgcolor=col_ny)
// Lock London Structural Lines
float mid = (lon_h + lon_l) / 2
line_lh := line.new(bar_index, lon_h, bar_index + 1, lon_h, color=color.gray, style=line.style_dashed)
line_ll := line.new(bar_index, lon_l, bar_index + 1, lon_l, color=color.gray, style=line.style_dashed)
line_lm := line.new(bar_index, mid, bar_index + 1, mid, color=color.gray, style=line.style_dotted)
bear_sweep := false
bull_sweep := false
else
ny_h := math.max(ny_h, high), ny_l := math.min(ny_l, low)
box.set_top(box_ny, ny_h), box.set_bottom(box_ny, ny_l), box.set_right(box_ny, bar_index)
line.set_x2(line_lh, bar_index), line.set_x2(line_ll, bar_index), line.set_x2(line_lm, bar_index)
// Liquidity Sweep Detection (Wick outside London, close inside)
if high > lon_h and close < lon_h and not bear_sweep
label.new(bar_index, high, "Liq. Sweep\n▼", color=color.new(color.white, 100), textcolor=col_sweep, style=label.style_label_down, size=size.small)
bear_sweep := true
if low < lon_l and close > lon_l and not bull_sweep
label.new(bar_index, low, "▲\nLiq. Sweep", color=color.new(color.white, 100), textcolor=col_sweep, style=label.style_label_up, size=size.small)
bull_sweep := true
// ==============================================================================
// QUANTITATIVE TERMINAL (HUD)
// ==============================================================================
var table panel = table.new(position.top_right, 2, 7, bgcolor=color.new(#000000, 10), border_width=1, border_color=color.new(#333333, 0))
if barstate.islast
color stat_col = z_score >= z_thresh ? color.red : color.green
string stat_msg = z_score >= z_thresh ? "STATISTICAL EXHAUSTION" : "CAPACITY REMAINS"
string sweep_msg = bear_sweep and bull_sweep ? "BOTH SIDES SWEPT" : bear_sweep ? "BUY-SIDE SWEPT" : bull_sweep ? "SELL-SIDE SWEPT" : "INTACT"
table.cell(panel, 0, 0, "NY OPEN : STRUCTURAL MATRIX", text_color=color.white, text_halign=text.align_center, text_weight="bold", bgcolor=color.new(#1e222d, 0))
table.merge_cells(panel, 0, 0, 1, 0)
table.cell(panel, 0, 1, "20D Mean Variance (ADR)", text_color=color.gray, text_halign=text.align_left, text_size=size.small)
table.cell(panel, 1, 1, str.tostring(adr / syminfo.mintick / 10, "#.0") + " p", text_color=color.white, text_halign=text.align_right, text_font_family=font.family_monospace)
table.cell(panel, 0, 2, "Current Intraday Expansion", text_color=color.gray, text_halign=text.align_left, text_size=size.small)
table.cell(panel, 1, 2, str.tostring(current_range / syminfo.mintick / 10, "#.0") + " p", text_color=color.white, text_halign=text.align_right, text_font_family=font.family_monospace)
table.cell(panel, 0, 3, "Expansion Z-Score", text_color=color.gray, text_halign=text.align_left, text_size=size.small)
table.cell(panel, 1, 3, str.tostring(z_score, "#.00"), text_color=stat_col, text_halign=text.align_right, text_weight="bold", text_font_family=font.family_monospace)
table.cell(panel, 0, 4, "Tape Environment", text_color=color.gray, text_halign=text.align_left, text_size=size.small)
table.cell(panel, 1, 4, stat_msg, text_color=stat_col, text_halign=text.align_right, text_weight="bold", text_size=size.small)
table.cell(panel, 0, 5, "London Liquidity Status", text_color=color.gray, text_halign=text.align_left, text_size=size.small)
table.cell(panel, 1, 5, sweep_msg, text_color=bear_sweep or bull_sweep ? col_sweep : color.gray, text_halign=text.align_right, text_weight="bold", text_size=size.small)