Multi-Session POC by Bybllo

Bybllo · study · 537 行 · 点赞 27 · TradingView 原页

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

Pine Script

// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Bybllo
 
//@version=6
// ═════════════════════════════════════════════════
// Multi-Session POC by Bybllo
// ═════════════════════════════════════════════════
// OVERVIEW
// This indicator builds a standard Volume Profile for each trading
// session (using precise 1-minute, or optional 1-second, lower-
// timeframe data regardless of your chart's own timeframe) and draws
// the resulting Point of Control (POC) - the price level where the
// most volume traded - as a horizontal line extending to the right.
// Up to 5 independent POC lines can be shown at once, each pulled
// from a different session (today, N days ago, etc.), so you can
// compare where the market's fair-value / heaviest-volume price sat
// across several recent sessions at a glance. A manual price-entry
// mode is also available for drawing reference lines at exact prices
// you've read off another Volume Profile tool.
//
// WHAT A POC IS AND WHY MULTIPLE SESSIONS MATTER
// The Point of Control is the single price level within a session
// where the most volume changed hands - the price the market spent
// the most "time and conviction" trading at, as opposed to the
// high/low/close which only mark the extremes and final print. A POC
// can behave as a magnet or a decision point: price returning to a
// prior session's POC can react there, since it represents a
// level where a large amount of trading previously agreed on value.
// Looking at just today's POC only tells part of the story, though -
// seeing the last several sessions' POCs stacked on the same chart
// reveals whether "fair value" has been drifting in one direction, or
// clustering repeatedly around the same price zone, which single-
// session tools can't show at a glance.
//
// HOW THE VOLUME PROFILE / POC IS CALCULATED
// - Each session's high/low range is divided into price buckets
//   (based on your symbol's tick size), and every underlying bar's
//   volume is distributed across the buckets its price range actually
//   overlaps - proportionally to how much of that bar's high-low
//   range falls inside each bucket - rather than assuming volume is
//   spread evenly across the whole bar. A bucket only slightly
//   touched by a bar receives a small share of that bar's volume; a
//   bucket the bar fully covers receives a much larger share. This
//   overlap-weighted approach is intended to be closer to a true
//   volume-at-price distribution than a naive equal-split method.
// - On charts coarser than 1 minute, this calculation runs on true
//   1-minute data (or optional 1-second data on Premium+ plans)
//   pulled via request.security_lower_tf(), regardless of what
//   timeframe your chart is currently displaying - so a POC
//   calculated while viewing a 1-hour chart uses the same 1-minute
//   data as one calculated on a 1-minute chart. On charts at or below
//   that resolution, the chart's own bars are used.
//
// SESSION BOUNDARY DETECTION
// In Auto-Detect mode (recommended), sessions are identified using
// TradingView's own actual trading-day (1D bar) boundaries for the
// symbol - on charts of 10-minute bars or higher, on a standard chart
// type, with lower-timeframe data available, this boundary is
// additionally pinpointed minute-by-minute so the session cutoff is
// exact rather than just "whichever bar the day changed on." Manual
// mode is available for special cases where you need to define your
// own session start hour and timezone instead of relying on the
// symbol's built-in day boundary.
//
// CHART-TYPE COMPATIBILITY AND SAFETY
// On standard candlestick/bar charts, the precise 1-minute session
// detection path is used. On non-standard chart types (Heikin Ashi,
// Renko, Kagi, Point & Figure, Range), the indicator automatically
// falls back to bar-resolution session detection instead, because
// request.security_lower_tf() is not reliable for session-boundary
// detection on synthetic chart types and can otherwise cause a
// session to never close - which lets internal data arrays grow
// without bound and eventually triggers a "Loop takes too long to
// execute" runtime error. POC values on these chart types are
// calculated from the same real-price data; only the underlying
// session-boundary detection method differs. All price data - for both the precise
// lower-timeframe path and the chart-bar fallback path - is pulled
// against a plain, forced-real ticker rather than the chart's own
// symbol reference, so the results are meant to stay the same across
// chart types even when the chart itself is displayed as Heikin Ashi,
// Renko, or any other non-standard style.
//
// MANUAL PRICE ENTRY MODE
// If you've already identified exact POC/value-area price levels from
// another Volume Profile or SVP-style tool and simply want to plot
// them as clean reference lines on this chart, Manual Price Entry
// mode lets you type each price in directly instead of relying on
// this indicator's own auto-calculation - useful for cross-checking
// or for combining values from multiple sources into one consistent
// set of lines.
//
// KEY FEATURES
// - Automatic trading-day session detection using TradingView's own
//   1D bar boundaries for the symbol (recommended), or a manual mode
//   where you set your own session start hour and timezone for
//   special cases.
// - Every session's Volume Profile is calculated at true 1-minute
//   resolution via request.security_lower_tf() regardless of your
//   chart's timeframe (charts at or below that resolution use their
//   own bars), so the POC does not depend on which timeframe you're
//   viewing. An optional 1-second mode (Premium
//   plans and above only) can be enabled for extra precision on
//   quiet, low-volume days.
// - Precise, overlap-weighted volume allocation: each bar's volume is
//   distributed across price buckets in proportion to how much of the
//   bar's high-low range actually falls inside each bucket, rather
//   than assuming volume is spread evenly - this should give a more
//   accurate POC than a naive equal-split method.
// - Up to 5 independently configurable POC lines, each pointing to a
//   different session (0 = today/in-progress, 1 = 1 day ago, etc.),
//   with its own color, width, and line style (solid/dashed/dotted).
// - Optional manual price-entry mode: instead of auto-calculating,
//   type in exact price levels (e.g. copied from another Volume
//   Profile / SVP indicator) to draw reference lines that match those
//   values exactly.
// - Configurable right-side extension so the lines project forward
//   from their session's start into the current price action.
// - Real-price calculation: both the precise lower-timeframe request
//   and the chart-bar fallback path pull prices via request.security()
//   / request.security_lower_tf() against a plain, forced-real
//   ticker, so the indicator is meant to produce the same results
//   whether your chart is displaying candlesticks, Heikin Ashi, Renko,
//   or any other non-standard chart type.
// - On non-standard chart types (Heikin Ashi, Renko, Kagi, Point &
//   Figure, Range), the indicator automatically falls back to
//   bar-resolution session detection instead of the 1-minute precise
//   path, since request.security_lower_tf() is not reliable for
//   session-boundary detection on synthetic chart types. This
//   prevents a rare runtime error ("Loop takes too long to execute")
//   that could occur on those chart types. Standard candlestick/bar
//   charts are unaffected and continue to use the precise 1-minute
//   session detection.
//
// HOW TO USE
// - Leave "Session Detection Mode" on Auto-Detect Trading Day for
//   normal use - it relies on TradingView's own session boundaries
//   for the symbol. Switch to Manual only if you need a custom
//   session start hour/timezone for a special case.
// - Set each POC line's "N days ago" value to choose which session it
//   tracks (0 = the current, still-forming session), and toggle,
//   recolor, or restyle each line independently.
// - Enable "Manual Price Entry" if you want to plot fixed reference
//   levels (for example, matching values you already confirmed on
//   another Volume Profile tool) instead of auto-calculated POCs.
// - Increase "Right Extension" if you want the lines to project
//   further into the current price action; increase "Manual Mode
//   Line Start" if you want manually-entered lines to start further
//   back in time.
// - Only enable "Second-Resolution Data" if you're on a TradingView
//   Premium (or higher) plan and specifically need extra precision on
//   thin, low-volume sessions - it will error out on lower plans.
// - Use the POC lines as reactive levels: price approaching a prior
//   session's POC from either side can be watched for a reaction, and
//   several POCs clustering in the same zone across multiple sessions
//   can be read as a stronger, more established value area.
//
// NOTES
// - Up to 30 past sessions' POC values and start times are stored, so
//   any of the 5 lines can reference up to 30 days back.
// - Because the underlying volume-profile calculation runs at
//   1-minute (or 1-second) resolution via lower-timeframe data on
//   charts coarser than that, POC accuracy is largely independent of
//   your chart's own timeframe -
//   though very old history may have limited lower-timeframe data
//   available from your data provider.
// - Line positions are anchored by time (not by bar index) internally
//   to avoid the runtime errors that can occur when a bar-index-based
//   "safe limit" shifts under different chart conditions.
// - On Heikin Ashi, Renko, Kagi, Point & Figure, and Range charts,
//   session detection automatically uses the chart's own bar
//   resolution rather than 1-minute lower-timeframe precision (see
//   Key Features above). POC values on these chart types are
//   calculated from the same real-price data as on standard charts;
//   only the underlying session-boundary detection method differs.
// - The POC of the current (in-progress) session is calculated from
//   confirmed bars only, so it updates when a bar closes.
// - The symbol must have volume data; without volume no POC can be
//   calculated.
// - In Manual (Set Time) session mode, a new session is only detected
//   when the bar at the chosen start hour follows a gap in the data
//   (longer than 10 minutes or 3 bars), so it suits markets with a
//   daily break. On 24/7 markets use Auto-Detect Trading Day.
//
// DISCLAIMER
// For educational and informational purposes only. This is not
// financial advice. Past performance does not guarantee future
// results. Always verify how these levels behave on your specific
// symbol and timeframe before relying on them for live trading.
// ═════════════════════════════════════════════════
indicator("Multi-Session POC by Bybllo", overlay=true, max_lines_count=20, max_bars_back=5000)
// ============================================
// INPUTS
// ============================================
sessionMode = input.string("Auto-Detect Trading Day (Recommended)", "Session Detection Mode",
     options=["Auto-Detect Trading Day (Recommended)", "Manual (Set Time)"],
     tooltip="Auto-Detect Trading Day: Uses TradingView's own predefined actual 'trading day (1D bar)' boundaries for this symbol as-is.\nManual (Set Time): Manually specify the time/timezone below (use only in special cases).")
useAutoDaily = sessionMode == "Auto-Detect Trading Day (Recommended)"
tzOption = input.string("Seoul (KST)", "Session Time Reference Timezone - Manual Mode Only",
     options=["Seoul (KST)", "Exchange Time", "New York (US Eastern)", "Chicago (US Central)", "London (UK)"],
     active=not useAutoDaily)
sessionHour = input.int(18, "Session Start Hour - Manual Mode Only", minval=0, maxval=23,
     active=not useAutoDaily)
requireGap = true
useSeconds = input.bool(false, "Second-Resolution Data (Premium plan and above only)",
     tooltip="When enabled, calculations use 1-second resolution instead of 1-minute for greater precision. This only works on TradingView Premium and above; enabling it on lower plans (Plus, etc.) will cause a runtime error on any timeframe. Only enable this if you want extra precision on quiet, low-volume days.")
binTicks = 1
maxBins = 100000 // Near the practical maximum size for a Pine array - a safety cap that should essentially never be hit
extendRight = input.int(3, "Right Extension (bars)", minval=0, maxval=500)
manualPriceMode = input.bool(false, "Manual Price Entry (e.g. enter an SVP price directly)",
     tooltip="When enabled, each line below is drawn at the price you enter manually instead of being auto-calculated. Enter the exact price you found from another indicator (such as SVP) to draw a line that matches that value exactly.")
manualLeftBars = input.int(300, "Manual Mode Line Start (bars back)", minval=1,
     tooltip="In manual price entry mode, sets how many bars back from the current bar the line should start.",
     active=manualPriceMode)
show1 = input.bool(true, "", inline="p1", group="POC Lines")
n1 = input.int(0, "POC #1 (N days ago)", inline="p1", minval=0, maxval=30, step=1, group="POC Lines", tooltip="0 = today, 1 = 1 day ago...", active=not manualPriceMode)
col1 = input.color(color.new(color.gray, 10), "", inline="p1", group="POC Lines")
wid1 = input.int(2, "", inline="p1", minval=1, maxval=5, group="POC Lines")
sty1 = input.string("Solid", "", inline="p1", options=["Solid", "Dashed", "Dotted"], group="POC Lines")
manPrice1 = input.float(0.0, "Manual Price (0 = unused)", inline="p1m", group="POC Lines", active=manualPriceMode)
show2 = input.bool(true, "", inline="p2", group="POC Lines")
n2 = input.int(1, "POC #2 (N days ago)", inline="p2", minval=0, maxval=30, step=1, group="POC Lines", active=not manualPriceMode)
col2 = input.color(color.new(#f23645, 25), "", inline="p2", group="POC Lines")
wid2 = input.int(2, "", inline="p2", minval=1, maxval=5, group="POC Lines")
sty2 = input.string("Dashed", "", inline="p2", options=["Solid", "Dashed", "Dotted"], group="POC Lines")
manPrice2 = input.float(0.0, "Manual Price (0 = unused)", inline="p2m", group="POC Lines", active=manualPriceMode)
show3 = input.bool(true, "", inline="p3", group="POC Lines")
n3 = input.int(2, "POC #3 (N days ago)", inline="p3", minval=0, maxval=30, step=1, group="POC Lines", active=not manualPriceMode)
col3 = input.color(color.new(#e045fb, 40), "", inline="p3", group="POC Lines")
wid3 = input.int(2, "", inline="p3", minval=1, maxval=5, group="POC Lines")
sty3 = input.string("Dashed", "", inline="p3", options=["Solid", "Dashed", "Dotted"], group="POC Lines")
manPrice3 = input.float(0.0, "Manual Price (0 = unused)", inline="p3m", group="POC Lines", active=manualPriceMode)
show4 = input.bool(true, "", inline="p4", group="POC Lines")
n4 = input.int(3, "POC #4 (N days ago)", inline="p4", minval=0, maxval=30, step=1, group="POC Lines", active=not manualPriceMode)
col4 = input.color(color.new(#067814, 40), "", inline="p4", group="POC Lines")
wid4 = input.int(2, "", inline="p4", minval=1, maxval=5, group="POC Lines")
sty4 = input.string("Dashed", "", inline="p4", options=["Solid", "Dashed", "Dotted"], group="POC Lines")
manPrice4 = input.float(0.0, "Manual Price (0 = unused)", inline="p4m", group="POC Lines", active=manualPriceMode)
show5 = input.bool(true, "", inline="p5", group="POC Lines")
n5 = input.int(4, "POC #5 (N days ago)", inline="p5", minval=0, maxval=30, step=1, group="POC Lines", active=not manualPriceMode)
col5 = input.color(color.new(color.gray, 50), "", inline="p5", group="POC Lines")
wid5 = input.int(2, "", inline="p5", minval=1, maxval=5, group="POC Lines")
sty5 = input.string("Dashed", "", inline="p5", options=["Solid", "Dashed", "Dotted"], group="POC Lines")
manPrice5 = input.float(0.0, "Manual Price (0 = unused)", inline="p5m", group="POC Lines", active=manualPriceMode)
toSty(s) =>
    s == "Dashed" ? line.style_dashed : s == "Dotted" ? line.style_dotted : line.style_solid
getTZ(opt) =>
    opt == "Seoul (KST)" ? "Asia/Seoul" : opt == "New York (US Eastern)" ? "America/New_York" : opt == "Chicago (US Central)" ? "America/Chicago" : opt == "London (UK)" ? "Europe/London" : syminfo.timezone
// ============================================
// SESSION DETECTION
// - Auto mode + 10-minute bars or higher + lower-timeframe (1-minute)
//   data available + standard chart type: determines the boundary
//   precisely, minute by minute, by checking exactly which trading
//   day each moment belongs to
// - Otherwise (manual mode, 1-5 minute bars, lower-timeframe data
//   unavailable, or a non-standard chart type such as Heikin Ashi /
//   Renko / Kagi / Point & Figure / Range): determined at the
//   chart's own bar resolution
// NOTE: request.security_lower_tf() is not reliable on non-standard
// (synthetic) chart types. Using it for
// day-boundary detection on those chart types can cause the session
// to never close, which lets the per-session data arrays grow
// without bound and eventually triggers a "Loop takes too long to
// execute" runtime error. This is why the precise path is gated on
// chart.is_standard below.
// ============================================
isNewSessionAuto = timeframe.change("1D")
sessHour = hour(time, getTZ(tzOption))
sessHourPrev = hour(time[1], getTZ(tzOption))
expectedGapMs = timeframe.in_seconds() * 1000
minGapMs = math.max(expectedGapMs * 3, 10 * 60 * 1000)
hasRealGap = not na(time[1]) and (time - time[1]) > minGapMs
isNewSessionManual = not na(sessHourPrev) and sessHour == sessionHour and sessHour != sessHourPrev and (not requireGap or hasRealGap)
isNewSession = useAutoDaily ? isNewSessionAuto : isNewSessionManual
// ============================================
// Standard Volume Profile-style POC calculation
// (Volume is precisely allocated to each bucket in proportion to how
// much the bar's low-to-high range actually overlaps that bucket - a
// bucket only slightly touched gets a small share, one fully
// enclosed gets most of the volume, which is more precise than an
// even split. A narrow bar naturally concentrates its whole volume
// into a single bucket, so no separate precise/fallback branch is
// needed for that case.)
// ============================================
calcPOC(lowArr, highArr, volArr, rHigh, rLow, binT, maxB) =>
    poc = float(na)
    n = array.size(lowArr)
    if n > 0 and rHigh > rLow
        bs = binT * syminfo.mintick
        nb = int(math.min(maxB, math.max(1.0, math.ceil((rHigh - rLow) / bs))))
        bins = array.new_float(nb, 0.0)
        if bs > 0
            for idx = 0 to n - 1
                l = array.get(lowArr, idx)
                h = array.get(highArr, idx)
                v = array.get(volArr, idx)
                bLo = int(math.max(0, math.min(nb - 1, math.floor((l - rLow) / bs))))
                bHi = int(math.max(0, math.min(nb - 1, math.floor((h - rLow) / bs))))
                barRange = h - l
                if barRange <= 0
                    array.set(bins, bLo, array.get(bins, bLo) + v)
                else
                    for bi = bLo to bHi
                        bucketLow = rLow + bi * bs
                        bucketHigh = bucketLow + bs
                        overlap = math.min(h, bucketHigh) - math.max(l, bucketLow)
                        if overlap > 0
                            array.set(bins, bi, array.get(bins, bi) + v * overlap / barRange)
            maxV = array.max(bins)
            if maxV > 0
                maxIdx = array.indexof(bins, maxV)
                poc := rLow + (maxIdx + 0.5) * bs
    poc
// ============================================
// Force real market prices regardless of chart type (Heikin Ashi,
// Renko, etc.) via request.security. This same forced-real ticker
// (t) must also be used for the request.security_lower_tf() calls
// below - using syminfo.tickerid there instead would return values
// converted to the chart's own display style (e.g. Heikin Ashi) when
// that display style is active, which would make the POC
// calculation differ depending on chart type.
// ============================================
t = ticker.new(syminfo.prefix, syminfo.ticker)
[rHigh, rLow] = request.security(t, timeframe.period, [high, low])
// ============================================
// Lower-timeframe data request - ensures the calculation always runs
// at 1-minute precision regardless of the chart's own bar size
// (available on all plans).
// Only when the chart is 10-minute bars or higher AND is a standard
// (non-synthetic) chart type, the session boundary is additionally
// determined at 1-minute precision as well (skipped on 1-5 minute
// charts to preserve performance, and skipped on Heikin Ashi / Renko
// / Kagi / Point & Figure / Range charts because
// request.security_lower_tf() is not reliable there - see Session
// Detection note above).
// ============================================
chartIsStandard = chart.is_standard
isCoarseTF = timeframe.in_seconds() >= 600
useLTF = timeframe.in_seconds() > (useSeconds ? 1 : 60)
ltfRes = useSeconds ? "1S" : "1"
var float[] ltfLows = array.new_float(0)
var float[] ltfHighs = array.new_float(0)
var float[] ltfVols = array.new_float(0)
var float[] ltfTimes = array.new_float(0)
var float[] ltfDayAnchor = array.new_float(0)
if useLTF
    if useAutoDaily and isCoarseTF and chartIsStandard
        // Bundle all 5 series into a single request so the bar order is guaranteed to line up
        [lo, hi, vo, ti, da] = request.security_lower_tf(t, ltfRes, [low, high, volume, float(time), float(time("D"))])
        ltfLows := lo
        ltfHighs := hi
        ltfVols := vo
        ltfTimes := ti
        ltfDayAnchor := da
    else
        [lo, hi, vo] = request.security_lower_tf(t, ltfRes, [low, high, volume])
        ltfLows := lo
        ltfHighs := hi
        ltfVols := vo
usePreciseAuto = useAutoDaily and isCoarseTF and useLTF and chartIsStandard and array.size(ltfDayAnchor) > 0
// ============================================
// Track the current session: accumulate every bar's low/high/volume
// within this session as-is
// ============================================
var int sesStartTime = 0
var float sesHigh = na
var float sesLow = na
var int barsInSession = 0
var float curDayAnchor = na
var float[] curLows = array.new_float(0)
var float[] curHighs = array.new_float(0)
var float[] curVols = array.new_float(0)
// Store past sessions' POC + start time (30 days)
var float[] pocArr = array.new_float(30, na)
var int[] timeArr = array.new_int(30, 0)
finalizeSession() =>
    if not na(sesHigh) and sesHigh > sesLow
        newPOC = calcPOC(curLows, curHighs, curVols, sesHigh, sesLow, binTicks, maxBins)
        if not na(newPOC)
            for i = 29 to 1
                array.set(pocArr, i, array.get(pocArr, i - 1))
                array.set(timeArr, i, array.get(timeArr, i - 1))
            array.set(pocArr, 0, newPOC)
            array.set(timeArr, 0, sesStartTime)
if barstate.isconfirmed
    if usePreciseAuto
        // Accumulate while checking exact trading-day boundaries at 1-minute resolution (always precise data)
        for i = 0 to array.size(ltfLows) - 1
            da = array.get(ltfDayAnchor, i)
            l = array.get(ltfLows, i)
            h = array.get(ltfHighs, i)
            v = array.get(ltfVols, i)
            ti = int(array.get(ltfTimes, i))
            if na(curDayAnchor)
                curDayAnchor := da
                sesStartTime := ti
                sesHigh := h
                sesLow := l
            else if da != curDayAnchor
                finalizeSession()
                curDayAnchor := da
                sesStartTime := ti
                sesHigh := h
                sesLow := l
                array.clear(curLows)
                array.clear(curHighs)
                array.clear(curVols)
            else
                sesHigh := math.max(sesHigh, h)
                sesLow := math.min(sesLow, l)
            array.push(curLows, l)
            array.push(curHighs, h)
            array.push(curVols, v)
    else
        // Determine the boundary at the chart's own bar resolution (manual mode, lower-timeframe data unavailable, or a non-standard chart type)
        if isNewSession and (useAutoDaily ? (na(sesHigh) or barsInSession >= 2) : true)
            finalizeSession()
            sesHigh := rHigh
            sesLow := rLow
            sesStartTime := time
            barsInSession := 0
            array.clear(curLows)
            array.clear(curHighs)
            array.clear(curVols)
        else
            sesHigh := na(sesHigh) ? rHigh : math.max(sesHigh, rHigh)
            sesLow := na(sesLow) ? rLow : math.min(sesLow, rLow)
        barsInSession := barsInSession + 1
        if array.size(ltfLows) > 0
            for i = 0 to array.size(ltfLows) - 1
                array.push(curLows, array.get(ltfLows, i))
                array.push(curHighs, array.get(ltfHighs, i))
                array.push(curVols, array.get(ltfVols, i))
        else
            // Fallback: no precise data is available at all, so this coarser bar is used as-is
            array.push(curLows, rLow)
            array.push(curHighs, rHigh)
            array.push(curVols, volume)
// Today's (in-progress) session POC: calculated from the bars confirmed so far, displayed on the last bar
float curPOC = na
if barstate.islast
    curPOC := calcPOC(curLows, curHighs, curVols, sesHigh, sesLow, binTicks, maxBins)
// ============================================
// Look up the POC / start time for N days ago
// ============================================
getPOC(d) =>
    d == 0 ? curPOC : (d <= 30 ? array.get(pocArr, d - 1) : na)
getStartTime(d) =>
    d == 0 ? sesStartTime : (d <= 30 ? array.get(timeArr, d - 1) : 0)
// ============================================
// Draw the lines (time-based - bar-index-based anchoring ran into
// runtime errors because the "safe limit" shifts depending on
// conditions, so a single stable time-based reference is used instead)
// ============================================
var line l1 = na
var line l2 = na
var line l3 = na
var line l4 = na
var line l5 = na
if barstate.islast
    extendMs = extendRight * timeframe.in_seconds() * 1000
    endT = timenow + extendMs
    manualStartTime = time[math.min(manualLeftBars, bar_index)]
    v1 = manualPriceMode ? (manPrice1 > 0 ? manPrice1 : na) : getPOC(n1)
    t1 = manualPriceMode ? manualStartTime : getStartTime(n1)
    v2 = manualPriceMode ? (manPrice2 > 0 ? manPrice2 : na) : getPOC(n2)
    t2 = manualPriceMode ? manualStartTime : getStartTime(n2)
    v3 = manualPriceMode ? (manPrice3 > 0 ? manPrice3 : na) : getPOC(n3)
    t3 = manualPriceMode ? manualStartTime : getStartTime(n3)
    v4 = manualPriceMode ? (manPrice4 > 0 ? manPrice4 : na) : getPOC(n4)
    t4 = manualPriceMode ? manualStartTime : getStartTime(n4)
    v5 = manualPriceMode ? (manPrice5 > 0 ? manPrice5 : na) : getPOC(n5)
    t5 = manualPriceMode ? manualStartTime : getStartTime(n5)
    if show1 and not na(v1) and t1 > 0
        if na(l1)
            l1 := line.new(t1, v1, endT, v1, xloc=xloc.bar_time, color=col1, width=wid1, style=toSty(sty1))
        else
            line.set_xy1(l1, t1, v1)
            line.set_xy2(l1, endT, v1)
            line.set_color(l1, col1)
            line.set_width(l1, wid1)
            line.set_style(l1, toSty(sty1))
    else
        if not na(l1)
            line.delete(l1)
            l1 := na
    if show2 and not na(v2) and t2 > 0
        if na(l2)
            l2 := line.new(t2, v2, endT, v2, xloc=xloc.bar_time, color=col2, width=wid2, style=toSty(sty2))
        else
            line.set_xy1(l2, t2, v2)
            line.set_xy2(l2, endT, v2)
            line.set_color(l2, col2)
            line.set_width(l2, wid2)
            line.set_style(l2, toSty(sty2))
    else
        if not na(l2)
            line.delete(l2)
            l2 := na
    if show3 and not na(v3) and t3 > 0
        if na(l3)
            l3 := line.new(t3, v3, endT, v3, xloc=xloc.bar_time, color=col3, width=wid3, style=toSty(sty3))
        else
            line.set_xy1(l3, t3, v3)
            line.set_xy2(l3, endT, v3)
            line.set_color(l3, col3)
            line.set_width(l3, wid3)
            line.set_style(l3, toSty(sty3))
    else
        if not na(l3)
            line.delete(l3)
            l3 := na
    if show4 and not na(v4) and t4 > 0
        if na(l4)
            l4 := line.new(t4, v4, endT, v4, xloc=xloc.bar_time, color=col4, width=wid4, style=toSty(sty4))
        else
            line.set_xy1(l4, t4, v4)
            line.set_xy2(l4, endT, v4)
            line.set_color(l4, col4)
            line.set_width(l4, wid4)
            line.set_style(l4, toSty(sty4))
    else
        if not na(l4)
            line.delete(l4)
            l4 := na
    if show5 and not na(v5) and t5 > 0
        if na(l5)
            l5 := line.new(t5, v5, endT, v5, xloc=xloc.bar_time, color=col5, width=wid5, style=toSty(sty5))
        else
            line.set_xy1(l5, t5, v5)
            line.set_xy2(l5, endT, v5)
            line.set_color(l5, col5)
            line.set_width(l5, wid5)
            line.set_style(l5, toSty(sty5))
    else
        if not na(l5)
            line.delete(l5)
            l5 := na

← 返回列表