SPY Auction Intelligence v2 - CVD Grid

salrafiq1 · study · 362 行 · 点赞 10 · TradingView 原页

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

Pine Script

//@version=6
import TradingView/ta/14 as tvta
 
indicator("SPY Auction Intelligence v2 - CVD Grid", shorttitle="SPY Auction Intel v2", overlay=true, max_lines_count=20, max_labels_count=100)
 
// -----------------------------------------------------------------------------
// Sessions and core settings
// -----------------------------------------------------------------------------
const string TZ = "America/New_York"
 
string premarketSession = input.session("0400-0930", "Premarket", group="Sessions")
string regularSession = input.session("0930-1600", "Regular session", group="Sessions")
string afterHoursSession = input.session("1600-2000", "After hours", group="Sessions")
string openingRangeSession = input.session("0930-0945", "Opening range", group="Sessions")
 
float gridStep = input.float(0.50, "Price grid increment ($)", minval=0.01, step=0.01, group="Price Grid")
float gridTouchTolerance = input.float(0.08, "Grid touch tolerance ($)", minval=0.01, step=0.01, group="Price Grid")
bool showGridLines = input.bool(true, "Show nearby grid lines", group="Price Grid")
 
// -----------------------------------------------------------------------------
// CVD settings
// -----------------------------------------------------------------------------
string cvdAnchorInput = input.timeframe("1D", "CVD anchor period", group="Order Flow")
bool useCustomLowerTimeframe = input.bool(false, "Use custom lower timeframe", group="Order Flow")
string customLowerTimeframe = input.timeframe("1", "Lower timeframe", group="Order Flow")
float strongDeltaPercent = input.float(18.0, "Strong bar delta threshold (%)", minval=1.0, maxval=100.0, step=1.0, group="Order Flow")
int divergenceLookback = input.int(12, "Divergence lookback bars", minval=3, maxval=100, group="Order Flow")
bool showSignalMarkers = input.bool(true, "Show response and divergence markers", group="Order Flow")
 
string lowerTimeframe = switch
    useCustomLowerTimeframe => customLowerTimeframe
    timeframe.isseconds => "1S"
    timeframe.isintraday => "1"
    timeframe.isdaily => "5"
    => "60"
 
if not timeframe.isintraday
    runtime.error("Use this dashboard on an intraday chart.")
 
if timeframe.in_seconds() > 900
    runtime.error("Use a chart timeframe of 15 minutes or lower.")
 
if timeframe.in_seconds(lowerTimeframe) > timeframe.in_seconds()
    runtime.error("The CVD lower timeframe must be equal to or lower than the chart timeframe.")
 
// -----------------------------------------------------------------------------
// Session detection (New York time)
// -----------------------------------------------------------------------------
bool inPremarket = not na(time(timeframe.period, premarketSession, TZ))
bool inRegular = not na(time(timeframe.period, regularSession, TZ))
bool inAfterHours = not na(time(timeframe.period, afterHoursSession, TZ))
bool inOpeningRange = not na(time(timeframe.period, openingRangeSession, TZ))
 
bool newPremarket = inPremarket and not inPremarket[1]
bool newRegular = inRegular and not inRegular[1]
 
// -----------------------------------------------------------------------------
// Developing session levels
// -----------------------------------------------------------------------------
var float premarketHigh = na
var float premarketLow = na
var bool premarketSeenToday = false
 
var float openingRangeHigh = na
var float openingRangeLow = na
var float regularHigh = na
var float regularLow = na
 
var float rthPriceVolume = 0.0
var float rthVolume = 0.0
 
if newPremarket
    premarketHigh := high
    premarketLow := low
    premarketSeenToday := true
    openingRangeHigh := na
    openingRangeLow := na
    regularHigh := na
    regularLow := na
    rthPriceVolume := 0.0
    rthVolume := 0.0
else if inPremarket
    premarketHigh := na(premarketHigh) ? high : math.max(premarketHigh, high)
    premarketLow := na(premarketLow) ? low : math.min(premarketLow, low)
 
if newRegular
    if not premarketSeenToday
        premarketHigh := na
        premarketLow := na
 
    premarketSeenToday := false
    openingRangeHigh := na
    openingRangeLow := na
    regularHigh := high
    regularLow := low
    rthPriceVolume := 0.0
    rthVolume := 0.0
 
if inRegular
    regularHigh := na(regularHigh) ? high : math.max(regularHigh, high)
    regularLow := na(regularLow) ? low : math.min(regularLow, low)
 
    if inOpeningRange
        openingRangeHigh := na(openingRangeHigh) ? high : math.max(openingRangeHigh, high)
        openingRangeLow := na(openingRangeLow) ? low : math.min(openingRangeLow, low)
 
    if not na(volume) and volume > 0
        rthPriceVolume += hlc3 * volume
        rthVolume += volume
 
float rthVwap = rthVolume > 0 ? rthPriceVolume / rthVolume : na
 
// -----------------------------------------------------------------------------
// Previous completed daily candle
// -----------------------------------------------------------------------------
float priorDayHigh = request.security(syminfo.tickerid, "D", high[1], gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on)
float priorDayLow = request.security(syminfo.tickerid, "D", low[1], gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_on)
 
// -----------------------------------------------------------------------------
// CVD: official TradingView ta library, version 14
// Standard CVD supplies chart-bar delta, not exact per-price-row delta.
// -----------------------------------------------------------------------------
[cvdOpen, cvdHigh, cvdLow, cvdClose] = tvta.requestVolumeDelta(lowerTimeframe, cvdAnchorInput)
 
bool cvdDataAvailable = not na(cvdOpen) and not na(cvdClose)
float barDelta = cvdDataAvailable ? cvdClose - cvdOpen : na
float barDeltaPercent = not na(barDelta) and not na(volume) and volume > 0 ? 100.0 * barDelta / volume : na
 
// Build an RTH-only cumulative delta from each chart bar's delta.
var float rthCvd = na
 
if newPremarket
    rthCvd := na
 
if newRegular
    rthCvd := nz(barDelta, 0.0)
else if inRegular
    rthCvd := nz(rthCvd[1], 0.0) + nz(barDelta, 0.0)
 
// -----------------------------------------------------------------------------
// CVD interpretation: response candidates and price/delta divergence
// -----------------------------------------------------------------------------
float barRange = math.max(high - low, syminfo.mintick)
float closeLocation = (close - low) / barRange
float nearestGridToClose = math.round(close / gridStep) * gridStep
float nearestGridToHigh = math.round(high / gridStep) * gridStep
float nearestGridToLow = math.round(low / gridStep) * gridStep
 
bool highNearGrid = math.abs(high - nearestGridToHigh) <= gridTouchTolerance
bool lowNearGrid = math.abs(low - nearestGridToLow) <= gridTouchTolerance
 
// These are candidate responses, not proof of hidden/passive orders.
// Negative delta + strong close near a grid low can indicate buyer absorption.
// Positive delta + weak close near a grid high can indicate seller absorption.
bool buyResponseCandidate = inRegular and barstate.isconfirmed and not na(barDeltaPercent) and barDeltaPercent <= -strongDeltaPercent and closeLocation >= 0.65 and lowNearGrid
bool sellResponseCandidate = inRegular and barstate.isconfirmed and not na(barDeltaPercent) and barDeltaPercent >= strongDeltaPercent and closeLocation <= 0.35 and highNearGrid
 
int barsSinceRthOpen = ta.barssince(newRegular)
float priorPriceHigh = ta.highest(high, divergenceLookback)[1]
float priorPriceLow = ta.lowest(low, divergenceLookback)[1]
float priorCvdHigh = ta.highest(rthCvd, divergenceLookback)[1]
float priorCvdLow = ta.lowest(rthCvd, divergenceLookback)[1]
bool enoughRthBars = inRegular and not na(barsSinceRthOpen) and barsSinceRthOpen >= divergenceLookback
 
bool bearishDeltaDivergence = enoughRthBars and barstate.isconfirmed and not na(priorPriceHigh) and not na(priorCvdHigh) and high > priorPriceHigh and rthCvd < priorCvdHigh
bool bullishDeltaDivergence = enoughRthBars and barstate.isconfirmed and not na(priorPriceLow) and not na(priorCvdLow) and low < priorPriceLow and rthCvd > priorCvdLow
 
// -----------------------------------------------------------------------------
// 50-cent grid levels
// -----------------------------------------------------------------------------
float gridLower = math.floor(close / gridStep) * gridStep
float gridUpper = gridLower + gridStep
float distanceToNearestGrid = math.abs(close - nearestGridToClose)
 
var array<line> gridLines = array.new<line>()
 
if barstate.isfirst
    for index = 0 to 8
        line newGridLine = line.new(bar_index, close, bar_index + 1, close, xloc=xloc.bar_index, extend=extend.right, color=color.new(color.gray, 82), style=line.style_dotted, width=1)
        array.push(gridLines, newGridLine)
 
if barstate.islast and showGridLines
    for index = 0 to 8
        float gridLevel = gridLower + (index - 4) * gridStep
        bool wholeDollarLevel = math.abs(gridLevel - math.round(gridLevel)) < 0.001
        line activeGridLine = array.get(gridLines, index)
 
        line.set_xy1(activeGridLine, bar_index, gridLevel)
        line.set_xy2(activeGridLine, bar_index + 1, gridLevel)
        line.set_color(activeGridLine, wholeDollarLevel ? color.new(color.orange, 48) : color.new(color.gray, 76))
        line.set_style(activeGridLine, wholeDollarLevel ? line.style_dashed : line.style_dotted)
        line.set_width(activeGridLine, wholeDollarLevel ? 2 : 1)
 
if barstate.islast and not showGridLines
    for index = 0 to 8
        line activeGridLine = array.get(gridLines, index)
        line.set_color(activeGridLine, color.new(color.gray, 100))
 
// -----------------------------------------------------------------------------
// Chart reference levels
// -----------------------------------------------------------------------------
plot(rthVwap, "RTH VWAP", color=color.yellow, linewidth=2)
plot(openingRangeHigh, "15m Opening Range High", color=color.aqua, linewidth=1, style=plot.style_linebr)
plot(openingRangeLow, "15m Opening Range Low", color=color.fuchsia, linewidth=1, style=plot.style_linebr)
plot(premarketHigh, "Premarket High", color=color.new(color.blue, 5), linewidth=1, style=plot.style_linebr)
plot(premarketLow, "Premarket Low", color=color.new(color.blue, 5), linewidth=1, style=plot.style_linebr)
plot(priorDayHigh, "Prior Day High", color=color.new(color.gray, 15), linewidth=1, style=plot.style_linebr)
plot(priorDayLow, "Prior Day Low", color=color.new(color.gray, 15), linewidth=1, style=plot.style_linebr)
 
plot(rthCvd, "RTH CVD", display=display.data_window)
plot(barDelta, "Current bar delta", display=display.data_window)
plot(barDeltaPercent, "Current bar delta (%)", display=display.data_window)
 
plotshape(showSignalMarkers and buyResponseCandidate, title="Potential buy response at grid", style=shape.triangleup, location=location.belowbar, color=color.lime, text="BUY\nRESP", textcolor=color.white, size=size.tiny)
plotshape(showSignalMarkers and sellResponseCandidate, title="Potential sell response at grid", style=shape.triangledown, location=location.abovebar, color=color.red, text="SELL\nRESP", textcolor=color.white, size=size.tiny)
plotshape(showSignalMarkers and bullishDeltaDivergence, title="Bullish CVD divergence candidate", style=shape.circle, location=location.belowbar, color=color.aqua, text="CVD+", textcolor=color.black, size=size.tiny)
plotshape(showSignalMarkers and bearishDeltaDivergence, title="Bearish CVD divergence candidate", style=shape.circle, location=location.abovebar, color=color.orange, text="CVD-", textcolor=color.black, size=size.tiny)
 
// -----------------------------------------------------------------------------
// Dashboard formatting helpers
// -----------------------------------------------------------------------------
f_price(float value) =>
    na(value) ? "n/a" : str.tostring(value, format.mintick)
 
f_volume(float value) =>
    na(value) ? "n/a" : str.tostring(value, format.volume)
 
f_range_pair(float upper, float lower) =>
    na(upper) or na(lower) ? "n/a" : f_price(upper) + " / " + f_price(lower)
 
f_range_state(float price, float upper, float lower, string aboveText, string belowText, string insideText) =>
    na(upper) or na(lower) ? "WAITING" : price > upper ? aboveText : price < lower ? belowText : insideText
 
f_signed_percent(float value) =>
    na(value) ? "n/a" : (value > 0 ? "+" : "") + str.tostring(value, "#.0") + "%"
 
// -----------------------------------------------------------------------------
// Dashboard states and colors
// -----------------------------------------------------------------------------
color panelBackground = color.rgb(19, 24, 33)
color headerBackground = color.rgb(35, 43, 56)
color neutralBackground = color.new(color.gray, 83)
color bullishBackground = color.new(color.green, 78)
color bearishBackground = color.new(color.red, 78)
color warningBackground = color.new(color.orange, 76)
color whiteText = color.white
 
string vwapStatus = na(rthVwap) ? "WAITING" : close > rthVwap ? "ABOVE VWAP" : close < rthVwap ? "BELOW VWAP" : "AT VWAP"
string vwapDetail = na(rthVwap) ? "n/a" : f_price(rthVwap) + " | " + (close >= rthVwap ? "+" : "") + str.tostring(close - rthVwap, format.mintick)
 
string openingRangeStatus = f_range_state(close, openingRangeHigh, openingRangeLow, "ABOVE OR HIGH", "BELOW OR LOW", "INSIDE OR")
string premarketStatus = f_range_state(close, premarketHigh, premarketLow, "ABOVE PM HIGH", "BELOW PM LOW", "INSIDE PM RANGE")
string priorDayStatus = f_range_state(close, priorDayHigh, priorDayLow, "ABOVE PD HIGH", "BELOW PD LOW", "INSIDE PRIOR RANGE")
 
float regularRangePosition = not na(regularHigh) and not na(regularLow) and regularHigh > regularLow ? 100.0 * (close - regularLow) / (regularHigh - regularLow) : na
string regularRangeStatus = not inRegular ? (na(regularHigh) ? "WAITING" : "RTH CLOSED") : na(regularRangePosition) ? "BUILDING" : str.tostring(regularRangePosition, "#.0") + "% FROM LOW"
 
string cvdStatus = na(rthCvd) ? "WAITING" : rthCvd > 0 ? "NET BUY DELTA" : rthCvd < 0 ? "NET SELL DELTA" : "BALANCED"
string cvdDirection = na(rthCvd) or na(rthCvd[3]) or na(barsSinceRthOpen) or barsSinceRthOpen < 3 ? "" : rthCvd > rthCvd[3] ? "RISING" : rthCvd < rthCvd[3] ? "FALLING" : "FLAT"
string cvdDetail = na(rthCvd) ? "n/a" : f_volume(rthCvd) + (cvdDirection == "" ? "" : " | " + cvdDirection)
 
string deltaStatus = na(barDeltaPercent) ? "NO DELTA DATA" : barDeltaPercent >= strongDeltaPercent ? "STRONG BUY DELTA" : barDeltaPercent <= -strongDeltaPercent ? "STRONG SELL DELTA" : "MIXED / SMALL"
string deltaDetail = na(barDelta) ? "n/a" : f_volume(barDelta) + " | " + f_signed_percent(barDeltaPercent)
 
string responseStatus = buyResponseCandidate ? "BUY RESPONSE CANDIDATE" : sellResponseCandidate ? "SELL RESPONSE CANDIDATE" : "NO QUALIFIED RESPONSE"
string responseDetail = buyResponseCandidate ? "Low near " + f_price(nearestGridToLow) : sellResponseCandidate ? "High near " + f_price(nearestGridToHigh) : "Requires strong delta + rejection near grid"
 
string divergenceStatus = bullishDeltaDivergence ? "BULLISH CVD DIVERGENCE" : bearishDeltaDivergence ? "BEARISH CVD DIVERGENCE" : "NONE ON THIS BAR"
string divergenceDetail = "Lookback: " + str.tostring(divergenceLookback) + " bars"
 
string gridStatus = distanceToNearestGrid <= gridTouchTolerance ? "NEAR GRID LEVEL" : "BETWEEN GRID LEVELS"
string gridDetail = "Nearest " + f_price(nearestGridToClose) + " | Band " + f_price(gridLower) + "–" + f_price(gridUpper)
 
bool priceAboveVwap = not na(rthVwap) and close > rthVwap
bool cvdPositive = not na(rthCvd) and rthCvd > 0
string auctionControl = na(rthVwap) or na(rthCvd) ? "WAITING" : priceAboveVwap and cvdPositive ? "BUYERS ALIGNED" : not priceAboveVwap and not cvdPositive ? "SELLERS ALIGNED" : priceAboveVwap and not cvdPositive ? "PRICE UP / CVD NEGATIVE" : "PRICE DOWN / CVD POSITIVE"
 
string marketSession = inRegular ? "REGULAR HOURS" : inPremarket ? "PREMARKET" : inAfterHours ? "AFTER HOURS" : "CLOSED"
string timeframeLabel = timeframe.isminutes ? timeframe.period + "m" : timeframe.period
 
color vwapBackground = na(rthVwap) ? neutralBackground : close > rthVwap ? bullishBackground : close < rthVwap ? bearishBackground : neutralBackground
color openingRangeBackground = na(openingRangeHigh) ? neutralBackground : close > openingRangeHigh ? bullishBackground : close < openingRangeLow ? bearishBackground : neutralBackground
color premarketBackground = na(premarketHigh) ? neutralBackground : close > premarketHigh ? bullishBackground : close < premarketLow ? bearishBackground : neutralBackground
color priorDayBackground = na(priorDayHigh) or na(priorDayLow) ? neutralBackground : close > priorDayHigh ? bullishBackground : close < priorDayLow ? bearishBackground : neutralBackground
color cvdBackground = na(rthCvd) ? neutralBackground : rthCvd > 0 ? bullishBackground : rthCvd < 0 ? bearishBackground : neutralBackground
color deltaBackground = na(barDeltaPercent) ? neutralBackground : barDeltaPercent >= strongDeltaPercent ? bullishBackground : barDeltaPercent <= -strongDeltaPercent ? bearishBackground : neutralBackground
color responseBackground = buyResponseCandidate ? bullishBackground : sellResponseCandidate ? bearishBackground : neutralBackground
color divergenceBackground = bullishDeltaDivergence ? bullishBackground : bearishDeltaDivergence ? bearishBackground : neutralBackground
color gridBackground = distanceToNearestGrid <= gridTouchTolerance ? warningBackground : neutralBackground
color controlBackground = auctionControl == "BUYERS ALIGNED" ? bullishBackground : auctionControl == "SELLERS ALIGNED" ? bearishBackground : auctionControl == "WAITING" ? neutralBackground : warningBackground
color rangeBackground = na(regularRangePosition) ? neutralBackground : regularRangePosition >= 50 ? bullishBackground : bearishBackground
 
// -----------------------------------------------------------------------------
// Dashboard table
// -----------------------------------------------------------------------------
var table dashboard = table.new(position.top_right, 3, 14, bgcolor=panelBackground, frame_color=color.rgb(85, 93, 106), frame_width=1, border_color=color.rgb(65, 73, 86), border_width=1)
 
if barstate.isfirst
    table.merge_cells(dashboard, 0, 0, 2, 0)
 
if barstate.islast
    table.cell(dashboard, 0, 0, "SPY AUCTION INTELLIGENCE v2  |  " + syminfo.ticker + "  |  " + f_price(close), text_color=whiteText, bgcolor=headerBackground, text_size=size.small, text_halign=text.align_left)
 
    table.cell(dashboard, 0, 1, "REFERENCE", text_color=whiteText, bgcolor=headerBackground, text_size=size.tiny)
    table.cell(dashboard, 1, 1, "READ", text_color=whiteText, bgcolor=headerBackground, text_size=size.tiny)
    table.cell(dashboard, 2, 1, "LEVELS / VALUE", text_color=whiteText, bgcolor=headerBackground, text_size=size.tiny)
 
    table.cell(dashboard, 0, 2, "RTH VWAP", text_color=whiteText, bgcolor=panelBackground, text_size=size.small, text_halign=text.align_left)
    table.cell(dashboard, 1, 2, vwapStatus, text_color=whiteText, bgcolor=vwapBackground, text_size=size.small)
    table.cell(dashboard, 2, 2, vwapDetail, text_color=whiteText, bgcolor=panelBackground, text_size=size.small)
 
    table.cell(dashboard, 0, 3, "15m OPENING RANGE", text_color=whiteText, bgcolor=panelBackground, text_size=size.small, text_halign=text.align_left)
    table.cell(dashboard, 1, 3, openingRangeStatus, text_color=whiteText, bgcolor=openingRangeBackground, text_size=size.small)
    table.cell(dashboard, 2, 3, f_range_pair(openingRangeHigh, openingRangeLow), text_color=whiteText, bgcolor=panelBackground, text_size=size.small)
 
    table.cell(dashboard, 0, 4, "PREMARKET RANGE", text_color=whiteText, bgcolor=panelBackground, text_size=size.small, text_halign=text.align_left)
    table.cell(dashboard, 1, 4, premarketStatus, text_color=whiteText, bgcolor=premarketBackground, text_size=size.small)
    table.cell(dashboard, 2, 4, f_range_pair(premarketHigh, premarketLow), text_color=whiteText, bgcolor=panelBackground, text_size=size.small)
 
    table.cell(dashboard, 0, 5, "PRIOR DAY RANGE", text_color=whiteText, bgcolor=panelBackground, text_size=size.small, text_halign=text.align_left)
    table.cell(dashboard, 1, 5, priorDayStatus, text_color=whiteText, bgcolor=priorDayBackground, text_size=size.small)
    table.cell(dashboard, 2, 5, f_range_pair(priorDayHigh, priorDayLow), text_color=whiteText, bgcolor=panelBackground, text_size=size.small)
 
    table.cell(dashboard, 0, 6, "RTH CUMULATIVE DELTA", text_color=whiteText, bgcolor=panelBackground, text_size=size.small, text_halign=text.align_left)
    table.cell(dashboard, 1, 6, cvdStatus, text_color=whiteText, bgcolor=cvdBackground, text_size=size.small)
    table.cell(dashboard, 2, 6, cvdDetail, text_color=whiteText, bgcolor=panelBackground, text_size=size.small)
 
    table.cell(dashboard, 0, 7, "LAST BAR DELTA", text_color=whiteText, bgcolor=panelBackground, text_size=size.small, text_halign=text.align_left)
    table.cell(dashboard, 1, 7, deltaStatus, text_color=whiteText, bgcolor=deltaBackground, text_size=size.small)
    table.cell(dashboard, 2, 7, deltaDetail, text_color=whiteText, bgcolor=panelBackground, text_size=size.small)
 
    table.cell(dashboard, 0, 8, "GRID RESPONSE", text_color=whiteText, bgcolor=panelBackground, text_size=size.small, text_halign=text.align_left)
    table.cell(dashboard, 1, 8, responseStatus, text_color=whiteText, bgcolor=responseBackground, text_size=size.small)
    table.cell(dashboard, 2, 8, responseDetail, text_color=whiteText, bgcolor=panelBackground, text_size=size.small)
 
    table.cell(dashboard, 0, 9, "PRICE / CVD DIVERGENCE", text_color=whiteText, bgcolor=panelBackground, text_size=size.small, text_halign=text.align_left)
    table.cell(dashboard, 1, 9, divergenceStatus, text_color=whiteText, bgcolor=divergenceBackground, text_size=size.small)
    table.cell(dashboard, 2, 9, divergenceDetail, text_color=whiteText, bgcolor=panelBackground, text_size=size.small)
 
    table.cell(dashboard, 0, 10, "$0.50 PRICE GRID", text_color=whiteText, bgcolor=panelBackground, text_size=size.small, text_halign=text.align_left)
    table.cell(dashboard, 1, 10, gridStatus, text_color=whiteText, bgcolor=gridBackground, text_size=size.small)
    table.cell(dashboard, 2, 10, gridDetail, text_color=whiteText, bgcolor=panelBackground, text_size=size.small)
 
    table.cell(dashboard, 0, 11, "AUCTION CONTROL", text_color=whiteText, bgcolor=panelBackground, text_size=size.small, text_halign=text.align_left)
    table.cell(dashboard, 1, 11, auctionControl, text_color=whiteText, bgcolor=controlBackground, text_size=size.small)
    table.cell(dashboard, 2, 11, "VWAP + RTH CVD alignment", text_color=whiteText, bgcolor=panelBackground, text_size=size.small)
 
    table.cell(dashboard, 0, 12, "RTH RANGE POSITION", text_color=whiteText, bgcolor=panelBackground, text_size=size.small, text_halign=text.align_left)
    table.cell(dashboard, 1, 12, regularRangeStatus, text_color=whiteText, bgcolor=rangeBackground, text_size=size.small)
    table.cell(dashboard, 2, 12, f_range_pair(regularHigh, regularLow), text_color=whiteText, bgcolor=panelBackground, text_size=size.small)
 
    table.cell(dashboard, 0, 13, "SESSION / CHART / CVD LTF", text_color=whiteText, bgcolor=panelBackground, text_size=size.small, text_halign=text.align_left)
    table.cell(dashboard, 1, 13, marketSession, text_color=whiteText, bgcolor=neutralBackground, text_size=size.small)
    table.cell(dashboard, 2, 13, timeframeLabel + " / " + lowerTimeframe, text_color=whiteText, bgcolor=panelBackground, text_size=size.small)
 
// -----------------------------------------------------------------------------
// Alerts
// -----------------------------------------------------------------------------
alertcondition(buyResponseCandidate, "Potential buy response at 50-cent grid", "Potential buy response: negative delta, strong close, and low near a grid level.")
alertcondition(sellResponseCandidate, "Potential sell response at 50-cent grid", "Potential sell response: positive delta, weak close, and high near a grid level.")
alertcondition(bullishDeltaDivergence, "Bullish CVD divergence candidate", "Price made a lookback low while RTH CVD held above its lookback low.")
alertcondition(bearishDeltaDivergence, "Bearish CVD divergence candidate", "Price made a lookback high while RTH CVD remained below its lookback high.")

← 返回列表