ICT Killzones vs Every Other Window: Where Do They Rank?

GuilleMustafa · study · 442 行 · 点赞 2 · TradingView 原页

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

Pine Script

//@version=6
indicator("ICT Killzones vs Every Other Window: Where Do They Rank?", shorttitle = "KZ-VS-24", overlay = true, behind_chart = false)
 
// ICT Killzones vs Every Other Window
// 1) A killzone is a block of whole hours on the New York clock, for example London Open from 02:00 to 05:00.
//    For a killzone of L hours the comparison set is the 24 windows of L hours that start at 00:00, 01:00 and
//    so on to 23:00, wrapping past midnight. The killzone is the window that starts at its own start hour.
// 2) Every window is measured the same way: the range of each complete occurrence as a percentage of its
//    opening price, and the share of the trading days on which the window was complete that it held that day's
//    high or low. An occurrence counts only when all of its bars are present.
// 3) The high/low share is set beside the share a driftless random walk with constant volatility gives to a
//    window in the same place among the same traded hours, day by day, and ranked by the difference: on a random
//    walk the extremes fall near the start and the end of the day far more often than in the middle.
// 4) On the last bar the table ranks each killzone among those of its 24 windows that can be ranked on each
//    measure, and names the window that comes first. Windows with fewer samples than the minimum, and for
//    high/low windows that cross the day start, are left out of the ranking.
// The result is a ranking of clock windows on this symbol and this chart, not a rule.
 
// ───────────────────────── Constants ─────────────────────────
const string TZ = "America/New_York"
const int HOUR_MS = 3600000
const int NKZ = 4
const string G_KZ = "Killzones (New York clock, whole hours)"
const string G_M = "Method"
const string G_D = "Display"
// Random-walk baseline: simulated days, Gaussian pairs per hour (2 steps each), days simulated per confirmed bar,
// and the generator's seed.
const int MC_PATHS = 2000
const int MC_PAIRS = 4
const int MC_PER_BAR = 4
const int MC_SEED = 7
 
// ───────────────────────── Inputs ─────────────────────────
const string KZ_TIP = "On/off, name, start hour (0-23) and length in whole hours (1-12) on the New York clock. The window runs from the start hour to start + length, wrapping past midnight: start 23 with 3 hours is 23:00 to 02:00."
on1 = input.bool(true, "", group = G_KZ, inline = "kz1")
name1 = input.string("Asia", "", group = G_KZ, inline = "kz1")
start1 = input.int(20, "start", minval = 0, maxval = 23, group = G_KZ, inline = "kz1")
len1 = input.int(4, "hours", minval = 1, maxval = 12, group = G_KZ, inline = "kz1", tooltip = KZ_TIP)
on2 = input.bool(true, "", group = G_KZ, inline = "kz2")
name2 = input.string("London Open", "", group = G_KZ, inline = "kz2")
start2 = input.int(2, "start", minval = 0, maxval = 23, group = G_KZ, inline = "kz2")
len2 = input.int(3, "hours", minval = 1, maxval = 12, group = G_KZ, inline = "kz2", tooltip = KZ_TIP)
on3 = input.bool(true, "", group = G_KZ, inline = "kz3")
name3 = input.string("New York Open", "", group = G_KZ, inline = "kz3")
start3 = input.int(7, "start", minval = 0, maxval = 23, group = G_KZ, inline = "kz3")
len3 = input.int(3, "hours", minval = 1, maxval = 12, group = G_KZ, inline = "kz3", tooltip = KZ_TIP)
on4 = input.bool(true, "", group = G_KZ, inline = "kz4")
name4 = input.string("London Close", "", group = G_KZ, inline = "kz4")
start4 = input.int(10, "start", minval = 0, maxval = 23, group = G_KZ, inline = "kz4")
len4 = input.int(2, "hours", minval = 1, maxval = 12, group = G_KZ, inline = "kz4", tooltip = KZ_TIP)
 
dayStart = input.int(18, "Trading day starts at (New York hour)", minval = 0, maxval = 23, group = G_M, tooltip = "Hour at which a trading day begins, for the high/low measure. 18 is the first hour after the daily halt of CME equity index futures; 0 is the New York calendar day.")
minN = input.int(100, "Minimum sample to rank", minval = 20, group = G_M, tooltip = "A window is ranked only with at least this many complete occurrences (range) or judged days (high/low). Below it the cell reads n < minimum.")
 
tablePos = input.string("Bottom right", "Table position", options = ["Top right", "Bottom right", "Top left", "Bottom left"], group = G_D)
textSize = input.string("Small", "Table text size", options = ["Tiny", "Small", "Normal"], group = G_D)
 
var array<bool> kzOn = array.from(on1, on2, on3, on4)
var array<string> kzName = array.from(name1, name2, name3, name4)
var array<int> kzStart = array.from(start1, start2, start3, start4)
var array<int> kzLen = array.from(len1, len2, len3, len4)
 
// ───────────────────────── Timeframe ─────────────────────────
// Each bar must sit inside one clock hour: minutes bars whose length divides 60 minutes.
int tfSec = timeframe.in_seconds(timeframe.period)
bool tfOk = timeframe.isminutes and tfSec > 0 and tfSec <= 3600 and 3600 % tfSec == 0
int barsPerHour = tfOk ? int(3600 / math.max(tfSec, 1)) : 0
 
// ───────────────────────── Window and day logic (pure) ─────────────────────────
// Position of clock hour hr inside the window that starts at clock hour s: 0 for its first hour. Wraps past
// midnight: for s = 23, hour 23 is at 0, hour 0 at 1, hour 1 at 2, hour 22 at 23.
posInWindow(int hr, int s) =>
    (hr - s + 24) % 24
 
// True when clock hour hr belongs to the window of L hours that starts at s.
inWindow(int hr, int s, int L) =>
    posInWindow(hr, s) < L
 
// True when the window of L hours that starts at s lies inside one trading day, which begins at dayStart.
fitsDay(int s, int L) =>
    posInWindow(s, dayStart) + L <= 24
 
// Date key on the New York clock: 20260302 for 2 March 2026.
dateKey(int t) =>
    year(t, TZ) * 10000 + month(t, TZ) * 100 + dayofmonth(t, TZ)
 
// Trading day of a bar: its New York date, or the next date when its hour is at or after dayStart (and
// dayStart is not 0). The next date is read from noon of the bar's date plus 24 hours, which stays on the
// next date even across a daylight saving change.
tradingDay(int t, int hr) =>
    int key = dateKey(t)
    if dayStart > 0 and hr >= dayStart
        key := dateKey(timestamp(TZ, year(t, TZ), month(t, TZ), dayofmonth(t, TZ), 12, 0, 0) + 24 * HOUR_MS)
    key
 
// ───────────────────────── State ─────────────────────────
// Slot i = k * 24 + s: killzone k (which sets the length L) and the window that starts at clock hour s.
// The open occurrence of each slot: open time of its first bar (0 when none), bar count, opening price, high,
// low, open time and clock hour of its last bar, and its trading day.
var array<int> wStart = array.new<int>(NKZ * 24, 0)
var array<int> wCount = array.new<int>(NKZ * 24, 0)
var array<float> wOpen = array.new<float>(NKZ * 24, 0.0)
var array<float> wHigh = array.new<float>(NKZ * 24, 0.0)
var array<float> wLow = array.new<float>(NKZ * 24, 0.0)
var array<int> wLastT = array.new<int>(NKZ * 24, 0)
var array<int> wLastHour = array.new<int>(NKZ * 24, 0)
var array<int> wDay = array.new<int>(NKZ * 24, 0)
// A complete occurrence that fits one trading day waits here, with its high and low, until that day ends.
var array<int> pDay = array.new<int>(NKZ * 24, 0)
var array<float> pHigh = array.new<float>(NKZ * 24, 0.0)
var array<float> pLow = array.new<float>(NKZ * 24, 0.0)
// Tallies per slot: sum and count of ranges (in % of the opening price), days judged and days held.
var array<float> rSum = array.new<float>(NKZ * 24, 0.0)
var array<int> rN = array.new<int>(NKZ * 24, 0)
var array<int> xN = array.new<int>(NKZ * 24, 0)
var array<int> xHold = array.new<int>(NKZ * 24, 0)
// Confirmed bars per New York clock hour, bars off the hour grid, and the trading day ledger.
var array<int> hourBars = array.new<int>(24, 0)
var int offGrid = 0
var int daysJudged = 0
var int curDay = 0
var bool curDayFromStart = false
var float dayHigh = na
var float dayLow = na
// Counted bars per position of the current trading day (0 = the day start hour), and, per slot, the number of
// judged days with each layout: key = slot * 10000 + traded hours of the day * 100 + traded hours before the window.
var array<int> dayBars = array.new<int>(24, 0)
var map<int, int> layoutCount = map.new<int, int>()
 
// ───────────────────────── Update ─────────────────────────
// Only confirmed bars update the state, so the realtime bar is never counted before it closes and nothing is
// recalculated after a bar has closed.
if tfOk and barstate.isconfirmed
    int h = hour(time, TZ)
    bool onGrid = (minute(time, TZ) * 60 + second(time, TZ)) % tfSec == 0
    bool onHour = minute(time, TZ) == 0 and second(time, TZ) == 0
    if not onGrid
        offGrid += 1
    else
        // 1) Close every occurrence whose L hours have passed. It is complete when it has L * barsPerHour bars, its
        //    last bar opens exactly L hours minus one bar after its first, and its last bar is in hour s + L - 1.
        //    A complete occurrence adds its range to the tally and, when the window fits one trading day, waits for
        //    the end of that day in the pending arrays.
        for k = 0 to NKZ - 1
            if array.get(kzOn, k)
                int L = array.get(kzLen, k)
                for s = 0 to 23
                    int i = k * 24 + s
                    if array.get(wStart, i) != 0 and time >= array.get(wStart, i) + L * HOUR_MS
                        bool complete = array.get(wCount, i) == L * barsPerHour and array.get(wLastT, i) - array.get(wStart, i) == (L * 3600 - tfSec) * 1000 and array.get(wLastHour, i) == (s + L - 1) % 24
                        if complete
                            float o = array.get(wOpen, i)
                            if o > 0
                                array.set(rSum, i, array.get(rSum, i) + (array.get(wHigh, i) - array.get(wLow, i)) / o * 100.0)
                                array.set(rN, i, array.get(rN, i) + 1)
                            if fitsDay(s, L)
                                array.set(pDay, i, array.get(wDay, i))
                                array.set(pHigh, i, array.get(wHigh, i))
                                array.set(pLow, i, array.get(wLow, i))
                        array.set(wStart, i, 0)
 
        // 2) Trading day. On the first bar of a new day the day that ended is judged, unless it is the first
        //    day on the chart, which may have started before the first loaded bar, or it has a partly traded
        //    hour.
        int d = tradingDay(time, h)
        if d != curDay
            if curDay != 0 and curDayFromStart
                // Layout of the day that ended. The random walk counts whole hours, so a day with a partly traded
                // hour (a session that opens or closes inside an hour, a missing bar) is not judged.
                array<int> before = array.new<int>(24, 0)
                int dayH = 0
                bool wholeHours = true
                for r = 0 to 23
                    array.set(before, r, dayH)
                    int nb = array.get(dayBars, r)
                    if nb > 0
                        dayH += 1
                        if nb != barsPerHour
                            wholeHours := false
                if wholeHours
                    daysJudged += 1
                    for i = 0 to NKZ * 24 - 1
                        if array.get(pDay, i) == curDay
                            array.set(xN, i, array.get(xN, i) + 1)
                            if array.get(pHigh, i) >= dayHigh or array.get(pLow, i) <= dayLow
                                array.set(xHold, i, array.get(xHold, i) + 1)
                            // The same day's layout, for the baseline: its traded hours and the window's place.
                            int key = i * 10000 + dayH * 100 + array.get(before, posInWindow(i % 24, dayStart))
                            map.put(layoutCount, key, (map.contains(layoutCount, key) ? map.get(layoutCount, key) : 0) + 1)
            for i = 0 to NKZ * 24 - 1
                array.set(pDay, i, 0)
            for r = 0 to 23
                array.set(dayBars, r, 0)
            curDayFromStart := curDay != 0
            curDay := d
            dayHigh := high
            dayLow := low
        else
            dayHigh := math.max(dayHigh, high)
            dayLow := math.min(dayLow, low)
        int pos = posInWindow(h, dayStart)
        array.set(dayBars, pos, array.get(dayBars, pos) + 1)
 
        // 3) Add the bar to every window that holds its hour. Only the bar that opens exactly on the window's
        //    first hour starts an occurrence, and a window starts at most once per trading day (on the night the
        //    clock repeats an hour, the second pass does not start a new one). Every other bar of the window's
        //    hours joins the open occurrence; with none open (the chart started mid-window, or the hour's first
        //    bar is missing) it is skipped.
        for k = 0 to NKZ - 1
            if array.get(kzOn, k)
                int L = array.get(kzLen, k)
                for s = 0 to 23
                    if inWindow(h, s, L)
                        int i = k * 24 + s
                        if posInWindow(h, s) == 0 and onHour and array.get(wDay, i) != d
                            array.set(wStart, i, time)
                            array.set(wCount, i, 1)
                            array.set(wOpen, i, open)
                            array.set(wHigh, i, high)
                            array.set(wLow, i, low)
                            array.set(wLastT, i, time)
                            array.set(wLastHour, i, h)
                            array.set(wDay, i, d)
                        else if array.get(wStart, i) != 0
                            array.set(wCount, i, array.get(wCount, i) + 1)
                            array.set(wHigh, i, math.max(array.get(wHigh, i), high))
                            array.set(wLow, i, math.min(array.get(wLow, i), low))
                            array.set(wLastT, i, time)
                            array.set(wLastHour, i, h)
 
        array.set(hourBars, h, array.get(hourBars, h) + 1)
 
// ───────────────────────── Random-walk baseline ─────────────────────────
// A driftless random walk with constant volatility, simulated MC_PATHS times over 24 hours of 2 * MC_PAIRS
// Gaussian steps each. For every prefix of H hours (H = 1 to 24), the hour that holds the path's highest point
// and the hour that holds its lowest point are counted together in mcJoint[(H - 1) * 576 + hMax * 24 + hMin].
// The starting point belongs to hour 0, as a day's opening price belongs to its first bar. The generator is
// seeded, so the counts are the same on every chart and every reload. MC_PER_BAR days are simulated per
// confirmed bar, so the simulation is complete after MC_PATHS / MC_PER_BAR = 500 confirmed bars, and every loop
// stays small.
var array<int> mcJoint = array.new<int>(24 * 576, 0)
var int mcState = MC_SEED
var int mcDone = 0
 
if tfOk and barstate.isconfirmed and mcDone < MC_PATHS
    for p = 1 to MC_PER_BAR
        float x = 0.0
        float xHi = 0.0
        float xLo = 0.0
        int hMax = 0
        int hMin = 0
        for hr = 0 to 23
            for q = 1 to MC_PAIRS
                // Two uniforms from state = (1103515245 * state + 12345) % 2^31, with the product taken in two
                // parts (1103515245 = 16838 * 65536 + 20077) so it stays exact.
                mcState := ((16838 * mcState) % 32768 * 65536 + 20077 * mcState + 12345) % 2147483648
                float u1 = (mcState + 1) / 2147483648.0
                mcState := ((16838 * mcState) % 32768 * 65536 + 20077 * mcState + 12345) % 2147483648
                float u2 = mcState / 2147483648.0
                // Box-Muller: two independent standard normal steps.
                float rad = math.sqrt(-2.0 * math.log(u1))
                x += rad * math.cos(2.0 * math.pi * u2)
                if x > xHi
                    xHi := x
                    hMax := hr
                if x < xLo
                    xLo := x
                    hMin := hr
                x += rad * math.sin(2.0 * math.pi * u2)
                if x > xHi
                    xHi := x
                    hMax := hr
                if x < xLo
                    xLo := x
                    hMin := hr
            int idx = hr * 576 + hMax * 24 + hMin
            array.set(mcJoint, idx, array.get(mcJoint, idx) + 1)
        mcDone += 1
 
// Share of days on which a window of L traded hours, with a traded hours before it in a day of H traded hours,
// holds the day's high or low on the random walk: P(max in window) + P(min in window) - P(both in window). The
// first two are equal and exact for a continuous random walk (arcsine law); the third is read from the
// simulation. Returns the share and the standard error of the simulated term, both as fractions.
rwShare(int H, int a, int L) =>
    float pMax = 2.0 / math.pi * (math.asin(math.sqrt(float(a + L) / H)) - math.asin(math.sqrt(float(a) / H)))
    int both = 0
    for i = a to a + L - 1
        for j = a to a + L - 1
            both += array.get(mcJoint, (H - 1) * 576 + i * 24 + j)
    float pBoth = float(both) / MC_PATHS
    [math.max(0.0, math.min(1.0, 2.0 * pMax - pBoth)), math.sqrt(pBoth * (1.0 - pBoth) / MC_PATHS)]
 
// ───────────────────────── Ranking ─────────────────────────
// Rank of the window at sK among the 24 windows of killzone k that have a value in vals (slot k * 24 + s): 1 + the
// number of windows with a strictly higher value, so ties share a rank. Also returns how many windows have a
// value, and the top window and its value; on a tie for the top the killzone itself is kept, otherwise the
// earliest start hour.
rankStats(array<float> vals, int k, int sK) =>
    float vK = array.get(vals, k * 24 + sK)
    int m = 0
    int above = 0
    int bestS = na(vK) ? -1 : sK
    float bestV = vK
    for s = 0 to 23
        float v = array.get(vals, k * 24 + s)
        if not na(v)
            m += 1
            if not na(vK) and v > vK
                above += 1
            if na(bestV) or v > bestV
                bestV := v
                bestS := s
    [na(vK) ? int(na) : above + 1, m, bestS, bestV]
 
// ───────────────────────── Table ─────────────────────────
tPos = switch tablePos
    "Top right" => position.top_right
    "Bottom right" => position.bottom_right
    "Top left" => position.top_left
    => position.bottom_left
 
tSize = switch textSize
    "Tiny" => size.tiny
    "Normal" => size.normal
    => size.small
 
// Eight columns: killzone, samples, then value, rank and top window for each measure. Eight rows: header,
// column titles, four killzones, two footer rows. 64 cells.
var table tbl = table.new(tPos, 8, 8, border_width = 1)
 
// The full-width rows are merged on the first bar, once. A merge cannot be repeated or undone, and a flag set on
// an open bar does not survive to the next update, so the merge is kept out of the last-bar block.
if barstate.isfirst
    table.merge_cells(tbl, 0, 0, 7, 0)
    if tfOk
        table.merge_cells(tbl, 0, 6, 7, 6)
        table.merge_cells(tbl, 0, 7, 7, 7)
 
// Opaque cell colors blended from the chart background, so candles do not show through the table.
cellBg = color.from_gradient(0.12, 0.0, 1.0, chart.bg_color, color.gray)
hdrBg = color.from_gradient(0.30, 0.0, 1.0, chart.bg_color, color.gray)
goodBg = color.from_gradient(0.40, 0.0, 1.0, chart.bg_color, color.green)
 
setCell(int col, int row, string txt, color bg = na, string align = text.align_center) =>
    table.cell(tbl, col, row, txt, text_color = chart.fg_color, text_size = tSize, text_halign = align, bgcolor = na(bg) ? cellBg : bg)
 
// "02-05" for the window that starts at 2 with 3 hours, "23-02" for 23 with 3 hours.
fmtWin(int s, int L) =>
    str.tostring(s, "00") + "-" + str.tostring((s + L) % 24, "00")
 
fmtPct(float v, string f) =>
    na(v) ? "n/a" : str.tostring(v, f) + "%"
 
// "+21.8" or "-3.0" from a difference in percentage points.
fmtPts(float v) =>
    (v > 0 ? "+" : "") + str.tostring(v, "0.0")
 
if barstate.islast
    if not tfOk
        setCell(0, 0, "Use a minutes timeframe that divides the hour, such as 5, 15, 30 or 60 minutes", hdrBg, text.align_left)
    else
        string emptyHours = ""
        for hr = 0 to 23
            if array.get(hourBars, hr) == 0
                emptyHours += (emptyHours == "" ? "" : " ") + str.tostring(hr, "00")
 
        // Baseline per slot: the random-walk share summed over the days the window was judged, each day with its own
        // number of traded hours and the window's place among them, and the simulated term's standard error.
        bool rwReady = mcDone >= MC_PATHS
        array<float> rwSum = array.new<float>(NKZ * 24, 0.0)
        array<float> rwSe = array.new<float>(NKZ * 24, 0.0)
        if rwReady
            for key in map.keys(layoutCount)
                int cnt = map.get(layoutCount, key)
                int a = key % 100
                int dayH = int((key % 10000 - a) / 100)
                int i = int((key - key % 10000) / 10000)
                int L = array.get(kzLen, int((i - i % 24) / 24))
                [b, se] = rwShare(dayH, a, L)
                array.set(rwSum, i, array.get(rwSum, i) + cnt * b)
                array.set(rwSe, i, array.get(rwSe, i) + cnt * se)
 
        // Rankable values per slot: mean range in %, and the high/low share minus its baseline in points; na when
        // the window lacks the sample, crosses the day start, or the baseline is not ready.
        array<float> rangeV = array.new<float>(NKZ * 24, float(na))
        array<float> diffV = array.new<float>(NKZ * 24, float(na))
        for i = 0 to NKZ * 24 - 1
            int s = i % 24
            int L = array.get(kzLen, int((i - s) / 24))
            int nR = array.get(rN, i)
            int nX = array.get(xN, i)
            if nR >= minN
                array.set(rangeV, i, array.get(rSum, i) / nR)
            if rwReady and nX >= minN and fitsDay(s, L)
                array.set(diffV, i, (float(array.get(xHold, i)) - array.get(rwSum, i)) / nX * 100.0)
 
        setCell(0, 0, ticker.standard(syminfo.tickerid) + " · " + timeframe.period + " · New York clock · trading day from " + str.tostring(dayStart, "00") + ":00 · " + str.tostring(daysJudged) + " trading days judged · a rank needs " + str.tostring(minN) + " samples", hdrBg, text.align_left)
        setCell(0, 1, "Killzone (New York)", hdrBg, text.align_left)
        setCell(1, 1, "Samples (windows / days)", hdrBg)
        setCell(2, 1, "Mean range", hdrBg)
        setCell(3, 1, "Range rank", hdrBg)
        setCell(4, 1, "Top range window", hdrBg)
        setCell(5, 1, "Holds day high/low vs random walk", hdrBg)
        setCell(6, 1, "High/low rank (difference)", hdrBg)
        setCell(7, 1, "Top high/low window (points)", hdrBg)
 
        for k = 0 to NKZ - 1
            int row = 2 + k
            int L = array.get(kzLen, k)
            int sK = array.get(kzStart, k)
            setCell(0, row, array.get(kzName, k) + " " + fmtWin(sK, L), na, text.align_left)
            if not array.get(kzOn, k)
                setCell(1, row, "off")
                for c = 2 to 7
                    setCell(c, row, "")
            else
                int i = k * 24 + sK
                int nR = array.get(rN, i)
                int nX = array.get(xN, i)
                [rRank, rM, rBest, rBestV] = rankStats(rangeV, k, sK)
                [xRank, xM, xBest, xBestV] = rankStats(diffV, k, sK)
                string nTxt = "n < " + str.tostring(minN)
                // The killzone's share, its baseline and the standard error of their difference, in points: the
                // share's binomial error and the simulated term's error, combined.
                float share = nX > 0 ? float(array.get(xHold, i)) / nX : na
                float base = nX > 0 ? array.get(rwSum, i) / nX : na
                float seD = nX > 0 ? 100.0 * math.sqrt(share * (1.0 - share) / nX + math.pow(array.get(rwSe, i) / nX, 2)) : na
                float dK = array.get(diffV, i)
 
                setCell(1, row, str.tostring(nR) + " / " + str.tostring(nX))
                setCell(2, row, nR >= minN ? fmtPct(array.get(rSum, i) / nR, "0.000") : nTxt)
                setCell(3, row, na(rRank) ? "not ranked" : str.tostring(rRank) + " of " + str.tostring(rM), not na(rRank) and rRank == 1 and rM > 1 ? goodBg : na)
                setCell(4, row, rBest < 0 ? "none" : fmtWin(rBest, L) + " · " + fmtPct(rBestV, "0.000"))
                setCell(5, row, not fitsDay(sK, L) ? "crosses day start" : nX < minN ? nTxt : not rwReady ? fmtPct(share * 100.0, "0.0") + " · random walk not ready" : fmtPct(share * 100.0, "0.0") + " vs " + fmtPct(base * 100.0, "0.0") + " (" + fmtPts(dK) + " ±" + str.tostring(2.0 * seD, "0.0") + ")")
                // Green only when the killzone is first among two or more windows and its difference is more than two
                // standard errors above zero.
                setCell(6, row, na(xRank) ? "not ranked" : str.tostring(xRank) + " of " + str.tostring(xM), not na(xRank) and xRank == 1 and xM > 1 and dK > 2.0 * seD ? goodBg : na)
                setCell(7, row, xBest < 0 ? "none" : fmtWin(xBest, L) + " · " + fmtPts(xBestV) + " pts")
 
        setCell(0, 6, "Clock hours with no bar: " + (emptyHours == "" ? "none" : emptyHours) + " · bars off the hour grid, left out: " + str.tostring(offGrid), hdrBg, text.align_left)
        string rwTxt = rwReady ? "High/low ranks by share minus a driftless random walk on the same traded hours (" + str.tostring(MC_PATHS, "#,###") + " simulated days); ± is 2 standard errors." : "Random-walk baseline not ready: it needs " + str.tostring(MC_PATHS / MC_PER_BAR, "#") + " confirmed bars."
        setCell(0, 7, "Confirmed bars only. " + rwTxt + " A rank is a position among same-length windows with a full sample on this chart. Not advice.", hdrBg, text.align_left)

← 返回列表