本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。
// This Pine Script™ code is subject to the terms of Mozilla Public License 2.0
// https://mozilla.org/MPL/2.0/
// © LiquidityEdgeFutures
// ============================================================================
// LIQUIDITY EDGE | MULTI-TIMEFRAME HTF FVG MATRIX & GRAY BOXES [PINE SCRIPT 6]
// Precision Multi-Zone Higher Timeframe Imbalance Matrix for NQ, ES, Gold
// ============================================================================
//
// AUDITED MULTI-ZONE ENGINE (PREMIUM INSTITUTIONAL STYLING):
// - Pure HTF FVG Engine: Strictly tracks genuine 3-candle Fair Value Gaps.
// No IFVGs (Inversion FVGs). Any zone closed through is permanently removed.
// - Smart Timeframe Auto-Filtering:
// * On <=5m charts: Displays 15M and 1H FVGs (plus 30M/4H if toggled)
// * On 15m charts: Displays 1H and 4H FVGs (hides 15M to avoid clutter)
// - 4 Visual Tag Styles (Matches User Aesthetic Exactly):
// 1. "Modern Micro-Pills": High-contrast dark pills with vibrant accents
// (Sky Blue 1H, Crisp White 15M, Amber 4H, Lavender 30M) - 100% pop.
// 2. "On-Line Minimalist": Pure text centered directly on the border line.
// 3. "Inside Box Corner": Text pinned neatly inside the box corner.
// 4. "None": Pure gray boxes and CE lines only.
// - Smart Anti-Collision Separation:
// * Intelligently detects 15M / 1H overlap and shifts 15M to Bottom of Zone
// with tiered staggering, guaranteeing zero label overlap.
// - Confirmation-Safe Mitigation Engine:
// * Invalidation checks strictly begin AFTER HTF 3-bar confirmation (cTime).
// - Signature Institutional Slate Gray Box Palette (matches NinjaTrader 8)
// - Consequent Encroachment (50% CE) dashed midlines
// - Order Flow Telemetry HUD with point distance to nearest active zones
// ============================================================================
//@version=6
indicator("Liquidity Edge - HTF FVG Gray Box Matrix",
shorttitle="LE - HTF FVG",
overlay=true,
max_boxes_count=500,
max_lines_count=500,
max_labels_count=500,
max_bars_back=3000)
// ----------------------------------------------------------------------------
// 1. INPUT CONFIGURATION
// ----------------------------------------------------------------------------
var string G_RULE = "1. Smart Timeframe Hierarchy"
var string G_HTF = "2. Higher Timeframe Toggles & Depth"
var string G_VIS = "3. Visuals & Premium Styling"
var string G_MIT = "4. Mitigation & Lifecycle Engine (No IFVG)"
var string G_HUD = "5. HUD Telemetry Dashboard"
var string G_ALT = "6. Audio & Webhook Alerts"
// Smart Hierarchy Rules
bool i_auto_tf = input.bool(true, "Smart Timeframe Filter",
tooltip="On <=5m charts shows 15M & 1H; on 15m charts shows 1H & 4H.",
group=G_RULE)
bool i_show_4h_low = input.bool(false, "Show 4H on <=5M Charts",
tooltip="If enabled, displays macro 4H zones on <=5M execution charts.",
group=G_RULE)
// Higher Timeframes (15M & 1H Default ON, 30M Optional, 4H Active for 15M)
bool i_show_15m = input.bool(true, "Show 15M FVG Zones (Default)",
group=G_HTF)
bool i_show_1h = input.bool(true, "Show 1H FVG Zones (Default)",
group=G_HTF)
bool i_show_30m = input.bool(false, "Show 30M FVG Zones (Optional)",
group=G_HTF)
bool i_show_4h = input.bool(true, "Show 4H FVG Zones (Optional HTF)",
group=G_HTF)
int i_depth = input.int(4, "Active Zones Memory Per Side",
minval=1, maxval=4,
tooltip="Number of active Bullish & Bearish FVGs to display per TF.",
group=G_HTF)
int i_min_ticks = input.int(6, "Min FVG Size (Ticks)",
minval=0, tooltip="Filters micro noise gaps (6 ticks = 0.6 pts Gold)",
group=G_HTF)
// Visuals & Premium Styling
string i_style_mode = input.string("Modern Micro-Pills", "Visual Tag Style",
options=["Modern Micro-Pills", "On-Line Minimalist",
"Inside Box Corner", "None"],
tooltip="Micro-Pills: High-contrast badges. On-Line: Text on line.",
group=G_VIS)
string i_tag_fmt = input.string("Short (1H / 15M)", "Tag Text Format",
options=["Short (1H / 15M)", "Standard (1H FVG / 15M FVG)"],
tooltip="Short: Minimal clean text. Standard: Includes FVG & Tested.",
group=G_VIS)
string i_lbl_size_str = input.string("Small", "Label Font Size",
options=["Tiny", "Small", "Normal", "Large"],
group=G_VIS)
string i_15m_align = input.string("Auto (Anti-Collision)",
"15M Label Placement",
options=["Auto (Anti-Collision)", "Bottom of Zone", "Top of Zone",
"50% CE Midline"],
tooltip="Auto places 15M at bottom when near 1H to prevent overlap.",
group=G_VIS)
color i_c_fill = input.color(color.new(#AFB4BE, 80), "Active Gray Fill",
group=G_VIS)
color i_c_border = input.color(color.new(#828791, 20), "Active Slate Border",
group=G_VIS)
color i_c_mit_fill = input.color(color.new(#94A3B8, 85), "Tested Gray Fill",
group=G_VIS)
color i_c_mit_brd = input.color(color.new(#94A3B8, 40), "Tested Border",
group=G_VIS)
bool i_show_ce = input.bool(true, "Show 50% CE Midline",
group=G_VIS)
color i_c_ce = input.color(color.new(#94A3B8, 30), "50% CE Midline Color",
group=G_VIS)
int i_ext_bars = input.int(16, "Forward Extension (Bars)",
minval=1, maxval=60,
group=G_VIS)
// Mitigation Engine (Strictly No IFVGs - True FVGs Only)
string i_mit_mode = input.string("Body Close Beyond Zone",
"Mitigation Invalidation Rule",
options=["Body Close Beyond Zone", "Wick Touch Beyond Zone"],
group=G_MIT)
bool i_keep_tested = input.bool(true, "Keep Tested Zones Visible (Ghost Gray)",
tooltip="When tapped, renders in ghost gray until body closes through.",
group=G_MIT)
bool i_hide_closed = input.bool(true, "Remove on Candle Close",
tooltip="Violated zones are permanently discarded. No IFVGs displayed.",
group=G_MIT)
// HUD Telemetry
bool i_show_hud = input.bool(true, "Show Order Flow Telemetry Table",
group=G_HUD)
string i_hud_pos = input.string("Bottom Right", "HUD Table Position",
options=["Top Right", "Bottom Right", "Top Left", "Bottom Left"],
group=G_HUD)
// Alerts
bool i_alt_15m = input.bool(true, "Alert: Inside 15M FVG", group=G_ALT)
bool i_alt_1h = input.bool(true, "Alert: Inside 1H FVG", group=G_ALT)
bool i_alt_conf = input.bool(true, "Alert: Multi-TF Confluence",
group=G_ALT)
// ----------------------------------------------------------------------------
// 2. TIMEFRAME HIERARCHY FILTER ENGINE
// ----------------------------------------------------------------------------
int tfM = timeframe.isminutes ? timeframe.multiplier :
(timeframe.isseconds ? 0 : 1440)
bool isLowTf = timeframe.isintraday and tfM <= 5
bool is15m = timeframe.isintraday and tfM > 5 and tfM <= 15
bool is30m = timeframe.isintraday and tfM > 15 and tfM <= 30
bool is1h = timeframe.isintraday and tfM > 30 and tfM <= 60
// Dynamic Render Booleans according to Hierarchy Rules
bool render15m = i_show_15m and (not i_auto_tf or isLowTf)
bool render30m = i_show_30m and (not i_auto_tf or isLowTf or is15m)
bool render1h = i_show_1h and (not i_auto_tf or isLowTf or is15m or is30m)
bool render4h = i_show_4h and (not i_auto_tf or is15m or is30m or is1h or
(isLowTf and i_show_4h_low))
// Resolve Label Font Size
string lblSize = i_lbl_size_str == "Large" ? size.large :
i_lbl_size_str == "Normal" ? size.normal :
i_lbl_size_str == "Small" ? size.small : size.tiny
// ----------------------------------------------------------------------------
// 3. HIGHER TIMEFRAME SCANNER (Pure 3-Candle FVG Only - No IFVG)
// ----------------------------------------------------------------------------
f_scan_htf(minTicks) =>
float minR = minTicks * syminfo.mintick
// True 3-Candle Imbalance Gap Detection
bool isB = (low > high[2]) and ((low - high[2]) >= minR)
bool isS = (high < low[2]) and ((low[2] - high) >= minR)
// 4 Recent Bullish Gaps
float b0_top = ta.valuewhen(isB, low, 0)
float b0_bot = ta.valuewhen(isB, high[2], 0)
int b0_st = ta.valuewhen(isB, time[2], 0)
int b0_ct = ta.valuewhen(isB, time, 0)
float b1_top = ta.valuewhen(isB, low, 1)
float b1_bot = ta.valuewhen(isB, high[2], 1)
int b1_st = ta.valuewhen(isB, time[2], 1)
int b1_ct = ta.valuewhen(isB, time, 1)
float b2_top = ta.valuewhen(isB, low, 2)
float b2_bot = ta.valuewhen(isB, high[2], 2)
int b2_st = ta.valuewhen(isB, time[2], 2)
int b2_ct = ta.valuewhen(isB, time, 2)
float b3_top = ta.valuewhen(isB, low, 3)
float b3_bot = ta.valuewhen(isB, high[2], 3)
int b3_st = ta.valuewhen(isB, time[2], 3)
int b3_ct = ta.valuewhen(isB, time, 3)
// 4 Recent Bearish Gaps
float s0_top = ta.valuewhen(isS, low[2], 0)
float s0_bot = ta.valuewhen(isS, high, 0)
int s0_st = ta.valuewhen(isS, time[2], 0)
int s0_ct = ta.valuewhen(isS, time, 0)
float s1_top = ta.valuewhen(isS, low[2], 1)
float s1_bot = ta.valuewhen(isS, high, 1)
int s1_st = ta.valuewhen(isS, time[2], 1)
int s1_ct = ta.valuewhen(isS, time, 1)
float s2_top = ta.valuewhen(isS, low[2], 2)
float s2_bot = ta.valuewhen(isS, high, 2)
int s2_st = ta.valuewhen(isS, time[2], 2)
int s2_ct = ta.valuewhen(isS, time, 2)
float s3_top = ta.valuewhen(isS, low[2], 3)
float s3_bot = ta.valuewhen(isS, high, 3)
int s3_st = ta.valuewhen(isS, time[2], 3)
int s3_ct = ta.valuewhen(isS, time, 3)
[b0_top, b0_bot, b0_st, b0_ct,
b1_top, b1_bot, b1_st, b1_ct,
b2_top, b2_bot, b2_st, b2_ct,
b3_top, b3_bot, b3_st, b3_ct,
s0_top, s0_bot, s0_st, s0_ct,
s1_top, s1_bot, s1_st, s1_ct,
s2_top, s2_bot, s2_st, s2_ct,
s3_top, s3_bot, s3_st, s3_ct]
// Query Security for 15M, 1H, 30M, 4H (Strictly Non-Repainting)
[b0_t_15, b0_b_15, b0_st_15, b0_ct_15,
b1_t_15, b1_b_15, b1_st_15, b1_ct_15,
b2_t_15, b2_b_15, b2_st_15, b2_ct_15,
b3_t_15, b3_b_15, b3_st_15, b3_ct_15,
s0_t_15, s0_b_15, s0_st_15, s0_ct_15,
s1_t_15, s1_b_15, s1_st_15, s1_ct_15,
s2_t_15, s2_b_15, s2_st_15, s2_ct_15,
s3_t_15, s3_b_15, s3_st_15, s3_ct_15] =
request.security(syminfo.tickerid, "15", f_scan_htf(i_min_ticks),
gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_off)
[b0_t_60, b0_b_60, b0_st_60, b0_ct_60,
b1_t_60, b1_b_60, b1_st_60, b1_ct_60,
b2_t_60, b2_b_60, b2_st_60, b2_ct_60,
b3_t_60, b3_b_60, b3_st_60, b3_ct_60,
s0_t_60, s0_b_60, s0_st_60, s0_ct_60,
s1_t_60, s1_b_60, s1_st_60, s1_ct_60,
s2_t_60, s2_b_60, s2_st_60, s2_ct_60,
s3_t_60, s3_b_60, s3_st_60, s3_ct_60] =
request.security(syminfo.tickerid, "60", f_scan_htf(i_min_ticks),
gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_off)
[b0_t_30, b0_b_30, b0_st_30, b0_ct_30,
b1_t_30, b1_b_30, b1_st_30, b1_ct_30,
b2_t_30, b2_b_30, b2_st_30, b2_ct_30,
b3_t_30, b3_b_30, b3_st_30, b3_ct_30,
s0_t_30, s0_b_30, s0_st_30, s0_ct_30,
s1_t_30, s1_b_30, s1_st_30, s1_ct_30,
s2_t_30, s2_b_30, s2_st_30, s2_ct_30,
s3_t_30, s3_b_30, s3_st_30, s3_ct_30] =
request.security(syminfo.tickerid, "30", f_scan_htf(i_min_ticks),
gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_off)
[b0_t_240, b0_b_240, b0_st_240, b0_ct_240,
b1_t_240, b1_b_240, b1_st_240, b1_ct_240,
b2_t_240, b2_b_240, b2_st_240, b2_ct_240,
b3_t_240, b3_b_240, b3_st_240, b3_ct_240,
s0_t_240, s0_b_240, s0_st_240, s0_ct_240,
s1_t_240, s1_b_240, s1_st_240, s1_ct_240,
s2_t_240, s2_b_240, s2_st_240, s2_ct_240,
s3_t_240, s3_b_240, s3_st_240, s3_ct_240] =
request.security(syminfo.tickerid, "240", f_scan_htf(i_min_ticks),
gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_off)
// ----------------------------------------------------------------------------
// 4. CONFIRMATION-SAFE MITIGATION & INVALIDATION EVALUATOR
// ----------------------------------------------------------------------------
bool useBody = i_mit_mode == "Body Close Beyond Zone"
f_check_zone_status(float top, float bot, int cTime, bool isBull,
bool bodyRule) =>
bool isTested = false
bool isClosed = false
if not na(top) and not na(bot) and cTime > 0
int maxScan = math.min(bar_index, 1000)
for i = 0 to maxScan
if (time[i] < cTime)
break
float c = close[i]
float h = high[i]
float l = low[i]
if isBull
// Strict Invalidation: Candle body closed below zone floor
if (bodyRule ? c < bot : l < bot)
isClosed := true
break
// Tested: Price wicked into zone without closing below
if l <= top and h >= bot
isTested := true
else
// Strict Invalidation: Candle body closed above zone ceiling
if (bodyRule ? c > top : h > top)
isClosed := true
break
// Tested: Price wicked into zone without closing above
if h >= bot and l <= top
isTested := true
[isTested, isClosed]
// ----------------------------------------------------------------------------
// 5. ON-CHART GRAY BOX & HIGH-END STYLING ENGINE
// ----------------------------------------------------------------------------
var box[] drawnBoxes = array.new_box()
var line[] drawnLines = array.new_line()
var label[] drawnLabels = array.new_label()
f_clean() =>
if array.size(drawnBoxes) > 0
for i = 0 to array.size(drawnBoxes) - 1
box.delete(array.get(drawnBoxes, i))
array.clear(drawnBoxes)
if array.size(drawnLines) > 0
for i = 0 to array.size(drawnLines) - 1
line.delete(array.get(drawnLines, i))
array.clear(drawnLines)
if array.size(drawnLabels) > 0
for i = 0 to array.size(drawnLabels) - 1
label.delete(array.get(drawnLabels, i))
array.clear(drawnLabels)
f_render_fvg(bool enabled, float top, float bot, int sTime, int cTime,
bool isBull, string tfPrefix, string anchorPos, int extMs,
color pillC, color lineC, bool isStaggered, bool bodyRule,
bool hideClosed, bool keepTested) =>
if enabled and not na(top) and not na(bot) and sTime > 0 and cTime > 0
[isTested, isClosed] = f_check_zone_status(top, bot, cTime,
isBull, bodyRule)
// If closed through, permanently removed (NO IFVG)
if not (hideClosed and isClosed)
if not (isTested and not keepTested)
int rTime = time + extMs
color fillC = isTested ? i_c_mit_fill : i_c_fill
color brdC = isTested ? i_c_mit_brd : i_c_border
// Build Clean Tag String
string shortTag = tfPrefix
string tSuffix = isTested ? " · Tested" : ""
string stdTag = tfPrefix + " FVG" + tSuffix
bool isShort = i_tag_fmt == "Short (1H / 15M)"
string tag = isShort ? shortTag : stdTag
// Native In-Box Text parameters
string bText = i_style_mode == "Inside Box Corner" ? tag : na
string bValign = anchorPos == "Bottom of Zone" ?
text.align_bottom : text.align_top
box b = box.new(left=sTime, top=top, right=rTime, bottom=bot,
xloc=xloc.bar_time, border_color=brdC, border_width=1,
bgcolor=fillC, text=bText, text_size=lblSize,
text_color=lineC, text_halign=text.align_right,
text_valign=bValign)
array.push(drawnBoxes, b)
if i_show_ce
float ce = (top + bot) / 2.0
line l = line.new(x1=sTime, y1=ce, x2=rTime, y2=ce,
xloc=xloc.bar_time, color=i_c_ce,
style=line.style_dashed, width=1)
array.push(drawnLines, l)
if i_style_mode == "Modern Micro-Pills"
float ceVal = (top + bot) / 2.0
float lblY = anchorPos == "Bottom of Zone" ? bot :
(anchorPos == "50% CE Midline" ? ceVal : top)
int bDeltaMs = int(time - time[1])
int safeMs = bDeltaMs > 0 ? bDeltaMs : 60000
int lblX = isStaggered ? (rTime - safeMs * 2) : rTime
label lb = label.new(x=lblX, y=lblY, text=tag,
xloc=xloc.bar_time, style=label.style_label_left,
color=color.new(#0F172A, 10),
textcolor=pillC, size=lblSize)
array.push(drawnLabels, lb)
else if i_style_mode == "On-Line Minimalist"
float ceVal = (top + bot) / 2.0
float lblY = anchorPos == "Bottom of Zone" ? bot :
(anchorPos == "50% CE Midline" ? ceVal : top)
int bDeltaMs = int(time - time[1])
int safeMs = bDeltaMs > 0 ? bDeltaMs : 60000
int lblX = rTime - (safeMs * 4)
label lb = label.new(x=lblX, y=lblY, text=tag,
xloc=xloc.bar_time, style=label.style_none,
textcolor=lineC, size=lblSize)
array.push(drawnLabels, lb)
int bDelta = int(time - time[1])
int safeDelta = bDelta > 0 ? bDelta : 60000
int extMs = safeDelta * i_ext_bars
// Theme-Proof Vibrant Accent Colors for Micro-Pills
color pill4H = #F59E0B // Amber Gold
color pill1H = #38BDF8 // Sky Blue
color pill30 = #A78BFA // Lavender Purple
color pill15 = #FFFFFF // Crisp Pure White
// High-Contrast Colors for On-Line Minimalist (Legible on Light & Dark)
color line4H = #D97706 // Amber Bronze
color line1H = #0284C7 // Ocean Blue
color line30 = #7C3AED // Royal Purple
color line15 = #334155 // Deep Slate Gray
// Universal Anti-Collision Proximity Helper
f_near_val(float a, float b, float d) =>
not na(a) and not na(b) and math.abs(a - b) <= d
// Smart Anti-Collision Resolver for 15M Zones
// Intelligently shifts 15M to Bottom of Zone if near or inside any 1H zone
f_get_15m_anchor(float top15, float bot15) =>
string res = "Top of Zone"
if i_15m_align == "Bottom of Zone"
res := "Bottom of Zone"
else if i_15m_align == "50% CE Midline"
res := "50% CE Midline"
else if i_15m_align == "Top of Zone"
res := "Top of Zone"
else
// Dynamic threshold: 40 ticks or 75% of zone height
float dMax = math.max(syminfo.mintick * 40.0, (top15 - bot15) * 0.75)
bool near1H = false
// Check 1H Bullish Zones
if not na(b0_t_60) and (f_near_val(top15, b0_t_60, dMax) or
(top15 <= b0_t_60 and top15 >= b0_b_60))
near1H := true
if not na(b1_t_60) and (f_near_val(top15, b1_t_60, dMax) or
(top15 <= b1_t_60 and top15 >= b1_b_60))
near1H := true
if not na(b2_t_60) and (f_near_val(top15, b2_t_60, dMax) or
(top15 <= b2_t_60 and top15 >= b2_b_60))
near1H := true
if not na(b3_t_60) and (f_near_val(top15, b3_t_60, dMax) or
(top15 <= b3_t_60 and top15 >= b3_b_60))
near1H := true
// Check 1H Bearish Zones
if not na(s0_t_60) and (f_near_val(top15, s0_t_60, dMax) or
(top15 <= s0_t_60 and top15 >= s0_b_60))
near1H := true
if not na(s1_t_60) and (f_near_val(top15, s1_t_60, dMax) or
(top15 <= s1_t_60 and top15 >= s1_b_60))
near1H := true
if not na(s2_t_60) and (f_near_val(top15, s2_t_60, dMax) or
(top15 <= s2_t_60 and top15 >= s2_b_60))
near1H := true
if not na(s3_t_60) and (f_near_val(top15, s3_t_60, dMax) or
(top15 <= s3_t_60 and top15 >= s3_b_60))
near1H := true
res := near1H ? "Bottom of Zone" : "Top of Zone"
res
if barstate.islast
f_clean()
// --- 4-Hour Macro Zones (Drawn First - Background Layer) ---
if render4h
f_render_fvg(true, b0_t_240, b0_b_240, b0_st_240, b0_ct_240, true,
"4H", "Top of Zone", extMs, pill4H, line4H, false, useBody,
i_hide_closed, i_keep_tested)
f_render_fvg(i_depth >= 2, b1_t_240, b1_b_240, b1_st_240, b1_ct_240,
true, "4H", "Top of Zone", extMs, pill4H, line4H, false, useBody,
i_hide_closed, i_keep_tested)
f_render_fvg(true, s0_t_240, s0_b_240, s0_st_240, s0_ct_240, false,
"4H", "Top of Zone", extMs, pill4H, line4H, false, useBody,
i_hide_closed, i_keep_tested)
f_render_fvg(i_depth >= 2, s1_t_240, s1_b_240, s1_st_240, s1_ct_240,
false, "4H", "Top of Zone", extMs, pill4H, line4H, false,
useBody, i_hide_closed, i_keep_tested)
// --- 1-Hour Macro Zones (Always Top of Zone for Hierarchy) ---
if render1h
f_render_fvg(true, b0_t_60, b0_b_60, b0_st_60, b0_ct_60, true,
"1H", "Top of Zone", extMs, pill1H, line1H, false, useBody,
i_hide_closed, i_keep_tested)
f_render_fvg(i_depth >= 2, b1_t_60, b1_b_60, b1_st_60, b1_ct_60,
true, "1H", "Top of Zone", extMs, pill1H, line1H, false, useBody,
i_hide_closed, i_keep_tested)
f_render_fvg(i_depth >= 3, b2_t_60, b2_b_60, b2_st_60, b2_ct_60,
true, "1H", "Top of Zone", extMs, pill1H, line1H, false, useBody,
i_hide_closed, i_keep_tested)
f_render_fvg(i_depth >= 4, b3_t_60, b3_b_60, b3_st_60, b3_ct_60,
true, "1H", "Top of Zone", extMs, pill1H, line1H, false, useBody,
i_hide_closed, i_keep_tested)
f_render_fvg(true, s0_t_60, s0_b_60, s0_st_60, s0_ct_60, false,
"1H", "Top of Zone", extMs, pill1H, line1H, false, useBody,
i_hide_closed, i_keep_tested)
f_render_fvg(i_depth >= 2, s1_t_60, s1_b_60, s1_st_60, s1_ct_60,
false, "1H", "Top of Zone", extMs, pill1H, line1H, false,
useBody, i_hide_closed, i_keep_tested)
f_render_fvg(i_depth >= 3, s2_t_60, s2_b_60, s2_st_60, s2_ct_60,
false, "1H", "Top of Zone", extMs, pill1H, line1H, false,
useBody, i_hide_closed, i_keep_tested)
f_render_fvg(i_depth >= 4, s3_t_60, s3_b_60, s3_st_60, s3_ct_60,
false, "1H", "Top of Zone", extMs, pill1H, line1H, false,
useBody, i_hide_closed, i_keep_tested)
// --- 30-Minute Intermediate Zones (Optional) ---
if render30m
f_render_fvg(true, b0_t_30, b0_b_30, b0_st_30, b0_ct_30, true,
"30M", "Bottom of Zone", extMs, pill30, line30, false, useBody,
i_hide_closed, i_keep_tested)
f_render_fvg(i_depth >= 2, b1_t_30, b1_b_30, b1_st_30, b1_ct_30,
true, "30M", "Bottom of Zone", extMs, pill30, line30, false,
useBody, i_hide_closed, i_keep_tested)
f_render_fvg(true, s0_t_30, s0_b_30, s0_st_30, s0_ct_30, false,
"30M", "Bottom of Zone", extMs, pill30, line30, false, useBody,
i_hide_closed, i_keep_tested)
f_render_fvg(i_depth >= 2, s1_t_30, s1_b_30, s1_st_30, s1_ct_30,
false, "30M", "Bottom of Zone", extMs, pill30, line30, false,
useBody, i_hide_closed, i_keep_tested)
// --- 15-Minute Precision Execution Zones (Foreground Layer) ---
if render15m
string a_b0 = f_get_15m_anchor(b0_t_15, b0_b_15)
string a_b1 = f_get_15m_anchor(b1_t_15, b1_b_15)
string a_b2 = f_get_15m_anchor(b2_t_15, b2_b_15)
string a_b3 = f_get_15m_anchor(b3_t_15, b3_b_15)
string a_s0 = f_get_15m_anchor(s0_t_15, s0_b_15)
string a_s1 = f_get_15m_anchor(s1_t_15, s1_b_15)
string a_s2 = f_get_15m_anchor(s2_t_15, s2_b_15)
string a_s3 = f_get_15m_anchor(s3_t_15, s3_b_15)
bool stg_b0 = a_b0 == "Bottom of Zone"
bool stg_b1 = a_b1 == "Bottom of Zone"
bool stg_b2 = a_b2 == "Bottom of Zone"
bool stg_b3 = a_b3 == "Bottom of Zone"
bool stg_s0 = a_s0 == "Bottom of Zone"
bool stg_s1 = a_s1 == "Bottom of Zone"
bool stg_s2 = a_s2 == "Bottom of Zone"
bool stg_s3 = a_s3 == "Bottom of Zone"
f_render_fvg(true, b0_t_15, b0_b_15, b0_st_15, b0_ct_15, true,
"15M", a_b0, extMs, pill15, line15, stg_b0, useBody,
i_hide_closed, i_keep_tested)
f_render_fvg(i_depth >= 2, b1_t_15, b1_b_15, b1_st_15, b1_ct_15,
true, "15M", a_b1, extMs, pill15, line15, stg_b1, useBody,
i_hide_closed, i_keep_tested)
f_render_fvg(i_depth >= 3, b2_t_15, b2_b_15, b2_st_15, b2_ct_15,
true, "15M", a_b2, extMs, pill15, line15, stg_b2, useBody,
i_hide_closed, i_keep_tested)
f_render_fvg(i_depth >= 4, b3_t_15, b3_b_15, b3_st_15, b3_ct_15,
true, "15M", a_b3, extMs, pill15, line15, stg_b3, useBody,
i_hide_closed, i_keep_tested)
f_render_fvg(true, s0_t_15, s0_b_15, s0_st_15, s0_ct_15, false,
"15M", a_s0, extMs, pill15, line15, stg_s0, useBody,
i_hide_closed, i_keep_tested)
f_render_fvg(i_depth >= 2, s1_t_15, s1_b_15, s1_st_15, s1_ct_15,
false, "15M", a_s1, extMs, pill15, line15, stg_s1, useBody,
i_hide_closed, i_keep_tested)
f_render_fvg(i_depth >= 3, s2_t_15, s2_b_15, s2_st_15, s2_ct_15,
false, "15M", a_s2, extMs, pill15, line15, stg_s2, useBody,
i_hide_closed, i_keep_tested)
f_render_fvg(i_depth >= 4, s3_t_15, s3_b_15, s3_st_15, s3_ct_15,
false, "15M", a_s3, extMs, pill15, line15, stg_s3, useBody,
i_hide_closed, i_keep_tested)
// ----------------------------------------------------------------------------
// 6. COLLISION & MULTI-TIMEFRAME CONFLUENCE ENGINE
// ----------------------------------------------------------------------------
bool in_15_b = not na(b0_t_15) and (close <= b0_t_15) and (close >= b0_b_15)
bool in_15_s = not na(s0_t_15) and (close <= s0_t_15) and (close >= s0_b_15)
bool in_1h_b = not na(b0_t_60) and (close <= b0_t_60) and (close >= b0_b_60)
bool in_1h_s = not na(s0_t_60) and (close <= s0_t_60) and (close >= s0_b_60)
bool in_30_b = not na(b0_t_30) and (close <= b0_t_30) and (close >= b0_b_30)
bool in_30_s = not na(s0_t_30) and (close <= s0_t_30) and (close >= s0_b_30)
bool in_4h_b = not na(b0_t_240) and (close <= b0_t_240) and (close >= b0_b_240)
bool in_4h_s = not na(s0_t_240) and (close <= s0_t_240) and (close >= s0_b_240)
bool conf_bull = in_15_b and in_1h_b
bool conf_bear = in_15_s and in_1h_s
// ----------------------------------------------------------------------------
// 7. HUD ORDER FLOW TELEMETRY DASHBOARD
// ----------------------------------------------------------------------------
hud_pos = i_hud_pos == "Top Right" ? position.top_right :
i_hud_pos == "Bottom Right" ? position.bottom_right :
i_hud_pos == "Top Left" ? position.top_left : position.bottom_left
var table tb = table.new(hud_pos, 4, 6,
bgcolor=color.new(#030712, 10),
border_color=color.new(#1E2D48, 30), border_width=1)
f_row(table t, int r, string tf, bool inB, bool inS, float bT, float sB) =>
table.cell(t, 0, r, tf, text_color=#94A3B8, text_size=size.tiny,
text_font_family=font.family_monospace)
string st = "Clear (No Zone)"
color sc = #64748B
color bg = color.new(#0E1626, 60)
string dt = "--"
string bs = "NEUTRAL"
color bc = #94A3B8
if inB
st := "INSIDE SUPPORT"
sc := #FFFFFF
bg := color.new(#10B981, 30)
dt := "0.0 pts"
bs := "BULLISH"
bc := #10B981
else if inS
st := "INSIDE RESIST"
sc := #FFFFFF
bg := color.new(#EF4444, 30)
dt := "0.0 pts"
bs := "BEARISH"
bc := #EF4444
else
float dSup = not na(bT) ? (close - bT) : na
float dRes = not na(sB) ? (sB - close) : na
if not na(dSup) and (dSup > 0) and (na(dRes) or dSup < dRes)
st := "Support Below"
sc := #10B981
bg := color.new(#0E1626, 60)
dt := str.tostring(dSup, "#.##") + " pts"
bs := "BULL BIAS"
bc := #10B981
else if not na(dRes) and (dRes > 0)
st := "Resist Above"
sc := #EF4444
bg := color.new(#0E1626, 60)
dt := str.tostring(dRes, "#.##") + " pts"
bs := "BEAR BIAS"
bc := #EF4444
table.cell(t, 1, r, st, text_color=sc, bgcolor=bg, text_size=size.tiny,
text_font_family=font.family_monospace)
table.cell(t, 2, r, dt, text_color=#F8FAFC,
bgcolor=bg, text_size=size.tiny,
text_font_family=font.family_monospace)
table.cell(t, 3, r, bs, text_color=bc, bgcolor=bg, text_size=size.tiny,
text_font_family=font.family_monospace)
if i_show_hud and barstate.islast
table.cell(tb, 0, 0, "HTF MATRIX", text_color=#38BDF8,
text_size=size.tiny, text_font_family=font.family_monospace)
table.cell(tb, 1, 0, "STATUS", text_color=#94A3B8,
text_size=size.tiny, text_font_family=font.family_monospace)
table.cell(tb, 2, 0, "PROXIMITY", text_color=#94A3B8,
text_size=size.tiny, text_font_family=font.family_monospace)
table.cell(tb, 3, 0, "BIAS", text_color=#94A3B8,
text_size=size.tiny, text_font_family=font.family_monospace)
f_row(tb, 1, "15M", in_15_b, in_15_s, b0_t_15, s0_b_15)
f_row(tb, 2, "30M", in_30_b, in_30_s, b0_t_30, s0_b_30)
f_row(tb, 3, "1H", in_1h_b, in_1h_s, b0_t_60, s0_b_60)
f_row(tb, 4, "4H", in_4h_b, in_4h_s, b0_t_240, s0_b_240)
color cBg = conf_bull ? color.new(#10B981, 20) :
(conf_bear ? color.new(#EF4444, 20) : color.new(#0E1626, 60))
string cTx = conf_bull ? "CONFLUENCE BULL" :
(conf_bear ? "CONFLUENCE BEAR" : "FLOW: BALANCED")
color cTc = conf_bull ? #10B981 : (conf_bear ? #EF4444 : #94A3B8)
table.cell(tb, 0, 5, "ALIGN", text_color=#94A3B8, bgcolor=cBg,
text_size=size.tiny, text_font_family=font.family_monospace)
table.cell(tb, 1, 5, cTx, text_color=cTc, bgcolor=cBg,
text_size=size.tiny, text_font_family=font.family_monospace)
table.cell(tb, 2, 5, "--", text_color=cTc, bgcolor=cBg,
text_size=size.tiny, text_font_family=font.family_monospace)
table.cell(tb, 3, 5, cTx, text_color=cTc, bgcolor=cBg,
text_size=size.tiny, text_font_family=font.family_monospace)
// ----------------------------------------------------------------------------
// 8. AUDIO & WEBHOOK ALERTS
// ----------------------------------------------------------------------------
bool alt_15_fire = ((in_15_b and not in_15_b[1]) or
(in_15_s and not in_15_s[1])) and i_alt_15m
bool alt_1h_fire = ((in_1h_b and not in_1h_b[1]) or
(in_1h_s and not in_1h_s[1])) and i_alt_1h
bool alt_cf_fire = ((conf_bull and not conf_bull[1]) or
(conf_bear and not conf_bear[1])) and i_alt_conf
alertcondition(alt_15_fire, "LE Alert: Inside 15M FVG",
"Price entered active 15M FVG zone.")
alertcondition(alt_1h_fire, "LE Alert: Inside 1H FVG",
"Price entered active 1H FVG zone.")
alertcondition(alt_cf_fire, "LE Alert: Multi-TF Confluence",
"Price aligned inside concurrent 15M and 1H FVG zones.")