Liquidity Edge - 10:00 AM Silver Bullet & Macro Radar PRO

liquidityedgefutures · study · 466 行 · 点赞 14 · TradingView 原页

本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。

Pine Script

// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © LiquidityEdgeFutures 
// =========================================================================================================
//  LIQUIDITY EDGE | 10:00 AM NY SILVER BULLET & MACRO LEVELS RADAR [PRO MASTER EDITION]
//  Institutional Timing, Session Levels, Initial Balance Sweeps & High-Visibility Desk HUD
// =========================================================================================================
 
//@version=6
indicator(
     title="Liquidity Edge - 10:00 AM Silver Bullet & Macro Radar PRO",
     shorttitle="LE - Silver Bullet Radar PRO",
     overlay=true,
     max_lines_count=500,
     max_labels_count=500,
     max_boxes_count=500
 )
 
// ---------------------------------------------------------------------------------------------------------
// INPUT CONFIGURATION
// ---------------------------------------------------------------------------------------------------------
var string G_TIMING = "1. Silver Bullet & Macro Timing Windows"
var string G_LEVELS = "2. Key Institutional Reference Levels"
var string G_SWEEPS = "3. 09:30 - 10:00 AM Opening Range & Sweeps"
var string G_HUD    = "4. High-Visibility Desk Telemetry HUD"
var string G_ALERTS = "5. Audio & Webhook Alerts"
 
// 1. Timing Windows
bool   i_showSbWindow   = input.bool(true, "Show NY AM Silver Bullet (10:00 - 11:00 AM)", group=G_TIMING)
color  i_sbColor        = input.color(color.new(#06B6D4, 92), "NY AM Window Tint (Cyan)", group=G_TIMING)
bool   i_showLondonSb   = input.bool(false, "Show London Silver Bullet (03:00 - 04:00 AM)", group=G_TIMING)
color  i_lonColor       = input.color(color.new(#8B5CF6, 92), "London Window Tint (Violet)", group=G_TIMING)
bool   i_showPmSb       = input.bool(false, "Show NY PM Silver Bullet (14:00 - 15:00 PM)", group=G_TIMING)
color  i_pmColor        = input.color(color.new(#F59E0B, 92), "NY PM Window Tint (Amber)", group=G_TIMING)
 
// 2. Key Institutional Reference Levels
bool   i_showPdhPdl     = input.bool(true, "Show Previous Day High / Low (PDH/PDL)", group=G_LEVELS)
color  i_pdhColor       = input.color(#EF4444, "PDH (Buy-Side Liquidity) Color", group=G_LEVELS)
color  i_pdlColor       = input.color(#10B981, "PDL (Sell-Side Liquidity) Color", group=G_LEVELS)
 
bool   i_showMidnight   = input.bool(true, "Show Midnight Open (00:00 NY True Day Open)", group=G_LEVELS)
color  i_midColor       = input.color(#A855F7, "Midnight Open Color (Purple)", group=G_LEVELS)
 
bool   i_show830        = input.bool(true, "Show 08:30 AM NY Open (News Benchmark)", group=G_LEVELS)
color  i_830Color       = input.color(#38BDF8, "08:30 AM Open Color (Sky Blue)", group=G_LEVELS)
 
bool   i_show930        = input.bool(true, "Show 09:30 AM Equity Open Bell", group=G_LEVELS)
color  i_930Color       = input.color(#F59E0B, "09:30 AM Open Color (Gold)", group=G_LEVELS)
 
string i_lineStyle      = input.string("Dashed", "Benchmark Line Style", options=["Dashed", "Solid", "Dotted"], group=G_LEVELS)
bool   i_cleanOldLines  = input.bool(true, "Clean Up Prior Day Benchmark Lines (Zero Clutter)", group=G_LEVELS)
 
// 3. Opening Range & Sweep Signals
bool   i_showORBox      = input.bool(true, "Draw 09:30 - 10:00 AM Initial Balance Box", group=G_SWEEPS)
color  i_orBoxColor     = input.color(color.new(#38BDF8, 93), "Opening Range Box Tint", group=G_SWEEPS)
bool   i_onlyFirstSweep = input.bool(true, "De-Duplicate: Only Signal First Sweep of Session", tooltip="Stops repetitive overlapping labels when multiple wicks breach liquidity.", group=G_SWEEPS)
string i_sweepStyle     = input.string("Sleek Minimalist Chevrons", "Sweep Marker Style", options=["Sleek Minimalist Chevrons", "Micro Badges (⚡ BSL/SSL)", "Standard Text Badges"], group=G_SWEEPS)
 
// 4. Desk Telemetry HUD
bool   i_showHud        = input.bool(true, "Display Desk Telemetry HUD", group=G_HUD)
string i_hudPosition    = input.string("Top Right", "HUD Position", options=["Top Right", "Bottom Right", "Top Left", "Bottom Left"], group=G_HUD)
string i_hudSize        = input.string("Normal (Readable)", "HUD Text Size", options=["Normal (Readable)", "Large (High-Res Monitors)", "Compact (Small)"], tooltip="Increase this to make the dashboard larger and more legible.", group=G_HUD)
int    i_targetPts      = input.int(20, "Silver Bullet Profit Objective (Points)", minval=5, maxval=100, step=5, group=G_HUD)
 
// 5. Alerts
bool   i_alt_sb_start   = input.bool(true, "Alert: Silver Bullet Window Active", group=G_ALERTS)
bool   i_alt_bsl_sweep  = input.bool(true, "Alert: Buy-Side Liquidity Swept", group=G_ALERTS)
bool   i_alt_ssl_sweep  = input.bool(true, "Alert: Sell-Side Liquidity Swept", group=G_ALERTS)
 
// ---------------------------------------------------------------------------------------------------------
// SESSION TIMING CHECKS (New York Time Zone)
// ---------------------------------------------------------------------------------------------------------
inSilverBullet = not na(time(timeframe.period, "1000-1100:23456", "America/New_York"))
inLondonMacro  = not na(time(timeframe.period, "0300-0400:23456", "America/New_York"))
inPMMacro      = not na(time(timeframe.period, "1400-1500:23456", "America/New_York"))
inOpeningRange = not na(time(timeframe.period, "0930-1000:23456", "America/New_York"))
 
// Background tinting
bgcolor(i_showSbWindow and inSilverBullet ? i_sbColor : na, title="10:00 AM NY Silver Bullet Window")
bgcolor(i_showLondonSb and inLondonMacro ? i_lonColor : na, title="03:00 AM London Silver Bullet Window")
bgcolor(i_showPmSb and inPMMacro ? i_pmColor : na, title="14:00 PM NY PM Silver Bullet Window")
 
// ---------------------------------------------------------------------------------------------------------
// PREVIOUS DAY HIGH & LOW (PDH / PDL)
// ---------------------------------------------------------------------------------------------------------
[prevDayHigh, prevDayLow] = request.security(
     syminfo.tickerid,
     "D",
     [high[1], low[1]],
     lookahead=barmerge.lookahead_on
 )
 
var line ln_pdh = na
var line ln_pdl = na
var label lbl_pdh = na
var label lbl_pdl = na
 
if i_showPdhPdl and barstate.islast
    line.delete(ln_pdh)
    line.delete(ln_pdl)
    label.delete(lbl_pdh)
    label.delete(lbl_pdl)
 
    ln_pdh := line.new(
         x1=bar_index - 80,
         y1=prevDayHigh,
         x2=bar_index + 15,
         y2=prevDayHigh,
         color=color.new(i_pdhColor, 20),
         width=2,
         style=line.style_dashed
     )
    lbl_pdh := label.new(
         x=bar_index + 16,
         y=prevDayHigh,
         text="PDH (BSL) " + str.tostring(prevDayHigh, "#.##"),
         textcolor=i_pdhColor,
         style=label.style_label_left,
         color=color.new(color.black, 100),
         size=size.tiny
     )
 
    ln_pdl := line.new(
         x1=bar_index - 80,
         y1=prevDayLow,
         x2=bar_index + 15,
         y2=prevDayLow,
         color=color.new(i_pdlColor, 20),
         width=2,
         style=line.style_dashed
     )
    lbl_pdl := label.new(
         x=bar_index + 16,
         y=prevDayLow,
         text="PDL (SSL) " + str.tostring(prevDayLow, "#.##"),
         textcolor=i_pdlColor,
         style=label.style_label_left,
         color=color.new(color.black, 100),
         size=size.tiny
     )
 
// ---------------------------------------------------------------------------------------------------------
// CLEAN INTRADAY BENCHMARK LINES (Midnight, 08:30 AM, 09:30 AM)
// ---------------------------------------------------------------------------------------------------------
var float price_midnight = na
var float price_830      = na
var float price_930      = na
 
var int bar_midnight     = na
var int bar_830          = na
var int bar_930          = na
 
var line ln_mid = na
var line ln_830 = na
var line ln_930 = na
 
var label lb_mid = na
var label lb_830 = na
var label lb_930 = na
 
t_midnight = not na(time(timeframe.period, "0000-0005:23456", "America/New_York"))
t_830      = not na(time(timeframe.period, "0830-0835:23456", "America/New_York"))
t_930      = not na(time(timeframe.period, "0930-0935:23456", "America/New_York"))
 
is_new_day = ta.change(time("D")) != 0
 
line_style_chosen = i_lineStyle == "Solid" ? line.style_solid : (i_lineStyle == "Dotted" ? line.style_dotted : line.style_dashed)
 
if is_new_day
    price_midnight := na
    price_830      := na
    price_930      := na
    bar_midnight   := na
    bar_830        := na
    bar_930        := na
    if i_cleanOldLines
        line.delete(ln_mid)
        line.delete(ln_830)
        line.delete(ln_930)
        label.delete(lb_mid)
        label.delete(lb_830)
        label.delete(lb_930)
 
if t_midnight and na(price_midnight)
    price_midnight := open
    bar_midnight   := bar_index
 
if t_830 and na(price_830)
    price_830 := open
    bar_830   := bar_index
 
if t_930 and na(price_930)
    price_930 := open
    bar_930   := bar_index
 
// Project clean benchmark lines to current bar on last state
if barstate.islast
    // Midnight line
    if i_showMidnight and not na(price_midnight) and not na(bar_midnight)
        line.delete(ln_mid)
        label.delete(lb_mid)
        ln_mid := line.new(
             x1=bar_midnight,
             y1=price_midnight,
             x2=bar_index + 10,
             y2=price_midnight,
             color=i_midColor,
             width=1,
             style=line_style_chosen
         )
        lb_mid := label.new(
             x=bar_index + 11,
             y=price_midnight,
             text="Midnight Open " + str.tostring(price_midnight, "#.##"),
             textcolor=i_midColor,
             style=label.style_label_left,
             color=color.new(color.black, 100),
             size=size.tiny
         )
 
    // 08:30 line
    if i_show830 and not na(price_830) and not na(bar_830)
        line.delete(ln_830)
        label.delete(lb_830)
        ln_830 := line.new(
             x1=bar_830,
             y1=price_830,
             x2=bar_index + 10,
             y2=price_830,
             color=i_830Color,
             width=1,
             style=line_style_chosen
         )
        lb_830 := label.new(
             x=bar_index + 11,
             y=price_830,
             text="08:30 Open " + str.tostring(price_830, "#.##"),
             textcolor=i_830Color,
             style=label.style_label_left,
             color=color.new(color.black, 100),
             size=size.tiny
         )
 
    // 09:30 Equity Open line
    if i_show930 and not na(price_930) and not na(bar_930)
        line.delete(ln_930)
        label.delete(lb_930)
        ln_930 := line.new(
             x1=bar_930,
             y1=price_930,
             x2=bar_index + 10,
             y2=price_930,
             color=i_930Color,
             width=1,
             style=line_style_chosen
         )
        lb_930 := label.new(
             x=bar_index + 11,
             y=price_930,
             text="09:30 Equity Open " + str.tostring(price_930, "#.##"),
             textcolor=i_930Color,
             style=label.style_label_left,
             color=color.new(color.black, 100),
             size=size.tiny
         )
 
// ---------------------------------------------------------------------------------------------------------
// 09:30 - 10:00 INITIAL BALANCE (OPENING RANGE) BOX
// ---------------------------------------------------------------------------------------------------------
var float or_high      = na
var float or_low       = na
var int   or_start_bar = na
var int   or_end_bar   = na
var box   or_box       = na
 
if is_new_day
    or_high      := na
    or_low       := na
    or_start_bar := na
    or_end_bar   := na
 
if inOpeningRange
    if na(or_start_bar)
        or_start_bar := bar_index
    or_high    := na(or_high) ? high : math.max(or_high, high)
    or_low     := na(or_low)  ? low  : math.min(or_low, low)
    or_end_bar := bar_index
 
// Project Initial Balance Box
if i_showORBox and not na(or_start_bar) and not na(or_high) and not na(or_low)
    int boxRight = inSilverBullet ? bar_index + 2 : (na(or_end_bar) ? bar_index : or_end_bar)
    if na(or_box)
        or_box := box.new(
             left=or_start_bar,
             top=or_high,
             right=boxRight,
             bottom=or_low,
             border_color=color.new(#38BDF8, 50),
             border_width=1,
             border_style=line.style_dashed,
             bgcolor=i_orBoxColor
         )
    else
        box.set_left(or_box, or_start_bar)
        box.set_top(or_box, or_high)
        box.set_right(or_box, boxRight)
        box.set_bottom(or_box, or_low)
 
// ---------------------------------------------------------------------------------------------------------
// DE-DUPLICATED LIQUIDITY SWEEP ENGINE
// ---------------------------------------------------------------------------------------------------------
var bool orHighSweptToday = false
var bool orLowSweptToday  = false
 
if is_new_day or (inSilverBullet and not inSilverBullet[1])
    orHighSweptToday := false
    orLowSweptToday  := false
 
bool trigSweepHigh = false
bool trigSweepLow  = false
 
if inSilverBullet and not na(or_high) and (high > or_high) and (close < or_high)
    if not i_onlyFirstSweep or not orHighSweptToday
        trigSweepHigh := true
    orHighSweptToday := true
 
if inSilverBullet and not na(or_low) and (low < or_low) and (close > or_low)
    if not i_onlyFirstSweep or not orLowSweptToday
        trigSweepLow := true
    orLowSweptToday := true
 
// Sweep Marker Rendering
bool useChevrons  = i_sweepStyle == "Sleek Minimalist Chevrons"
bool useMicro     = i_sweepStyle == "Micro Badges (⚡ BSL/SSL)"
bool useStdBadges = i_sweepStyle == "Standard Text Badges"
 
// 1. Sleek Chevrons (Zero chart clutter, no blocking text)
plotshape(
     useChevrons and trigSweepHigh,
     title="OR High BSL Swept (Chevron)",
     style=shape.triangledown,
     location=location.abovebar,
     color=#EF4444,
     size=size.small
 )
 
plotshape(
     useChevrons and trigSweepLow,
     title="OR Low SSL Swept (Chevron)",
     style=shape.triangleup,
     location=location.belowbar,
     color=#10B981,
     size=size.small
 )
 
// 2. Micro Badges
if useMicro and trigSweepHigh
    label.new(
         x=bar_index,
         y=high,
         text="⚡ BSL SWEPT",
         yloc=yloc.abovebar,
         color=color.new(#0A0F1D, 15),
         textcolor=#EF4444,
         style=label.style_label_down,
         size=size.tiny
     )
 
if useMicro and trigSweepLow
    label.new(
         x=bar_index,
         y=low,
         text="⚡ SSL SWEPT",
         yloc=yloc.belowbar,
         color=color.new(#0A0F1D, 15),
         textcolor=#10B981,
         style=label.style_label_up,
         size=size.tiny
     )
 
// 3. Standard Text Badges (Now cleanly de-duplicated so they never overlap 4x!)
plotshape(
     useStdBadges and trigSweepHigh,
     title="OR High BSL Swept",
     style=shape.triangledown,
     location=location.abovebar,
     color=#EF4444,
     size=size.small,
     text="BUY-SIDE SWEPT"
 )
 
plotshape(
     useStdBadges and trigSweepLow,
     title="OR Low SSL Swept",
     style=shape.triangleup,
     location=location.belowbar,
     color=#10B981,
     size=size.small,
     text="SELL-SIDE SWEPT"
 )
 
// ---------------------------------------------------------------------------------------------------------
// HIGH-VISIBILITY DESK TELEMETRY HUD (Enlarged & Highly Readable)
// ---------------------------------------------------------------------------------------------------------
hud_pos = i_hudPosition == "Top Right" ? position.top_right : (i_hudPosition == "Bottom Right" ? position.bottom_right : (i_hudPosition == "Top Left" ? position.top_left : position.bottom_left))
 
// Size resolver
hud_hdrSize  = i_hudSize == "Large (High-Res Monitors)" ? size.normal : (i_hudSize == "Compact (Small)" ? size.small : size.normal)
hud_bodySize = i_hudSize == "Large (High-Res Monitors)" ? size.normal : (i_hudSize == "Compact (Small)" ? size.tiny : size.small)
 
var table hud = table.new(
     position=hud_pos,
     columns=2,
     rows=7,
     bgcolor=color.new(#030712, 10),
     border_color=color.new(#1E2D48, 30),
     border_width=1
 )
 
if i_showHud and barstate.islast
    // Header
    color hdrBg = inSilverBullet ? #0E3B43 : (inOpeningRange ? #3B2A05 : #0A0F1D)
    string hdrSub = inSilverBullet ? "ACTIVE: SILVER BULLET" : (inOpeningRange ? "OPENING RANGE (09:30)" : "MACRO RADAR PRO")
    table.cell(hud, 0, 0, "⚡ LIQUIDITY EDGE", text_color=#38BDF8, text_size=hud_hdrSize, text_font_family=font.family_monospace, bgcolor=hdrBg)
    table.cell(hud, 1, 0, hdrSub, text_color=#F8FAFC, text_size=hud_hdrSize, text_font_family=font.family_monospace, bgcolor=hdrBg)
 
    // 1. Current Macro Window Status
    string macroStatus = inSilverBullet ? "● ACTIVE: NY AM (10:00-11:00)" : (inOpeningRange ? "● INITIAL BALANCE (09:30-10:00)" : (inLondonMacro ? "● ACTIVE: LONDON (03:00-04:00)" : (inPMMacro ? "● ACTIVE: NY PM (14:00-15:00)" : "○ OFF-MACRO WINDOW")))
    color  macroColor  = inSilverBullet ? #00F2FE : (inOpeningRange ? #F59E0B : (inLondonMacro ? #A855F7 : (inPMMacro ? #FB923C : #64748B)))
    table.cell(hud, 0, 1, "Macro Window", text_color=#94A3B8, text_size=hud_bodySize, text_font_family=font.family_monospace)
    table.cell(hud, 1, 1, macroStatus, text_color=macroColor, text_size=hud_bodySize, text_font_family=font.family_monospace)
 
    // 2. 09:30 Opening Range Sweeps
    string sweepTxt = (orHighSweptToday and orLowSweptToday) ? "⚡ BSL & SSL SWEPT" : (orHighSweptToday ? "⚡ BSL SWEPT (Bearish Bias)" : (orLowSweptToday ? "⚡ SSL SWEPT (Bullish Bias)" : "WAITING FOR 10:00 SWEEP"))
    color  sweepCol = (orHighSweptToday and orLowSweptToday) ? #F59E0B : (orHighSweptToday ? #EF4444 : (orLowSweptToday ? #10B981 : #94A3B8))
    table.cell(hud, 0, 2, "09:30 OR Sweeps", text_color=#94A3B8, text_size=hud_bodySize, text_font_family=font.family_monospace)
    table.cell(hud, 1, 2, sweepTxt, text_color=sweepCol, text_size=hud_bodySize, text_font_family=font.family_monospace)
 
    // 3. Distance to PDH
    float distPdh = prevDayHigh - close
    string pdhTxt = (distPdh > 0 ? "+" : "") + str.tostring(distPdh, "#.#") + " pts (" + str.tostring(prevDayHigh, "#.##") + ")"
    table.cell(hud, 0, 3, "Dist to PDH (BSL)", text_color=#94A3B8, text_size=hud_bodySize, text_font_family=font.family_monospace)
    table.cell(hud, 1, 3, pdhTxt, text_color=(distPdh > 0 ? #EF4444 : #10B981), text_size=hud_bodySize, text_font_family=font.family_monospace)
 
    // 4. Distance to PDL
    float distPdl = close - prevDayLow
    string pdlTxt = (distPdl > 0 ? "+" : "") + str.tostring(distPdl, "#.#") + " pts (" + str.tostring(prevDayLow, "#.##") + ")"
    table.cell(hud, 0, 4, "Dist to PDL (SSL)", text_color=#94A3B8, text_size=hud_bodySize, text_font_family=font.family_monospace)
    table.cell(hud, 1, 4, pdlTxt, text_color=(distPdl > 0 ? #10B981 : #EF4444), text_size=hud_bodySize, text_font_family=font.family_monospace)
 
    // 5. Midnight Open Directional Bias
    string midBias = not na(price_midnight) ? (close > price_midnight ? "▲ BULLISH (+" + str.tostring(close - price_midnight, "#.#") + " pts)" : "▼ BEARISH (-" + str.tostring(price_midnight - close, "#.#") + " pts)") : "N/A"
    color  midColor = not na(price_midnight) ? (close > price_midnight ? #10B981 : #EF4444) : #64748B
    table.cell(hud, 0, 5, "Midnight Bias (00:00)", text_color=#94A3B8, text_size=hud_bodySize, text_font_family=font.family_monospace)
    table.cell(hud, 1, 5, midBias, text_color=midColor, text_size=hud_bodySize, text_font_family=font.family_monospace)
 
    // 6. Silver Bullet Profit Objective
    string tgtTxt = str.tostring(i_targetPts, "#") + ".00 pts (" + str.tostring(i_targetPts * 4, "#") + " ticks)"
    table.cell(hud, 0, 6, "Macro Objective", text_color=#94A3B8, text_size=hud_bodySize, text_font_family=font.family_monospace)
    table.cell(hud, 1, 6, tgtTxt, text_color=#00F2FE, text_size=hud_bodySize, text_font_family=font.family_monospace)
 
// ---------------------------------------------------------------------------------------------------------
// ALERTS
// ---------------------------------------------------------------------------------------------------------
alertcondition(inSilverBullet and not inSilverBullet[1], title="Silver Bullet Macro Activated", message="[Liquidity Edge] 🚀 10:00 AM NY Silver Bullet Window Activated on {{ticker}}!")
alertcondition(trigSweepHigh, title="Buy-Side Liquidity Swept", message="[Liquidity Edge] 🩸 10:00 AM Buy-Side Liquidity (OR High) Swept on {{ticker}}! Watch for Bearish Reversal / FVG.")
alertcondition(trigSweepLow, title="Sell-Side Liquidity Swept", message="[Liquidity Edge] 🟢 10:00 AM Sell-Side Liquidity (OR Low) Swept on {{ticker}}! Watch for Bullish Reversal / FVG.")

← 返回列表