Liquidity Target Mapper v2 | NQ/MNQ

jimmyjames4684 · study · 486 行 · 点赞 5 · TradingView 原页

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

Pine Script

//@version=6
indicator("Liquidity Target Mapper v2 | NQ/MNQ", shorttitle="LTM v2", overlay=true, scale=scale.right, format=format.price, max_lines_count=200, max_labels_count=200, max_bars_back=5000)
 
// ============================================
// 1. SETTINGS
// ============================================
 
g1 = "01 | Ranked Target Sources"
showPD       = input.bool(true, "Previous day high / low", group=g1)
showSessions = input.bool(true, "Session highs / lows", group=g1)
showSwings   = input.bool(true, "Confirmed swing highs / lows", group=g1)
pivotLen     = input.int(5, "Swing confirmation bars", minval=1, maxval=30, group=g1)
swingCount   = input.int(8, "Recent swings per side", minval=1, maxval=30, group=g1)
duplicateTicks = input.int(8, "Merge nearby levels (ticks)", minval=0, group=g1)
 
g2 = "02 | Session Settings"
tz         = input.string("America/Chicago", "Session timezone", group=g2)
asiaSess   = input.session("1800-2300", "Asia (CT)", group=g2)
londonSess = input.session("0200-0500", "London (CT)", group=g2)
nySess     = input.session("0830-1100", "New York morning (CT)", group=g2)
 
g3 = "03 | Key Levels (always drawn)"
showKeyLevels = input.bool(true, "Draw key levels", group=g3)
keyAsia   = input.bool(true, "Asia high / low", inline="ka", group=g3)
asiaCol   = input.color(color.aqua, "", inline="ka", group=g3)
keyLondon = input.bool(true, "London high / low", inline="kl", group=g3)
londonCol = input.color(color.fuchsia, "", inline="kl", group=g3)
keyNY     = input.bool(false, "NY AM high / low", inline="kn", group=g3)
nyCol     = input.color(color.yellow, "", inline="kn", group=g3)
keyPD     = input.bool(true, "Previous day high / low", inline="kp", group=g3)
pdCol     = input.color(color.orange, "", inline="kp", group=g3)
showForming  = input.bool(true, "Show session range while it is forming", group=g3)
markSwept    = input.bool(true, "Fade a level once price sweeps it", group=g3)
showAxisTags = input.bool(true, "Show key level prices on price scale", group=g3)
keyWidth     = input.int(2, "Key line width", minval=1, maxval=4, group=g3)
keyLabelOffset = input.int(30, "Key label offset (bars right of price)", minval=0, maxval=200, group=g3)
 
g4 = "04 | ATR Targets"
showATR    = input.bool(true, "Display ATR projections", group=g4)
atrLen     = input.int(14, "ATR length", minval=1, group=g4)
atrTarget1 = input.float(1.0, "ATR target 1", step=0.25, minval=0.25, group=g4)
atrTarget2 = input.float(2.0, "ATR target 2", step=0.25, minval=0.25, group=g4)
 
g5 = "05 | Trade Planner"
usePlan        = input.bool(false, "Enable manual trade planning", group=g5)
tradeDirection = input.string("Long", "Trade direction", options=["Long", "Short"], group=g5)
manualEntry    = input.float(28000.0, "Planned entry price", step=0.25, group=g5)
manualStop     = input.float(27950.0, "Planned stop price", step=0.25, group=g5)
 
g6 = "06 | Appearance"
showLines  = input.bool(true, "Show ranked target lines", group=g6)
showLabels = input.bool(true, "Show labels", group=g6)
showTable  = input.bool(true, "Show dashboard", group=g6)
showSourcePlots = input.bool(false, "Show source levels across chart", group=g6)
lineLength = input.int(45, "Target line length (bars)", minval=5, maxval=150, group=g6)
labelSizeIn = input.string("Normal", "Label text size", options=["Tiny", "Small", "Normal", "Large", "Huge"], group=g6)
tableSizeIn = input.string("Normal", "Dashboard text size", options=["Tiny", "Small", "Normal", "Large", "Huge"], group=g6)
tablePosIn  = input.string("Top Right", "Dashboard position", options=["Top Right", "Top Left", "Middle Right", "Bottom Right", "Bottom Left"], group=g6)
 
// ============================================
// 2. HELPERS
// ============================================
 
sizeOf(string s) =>
    switch s
        "Tiny"   => size.tiny
        "Small"  => size.small
        "Large"  => size.large
        "Huge"   => size.huge
        => size.normal
 
posOf(string s) =>
    switch s
        "Top Left"     => position.top_left
        "Middle Right" => position.middle_right
        "Bottom Right" => position.bottom_right
        "Bottom Left"  => position.bottom_left
        => position.top_right
 
string lblSize = sizeOf(labelSizeIn)
string tblSize = sizeOf(tableSizeIn)
 
// ============================================
// 3. BASE VALUES
// ============================================
 
float tick   = syminfo.mintick
float atr    = ta.atr(atrLen)
float anchor = usePlan ? manualEntry : close
float risk   = math.abs(manualEntry - manualStop)
 
bool validPlan = usePlan and ((tradeDirection == "Long" and manualStop < manualEntry) or (tradeDirection == "Short" and manualStop > manualEntry)) and risk >= tick
 
// Previous completed trading day (offset + lookahead_on = no repainting).
[pdh, pdl] = request.security(syminfo.tickerid, "D", [high[1], low[1]], lookahead=barmerge.lookahead_on)
 
var int dayStart     = na
var int prevDayStart = na
var float dayHigh    = na
var float dayLow     = na
 
if timeframe.change("D")
    prevDayStart := dayStart
    dayStart     := bar_index
    dayHigh      := high
    dayLow       := low
else
    dayHigh := math.max(nz(dayHigh, high), high)
    dayLow  := math.min(nz(dayLow, low), low)
 
bool pdhSwept = not na(pdh) and dayHigh > pdh
bool pdlSwept = not na(pdl) and dayLow < pdl
 
// ============================================
// 4. SESSION TRACKING
// ============================================
 
type SessionLevels
    float runHigh
    float runLow
    int   runHighBar
    int   runLowBar
    int   startBar
    float hi
    float lo
    int   hiBar
    int   loBar
    bool  hiSwept = false
    bool  loSwept = false
 
method update(SessionLevels this, bool inSess, bool wasIn) =>
    if inSess and not wasIn
        this.runHigh    := high
        this.runLow     := low
        this.runHighBar := bar_index
        this.runLowBar  := bar_index
        this.startBar   := bar_index
    else if inSess
        if high > this.runHigh
            this.runHigh    := high
            this.runHighBar := bar_index
        if low < this.runLow
            this.runLow    := low
            this.runLowBar := bar_index
 
    if not inSess and wasIn
        this.hi      := this.runHigh
        this.lo      := this.runLow
        this.hiBar   := this.runHighBar
        this.loBar   := this.runLowBar
        this.hiSwept := false
        this.loSwept := false
 
    if not na(this.hi) and high > this.hi
        this.hiSwept := true
    if not na(this.lo) and low < this.lo
        this.loSwept := true
    this
 
bool inAsia   = not na(time(timeframe.period, asiaSess, tz))
bool inLondon = not na(time(timeframe.period, londonSess, tz))
bool inNY     = not na(time(timeframe.period, nySess, tz))
 
var SessionLevels asia   = SessionLevels.new()
var SessionLevels london = SessionLevels.new()
var SessionLevels ny     = SessionLevels.new()
 
asia.update(inAsia, inAsia[1])
london.update(inLondon, inLondon[1])
ny.update(inNY, inNY[1])
 
// Plain copies of object fields (needed for history references and plots).
float asiaHi   = asia.hi
float asiaLo   = asia.lo
float londonHi = london.hi
float londonLo = london.lo
float nyHi     = ny.hi
float nyLo     = ny.lo
bool asiaHiSwept   = asia.hiSwept
bool asiaLoSwept   = asia.loSwept
bool londonHiSwept = london.hiSwept
bool londonLoSwept = london.loSwept
 
// ============================================
// 5. CONFIRMED SWING LIQUIDITY
// ============================================
 
float ph = ta.pivothigh(high, pivotLen, pivotLen)
float pl = ta.pivotlow(low, pivotLen, pivotLen)
 
var array<float> swingHighs = array.new_float()
var array<float> swingLows  = array.new_float()
 
if not na(ph) and barstate.isconfirmed
    swingHighs.unshift(ph)
    if swingHighs.size() > swingCount
        swingHighs.pop()
 
if not na(pl) and barstate.isconfirmed
    swingLows.unshift(pl)
    if swingLows.size() > swingCount
        swingLows.pop()
 
// ============================================
// 6. LEVEL FUNCTIONS
// ============================================
 
addLevel(array<float> prices, array<string> names, float level, string name, float mergeDistance) =>
    if not na(level)
        bool duplicate = false
        if prices.size() > 0
            for j = 0 to prices.size() - 1
                if math.abs(prices.get(j) - level) <= mergeDistance
                    duplicate := true
                    break
        if not duplicate
            prices.push(level)
            names.push(name)
 
getNearest(array<float> prices, array<string> names, float reference, int side) =>
    float selected = na
    string selectedName = "None"
    int selectedIndex = -1
    if prices.size() > 0
        for j = 0 to prices.size() - 1
            float level = prices.get(j)
            float distance = (level - reference) * side
            if distance > 0
                if na(selected) or distance < (selected - reference) * side
                    selected      := level
                    selectedName  := names.get(j)
                    selectedIndex := j
    if selectedIndex >= 0
        prices.remove(selectedIndex)
        names.remove(selectedIndex)
    [selected, selectedName]
 
getR(float level, float reference, float riskDistance, bool planValid, int side) =>
    string result = "—"
    if planValid and not na(level) and riskDistance > 0
        bool correctSide = (tradeDirection == "Long" and side == 1) or (tradeDirection == "Short" and side == -1)
        if correctSide
            result := str.tostring(math.abs(level - reference) / riskDistance, "#.##") + "R"
    result
 
drawKey(array<line> ls, array<label> lbs, float price, int startBar, string name, color col, bool swept, bool forming) =>
    if not na(price)
        bool faded = swept and markSwept
        int x1 = na(startBar) ? bar_index - 50 : math.max(startBar, bar_index - 4900)
        int x2 = bar_index + keyLabelOffset
        color lc = faded ? color.new(col, 65) : forming ? color.new(col, 30) : col
        string st = forming ? line.style_dashed : faded ? line.style_dotted : line.style_solid
        ls.push(line.new(x1, price, x2, price, color=lc, width=faded ? 1 : keyWidth, style=st))
        if showLabels
            string suffix = forming ? "  (forming)" : faded ? "  ✓ swept" : ""
            string txt = name + "  " + str.tostring(price, format.mintick) + suffix
            lbs.push(label.new(x2, price, txt, style=label.style_label_left, color=faded ? color.new(color.gray, 60) : color.new(col, 25), textcolor=faded ? color.silver : color.black, size=lblSize))
 
keyRow(table t, int row, string name, float price, bool swept, color col) =>
    string pTxt = na(price) ? "—" : str.tostring(price, format.mintick) + "  (" + str.tostring(price - close, "+#.##;-#.##") + ")"
    table.cell(t, 0, row, name, text_color=col, text_size=tblSize, text_halign=text.align_left)
    table.cell(t, 1, row, pTxt, text_color=color.white, text_size=tblSize, text_halign=text.align_left)
    table.cell(t, 2, row, na(price) ? "" : swept ? "Swept" : "Open", text_color=swept ? color.gray : color.lime, text_size=tblSize)
 
// ============================================
// 7. PLOTS (anchor the script to the price scale)
// ============================================
 
// Invisible close plot keeps the indicator tied to the main price scale.
plot(close, "Scale anchor", color=color.new(color.white, 100), display=display.none, editable=false)
 
plot(showSourcePlots and showPD ? pdh : na, "PDH", color=color.orange, style=plot.style_stepline)
plot(showSourcePlots and showPD ? pdl : na, "PDL", color=color.orange, style=plot.style_stepline)
plot(showSourcePlots and showSessions ? asiaHi : na, "Asia High", color=color.aqua, style=plot.style_stepline)
plot(showSourcePlots and showSessions ? asiaLo : na, "Asia Low", color=color.aqua, style=plot.style_stepline)
plot(showSourcePlots and showSessions ? londonHi : na, "London High", color=color.fuchsia, style=plot.style_stepline)
plot(showSourcePlots and showSessions ? londonLo : na, "London Low", color=color.fuchsia, style=plot.style_stepline)
plot(showSourcePlots and showSessions ? nyHi : na, "NY High", color=color.yellow, style=plot.style_stepline)
plot(showSourcePlots and showSessions ? nyLo : na, "NY Low", color=color.yellow, style=plot.style_stepline)
 
bool tagsOn = showKeyLevels and showAxisTags
plot(tagsOn and keyAsia ? asiaHi : na, "Asia High tag", color=asiaCol, display=display.price_scale)
plot(tagsOn and keyAsia ? asiaLo : na, "Asia Low tag", color=asiaCol, display=display.price_scale)
plot(tagsOn and keyLondon ? londonHi : na, "London High tag", color=londonCol, display=display.price_scale)
plot(tagsOn and keyLondon ? londonLo : na, "London Low tag", color=londonCol, display=display.price_scale)
plot(tagsOn and keyNY ? nyHi : na, "NY AM High tag", color=nyCol, display=display.price_scale)
plot(tagsOn and keyNY ? nyLo : na, "NY AM Low tag", color=nyCol, display=display.price_scale)
plot(tagsOn and keyPD ? pdh : na, "PDH tag", color=pdCol, display=display.price_scale)
plot(tagsOn and keyPD ? pdl : na, "PDL tag", color=pdCol, display=display.price_scale)
 
// ============================================
// 8. DRAWING STORAGE
// ============================================
 
var array<line>  allLines  = array.new_line()
var array<label> allLabels = array.new_label()
 
var table dashboard = table.new(posOf(tablePosIn), 3, 20, bgcolor=color.new(color.black, 12), border_width=1, border_color=color.new(color.gray, 70))
 
// ============================================
// 9. TARGET SELECTION AND DISPLAY
// ============================================
 
if barstate.islast
    for l in allLines
        l.delete()
    allLines.clear()
    for lb in allLabels
        lb.delete()
    allLabels.clear()
 
    // ---------- KEY LEVELS ----------
    if showKeyLevels
        if keyPD
            drawKey(allLines, allLabels, pdh, prevDayStart, "PDH", pdCol, pdhSwept, false)
            drawKey(allLines, allLabels, pdl, prevDayStart, "PDL", pdCol, pdlSwept, false)
        if keyAsia
            drawKey(allLines, allLabels, asia.hi, asia.hiBar, "ASIA HIGH", asiaCol, asia.hiSwept, false)
            drawKey(allLines, allLabels, asia.lo, asia.loBar, "ASIA LOW", asiaCol, asia.loSwept, false)
            if showForming and inAsia
                drawKey(allLines, allLabels, asia.runHigh, asia.startBar, "ASIA HIGH", asiaCol, false, true)
                drawKey(allLines, allLabels, asia.runLow, asia.startBar, "ASIA LOW", asiaCol, false, true)
        if keyLondon
            drawKey(allLines, allLabels, london.hi, london.hiBar, "LONDON HIGH", londonCol, london.hiSwept, false)
            drawKey(allLines, allLabels, london.lo, london.loBar, "LONDON LOW", londonCol, london.loSwept, false)
            if showForming and inLondon
                drawKey(allLines, allLabels, london.runHigh, london.startBar, "LONDON HIGH", londonCol, false, true)
                drawKey(allLines, allLabels, london.runLow, london.startBar, "LONDON LOW", londonCol, false, true)
        if keyNY
            drawKey(allLines, allLabels, ny.hi, ny.hiBar, "NY AM HIGH", nyCol, ny.hiSwept, false)
            drawKey(allLines, allLabels, ny.lo, ny.loBar, "NY AM LOW", nyCol, ny.loSwept, false)
            if showForming and inNY
                drawKey(allLines, allLabels, ny.runHigh, ny.startBar, "NY AM HIGH", nyCol, false, true)
                drawKey(allLines, allLabels, ny.runLow, ny.startBar, "NY AM LOW", nyCol, false, true)
 
    // ---------- CANDIDATE POOL ----------
    array<float>  prices = array.new_float()
    array<string> names  = array.new_string()
    float mergeDistance = duplicateTicks * tick
 
    if showPD
        addLevel(prices, names, pdh, "PDH", mergeDistance)
        addLevel(prices, names, pdl, "PDL", mergeDistance)
    if showSessions
        addLevel(prices, names, asia.hi, "Asia High", mergeDistance)
        addLevel(prices, names, asia.lo, "Asia Low", mergeDistance)
        addLevel(prices, names, london.hi, "London High", mergeDistance)
        addLevel(prices, names, london.lo, "London Low", mergeDistance)
        addLevel(prices, names, ny.hi, "NY High", mergeDistance)
        addLevel(prices, names, ny.lo, "NY Low", mergeDistance)
    if showSwings
        for v in swingHighs
            addLevel(prices, names, v, "Swing High", mergeDistance)
        for v in swingLows
            addLevel(prices, names, v, "Swing Low", mergeDistance)
 
    array<float>  upperPrices = prices.copy()
    array<string> upperNames  = names.copy()
    array<float>  lowerPrices = prices.copy()
    array<string> lowerNames  = names.copy()
 
    array<float>  rankedAbove      = array.new_float()
    array<string> rankedAboveNames = array.new_string()
    array<float>  rankedBelow      = array.new_float()
    array<string> rankedBelowNames = array.new_string()
 
    for k = 0 to 2
        [abovePrice, aboveName] = getNearest(upperPrices, upperNames, anchor, 1)
        [belowPrice, belowName] = getNearest(lowerPrices, lowerNames, anchor, -1)
        rankedAbove.push(abovePrice)
        rankedAboveNames.push(aboveName)
        rankedBelow.push(belowPrice)
        rankedBelowNames.push(belowName)
 
    // ---------- RANKED TARGET LINES ----------
    if showLines
        for k = 0 to 2
            float upper = rankedAbove.get(k)
            float lower = rankedBelow.get(k)
            color upperColor = k == 0 ? color.lime : color.new(color.green, 25 + k * 15)
            color lowerColor = k == 0 ? color.red : color.new(color.red, 25 + k * 15)
            string st = k == 0 ? line.style_solid : line.style_dashed
            int w = k == 0 ? 2 : 1
 
            if not na(upper)
                allLines.push(line.new(bar_index - lineLength, upper, bar_index + 5, upper, color=upperColor, style=st, width=w))
                if showLabels
                    string cap = "T" + str.tostring(k + 1) + " ▲ " + rankedAboveNames.get(k)
                    allLabels.push(label.new(bar_index + 5, upper, cap, style=label.style_label_left, color=color.new(color.green, 45), textcolor=color.white, size=lblSize))
 
            if not na(lower)
                allLines.push(line.new(bar_index - lineLength, lower, bar_index + 5, lower, color=lowerColor, style=st, width=w))
                if showLabels
                    string cap = "T" + str.tostring(k + 1) + " ▼ " + rankedBelowNames.get(k)
                    allLabels.push(label.new(bar_index + 5, lower, cap, style=label.style_label_left, color=color.new(color.red, 45), textcolor=color.white, size=lblSize))
 
    // ---------- ATR PROJECTIONS ----------
    if showATR and not na(atr)
        float atrUp1 = anchor + atr * atrTarget1
        float atrUp2 = anchor + atr * atrTarget2
        float atrDn1 = anchor - atr * atrTarget1
        float atrDn2 = anchor - atr * atrTarget2
        allLines.push(line.new(bar_index - 15, atrUp1, bar_index + 3, atrUp1, color=color.new(color.blue, 35), style=line.style_dotted))
        allLines.push(line.new(bar_index - 15, atrUp2, bar_index + 3, atrUp2, color=color.new(color.blue, 55), style=line.style_dotted))
        allLines.push(line.new(bar_index - 15, atrDn1, bar_index + 3, atrDn1, color=color.new(color.blue, 35), style=line.style_dotted))
        allLines.push(line.new(bar_index - 15, atrDn2, bar_index + 3, atrDn2, color=color.new(color.blue, 55), style=line.style_dotted))
 
    // ---------- MANUAL TRADE PLAN ----------
    if usePlan
        allLines.push(line.new(bar_index - lineLength, manualEntry, bar_index + 5, manualEntry, color=color.white, width=2))
        allLines.push(line.new(bar_index - lineLength, manualStop, bar_index + 5, manualStop, color=color.red, width=2))
        if showLabels
            allLabels.push(label.new(bar_index + 5, manualEntry, "ENTRY", style=label.style_label_left, color=color.gray, textcolor=color.white, size=lblSize))
            allLabels.push(label.new(bar_index + 5, manualStop, "STOP", style=label.style_label_left, color=color.red, textcolor=color.white, size=lblSize))
 
    // ---------- DASHBOARD ----------
    if showTable
        color hdr = color.new(color.blue, 50)
        table.cell(dashboard, 0, 0, "TARGET", bgcolor=hdr, text_color=color.white, text_size=tblSize)
        table.cell(dashboard, 1, 0, "PRICE / SOURCE", bgcolor=hdr, text_color=color.white, text_size=tblSize)
        table.cell(dashboard, 2, 0, "RR", bgcolor=hdr, text_color=color.white, text_size=tblSize)
 
        for k = 0 to 2
            float upper = rankedAbove.get(k)
            float lower = rankedBelow.get(k)
            int rowUp = 3 - k
            int rowDn = 5 + k
            string upperText = na(upper) ? "None" : str.tostring(upper, format.mintick) + "  " + rankedAboveNames.get(k)
            string lowerText = na(lower) ? "None" : str.tostring(lower, format.mintick) + "  " + rankedBelowNames.get(k)
 
            table.cell(dashboard, 0, rowUp, "UP " + str.tostring(k + 1), text_color=color.lime, text_size=tblSize)
            table.cell(dashboard, 1, rowUp, upperText, text_color=color.white, text_size=tblSize, text_halign=text.align_left)
            table.cell(dashboard, 2, rowUp, getR(upper, anchor, risk, validPlan, 1), text_color=color.lime, text_size=tblSize)
 
            table.cell(dashboard, 0, rowDn, "DOWN " + str.tostring(k + 1), text_color=color.red, text_size=tblSize)
            table.cell(dashboard, 1, rowDn, lowerText, text_color=color.white, text_size=tblSize, text_halign=text.align_left)
            table.cell(dashboard, 2, rowDn, getR(lower, anchor, risk, validPlan, -1), text_color=color.red, text_size=tblSize)
 
        table.cell(dashboard, 0, 4, "REFERENCE", text_color=color.silver, text_size=tblSize, bgcolor=color.new(color.gray, 80))
        table.cell(dashboard, 1, 4, str.tostring(anchor, format.mintick), text_color=color.white, text_size=tblSize, bgcolor=color.new(color.gray, 80))
        table.cell(dashboard, 2, 4, usePlan ? tradeDirection : "Live", text_color=color.white, text_size=tblSize, bgcolor=color.new(color.gray, 80))
 
        table.cell(dashboard, 0, 8, "ATR (" + str.tostring(atrLen) + ")", text_color=color.silver, text_size=tblSize)
        table.cell(dashboard, 1, 8, str.tostring(atr, "#.##") + " pts", text_color=color.white, text_size=tblSize)
        table.cell(dashboard, 2, 8, "", text_size=tblSize)
 
        table.cell(dashboard, 0, 9, "STOP RISK", text_color=color.silver, text_size=tblSize)
        table.cell(dashboard, 1, 9, usePlan ? str.tostring(risk, "#.##") + " pts" : "Plan off", text_color=color.white, text_size=tblSize)
        table.cell(dashboard, 2, 9, validPlan ? "Valid" : "—", text_color=validPlan ? color.lime : color.gray, text_size=tblSize)
 
        table.cell(dashboard, 0, 10, "STATUS", text_color=color.silver, text_size=tblSize)
        table.cell(dashboard, 1, 10, usePlan and not validPlan ? "Check stop direction" : "Levels updated", text_color=color.white, text_size=tblSize)
        table.cell(dashboard, 2, 10, "", text_size=tblSize)
 
        table.cell(dashboard, 0, 11, "KEY LEVEL", bgcolor=hdr, text_color=color.white, text_size=tblSize)
        table.cell(dashboard, 1, 11, "PRICE  (distance)", bgcolor=hdr, text_color=color.white, text_size=tblSize)
        table.cell(dashboard, 2, 11, "STATE", bgcolor=hdr, text_color=color.white, text_size=tblSize)
 
        int row = 12
        if keyPD
            keyRow(dashboard, row, "PDH", pdh, pdhSwept, pdCol)
            keyRow(dashboard, row + 1, "PDL", pdl, pdlSwept, pdCol)
            row += 2
        if keyAsia
            keyRow(dashboard, row, "Asia High", asia.hi, asia.hiSwept, asiaCol)
            keyRow(dashboard, row + 1, "Asia Low", asia.lo, asia.loSwept, asiaCol)
            row += 2
        if keyLondon
            keyRow(dashboard, row, "London High", london.hi, london.hiSwept, londonCol)
            keyRow(dashboard, row + 1, "London Low", london.lo, london.loSwept, londonCol)
            row += 2
        if keyNY
            keyRow(dashboard, row, "NY AM High", ny.hi, ny.hiSwept, nyCol)
            keyRow(dashboard, row + 1, "NY AM Low", ny.lo, ny.loSwept, nyCol)
            row += 2
 
// ============================================
// 10. ALERTS
// ============================================
 
alertcondition(asiaHiSwept and not asiaHiSwept[1], "Asia High swept", "Price swept the Asia high")
alertcondition(asiaLoSwept and not asiaLoSwept[1], "Asia Low swept", "Price swept the Asia low")
alertcondition(londonHiSwept and not londonHiSwept[1], "London High swept", "Price swept the London high")
alertcondition(londonLoSwept and not londonLoSwept[1], "London Low swept", "Price swept the London low")
alertcondition(pdhSwept and not pdhSwept[1], "PDH swept", "Price swept the previous day high")
alertcondition(pdlSwept and not pdlSwept[1], "PDL swept", "Price swept the previous day low")

← 返回列表