Prism Breakout Atlas [NalnAlgo]

NalnAlgo · study · 428 行 · 点赞 28 · TradingView 原页

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

Pine Script

//@version=6
indicator("PRISM · Breakout Atlas", "PRISM", overlay = true, max_boxes_count = 80, max_labels_count = 150, max_lines_count = 20, max_bars_back = 1000)
 
// PRISM 1.1 — Deferred drawing and closed-bar presentation. Built from OHLCV only.
// Scores describe evidence, NOT probability. No future bars or HTF requests.
// Signals and lifecycle transitions occur at confirmed closes only.
 
string G1 = "01 / ENGINE"
int length = input.int(20, "Structure length", minval = 5, maxval = 100, group = G1)
int memory = input.int(120, "Volatility memory", minval = 40, maxval = 500, group = G1)
int threshold = input.int(30, "Compression percentile", minval = 5, maxval = 50, group = G1, tooltip = "A lower percentile requires rarer, tighter volatility. Percentiles are relative to this symbol and timeframe.")
int minCoil = input.int(4, "Minimum compression bars", minval = 2, maxval = 20, group = G1)
int expiry = input.int(15, "Breakout window (bars)", minval = 3, maxval = 60, group = G1)
float buffer = input.float(0.10, "Breakout buffer / ATR", minval = 0, maxval = 1, step = 0.05, group = G1)
int minScore = input.int(55, "Minimum release evidence", minval = 0, maxval = 95, group = G1, tooltip = "0–100 heuristic evidence score, not a win probability.")
int acceptBars = input.int(3, "Closes outside to accept", minval = 2, maxval = 8, group = G1)
int trackBars = input.int(30, "Lifecycle observation bars", minval = 10, maxval = 100, group = G1)
 
string G2 = "02 / APPEARANCE"
bool ribbon = input.bool(true, "Adaptive ribbon", group = G2)
bool zones = input.bool(true, "Compression chambers", group = G2)
bool events = input.bool(true, "Release / acceptance / failure marks", group = G2)
bool rails = input.bool(true, "Latest event reference rails", group = G2)
bool candles = input.bool(false, "Tint candles by regime", group = G2)
bool dashboard = input.bool(true, "Atlas dashboard", group = G2)
bool filmstrip = input.bool(true, "32-bar regime filmstrip", group = G2)
bool light = input.bool(false, "Light chart palette", group = G2)
bool livePreview = input.bool(false, "Live preview (developing bar)", group = G2, tooltip = "Off: ribbon, candle tint and dashboard use confirmed bars only. On: these readings fluctuate intrabar; release/acceptance/return events still require a confirmed close.")
bool backfill = input.bool(false, "Backfill chamber to compression start", group = G2, tooltip = "Off: the chamber starts when minimum compression bars are confirmed. On: its left edge is drawn back to the start of compression. Developing chambers can expand and change status after confirmed closes.")
string corner = input.string("Top right", "Dashboard position", options = ["Top right", "Top left", "Bottom right"], group = G2)
int keep = input.int(12, "Historical chambers", minval = 1, maxval = 40, group = G2)
 
color mint = light ? #008C83 : #49E2C2
color coral = light ? #CF4260 : #FF718A
color gold = light ? #B67A12 : #F0C879
color ice = light ? #50647F : #8B9EBB
color ink = light ? #F4F7FC : #101A2B
color card = light ? #FFFFFF : #162238
color edge = light ? #D8E0EE : #293A53
color textMain = light ? #1A2940 : #E6EDF8
color violet = light ? #7461BB : #B6A0F5
 
f_clamp(float x, float lo, float hi) =>
    math.max(lo, math.min(hi, x))
 
f_meter(float value) =>
    int n = int(math.round(f_clamp(nz(value), 0, 100) / 10))
    str.repeat("━", n) + str.repeat("·", 10 - n)
 
f_num(float x) =>
    na(x) ? "—" : str.tostring(x, "#")
 
f_price(float x) =>
    na(x) ? "—" : str.tostring(x, format.mintick)
 
// Scalar evidence is needed only on an eligible escape. Rolling ta.* calls
// stay unconditional below, so skipping this function cannot change history.
f_evidence(bool upward, float axisSlope, float currentATR, float trueRange, float relVolume, bool validVolume) =>
    float barRange = math.max(high - low, syminfo.mintick)
    float closePosition = high > low ? (close - low) / (high - low) : 0.5
    float body = math.abs(close - open) / barRange
    float alignment = f_clamp(0.5 + axisSlope * 2, 0, 1)
    float expansion = f_clamp(trueRange / currentATR / 1.8, 0, 1)
    float volumeEvidence = validVolume ? f_clamp(relVolume / 2, 0, 1) : 0
    float positionEvidence = upward ? closePosition : 1 - closePosition
    float directionEvidence = upward ? alignment : 1 - alignment
    100 * (0.30 * positionEvidence + 0.20 * body + 0.20 * directionEvidence + 0.15 * expansion + 0.15 * volumeEvidence) / (validVolume ? 1 : 0.85)
 
// Retain bounded metadata through history; materialize only surviving drawings.
// Time coordinates also keep long-lived chambers clear of bar-index limits.
type Chamber
    int leftTime
    int rightTime
    float top
    float bottom
    string state = "COIL"
    int side = 0
    bool dirty = true
    box drawing = na
 
type ReleaseMark
    int atTime
    float price
    int side
    float score
    label drawing = na
 
// Efficiency-adjusted mean: responsive during travel, quieter during noise.
float atr = math.max(ta.atr(length), syminfo.mintick)
float travel = math.sum(math.abs(ta.change(close)), length)
float efficiency = f_clamp(math.abs(close - close[length]) / math.max(travel, syminfo.mintick), 0, 1)
float alpha = math.pow(nz(efficiency) * (0.50 - 0.06) + 0.06, 2)
var float axis = na
axis := na(axis[1]) ? close : axis[1] + alpha * (close - axis[1])
float width = atr * (0.65 + 0.55 * (1 - nz(efficiency)))
float slope = (axis - axis[3]) / atr
int direction = close > axis and slope > 0.035 ? 1 : close < axis and slope < -0.035 ? -1 : 0
 
// Normalized width makes the compression percentile scale independent.
float normWidth = ta.stdev(close, length) / math.max(math.abs(ta.sma(close, length)), syminfo.mintick)
float widthRank = ta.percentrank(normWidth, memory)
bool ready = bar_index >= length + memory and not na(widthRank)
bool compressed = ready and widthRank <= threshold
float energy = ready ? 100 - widthRank : na
float volBase = ta.sma(volume, length)[1]
bool hasVolume = not na(volume) and not na(volBase) and volBase > 0
float relativeVolume = hasVolume ? volume / volBase : na
float trueRange = ta.tr(true)
float upScore = na
float dnScore = na
 
// Chamber lifecycle: BUILD -> ARMED -> RELEASED or EXPIRED.
// Boundaries are frozen on the first non-compressed close. A release is tested
// against the preceding chamber boundary BEFORE incorporating the current bar.
var int coilBars = 0
var int coilStartTime = na
var float chamberHigh = na
var float chamberLow = na
var bool armed = false
var int armedAt = na
var bool consumed = false
var Chamber chamber = na
var array<Chamber> chambers = array.new<Chamber>()
var array<ReleaseMark> releaseMarks = array.new<ReleaseMark>()
var bool chambersDirty = false
var int drawnMarkTime = na
bool upRelease = false
bool dnRelease = false
bool acceptance = false
bool rejection = false
 
// Latest event passport. Reference ATR and boundary never move after release.
var int eventDir = 0
var int eventAt = na
var float eventClose = na
var float eventBoundary = na
var float eventATR = na
var float eventScore = na
var string eventState = "WAITING"
var int outsideCloses = 0
var bool active = false
var float bestExcursion = 0
var float eventMove = na
var line gateLine = na
var line oneLine = na
var line twoLine = na
var label gateLabel = na
var label oneLabel = na
var label twoLabel = na
var int drawnEventAt = na
var int drawnRailEnd = na
 
// Capture the old event's direction: it may finish on a new release bar.
int lifecycleDir = eventDir
if barstate.isconfirmed and ready
    // The release bar's high/low are excluded from post-release excursion.
    if active and bar_index > eventAt
        float move = eventDir * (close - eventClose) / eventATR
        eventMove := move
        bestExcursion := math.max(bestExcursion, (eventDir == 1 ? high - eventClose : eventClose - low) / eventATR)
        bool holds = eventDir * (close - eventBoundary) > 0
        outsideCloses := holds ? outsideCloses + 1 : 0
        if not holds
            eventState := "RETURNED INSIDE"
            rejection := true
            active := false
        else if outsideCloses >= acceptBars and eventState == "RELEASED"
            eventState := "ACCEPTED"
            acceptance := true
        if active and bar_index - eventAt >= trackBars
            eventState := eventState == "ACCEPTED" ? "HELD / WINDOW END" : "WINDOW END"
            active := false
 
    bool inWindow = armed and bar_index - armedAt < expiry
    bool canRelease = not consumed and (inWindow or coilBars >= minCoil) and not na(chamberHigh)
    bool breaksUp = canRelease and close > chamberHigh + atr * buffer
    bool breaksDown = canRelease and close < chamberLow - atr * buffer
    if breaksUp
        upScore := f_evidence(true, slope, atr, trueRange, relativeVolume, hasVolume)
    if breaksDown
        dnScore := f_evidence(false, slope, atr, trueRange, relativeVolume, hasVolume)
    upRelease := breaksUp and upScore >= minScore
    dnRelease := breaksDown and dnScore >= minScore
 
    if upRelease or dnRelease
        eventDir := upRelease ? 1 : -1
        eventAt := bar_index
        eventClose := close
        eventBoundary := upRelease ? chamberHigh : chamberLow
        eventATR := atr
        eventScore := upRelease ? upScore : dnScore
        eventState := "RELEASED"
        eventMove := 0
        outsideCloses := 1
        bestExcursion := 0
        active := true
        consumed := true
        armed := false
        if not na(chamber)
            chamber.rightTime := time
            chamber.state := "RELEASE"
            chamber.side := eventDir
            chamber.dirty := true
            chambersDirty := true
        if events
            array.push(releaseMarks, ReleaseMark.new(time, upRelease ? low - atr * 0.40 : high + atr * 0.40, eventDir, eventScore))
            if array.size(releaseMarks) > 147
                ReleaseMark oldest = array.shift(releaseMarks)
                label.delete(oldest.drawing)
 
    // Consume a low-quality escape too: do not relabel a later bar as its breakout.
    if (breaksUp or breaksDown) and not (upRelease or dnRelease)
        consumed := true
        armed := false
        if not na(chamber)
            chamber.state := "UNQUALIFIED"
            chamber.dirty := true
            chambersDirty := true
 
    if compressed
        if not compressed[1]
            if armed and not na(chamber)
                chamber.state := "SUPERSEDED"
                chamber.dirty := true
                chambersDirty := true
            coilBars := 0
            coilStartTime := time
            chamberHigh := high
            chamberLow := low
            chamber := na
            armed := false
            consumed := false
        coilBars += 1
        if not consumed
            chamberHigh := math.max(chamberHigh, high)
            chamberLow := math.min(chamberLow, low)
            if coilBars == minCoil and zones
                chamber := Chamber.new(backfill ? coilStartTime : time, time, chamberHigh, chamberLow)
                chambersDirty := true
                array.push(chambers, chamber)
                if array.size(chambers) > keep
                    Chamber oldest = array.shift(chambers)
                    box.delete(oldest.drawing)
            if not na(chamber)
                chamber.top := chamberHigh
                chamber.bottom := chamberLow
                chamber.rightTime := time
                chamber.dirty := true
                chambersDirty := true
    else
        if compressed[1] and coilBars >= minCoil and not consumed
            armed := true
            armedAt := bar_index
        coilBars := 0
        if armed
            if bar_index - armedAt >= expiry
                armed := false
                consumed := true
                if not na(chamber)
                    chamber.state := "EXPIRED"
                    chamber.dirty := true
                    chambersDirty := true
            else if not na(chamber)
                chamber.rightTime := time
                chamber.state := "ARMED"
                chamber.dirty := true
                chambersDirty := true
 
// Historical and realtime closes commit identical engine state. No last-bar
// shortcut is used for any rolling calculation, release or lifecycle transition.
bool renderClosed = barstate.islastconfirmedhistory or (barstate.islast and barstate.isconfirmed)
bool renderDashboard = renderClosed or (barstate.islast and livePreview)
if renderClosed
    if zones and chambersDirty and array.size(chambers) > 0
        for item in chambers
            if item.dirty
                bool released = item.state == "RELEASE"
                bool ended = item.state == "EXPIRED" or item.state == "SUPERSEDED"
                color chamberColor = released ? (item.side == 1 ? mint : coral) : ended or item.state == "UNQUALIFIED" ? ice : gold
                string caption = released ? "RELEASE " + (item.side == 1 ? "↑" : "↓") : item.state
                if na(item.drawing)
                    item.drawing := box.new(item.leftTime, item.top, item.rightTime, item.bottom, xloc = xloc.bar_time, border_color = color.new(chamberColor, 40), bgcolor = color.new(chamberColor, 93), text = caption, text_size = size.tiny, text_color = chamberColor, text_halign = text.align_left, text_valign = text.align_top)
                else
                    box.set_top(item.drawing, item.top)
                    box.set_bottom(item.drawing, item.bottom)
                    box.set_right(item.drawing, item.rightTime)
                    box.set_border_color(item.drawing, color.new(chamberColor, 40))
                    box.set_bgcolor(item.drawing, color.new(chamberColor, 93))
                    box.set_text(item.drawing, caption)
                    box.set_text_color(item.drawing, chamberColor)
                item.dirty := false
        chambersDirty := false
    if events and array.size(releaseMarks) > 0 and (na(drawnMarkTime) or array.last(releaseMarks).atTime != drawnMarkTime)
        for mark in releaseMarks
            if na(mark.drawing)
                color markColor = mark.side == 1 ? mint : coral
                mark.drawing := label.new(mark.atTime, mark.price, (mark.side == 1 ? "↑ " : "↓ ") + f_num(mark.score), xloc = xloc.bar_time, style = mark.side == 1 ? label.style_label_up : label.style_label_down, color = color.new(markColor, 10), textcolor = ink, size = size.small)
        drawnMarkTime := array.last(releaseMarks).atTime
    // Only the latest event needs reference rails. Reuse six objects; stop
    // touching bar-index coordinates before they become too old for Pine.
    if rails and not na(eventAt) and bar_index - eventAt <= 9000
        int railEnd = math.min(bar_index + 8, eventAt + trackBars + 8)
        color railColor = eventDir == 1 ? mint : coral
        float onePrice = eventClose + eventDir * eventATR
        float twoPrice = eventClose + eventDir * eventATR * 2
        if na(gateLine)
            gateLine := line.new(eventAt, eventBoundary, railEnd, eventBoundary, color = gold, style = line.style_dashed)
            oneLine := line.new(eventAt, onePrice, railEnd, onePrice, color = color.new(railColor, 45), style = line.style_dotted)
            twoLine := line.new(eventAt, twoPrice, railEnd, twoPrice, color = color.new(railColor, 65), style = line.style_dotted)
            gateLabel := label.new(railEnd, eventBoundary, "GATE  " + f_price(eventBoundary), style = label.style_label_left, color = ink, textcolor = gold, size = size.tiny)
            oneLabel := label.new(railEnd, onePrice, "+1 ATR", style = label.style_label_left, color = ink, textcolor = railColor, size = size.tiny)
            twoLabel := label.new(railEnd, twoPrice, "+2 ATR", style = label.style_label_left, color = ink, textcolor = railColor, size = size.tiny)
        else if drawnEventAt != eventAt
            line.set_xy1(gateLine, eventAt, eventBoundary)
            line.set_xy1(oneLine, eventAt, onePrice)
            line.set_xy1(twoLine, eventAt, twoPrice)
            line.set_xy2(gateLine, railEnd, eventBoundary)
            line.set_xy2(oneLine, railEnd, onePrice)
            line.set_xy2(twoLine, railEnd, twoPrice)
            line.set_color(oneLine, color.new(railColor, 45))
            line.set_color(twoLine, color.new(railColor, 65))
            label.set_xy(gateLabel, railEnd, eventBoundary)
            label.set_xy(oneLabel, railEnd, onePrice)
            label.set_xy(twoLabel, railEnd, twoPrice)
            label.set_text(gateLabel, "GATE  " + f_price(eventBoundary))
            label.set_textcolor(oneLabel, railColor)
            label.set_textcolor(twoLabel, railColor)
        else if drawnRailEnd != railEnd
            line.set_x2(gateLine, railEnd)
            line.set_x2(oneLine, railEnd)
            line.set_x2(twoLine, railEnd)
            label.set_x(gateLabel, railEnd)
            label.set_x(oneLabel, railEnd)
            label.set_x(twoLabel, railEnd)
        drawnEventAt := eventAt
        drawnRailEnd := railEnd
 
// Default presentation holds the last confirmed readings on the open bar.
bool showCurrent = barstate.isconfirmed or livePreview
float viewAxis = showCurrent ? axis : axis[1]
float viewWidth = showCurrent ? width : width[1]
color rawRegimeColor = compressed ? gold : direction == 1 ? mint : direction == -1 ? coral : ice
color regimeColor = showCurrent ? rawRegimeColor : rawRegimeColor[1]
pOuterHigh = plot(ribbon ? viewAxis + viewWidth : na, "Outer high", color.new(regimeColor, 82), display = display.pane)
pInnerHigh = plot(ribbon ? viewAxis + viewWidth * 0.30 : na, "Inner high", color.new(regimeColor, 65), display = display.pane)
pAxis = plot(ribbon ? viewAxis : na, "Adaptive axis", color.new(regimeColor, 12), 2, display = display.pane)
pInnerLow = plot(ribbon ? viewAxis - viewWidth * 0.30 : na, "Inner low", color.new(regimeColor, 65), display = display.pane)
pOuterLow = plot(ribbon ? viewAxis - viewWidth : na, "Outer low", color.new(regimeColor, 82), display = display.pane)
fill(pOuterHigh, pInnerHigh, color.new(regimeColor, 96), "Upper atmosphere")
fill(pInnerHigh, pInnerLow, color.new(regimeColor, 87), "Core ribbon")
fill(pInnerLow, pOuterLow, color.new(regimeColor, 96), "Lower atmosphere")
barcolor(candles ? color.new(regimeColor, 10) : na)
plotshape(events and acceptance and lifecycleDir == 1, "Up acceptance", shape.diamond, location.belowbar, mint, size = size.tiny, text = "A", textcolor = mint)
plotshape(events and acceptance and lifecycleDir == -1, "Down acceptance", shape.diamond, location.abovebar, coral, size = size.tiny, text = "A", textcolor = coral)
plotshape(events and rejection and lifecycleDir == 1, "Up release returned", shape.xcross, location.abovebar, gold, size = size.tiny, text = "R", textcolor = gold)
plotshape(events and rejection and lifecycleDir == -1, "Down release returned", shape.xcross, location.belowbar, gold, size = size.tiny, text = "R", textcolor = gold)
plot(upRelease ? upScore : dnRelease ? dnScore : na, "Release evidence", display = display.data_window)
plot(showCurrent ? energy : energy[1], "Compression energy", display = display.data_window)
 
// Dashboard: current readings may develop intrabar; event passport is closed-bar only.
string pos = corner == "Top left" ? position.top_left : corner == "Bottom right" ? position.bottom_right : position.top_right
var table board = table.new(pos, 3, 15, bgcolor = ink, frame_color = edge, frame_width = 1, border_width = 0)
if barstate.isfirst
    table.merge_cells(board, 0, 0, 1, 0)
    table.merge_cells(board, 0, 1, 2, 1)
    table.merge_cells(board, 0, 2, 2, 2)
    table.merge_cells(board, 0, 7, 2, 7)
    table.merge_cells(board, 0, 8, 2, 8)
    table.merge_cells(board, 0, 12, 2, 12)
    table.merge_cells(board, 0, 13, 2, 13)
    table.merge_cells(board, 0, 14, 2, 14)
 
if barstate.isfirst and dashboard
    table.cell(board, 0, 0, "◈  P R I S M", text_color = textMain, text_size = size.large, text_halign = text.align_left, bgcolor = card)
    table.cell(board, 2, 0, "ATLAS / 01", text_color = gold, text_size = size.tiny, bgcolor = card)
    table.cell(board, 0, 1, syminfo.ticker + "  /  " + timeframe.period + "   ·   BREAKOUT LIFECYCLE", text_color = ice, text_size = size.tiny, text_halign = text.align_left)
    table.cell(board, 0, 3, "COMPRESSION", text_color = ice, text_size = size.tiny, text_halign = text.align_left)
    table.cell(board, 0, 4, "EFFICIENCY", text_color = ice, text_size = size.tiny, text_halign = text.align_left)
    table.cell(board, 0, 5, "DIRECTION", text_color = ice, text_size = size.tiny, text_halign = text.align_left)
    table.cell(board, 0, 6, "REL. VOLUME", text_color = ice, text_size = size.tiny, text_halign = text.align_left)
    table.cell(board, 0, 7, "L A T E S T   R E L E A S E", text_color = ice, text_size = size.tiny, text_halign = text.align_left, bgcolor = card)
    table.cell(board, 0, 9, "EVIDENCE", text_color = ice, text_size = size.tiny, text_halign = text.align_left)
    table.cell(board, 0, 10, "FROZEN GATE", text_color = ice, text_size = size.tiny, text_halign = text.align_left)
    table.cell(board, 2, 10, "PRICE", text_color = ice, text_size = size.tiny)
    table.cell(board, 0, 11, "MOVE / BEST", text_color = ice, text_size = size.tiny, text_halign = text.align_left)
    table.cell(board, 2, 11, "ATR", text_color = ice, text_size = size.tiny)
    table.cell(board, 0, 12, "COIL  →  RELEASE  →  ACCEPT / RETURN", text_color = violet, text_size = size.tiny, bgcolor = card)
    table.cell(board, 0, 13, "Closed-bar events · Evidence ≠ probability", text_color = ice, text_size = size.tiny)
    table.cell(board, 0, 14, "ATR rails = distances, not forecasts", text_color = ice, text_size = size.tiny)
 
if renderDashboard and dashboard
    string phase = not ready ? "WARMING UP" : compressed ? "01   /   COMPRESSION" : armed ? "02   /   ARMED" : active ? "03   /   EXPANSION" : direction != 0 ? "04   /   DIRECTIONAL" : "00   /   BALANCE"
    string bias = direction == 1 ? "UPWARD" : direction == -1 ? "DOWNWARD" : "TWO-SIDED"
    color biasColor = direction == 1 ? mint : direction == -1 ? coral : ice
    color passportColor = eventDir == 1 ? mint : eventDir == -1 ? coral : ice
    table.cell(board, 0, 2, phase, text_color = regimeColor, text_size = size.normal, text_halign = text.align_left, bgcolor = color.new(regimeColor, 90))
    table.cell(board, 1, 3, f_meter(energy), text_color = gold, text_size = size.small)
    table.cell(board, 2, 3, f_num(energy), text_color = gold, text_size = size.small)
    table.cell(board, 1, 4, f_meter(efficiency * 100), text_color = biasColor, text_size = size.small)
    table.cell(board, 2, 4, f_num(efficiency * 100), text_color = biasColor, text_size = size.small)
    table.cell(board, 1, 5, bias, text_color = biasColor, text_size = size.small)
    table.cell(board, 2, 5, direction == 1 ? "↗" : direction == -1 ? "↘" : "↔", text_color = biasColor, text_size = size.normal)
    table.cell(board, 1, 6, hasVolume ? str.tostring(relativeVolume, "0.00") + "×" : "NO DATA", text_color = textMain, text_size = size.small)
    table.cell(board, 2, 6, barstate.isconfirmed ? "CLOSE" : "LIVE", text_color = ice, text_size = size.tiny)
    table.cell(board, 0, 8, (eventDir == 1 ? "↑  " : eventDir == -1 ? "↓  " : "◌  ") + eventState, text_color = eventState == "RETURNED INSIDE" ? coral : passportColor, text_size = size.normal, text_halign = text.align_left)
    table.cell(board, 1, 9, f_num(eventScore) + " / 100", text_color = passportColor, text_size = size.small)
    table.cell(board, 2, 9, na(eventAt) ? "—" : str.tostring(bar_index - eventAt) + " bars", text_color = ice, text_size = size.tiny)
    table.cell(board, 1, 10, f_price(eventBoundary), text_color = gold, text_size = size.small)
    table.cell(board, 1, 11, na(eventAt) ? "—" : (eventMove >= 0 ? "+" : "") + str.tostring(eventMove, "0.00") + " / " + str.tostring(bestExcursion, "0.00"), text_color = textMain, text_size = size.small)
 
 
// A compact temporal fingerprint, oldest on the left; confirmed bars only.
int regime = compressed ? 2 : direction
var table tape = table.new(position.bottom_center, 32, 2, bgcolor = ink, frame_color = edge, frame_width = 1, border_width = 1, border_color = ink)
if barstate.isfirst
    table.merge_cells(tape, 0, 0, 31, 0)
if renderClosed and filmstrip
    table.cell(tape, 0, 0, "P R I S M   /   REGIME MEMORY                                  32 CLOSED BARS  →", text_color = ice, text_size = size.tiny, bgcolor = ink)
    int shift = barstate.isconfirmed ? 0 : 1
    for i = 0 to 31
        int r = regime[31 - i + shift]
        color c = r == 2 ? gold : r == 1 ? mint : r == -1 ? coral : edge
        table.cell(tape, i, 1, " ", width = 0.7, height = 0.9, bgcolor = color.new(c, 20))
 
alertcondition(upRelease, "PRISM / Upward release", "PRISM upward release confirmed on {{ticker}} {{interval}}. Close: {{close}}. Evidence is descriptive, not probability.")
alertcondition(dnRelease, "PRISM / Downward release", "PRISM downward release confirmed on {{ticker}} {{interval}}. Close: {{close}}. Evidence is descriptive, not probability.")
alertcondition(acceptance, "PRISM / Acceptance", "PRISM release accepted: consecutive confirmed closes outside the frozen gate on {{ticker}} {{interval}}.")
alertcondition(rejection, "PRISM / Return inside", "PRISM release returned inside its frozen gate on {{ticker}} {{interval}}.")

← 返回列表