Saturnian CVD Engine

VORSwingTrading · study · 397 行 · 点赞 10 · TradingView 原页

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

Pine Script

//@version=6
// =============================================================================
// SATURNIAN CVD ENGINE [STANDALONE MASTER AUDITED v6]
// =============================================================================
// 1. Multi-Session Intraday Resets (Every Session Tokyo/London/NY, Individual, Daily, Continuous).
// 2. Session-segmented CVD SMA (0 morning bias).
// 3. Proportional footprint delta wick-scaling.
// 4. Timeframe-guarded intraday session resets (1D+ safe).
// 5. VSA Squat Absorption + RVOL 0.8x breakout ignition gating.
// 6. Anti-overlap Pivot Divergence Engine (Regular + Hidden).
// =============================================================================
 
indicator("Saturnian CVD Engine", overlay=false, max_boxes_count=500, max_labels_count=500, max_lines_count=500)
 
// =============================================================================
// 1. INPUT CONFIGURATION & SETTINGS
// =============================================================================
grp_calc     = "CVD Calculation Engine & Session Resets"
calcMode     = input.string("Native Footprint + LTF (Premium)", "Calculation Mode", options=["Native Footprint + LTF (Premium)", "Intrabar LTF (High Precision)", "Price Action Hybrid (Fast/Universal)"], group=grp_calc)
ticksPerRow  = input.int(75, "Footprint Ticks Per Row", minval=10, group=grp_calc)
ltfResInput  = input.string("Auto", "Intrabar LTF Resolution", options=["Auto", "1S", "5S", "15S", "30S", "1", "3", "5"], group=grp_calc)
resetMode    = input.string("Every Session Open (Tokyo, London & NY)", "CVD Reset Anchor (Intraday Only)", options=["Every Session Open (Tokyo, London & NY)", "NY Session Open", "London Session Open", "Tokyo Session Open", "Daily Bar Open (00:00 UTC)", "Continuous (No Reset)"], group=grp_calc, tooltip="Controls when Cumulative Volume Delta resets to 0: 'Every Session Open (Tokyo, London & NY)' resets dynamically at Tokyo, London, and NY starts; or select an individual session open, daily bar open, or continuous accumulation.")
aggThresh    = input.float(15.0, "Aggressive Delta Threshold (%)", minval=5.0, maxval=50.0, step=1.0, group=grp_calc)
minIgnRvol   = input.float(0.8, "Min RVOL for ±15% Ignition (0.8 = Synced to Engine)", minval=0.1, maxval=3.0, step=0.1, group=grp_calc)
 
grp_sess     = "Market Session Timings (Reset Anchor)"
tz           = input.string("GMT+5", "Session Timezone", group=grp_sess)
tTok         = input.session("0500-1400", "Tokyo Session", group=grp_sess)
tLon         = input.session("1300-2200", "London Session", group=grp_sess)
tNy          = input.session("1700-0200", "New York Session", group=grp_sess)
 
grp_sma      = "CVD Moving Average"
showSma      = input.bool(true, "Show Session-Aware CVD SMA", group=grp_sma)
smaLen       = input.int(15, "CVD SMA Length", minval=1, group=grp_sma)
colSma       = input.color(color.rgb(255, 171, 0), "SMA Line Color", group=grp_sma)
 
grp_div      = "Advanced Divergence & Absorption Engine"
enableDiv    = input.bool(true, "Enable Regular Divergences", group=grp_div)
enableHidDiv = input.bool(true, "Enable Hidden Continuation Divergences", group=grp_div)
showDivTags  = input.bool(false, "Show Text Labels on Divergences (Off = Clean Dots)", group=grp_div)
divLeft      = input.int(14, "Pivot Left Lookback (Bars)", minval=2, maxval=200, group=grp_div)
divRight     = input.int(3, "Pivot Right Confirmation (Bars)", minval=1, maxval=50, group=grp_div)
minBarsDiv   = input.int(4, "Min Distance Between Pivots (Bars)", minval=2, maxval=100, group=grp_div)
maxBarsDiv   = input.int(120, "Max Distance Between Pivots (Bars)", minval=5, maxval=2000, group=grp_div)
enableAbsorb = input.bool(true, "Enable Delta & VSA Squat Absorption Signals", group=grp_div)
volAbsLen    = input.int(15, "Volume MA Length (Synced to Engine)", minval=1, group=grp_div)
colBullDiv   = input.color(color.lime, "Bullish Divergence Color", group=grp_div)
colBearDiv   = input.color(color.red, "Bearish Divergence Color", group=grp_div)
 
grp_theme    = "Visuals & Palette"
colBullCand  = input.color(color.rgb(0, 230, 118), "CVD Bull Candle", group=grp_theme)
colBearCand  = input.color(color.rgb(255, 23, 68), "CVD Bear Candle", group=grp_theme)
colBullIgn   = input.color(color.rgb(0, 255, 255), "Aggressive +15% Bull Candle", group=grp_theme)
colBearIgn   = input.color(color.rgb(255, 0, 255), "Aggressive -15% Bear Candle", group=grp_theme)
colZero      = input.color(color.new(color.gray, 60), "Zero Line Color", group=grp_theme)
 
grp_hud      = "Live Aggression HUD"
showHud      = input.bool(true, "Show CVD HUD Table", group=grp_hud)
hudPosInput  = input.string("Top Right", "HUD Position", options=["Top Right", "Bottom Right", "Top Left", "Bottom Left"], group=grp_hud)
hudBg        = input.color(color.new(color.black, 15), "HUD Background Color", group=grp_hud)
hudBorder    = input.color(color.rgb(48, 54, 61), "HUD Border Color", group=grp_hud)
 
// =============================================================================
// 2. HELPER FUNCTIONS & PREMIUM AUTO LTF RESOLUTION ROUTING
// =============================================================================
f_get_hud_position(string pos) =>
    pos == "Top Right" ? position.top_right : pos == "Top Left" ? position.top_left : pos == "Bottom Left" ? position.bottom_left : position.bottom_right
 
f_fmt_num(float val) =>
    float a = math.abs(val)
    string s = val > 0 ? "+" : val < 0 ? "-" : ""
    if a >= 1000000000
        s + str.tostring(a / 1000000000, "#.##") + "B"
    else if a >= 1000000
        s + str.tostring(a / 1000000, "#.##") + "M"
    else if a >= 1000
        s + str.tostring(a / 1000, "#.##") + "K"
    else
        s + str.tostring(a, "#.##")
 
int tfSec = timeframe.in_seconds(timeframe.period)
string autoLtf = tfSec <= 60 ? "5S" : tfSec <= 900 ? "15S" : tfSec <= 3600 ? "1" : "5"
string activeLtfRes = ltfResInput == "Auto" ? autoLtf : ltfResInput
 
// Session-segmented intraday resets (Tokyo, London, NY, Daily, or Continuous)
bool inTok          = not na(time(timeframe.period, tTok, tz))
bool inLon          = not na(time(timeframe.period, tLon, tz))
bool inNy           = not na(time(timeframe.period, tNy, tz))
bool isTokStart     = inTok and not inTok[1]
bool isLonStart     = inLon and not inLon[1]
bool isNyStart      = inNy and not inNy[1]
bool isAnySessStart = isTokStart or isLonStart or isNyStart
 
bool rawNewDay      = timeframe.change("D")
bool isSessionReset = resetMode == "Every Session Open (Tokyo, London & NY)" ? isAnySessStart : 
                      resetMode == "NY Session Open" ? isNyStart : 
                      resetMode == "London Session Open" ? isLonStart : 
                      resetMode == "Tokyo Session Open" ? isTokStart : 
                      resetMode == "Daily Bar Open (00:00 UTC)" ? rawNewDay : 
                      false
 
bool isResetEnabled = resetMode != "Continuous (No Reset)"
bool effectiveReset = isResetEnabled and tfSec < 86400 and (isSessionReset or barstate.isfirst)
 
// =============================================================================
// 3. FOOTPRINT + INTRABAR VOLUME DELTA COMPUTATION (PINE v6 SAFE)
// =============================================================================
float barRng   = high - low
float closePos = barRng > 0 ? (close - low) / barRng : 0.5
float hybridDelta = barRng > 0 ? volume * ((2.0 * (close - low) - barRng) / barRng) : (close > open ? volume : close < open ? -volume : 0.0)
 
float upperWickRatio = barRng > 0 ? (high - math.max(open, close)) / barRng : 0.0
float lowerWickRatio = barRng > 0 ? (math.min(open, close) - low) / barRng : 0.0
 
float hybridMaxDelta = math.max(0.0, hybridDelta) + (volume * upperWickRatio * 0.35)
float hybridMinDelta = math.min(0.0, hybridDelta) - (volume * lowerWickRatio * 0.35)
 
[ltf_o, ltf_h, ltf_l, ltf_c, ltf_v] = request.security_lower_tf(syminfo.tickerid, activeLtfRes, [open, high, low, close, volume])
 
// Unconditional Footprint & TA evaluations in global scope prevent CW10002 warnings
footprint rawFp = request.footprint(ticksPerRow, 70, 300)
float volSma    = ta.sma(volume, volAbsLen)
float atrVal    = ta.atr(volAbsLen)
float rawLow5   = ta.lowest(low, 5)
float rawHigh5  = ta.highest(high, 5)
float rvol      = volSma > 0 ? volume / volSma : 1.0
 
bool useFpMode  = calcMode == "Native Footprint + LTF (Premium)"
bool hasFp      = useFpMode and not na(rawFp)
 
float bar_net_delta = 0.0
float bar_min_delta = 0.0
float bar_max_delta = 0.0
 
bool useLtf = (calcMode != "Price Action Hybrid (Fast/Universal)") and not na(ltf_c) and array.size(ltf_c) > 0
 
if useLtf
    float running = 0.0
    float runMin  = 0.0
    float runMax  = 0.0
    int sz = array.size(ltf_c)
    for i = 0 to sz - 1
        float sub_c = array.get(ltf_c, i)
        float sub_o = array.get(ltf_o, i)
        float sub_h = array.get(ltf_h, i)
        float sub_l = array.get(ltf_l, i)
        float sub_v = array.get(ltf_v, i)
        float sub_rng = sub_h - sub_l
        float sub_d = sub_rng > 0 ? sub_v * ((2.0 * (sub_c - sub_l) - sub_rng) / sub_rng) : (sub_c > sub_o ? sub_v : sub_c < sub_o ? -sub_v : 0.0)
        running += sub_d
        runMin := math.min(runMin, running)
        runMax := math.max(runMax, running)
    bar_net_delta := running
    bar_min_delta := runMin
    bar_max_delta := runMax
else
    bar_net_delta := hybridDelta
    bar_min_delta := hybridMinDelta
    bar_max_delta := hybridMaxDelta
 
// Proportional Wick-Preserving Footprint Synchronization
float fpTotalVol = volume
if hasFp
    float fpBuy        = footprint.buy_volume(rawFp)
    float fpSell       = footprint.sell_volume(rawFp)
    float exactD       = fpBuy - fpSell
    float exactTot     = fpBuy + fpSell
    float rawUpperWick = math.max(0.0, bar_max_delta - math.max(0.0, bar_net_delta))
    float rawLowerWick = math.max(0.0, math.min(0.0, bar_net_delta) - bar_min_delta)
    float volScale     = (volume > 0 and exactTot > 0) ? (exactTot / volume) : 1.0
    bar_net_delta := exactD
    fpTotalVol    := exactTot > 0 ? exactTot : volume
    bar_max_delta := math.max(0.0, exactD) + (rawUpperWick * volScale)
    bar_min_delta := math.min(0.0, exactD) - (rawLowerWick * volScale)
 
// =============================================================================
// 4. CVD ACCUMULATION, SESSION-AWARE SMA & CANDLE ENGINE
// =============================================================================
var float cvdClose      = 0.0
var int   barsInSession = 0
 
if effectiveReset
    barsInSession := 1
else
    barsInSession += 1
 
float priorClose = effectiveReset ? 0.0 : nz(cvdClose[1], 0.0)
 
float cvdOpen  = priorClose
cvdClose      := priorClose + bar_net_delta
float cvdHigh  = priorClose + bar_max_delta
float cvdLow   = priorClose + bar_min_delta
 
cvdHigh := math.max(cvdHigh, math.max(cvdOpen, cvdClose))
cvdLow  := math.min(cvdLow,  math.min(cvdOpen, cvdClose))
 
// Session-segmented SMA prevents prior-session CVD from distorting opening SMA
float rawCvdSma = ta.sma(cvdClose, smaLen)
float cvdSma    = rawCvdSma
if isResetEnabled and tfSec < 86400 and barsInSession < smaLen
    float sessSum = 0.0
    for i = 0 to barsInSession - 1
        sessSum += nz(cvdClose[i], 0.0)
    cvdSma := sessSum / barsInSession
 
float deltaPct  = fpTotalVol > 0 ? (bar_net_delta / fpTotalVol) * 100.0 : 0.0
bool  qualRvol  = rvol >= minIgnRvol
bool  aggBuyers  = deltaPct >= aggThresh and qualRvol
bool  aggSellers = deltaPct <= -aggThresh and qualRvol
 
bool isBullCvd = cvdClose >= cvdOpen
color bodyCol  = aggBuyers ? colBullIgn : aggSellers ? colBearIgn : isBullCvd ? colBullCand : colBearCand
 
plotcandle(cvdOpen, cvdHigh, cvdLow, cvdClose, title="CVD Candles", color=bodyCol, wickcolor=bodyCol, bordercolor=bodyCol)
hline(0, "Zero Line", color=colZero, linestyle=hline.style_dotted, linewidth=1)
plot(showSma ? cvdSma : na, title="Session-Aware CVD SMA", color=colSma, linewidth=2)
 
// =============================================================================
// 5. INSTITUTIONAL PASSIVE LIMIT, VSA SQUAT & WYCKOFF SWEEP ABSORPTION
// =============================================================================
bool  hasVol = rvol >= minIgnRvol
float low5   = rawLow5[1]
float high5  = rawHigh5[1]
 
// 1. Wyckoff Sweep Reversal: Sweeps 5-bar extreme on volume and reverses with delta
bool bullSweepAbs = hasVol and low < low5 and bar_net_delta > 0 and close >= open and closePos >= 0.50 and lowerWickRatio >= 0.25
bool bearSweepAbs = hasVol and high > high5 and bar_net_delta < 0 and close <= open and closePos <= 0.50 and upperWickRatio >= 0.25
 
// 2. Passive Limit & VSA Squat Absorption: Heavy opposing delta fails to break price
bool bullBodyHold  = close > open and closePos >= 0.50 and upperWickRatio < 0.45
bool bearBodyHold  = close < open and closePos <= 0.50 and lowerWickRatio < 0.45
bool bullWickHold  = lowerWickRatio >= 0.45 and lowerWickRatio > upperWickRatio and closePos >= 0.45
bool bearWickHold  = upperWickRatio >= 0.45 and upperWickRatio > lowerWickRatio and closePos <= 0.55
bool bullSquatHold = rvol >= 1.5 and deltaPct <= -10.0 and barRng <= atrVal * 0.60 and closePos >= 0.45
bool bearSquatHold = rvol >= 1.5 and deltaPct >= 10.0  and barRng <= atrVal * 0.60 and closePos <= 0.55
 
bool bullLimitAbs = hasVol and deltaPct <= -5.0 and (bullBodyHold or bullWickHold or bullSquatHold)
bool bearLimitAbs = hasVol and deltaPct >= 5.0  and (bearBodyHold or bearWickHold or bearSquatHold)
 
bool rawBullAbs = enableAbsorb and (bullSweepAbs or bullLimitAbs)
bool rawBearAbs = enableAbsorb and (bearSweepAbs or bearLimitAbs)
 
bool bullAbsorb = rawBullAbs and (not rawBearAbs or closePos >= 0.50)
bool bearAbsorb = rawBearAbs and (not rawBullAbs or closePos < 0.50)
 
plotchar(bullAbsorb, title="Bull Absorption (Put Wall Hold)", char="▲", location=location.bottom, color=color.lime, size=size.tiny)
plotchar(bearAbsorb, title="Bear Absorption (Call Wall Hold)", char="▼", location=location.top, color=color.red, size=size.tiny)
 
// =============================================================================
// 6. ANTI-OVERLAP PIVOT DIVERGENCE ENGINE (REGULAR + HIDDEN + INVALIDATION)
// =============================================================================
float plPrice = ta.pivotlow(low, divLeft, divRight)
float phPrice = ta.pivothigh(high, divLeft, divRight)
 
var float prevPlPrice = na
var float prevPlCvd   = na
var int   prevPlBar   = na
 
var float prevPhPrice = na
var float prevPhCvd   = na
var int   prevPhBar   = na
 
var int   lastDivType  = 0
var int   lastDivBar   = na
var float lastDivPrice = na
var line[] divLines    = array.new_line()
 
if effectiveReset
    prevPlPrice  := na
    prevPlCvd    := na
    prevPlBar    := na
    prevPhPrice  := na
    prevPhCvd    := na
    prevPhBar    := na
    lastDivType  := 0
    lastDivBar   := na
    lastDivPrice := na
 
bool  isBullDiv = false
bool  isBearDiv = false
float bullDivY  = na
float bearDivY  = na
 
if (enableDiv or enableHidDiv) and not na(plPrice)
    float currentCvdLow = cvdLow[divRight]
    int   currentBar    = bar_index - divRight
    int   barDist       = not na(prevPlBar) ? (currentBar - prevPlBar) : 0
    if not na(prevPlPrice) and barDist >= minBarsDiv and barDist <= maxBarsDiv
        bool regBull = enableDiv and plPrice < prevPlPrice and currentCvdLow > prevPlCvd
        bool hidBull = enableHidDiv and plPrice > prevPlPrice and currentCvdLow < prevPlCvd
        if regBull or hidBull
            isBullDiv    := true
            bullDivY     := currentCvdLow
            lastDivType  := 1
            lastDivBar   := bar_index
            lastDivPrice := plPrice
            line l = line.new(prevPlBar, prevPlCvd, currentBar, currentCvdLow, xloc=xloc.bar_index, color=colBullDiv, width=2, style=regBull ? line.style_solid : line.style_dashed)
            array.push(divLines, l)
            if array.size(divLines) > 100
                line.delete(array.shift(divLines))
    prevPlPrice := plPrice
    prevPlCvd   := currentCvdLow
    prevPlBar   := currentBar
 
if (enableDiv or enableHidDiv) and not na(phPrice)
    float currentCvdHigh = cvdHigh[divRight]
    int   currentBar     = bar_index - divRight
    int   barDist        = not na(prevPhBar) ? (currentBar - prevPhBar) : 0
    if not na(prevPhPrice) and barDist >= minBarsDiv and barDist <= maxBarsDiv
        bool regBear = enableDiv and phPrice > prevPhPrice and currentCvdHigh < prevPhCvd
        bool hidBear = enableHidDiv and phPrice < prevPhPrice and currentCvdHigh > prevPhCvd
        if regBear or hidBear
            isBearDiv    := true
            bearDivY     := currentCvdHigh
            lastDivType  := -1
            lastDivBar   := bar_index
            lastDivPrice := phPrice
            line l = line.new(prevPhBar, prevPhCvd, currentBar, currentCvdHigh, xloc=xloc.bar_index, color=colBearDiv, width=2, style=regBear ? line.style_solid : line.style_dashed)
            array.push(divLines, l)
            if array.size(divLines) > 100
                line.delete(array.shift(divLines))
    prevPhPrice := phPrice
    prevPhCvd   := currentCvdHigh
    prevPhBar   := currentBar
 
// Invalidate active divergence state if price closes beyond the divergence pivot extreme
if lastDivType == 1 and not na(lastDivPrice) and close < lastDivPrice
    lastDivType := 0
if lastDivType == -1 and not na(lastDivPrice) and close > lastDivPrice
    lastDivType := 0
 
plotchar(isBullDiv ? bullDivY : na, title="Bullish Divergence Dot", char="•", location=location.absolute, color=colBullDiv, size=size.small, offset=-divRight)
plotchar(isBearDiv ? bearDivY : na, title="Bearish Divergence Dot", char="•", location=location.absolute, color=colBearDiv, size=size.small, offset=-divRight)
 
plotshape(showDivTags and isBullDiv ? bullDivY : na, title="Bullish Divergence Tag", style=shape.labelup, location=location.absolute, color=colBullDiv, text="BULL", textcolor=color.black, size=size.tiny, offset=-divRight)
plotshape(showDivTags and isBearDiv ? bearDivY : na, title="Bearish Divergence Tag", style=shape.labeldown, location=location.absolute, color=colBearDiv, text="BEAR", textcolor=color.white, size=size.tiny, offset=-divRight)
 
bool recentBullDiv = lastDivType == 1  and not na(lastDivBar) and (bar_index - lastDivBar <= 8)
bool recentBearDiv = lastDivType == -1 and not na(lastDivBar) and (bar_index - lastDivBar <= 8)
 
// =============================================================================
// 7. COMPANION LIVE HUD TABLE (100% SYNCED TO FOOTPRINT & SATURNIAN PLAYBOOK)
// =============================================================================
if showHud
    var table hud = table.new(f_get_hud_position(hudPosInput), 2, 9, bgcolor=hudBg, border_color=hudBorder, border_width=1)
    if barstate.islast
        bool longTrigger  = aggBuyers or bullAbsorb or recentBullDiv
        bool shortTrigger = aggSellers or bearAbsorb or recentBearDiv
        string trigText   = (aggBuyers and (bullAbsorb or recentBullDiv)) ? "🔥 A+ LONG (+15% & ABS)" : (aggSellers and (bearAbsorb or recentBearDiv)) ? "🔥 A+ SHORT (-15% & ABS)" : aggBuyers ? "🟢 +15% LONG OK" : aggSellers ? "🔴 -15% SHORT OK" : (bullAbsorb or recentBullDiv) ? "🟢 ABS/DIV LONG WATCH" : (bearAbsorb or recentBearDiv) ? "🔴 ABS/DIV SHORT WATCH" : "⚪ WAIT FOR ±15%"
        color trigCol     = longTrigger and not shortTrigger ? color.lime : shortTrigger and not longTrigger ? color.red : color.silver
        table.cell(hud, 0, 0, "Saturnian Trigger", text_color=color.gray, text_size=size.tiny)
        table.cell(hud, 1, 0, trigText, text_color=trigCol, text_size=size.tiny)
 
        string aggText = aggBuyers ? "BUYERS (BULL)" : aggSellers ? "SELLERS (BEAR)" : not qualRvol and math.abs(deltaPct) >= aggThresh ? "LOW RVOL (" + str.tostring(rvol, "#.##") + "x)" : "BALANCED"
        color aggColor = aggBuyers ? color.lime : aggSellers ? color.red : color.gray
        table.cell(hud, 0, 1, "Aggression", text_color=color.gray, text_size=size.tiny)
        table.cell(hud, 1, 1, aggText, text_color=aggColor, text_size=size.tiny)
 
        string dPctText = (deltaPct > 0 ? "+" : "") + str.tostring(deltaPct, "#.#") + "% (" + str.tostring(rvol, "#.##") + "x)"
        table.cell(hud, 0, 2, "Delta Ratio", text_color=color.gray, text_size=size.tiny)
        table.cell(hud, 1, 2, dPctText, text_color=aggColor, text_size=size.tiny)
 
        table.cell(hud, 0, 3, "Bar Delta", text_color=color.gray, text_size=size.tiny)
        table.cell(hud, 1, 3, f_fmt_num(bar_net_delta), text_color=bar_net_delta >= 0 ? color.lime : color.red, text_size=size.tiny)
 
        table.cell(hud, 0, 4, "Cum. Delta", text_color=color.gray, text_size=size.tiny)
        table.cell(hud, 1, 4, f_fmt_num(cvdClose), text_color=cvdClose >= 0 ? color.aqua : color.fuchsia, text_size=size.tiny)
 
        bool aboveSma = cvdClose > cvdSma
        table.cell(hud, 0, 5, "CVD vs SMA", text_color=color.gray, text_size=size.tiny)
        table.cell(hud, 1, 5, aboveSma ? "ABOVE (Bull)" : "BELOW (Bear)", text_color=aboveSma ? color.lime : color.red, text_size=size.tiny)
 
        string divText = recentBullDiv ? "🟢 BULL DIV" : recentBearDiv ? "🔴 BEAR DIV" : "NONE"
        color divColor = recentBullDiv ? color.lime : recentBearDiv ? color.red : color.gray
        table.cell(hud, 0, 6, "Divergence", text_color=color.gray, text_size=size.tiny)
        table.cell(hud, 1, 6, divText, text_color=divColor, text_size=size.tiny)
 
        string absText = bullSquatHold ? "🟢 VSA SQUAT ABS" : bearSquatHold ? "🔴 VSA SQUAT ABS" : bullLimitAbs ? "🟢 PASSIVE BUY ABS" : bearLimitAbs ? "🔴 PASSIVE SELL ABS" : bullSweepAbs ? "🟢 SWEEP SPRING" : bearSweepAbs ? "🔴 SWEEP UTAD" : "NONE"
        color absColor = bullAbsorb ? color.lime : bearAbsorb ? color.red : color.gray
        table.cell(hud, 0, 7, "Absorption", text_color=color.gray, text_size=size.tiny)
        table.cell(hud, 1, 7, absText, text_color=absColor, text_size=size.tiny)
 
        string anchorTag = resetMode == "Every Session Open (Tokyo, London & NY)" ? (inNy ? "NY Session" : inLon ? "London Session" : inTok ? "Tokyo Session" : "Inter-Session") : resetMode == "Continuous (No Reset)" ? "Continuous" : resetMode
        string sessInfo = anchorTag + " (" + str.tostring(barsInSession) + " bars)"
        table.cell(hud, 0, 8, "CVD Reset Anchor", text_color=color.gray, text_size=size.tiny)
        table.cell(hud, 1, 8, sessInfo, text_color=color.yellow, text_size=size.tiny)
 
// =============================================================================
// 8. ALERTS
// =============================================================================
alertcondition(effectiveReset and not barstate.isfirst, "CVD Session Reset", "Saturnian CVD: Reset Cumulative Volume Delta to 0 at new market session open!")
alertcondition(isBullDiv,   "CVD Bullish Divergence",  "Saturnian CVD: Bullish Divergence Detected!")
alertcondition(isBearDiv,   "CVD Bearish Divergence",  "Saturnian CVD: Bearish Divergence Detected!")
alertcondition(bullAbsorb,  "CVD Bullish Absorption",  "Saturnian CVD: Passive Buyers Absorbing / Spring at Lows!")
alertcondition(bearAbsorb,  "CVD Bearish Absorption",  "Saturnian CVD: Passive Sellers Absorbing / UTAD at Highs!")
alertcondition(aggBuyers,   "Aggressive Buyers Spike", "Saturnian CVD: Aggressive Buyer Influx (+15% Delta & RVOL >= 0.8x)!")
alertcondition(aggSellers,  "Aggressive Sellers Drop", "Saturnian CVD: Aggressive Seller Influx (-15% Delta & RVOL >= 0.8x)!")

← 返回列表