HTF Liquidity Sweep Reclaim Pyramid

TaninWiselyWealth · study · 405 行 · 点赞 13 · TradingView 原页

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

Pine Script

//@version=6
// ══════════════════════════════════════════════════════════
 
// ══════════════════════════════════════════════════════════
indicator(title = "HTF Liquidity Sweep Reclaim Pyramid", shorttitle = "LSR Pyramid", overlay = true, max_labels_count = 500, max_lines_count = 100)
 
// ══════════════════════════════════════════════════════════
// CONSTANTS
// ══════════════════════════════════════════════════════════
const string GRP_HTF = "① HTF Liquidity Sweep"
const string GRP_SIG = "② Reclaim Signal"
const string GRP_FIX = "③ Weakness Fixes"
const string GRP_PYR = "④ Pyramid Orders"
const string GRP_VIS = "⑤ Visuals"
 
// ══════════════════════════════════════════════════════════
// INPUTS
// ══════════════════════════════════════════════════════════
// ── ① HTF sweep ──
htfAutoInput   = input.bool(true, "Auto HTF", group = GRP_HTF,
     tooltip = "Pick the higher timeframe from the chart timeframe: 1m→15m, 3m→30m, 5m→1H, 15m→4H, 1H→D, 4H→W. Turn off to use Manual HTF.")
htfManualInput = input.timeframe("60", "Manual HTF", group = GRP_HTF,
     tooltip = "Higher timeframe used when Auto HTF is off. Must be higher than the chart timeframe, otherwise the script stops with an error.")
liqSourceInput = input.string("Previous candle", "Liquidity Source", options = ["Previous candle", "Rolling range"], group = GRP_HTF,
     tooltip = "Previous candle: sweep of the last closed HTF high/low. Rolling range: sweep of the highest high / lowest low of the last N closed HTF candles (fewer, stronger sweeps).")
rangeLenInput  = input.int(3, "Rolling Range Candles", minval = 2, maxval = 20, group = GRP_HTF,
     tooltip = "Closed HTF candles used by Rolling range. Higher = larger, rarer liquidity pools. Lower = more frequent sweeps.")
maxWaitInput   = input.int(30, "Max Bars After Sweep", minval = 3, maxval = 300, group = GRP_HTF,
     tooltip = "Chart bars a sweep stays valid while waiting for the reclaim candle. Higher = more late signals. Lower = only fast reversals.")
 
// ── ② Reclaim signal ──
triggerInput   = input.string("CISD (run open)", "Reclaim Model", options = ["CISD (run open)", "Micro structure break"], group = GRP_SIG,
     tooltip = "CISD: close beyond the open of the opposite-candle run that made the sweep extreme. Micro structure break: close beyond the highest high / lowest low of the bars before the extreme.")
msLenInput     = input.int(5, "Micro Structure Lookback", minval = 2, maxval = 50, group = GRP_SIG,
     tooltip = "Bars before the sweep extreme used by Micro structure break. Higher = deeper break required, fewer but later signals.")
dispAtrInput   = input.float(0.5, "Displacement Body (×ATR)", minval = 0.0, maxval = 3.0, step = 0.05, group = GRP_SIG,
     tooltip = "The reclaim candle body must be at least this many ATRs. Higher = only strong displacement, fewer signals. 0 disables the check.")
atrLenInput    = input.int(14, "ATR Length", minval = 2, maxval = 100, group = GRP_SIG,
     tooltip = "ATR period for displacement and the volatility filter. Higher = smoother, slower ATR. Lower = reacts faster to volatility changes.")
directionInput = input.string("Both", "Direction", options = ["Both", "Long only", "Short only"], group = GRP_SIG,
     tooltip = "Which side may generate Buy / Sell signals.")
 
// ── ③ Weakness fixes ──
confirmInput   = input.bool(true, "FIX · Confirmed Bars Only", group = GRP_FIX,
     tooltip = "Signals and pyramid adds fire only on closed bars, so they never appear and disappear intrabar (no repaint). Off = earlier but repainting signals.")
trendInput     = input.bool(true, "FIX · HTF EMA Trend Filter", group = GRP_FIX,
     tooltip = "Longs only when close is above the EMA of closed HTF candles, shorts only below. Cuts counter-trend reversals but can miss major turning points.")
trendLenInput  = input.int(20, "  HTF EMA Length", minval = 2, maxval = 200, group = GRP_FIX,
     tooltip = "EMA length counted in closed HTF candles. Higher = slower trend, fewer flips but more lag. Lower = faster, noisier trend.")
chopInput      = input.bool(true, "FIX · Choppiness Filter", group = GRP_FIX,
     tooltip = "Blocks signals when the Choppiness Index is above the threshold, i.e. in sideways markets where sweeps fail often.")
chopLenInput   = input.int(14, "  Choppiness Length", minval = 5, maxval = 100, group = GRP_FIX,
     tooltip = "Bars used for the Choppiness Index. Higher = slower, smoother regime detection. Lower = reacts faster but flips more often.")
chopMaxInput   = input.float(61.8, "  Max Choppiness", minval = 30.0, maxval = 100.0, step = 0.5, group = GRP_FIX,
     tooltip = "Signals are blocked above this value. Lower = stricter, trending conditions only. Higher = more signals inside ranges.")
volInput       = input.bool(true, "FIX · Volatility Filter (ATR percentile)", group = GRP_FIX,
     tooltip = "Blocks signals when current ATR ranks below the minimum percentile, avoiding dead, low-volatility sessions.")
volLenInput    = input.int(200, "  ATR Percentile Lookback", minval = 20, maxval = 2000, group = GRP_FIX,
     tooltip = "Bars used to rank the current ATR. Higher = compares with a longer history, more stable ranking.")
volMinInput    = input.float(20.0, "  Min ATR Percentile", minval = 0.0, maxval = 95.0, step = 5.0, group = GRP_FIX,
     tooltip = "Minimum ATR percentile for a signal. Higher = only active markets, fewer signals. 0 effectively disables the filter.")
rvolInput      = input.bool(false, "FIX · Relative Volume on Reclaim", group = GRP_FIX,
     tooltip = "The reclaim candle must have volume above its average. Ignored on symbols without volume data.")
rvolLenInput   = input.int(20, "  Volume Average Length", minval = 2, maxval = 200, group = GRP_FIX,
     tooltip = "Length of the volume moving average. Higher = smoother baseline.")
rvolMinInput   = input.float(1.2, "  Min Relative Volume", minval = 0.5, maxval = 5.0, step = 0.1, group = GRP_FIX,
     tooltip = "Reclaim volume must be at least this multiple of the average. Higher = only high-participation reclaims, fewer signals.")
cooldownInput  = input.int(5, "FIX · Cooldown Bars (same side)", minval = 0, maxval = 200, group = GRP_FIX,
     tooltip = "Minimum bars between two main signals on the same side. Prevents clustered duplicate signals. 0 = off.")
conflictInput  = input.string("Skip both", "FIX · Same-Bar Long & Short", options = ["Skip both", "Follow HTF EMA"], group = GRP_FIX,
     tooltip = "When long and short signals appear on the same bar: skip both, or keep only the side that matches the HTF EMA trend.")
invalidInput   = input.bool(true, "FIX · Reset on Sweep Extreme Break", group = GRP_FIX,
     tooltip = "A close beyond the sweep extreme ends the position state and pyramid count, so no orders are added into a failed setup.")
 
// ── ④ Pyramid ──
pyrOnInput      = input.bool(true, "Enable Pyramid", group = GRP_PYR,
     tooltip = "Allow extra add-on orders after the first Buy / Sell signal while the position state is open.")
pyrMaxInput     = input.int(3, "Max Orders per Side", minval = 1, maxval = 10, group = GRP_PYR,
     tooltip = "Total orders per side including the first signal. Higher = more scaling and more exposure. 1 = no add-ons.")
pyrModeInput    = input.string("ATR", "Spacing Mode", options = ["Ticks", "ATR"], group = GRP_PYR,
     tooltip = "How the distance between orders is measured: a fixed number of ticks, or a multiple of ATR (adapts to volatility).")
pyrTicksInput   = input.int(50, "  Spacing (Ticks)", minval = 1, maxval = 100000, group = GRP_PYR,
     tooltip = "Ticks Mode: distance from the last order in ticks (syminfo.mintick). Higher = fewer, wider-spaced add-ons.")
pyrAtrLenInput  = input.int(14, "  Spacing ATR Length", minval = 2, maxval = 100, group = GRP_PYR,
     tooltip = "ATR Mode: ATR period used for spacing. Higher = smoother spacing.")
pyrAtrMultInput = input.float(1.0, "  Spacing ATR Multiplier", minval = 0.1, maxval = 10.0, step = 0.1, group = GRP_PYR,
     tooltip = "ATR Mode: spacing = multiplier × ATR. Higher = wider spacing, fewer add-ons.")
pyrDirInput     = input.string("Favorable", "Add When Price Moves", options = ["Favorable", "Adverse"], group = GRP_PYR,
     tooltip = "Favorable: add Buy when price rises by the spacing above the last buy (Sell when it falls). Adverse: add when price moves against the last order (averaging).")
pyrBarDirInput  = input.bool(true, "  Add Only on Bar Closing With Trade", group = GRP_PYR,
     tooltip = "Pyramid Buy only on a bullish close, Pyramid Sell only on a bearish close. Reduces adds into momentum against the position.")
 
// ── ⑤ Visuals ──
showLevelsInput  = input.bool(true, "Show HTF Liquidity Levels", group = GRP_VIS,
     tooltip = "Step lines at the HTF high (buy-side) and low (sell-side) liquidity being watched for sweeps.")
showReclaimInput = input.bool(true, "Show Reclaim Level", group = GRP_VIS,
     tooltip = "Dots at the level price must close beyond after a sweep to trigger a signal.")
showEmaInput     = input.bool(false, "Show HTF EMA", group = GRP_VIS,
     tooltip = "Plot the EMA of closed HTF candles used by the trend filter.")
showStopInput    = input.bool(true, "Show Sweep Extreme (Invalidation)", group = GRP_VIS,
     tooltip = "Line at the sweep extreme of the open position; a close beyond it resets the position state.")
showNumInput     = input.bool(true, "Numbered Pyramid Labels", group = GRP_VIS,
     tooltip = "Label each add-on as B2, B3… / S2, S3…. Off = small diamond markers instead.")
showDashInput    = input.bool(true, "Show Dashboard", group = GRP_VIS,
     tooltip = "Small status table: position, order count, pending setups and filter state.")
bullColorInput   = input.color(#00C853, "Buy Color", group = GRP_VIS,
     tooltip = "Color of Buy signals, pyramid buys and the sell-side liquidity line.")
bearColorInput   = input.color(#FF1744, "Sell Color", group = GRP_VIS,
     tooltip = "Color of Sell signals, pyramid sells and the buy-side liquidity line.")
 
// ══════════════════════════════════════════════════════════
// HTF SELECTION & VALIDATION
// ══════════════════════════════════════════════════════════
int    chartSec = timeframe.in_seconds()
string autoTF   = chartSec <= 60 ? "15" : chartSec <= 180 ? "30" : chartSec <= 300 ? "60" : chartSec <= 900 ? "240" : chartSec <= 3600 ? "D" : chartSec <= 14400 ? "W" : "M"
string htfTF    = htfAutoInput ? autoTF : htfManualInput
 
if barstate.isfirst and timeframe.in_seconds(htfTF) <= chartSec
    runtime.error("HTF must be higher than the chart timeframe")
 
// ══════════════════════════════════════════════════════════
// CORE SERIES (computed every bar)
// ══════════════════════════════════════════════════════════
float atr    = ta.atr(atrLenInput)
float atrPct = ta.percentrank(atr, volLenInput)
float pyrAtr = ta.atr(pyrAtrLenInput)
float volSma = ta.sma(volume, rvolLenInput)
float msHigh = ta.highest(high, msLenInput)[1]
float msLow  = ta.lowest(low, msLenInput)[1]
 
// Choppiness Index
float chopRange = ta.highest(high, chopLenInput) - ta.lowest(low, chopLenInput)
float chopSum   = math.sum(ta.atr(1), chopLenInput)
float chop      = chopRange > 0 ? 100 * math.log10(chopSum / chopRange) / math.log10(chopLenInput) : 100.0
 
// ══════════════════════════════════════════════════════════
// HTF AGGREGATION (built from chart bars — no request.security, no lookahead)
// ══════════════════════════════════════════════════════════
var float        curH      = na
var float        curL      = na
var float        curC      = na
var int          htfSeen   = 0
var array<float> hHist     = array.new<float>()
var array<float> lHist     = array.new<float>()
var float        htfEma    = na
var bool         bSweptHtf = false
var bool         sSweptHtf = false
 
bool newHtf = timeframe.change(htfTF)
if newHtf or na(curH)
    // FIX: the first aggregated HTF candle is usually partial — never stored
    if not na(curH) and htfSeen > 1
        hHist.push(curH)
        lHist.push(curL)
        if hHist.size() > 50
            hHist.shift()
            lHist.shift()
        float alpha = 2.0 / (trendLenInput + 1)
        htfEma := na(htfEma) ? curC : alpha * curC + (1 - alpha) * htfEma
    htfSeen   += 1
    curH      := high
    curL      := low
    curC      := close
    bSweptHtf := false
    sSweptHtf := false
else
    curH := math.max(curH, high)
    curL := math.min(curL, low)
    curC := close
 
int   nLiq    = liqSourceInput == "Previous candle" ? 1 : rangeLenInput
float liqHigh = na
float liqLow  = na
if hHist.size() >= nLiq
    int sz = hHist.size()
    liqHigh := hHist.slice(sz - nLiq, sz).max()
    liqLow  := lHist.slice(sz - nLiq, sz).min()
 
// ══════════════════════════════════════════════════════════
// OPPOSITE-CANDLE RUNS (for the CISD reclaim level)
// ══════════════════════════════════════════════════════════
var float dnRunOpen = na   // open of the latest run of down-close candles
var float upRunOpen = na   // open of the latest run of up-close candles
var bool  inDn      = false
var bool  inUp      = false
if close < open
    if not inDn
        dnRunOpen := open
    inDn := true
    inUp := false
else if close > open
    if not inUp
        upRunOpen := open
    inUp := true
    inDn := false
 
bool  useCisd    = triggerInput == "CISD (run open)"
float longLvlNow = useCisd ? dnRunOpen : msHigh
float shortLvlNow = useCisd ? upRunOpen : msLow
 
// ══════════════════════════════════════════════════════════
// SWEEP CONTEXTS
// ══════════════════════════════════════════════════════════
var bool  bActive = false
var float bExt    = na
var int   bStart  = na
var float bLevel  = na
var bool  sActive = false
var float sExt    = na
var int   sStart  = na
var float sLevel  = na
 
bool allowLong  = directionInput != "Short only"
bool allowShort = directionInput != "Long only"
 
// sell-side sweep → long context (one sweep event per HTF candle)
if not na(liqLow) and low < liqLow and not bSweptHtf
    bSweptHtf := true
    if allowLong
        if not bActive
            bActive := true
            bExt    := low
            bLevel  := longLvlNow
        bStart := bar_index   // a fresh sweep restarts the wait window
// new extreme while active → re-anchor the reclaim level
if bActive and low < bExt
    bExt   := low
    bLevel := longLvlNow
 
// buy-side sweep → short context
if not na(liqHigh) and high > liqHigh and not sSweptHtf
    sSweptHtf := true
    if allowShort
        if not sActive
            sActive := true
            sExt    := high
            sLevel  := shortLvlNow
        sStart := bar_index
if sActive and high > sExt
    sExt   := high
    sLevel := shortLvlNow
 
// expiry
if bActive and bar_index - bStart > maxWaitInput
    bActive := false
if sActive and bar_index - sStart > maxWaitInput
    sActive := false
 
// ══════════════════════════════════════════════════════════
// SIGNAL CONDITIONS + FILTERS
// ══════════════════════════════════════════════════════════
var int lastBuyBar  = na
var int lastSellBar = na
 
bool  confOk  = not confirmInput or barstate.isconfirmed               // FIX: repaint
float body    = math.abs(close - open)
bool  dispOk  = dispAtrInput == 0 or body >= dispAtrInput * nz(atr)
bool  rvolOk  = not rvolInput or na(volume) or na(volSma) or volSma == 0 or volume >= rvolMinInput * volSma   // FIX: volume
bool  chopOk  = not chopInput or chop <= chopMaxInput                    // FIX: sideways
bool  volOk   = not volInput or (not na(atrPct) and atrPct >= volMinInput)   // FIX: volatility
bool  warmOk  = bar_index > math.max(atrLenInput, chopLenInput)
bool  baseOk  = confOk and dispOk and rvolOk and chopOk and volOk and warmOk
 
bool trendLongOk  = not trendInput or (not na(htfEma) and close > htfEma)   // FIX: trend
bool trendShortOk = not trendInput or (not na(htfEma) and close < htfEma)
bool coolLongOk   = cooldownInput == 0 or na(lastBuyBar)  or bar_index - lastBuyBar  > cooldownInput   // FIX: duplicates
bool coolShortOk  = cooldownInput == 0 or na(lastSellBar) or bar_index - lastSellBar > cooldownInput
 
// Buy: after a sell-side sweep, a bullish displacement candle closes above the reclaim level
bool longSig  = bActive and not na(bLevel) and close > bLevel and close > open and baseOk and trendLongOk and coolLongOk
// Sell: after a buy-side sweep, a bearish displacement candle closes below the reclaim level
bool shortSig = sActive and not na(sLevel) and close < sLevel and close < open and baseOk and trendShortOk and coolShortOk
 
// FIX: same-bar conflict
if longSig and shortSig
    bool keepLong  = conflictInput == "Follow HTF EMA" and not na(htfEma) and close > htfEma
    bool keepShort = conflictInput == "Follow HTF EMA" and not na(htfEma) and close < htfEma
    longSig  := keepLong
    shortSig := keepShort
    bActive  := false
    sActive  := false
 
// ══════════════════════════════════════════════════════════
// POSITION STATE & PYRAMID
// ══════════════════════════════════════════════════════════
var int   posDir     = 0
var int   buyCount   = 0
var int   sellCount  = 0
var float lastBuyPx  = na
var float lastSellPx = na
var float stopLvl    = na
 
bool evBuy     = false
bool evSell    = false
bool evPyrBuy  = false
bool evPyrSell = false
bool evInvalid = false
 
// FIX: invalidation — close beyond the sweep extreme resets the state
if invalidInput and confOk and posDir == 1 and not na(stopLvl) and close < stopLvl
    evInvalid := true
    posDir    := 0
    buyCount  := 0
    lastBuyPx := na
if invalidInput and confOk and posDir == -1 and not na(stopLvl) and close > stopLvl
    evInvalid  := true
    posDir     := 0
    sellCount  := 0
    lastSellPx := na
 
float spacing = pyrModeInput == "Ticks" ? pyrTicksInput * syminfo.mintick : pyrAtrMultInput * nz(pyrAtr)
 
if longSig
    // first order — opposite side is reset
    evBuy      := true
    posDir     := 1
    buyCount   := 1
    lastBuyPx  := close
    sellCount  := 0
    lastSellPx := na
    stopLvl    := bExt
    lastBuyBar := bar_index
    bActive    := false
else if shortSig
    evSell      := true
    posDir      := -1
    sellCount   := 1
    lastSellPx  := close
    buyCount    := 0
    lastBuyPx   := na
    stopLvl     := sExt
    lastSellBar := bar_index
    sActive     := false
else if pyrOnInput and confOk and spacing > 0
    // Pyramid Buy  — Favorable: close ≥ last buy + spacing (price moved UP)
    //                Adverse:   close ≤ last buy − spacing (price moved DOWN)
    if posDir == 1 and buyCount < pyrMaxInput and (not pyrBarDirInput or close > open)
        bool distOk = pyrDirInput == "Favorable" ? close >= lastBuyPx + spacing : close <= lastBuyPx - spacing
        if distOk
            evPyrBuy  := true
            buyCount  += 1
            lastBuyPx := close
    // Pyramid Sell — Favorable: close ≤ last sell − spacing (price moved DOWN)
    //                Adverse:   close ≥ last sell + spacing (price moved UP)
    else if posDir == -1 and sellCount < pyrMaxInput and (not pyrBarDirInput or close < open)
        bool distOk = pyrDirInput == "Favorable" ? close <= lastSellPx - spacing : close >= lastSellPx + spacing
        if distOk
            evPyrSell  := true
            sellCount  += 1
            lastSellPx := close
 
// ══════════════════════════════════════════════════════════
// PLOTS
// ══════════════════════════════════════════════════════════
plot(showLevelsInput ? liqHigh : na, "HTF Buy-side Liquidity", color.new(bearColorInput, 40), 1, plot.style_stepline)
plot(showLevelsInput ? liqLow  : na, "HTF Sell-side Liquidity", color.new(bullColorInput, 40), 1, plot.style_stepline)
plot(showReclaimInput and bActive ? bLevel : na, "Long Reclaim Level", color.new(bullColorInput, 20), 2, plot.style_circles)
plot(showReclaimInput and sActive ? sLevel : na, "Short Reclaim Level", color.new(bearColorInput, 20), 2, plot.style_circles)
plot(showEmaInput ? htfEma : na, "HTF EMA", color.new(color.orange, 0), 2, plot.style_stepline)
plot(showStopInput and posDir != 0 ? stopLvl : na, "Sweep Extreme", color.new(color.gray, 20), 1, plot.style_linebr)
 
// first orders
plotshape(evBuy,  "Buy",  shape.triangleup,   location.belowbar, bullColorInput, size = size.small, text = "B1", textcolor = bullColorInput)
plotshape(evSell, "Sell", shape.triangledown, location.abovebar, bearColorInput, size = size.small, text = "S1", textcolor = bearColorInput)
// pyramid adds (diamonds when numbered labels are off)
plotshape(evPyrBuy  and not showNumInput, "Pyramid Buy",  shape.diamond, location.belowbar, color.new(bullColorInput, 25), size = size.tiny)
plotshape(evPyrSell and not showNumInput, "Pyramid Sell", shape.diamond, location.abovebar, color.new(bearColorInput, 25), size = size.tiny)
plotshape(evInvalid, "Setup Invalidated", shape.xcross, location.abovebar, color.new(color.gray, 0), size = size.tiny)
 
if showNumInput and evPyrBuy
    label.new(bar_index, low, "B" + str.tostring(buyCount), yloc = yloc.belowbar, style = label.style_label_up, color = color.new(bullColorInput, 25), textcolor = color.white, size = size.small)
if showNumInput and evPyrSell
    label.new(bar_index, high, "S" + str.tostring(sellCount), yloc = yloc.abovebar, style = label.style_label_down, color = color.new(bearColorInput, 25), textcolor = color.white, size = size.small)
 
// ══════════════════════════════════════════════════════════
// DASHBOARD
// ══════════════════════════════════════════════════════════
var table dash = table.new(position.top_right, 2, 8, bgcolor = color.new(#131722, 10), border_color = color.new(#2A2E39, 0), border_width = 1)
 
dashRow(int r, string k, string v, color vc) =>
    table.cell(dash, 0, r, k, text_color = color.new(#9E9E9E, 0), text_size = size.small, text_halign = text.align_left)
    table.cell(dash, 1, r, v, text_color = vc, text_size = size.small, text_halign = text.align_right)
 
if showDashInput and barstate.islast
    table.cell(dash, 0, 0, "LSR Pyramid · HTF " + htfTF, text_color = color.white, bgcolor = color.new(#1565C0, 0), text_size = size.small)
    table.merge_cells(dash, 0, 0, 1, 0)
    string posStr = posDir == 1 ? "LONG ×" + str.tostring(buyCount) : posDir == -1 ? "SHORT ×" + str.tostring(sellCount) : "Flat"
    color  posCol = posDir == 1 ? bullColorInput : posDir == -1 ? bearColorInput : color.gray
    dashRow(1, "Position", posStr, posCol)
    dashRow(2, "Max Orders", pyrOnInput ? str.tostring(pyrMaxInput) : "1 (pyramid off)", color.white)
    dashRow(3, "Long Setup", bActive ? "Reclaim > " + str.tostring(bLevel, format.mintick) : "—", bActive ? bullColorInput : color.gray)
    dashRow(4, "Short Setup", sActive ? "Reclaim < " + str.tostring(sLevel, format.mintick) : "—", sActive ? bearColorInput : color.gray)
    string trStr = not trendInput ? "Off" : na(htfEma) ? "Warming up" : close > htfEma ? "Bullish" : "Bearish"
    dashRow(5, "HTF Trend", trStr, trStr == "Bullish" ? bullColorInput : trStr == "Bearish" ? bearColorInput : color.gray)
    dashRow(6, "Choppiness", str.tostring(chop, "#.0") + (chopOk ? " ✓" : " ✕"), chopOk ? color.white : color.orange)
    dashRow(7, "ATR Pct", na(atrPct) ? "—" : str.tostring(atrPct, "#") + (volOk ? " ✓" : " ✕"), volOk ? color.white : color.orange)
 
// ══════════════════════════════════════════════════════════
// ALERTS
// ══════════════════════════════════════════════════════════
alertcondition(evBuy,     "Buy",          "LSR Pyramid: BUY (first order) on {{ticker}} {{interval}} @ {{close}}")
alertcondition(evSell,    "Sell",         "LSR Pyramid: SELL (first order) on {{ticker}} {{interval}} @ {{close}}")
alertcondition(evPyrBuy,  "Pyramid Buy",  "LSR Pyramid: PYRAMID BUY add-on on {{ticker}} {{interval}} @ {{close}}")
alertcondition(evPyrSell, "Pyramid Sell", "LSR Pyramid: PYRAMID SELL add-on on {{ticker}} {{interval}} @ {{close}}")
alertcondition(evInvalid, "Setup Invalidated", "LSR Pyramid: sweep extreme broken, position state reset on {{ticker}} @ {{close}}")

← 返回列表