Crypto Rotation Radar: Live Activity Scanner [Artio]

Artio_Scalping_Life · study · 546 行 · 点赞 8 · TradingView 原页

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

Pine Script

//@version=6
indicator("Crypto Rotation Radar: Live Activity Scanner [Artio]", shorttitle="ARTIO ROT", overlay=false, dynamic_requests=true, max_bars_back=600, calc_bars_count=500)
// ARTIO ROTATION RADAR v3.6 | curated cross-symbol activity workspace.
// One selected page, up to 40 symbols INCLUDING BTC. No exchange-wide discovery.
// Use ordinary candles on a 5-minute crypto chart. LIVE values are provisional.
// Q/s and VEL measure observed feed changes, NOT trades/second or order flow.
// EN default / RU panel translation; static Pine input-option identifiers intentionally English.
// The fixed pool is manually editable; page navigation happens via the Page input.
// Reordering occurs on feed updates, not on a wall-clock timer.
// Signals are attention rankings, not trade directions or expected returns.
// 01 / SETTINGS
string exchange = input.string("BYBIT", "Exchange", options=["BYBIT", "BINANCE"], group="01 / POOL")
string language = input.string("EN", "Language / Язык", options=["EN", "RU"], group="00 / INTERFACE")
int perPage = input.int(40, "Symbols per page, BTC included", minval=2, maxval=40, group="01 / POOL")
int pageInput = input.int(1, "Pool page - manual", minval=1, maxval=1000, group="01 / POOL")
string poolText = input.text_area("BTC,ETH,SOL,XRP,BNB,DOGE,ADA,LINK,AVAX,SUI,HYPE,TAO,LTC,BCH,UNI,AAVE,NEAR,DOT,ATOM,INJ,ARB,OP,TRX,XLM,ETC,FIL,RENDER,PEPE,WIF,SHIB,ZEC,PENDLE,ENA,ONDO,JUP,SEI,TIA,ICP,APT,LDO,CRV,DYDX,FET,WLD,RUNE,IMX,STX,GALA,SAND,APE,BONK,FLOKI,PYTH,JTO", "Coins or full exchange:SYMBOLUSDT.P", group="01 / POOL")
string mode = input.string("LIVE", "Data", options=["LIVE", "CLOSED"], group="02 / VIEW")
string layout = input.string("COMPACT", "Layout", options=["COMPACT", "RICH"], group="02 / VIEW")
string show = input.string("ALL POOL", "Visible instruments", options=["ALL POOL", "QUALIFIED", "ACTIVE ONLY"], group="02 / VIEW")
int maxRows = input.int(40, "Maximum visible rows", minval=8, maxval=40, group="02 / VIEW")
int fontSize = input.int(10, "Text size", minval=8, maxval=16, group="02 / VIEW")
string sortMode = input.string("SMART", "Sort", options=["SMART", "NATR %", "NATR ROTATION", "ACTIVITY", "EARLY", "BURST", "SPEED", "POOL ORDER"], group="03 / RANKING")
int reorderSec = input.int(20, "Reorder every seconds", minval=5, maxval=120, group="03 / RANKING")
bool freezeOrder = input.bool(false, "Freeze row order, keep live values", group="03 / RANKING")
float minNatr = input.float(0.25, "NATR(14) 5m minimum, %", minval=0.01, step=0.05, group="04 / QUALIFICATION")
float minPct = input.float(60, "NATR percentile for impulse", minval=0, maxval=100, step=5, group="04 / QUALIFICATION")
float minAvg = input.float(250000, "Average 5m turnover, USDT", minval=0, step=50000, group="04 / QUALIFICATION")
float min24 = input.float(50000000, "Previous 24h turnover; 0 = off", minval=0, step=10000000, group="04 / QUALIFICATION")
float minRvol = input.float(1.35, "PACE trigger", minval=1, step=0.05, group="05 / ACTIVITY")
float minAccel = input.float(1.20, "Acceleration trigger", minval=1, step=0.05, group="05 / ACTIVITY")
float minRange = input.float(1.00, "Range / previous ATR trigger", minval=0.1, step=0.1, group="05 / ACTIVITY")
int warmupSec = input.int(20, "LIVE: activity warm-up at bar open, sec", minval=5, maxval=60, group="05 / ACTIVITY")
int sampleSec = input.int(15, "LIVE speed observation window, sec", minval=5, maxval=60, group="06 / SPEED AND DATA")
string volumeMode = input.string("AUTO", "Volume units - override only if verified", options=["AUTO", "BASE", "QUOTE"], group="06 / SPEED AND DATA")
bool enableAlerts = input.bool(false, "New HOT/IGNITE alerts, CLOSED only", group="07 / ALERTS")
// 02 / COLORS AND PURE HELPERS
color BG = color.rgb(9, 16, 26)
color ALT = color.rgb(14, 25, 39)
color HEAD = color.rgb(32, 53, 79)
color GRID = color.rgb(40, 56, 73)
color TXT = color.rgb(225, 234, 243)
color DIM = color.rgb(124, 145, 166)
color GREEN = color.rgb(33, 213, 155)
color RED = color.rgb(255, 92, 111)
color AMBER = color.rgb(255, 190, 77)
color CYAN = color.rgb(82, 212, 234)
color PURPLE = color.rgb(181, 137, 246)
f_lang(string en, string ru) =>
    language == "RU" ? ru : en
f_status(string st) =>
    language != "RU" ? st : st == "NO DATA" ? "НЕТ ДАННЫХ" : st == "HISTORY" ? "ПРОГРЕВ" : st == "OLD BAR" ? "СТАРЫЙ БАР" : st == "VOL UNIT" ? "ЕД. ОБЪЁМА?" : st == "NO VOL" ? "НЕТ ОБЪЁМА" : st == "LOW LIQ" ? "МАЛО ОБОРОТА" : st == "GAP24" ? "ПРОПУСК 24Ч" : st == "LOW N" ? "МАЛО NATR" : st == "WARMUP" ? "ОЖИДАНИЕ" : st
f_clip(float x, float lo, float hi) =>
    math.max(lo, math.min(hi, x))
f_num(float x, string pattern) =>
    string s = "--"
    if not na(x)
        s := str.tostring(x, pattern)
    s
f_sign(float x) =>
    string s = f_num(x, "0.00")
    if not na(x) and x > 0
        s := "+" + s
    s
f_money(float x) =>
    string s = "--"
    if not na(x)
        if x >= 1e9
            s := str.tostring(x / 1e9, "0.00") + "B"
        else if x >= 1e6
            s := str.tostring(x / 1e6, "0.00") + "M"
        else if x >= 1e3
            s := str.tostring(x / 1e3, "0.0") + "K"
        else
            s := str.tostring(x, "0")
    s
f_dir(float x) =>
    color c = DIM
    if not na(x)
        if x > 0
            c := GREEN
        else if x < 0
            c := RED
    c
f_state(int st) =>
    string result = st == 1 ? f_lang("WATCH", "НАБЛЮД.") : st == 2 ? f_lang("ROTATE", "РОТАЦИЯ") : st == 3 ? f_lang("WAKE", "ПРОБУЖД.") : st == 4 ? f_lang("HOT", "АКТИВНО") : st == 5 ? f_lang("IGNITE", "ИМПУЛЬС") : st == 6 ? f_lang("EXTEND", "ПОЗДН. ХОД") : f_lang("QUIET", "ТИХО")
    result
f_stateColor(int st) =>
    color c = DIM
    if st == 1 or st == 3
        c := CYAN
    else if st == 2
        c := PURPLE
    else if st == 4
        c := GREEN
    else if st == 5
        c := AMBER
    else if st == 6
        c := RED
    c
f_symbol(string token) =>
    string s = str.upper(str.trim(token))
    if not str.contains(s, ":")
        if not str.endswith(s, "USDT.P")
            if s == "PEPE" or s == "BONK" or s == "FLOKI"
                s := "1000" + s
            else if s == "SHIB"
                s := "1000SHIB"
                if exchange == "BYBIT"
                    s := "SHIB1000"
            s += "USDT.P"
        s := exchange + ":" + s
    s
f_name(string sym) =>
    string s = str.replace_all(str.replace_all(sym, exchange + ":", ""), "USDT.P", "")
    if str.startswith(s, "1000")
        s := str.substring(s, 4)
    else if s == "SHIB1000"
        s := "SHIB"
    s
type Snapshot
    int t0
    int t1
    float price
    float rawVol
    int units
    float natr
    float pctl
    float move
    float rvol
    float prevRvol
    float rng
    float eff
    float avg5
    float q24
    bool contiguous
type Rating
    float score = na
    float rot = na
    float act = na
    int state = 0
// Pure arithmetic only: safe to call for each symbol.
f_rating(Snapshot d, float pace, float accel, float rel, bool mature, bool qualified) =>
    float liq = f_clip(math.log(math.max(d.avg5, 1) / math.max(minAvg, 10000)) / math.log(40), 0, 1)
    float rot = 60 * d.pctl / 100 + 25 * f_clip(d.natr / (minNatr * 3), 0, 1) + 15 * liq
    float act = 0.0
    float fresh = 0.0
    bool impulse = false
    bool extended = false
    if mature and not na(pace)
        float a = 0.0
        if not na(accel)
            a := f_clip((accel - 0.85) / 1.65, 0, 1)
        act := 30 * f_clip((pace - 0.85) / 2.65, 0, 1) + 22 * a + 20 * f_clip((d.rng - 0.70) / 1.80, 0, 1) + 18 * f_clip(math.abs(d.move) / math.max(d.natr * 1.5, 0.05), 0, 1) + 10 * f_clip(d.eff, 0, 1)
        bool trigger = pace >= minRvol or (not na(accel) and accel >= minAccel and pace >= 1.05)
        impulse := qualified and d.pctl >= minPct and d.rng >= minRange and trigger
        if impulse
            fresh := 58
            if pace >= minRvol and d.prevRvol < minRvol
                fresh := 100
            else if not na(accel) and accel >= 1.60
                fresh := 85
            else if not na(accel) and accel >= minAccel
                fresh := 72
        else if qualified and not na(accel) and accel >= minAccel * 1.15 and pace >= 1.05
            fresh := 68
        extended := qualified and math.abs(d.move) >= math.max(d.natr * 2, 0.30) and not na(accel) and accel < 0.85 and d.rng > 1.25
    float rs = 0.0
    if not na(rel)
        rs := 100 * f_clip(math.abs(rel) / math.max(d.natr * 1.5, 0.05), 0, 1)
    float smart = 0.44 * act + 0.31 * rot + 0.15 * fresh + 0.10 * rs
    float score = smart
    if sortMode == "NATR ROTATION"
        score := 0.68 * rot + 0.17 * act + 0.15 * fresh
    else if sortMode == "ACTIVITY"
        score := 0.72 * act + 0.13 * rot + 0.15 * fresh
    else if sortMode == "EARLY"
        score := 0.48 * fresh + 0.32 * act + 0.20 * rot
    int st = 0
    if qualified
        if extended
            st := 6
        else if impulse and smart >= 80 and fresh >= 72
            st := 5
        else if impulse and smart >= 64
            st := 4
        else if fresh >= 65 and act >= 45
            st := 3
        else if rot >= 72
            st := 2
        else if smart >= 48
            st := 1
    if extended
        score := math.max(0, score - 12)
    Rating.new(score, rot, act, st)
// 03 / HISTORY ENGINE: all history-dependent calls run globally.
int unitCode = 0
float q = na
if volumeMode == "BASE" or (volumeMode == "AUTO" and syminfo.volumetype == "base")
    unitCode := 1
    q := volume * close
else if volumeMode == "QUOTE" or (volumeMode == "AUTO" and syminfo.volumetype == "quote")
    unitCode := 2
    q := volume
float atr14 = ta.atr(14)
float tr = ta.tr(true)
float avg5 = ta.sma(q, 48)[1]
float q24 = math.sum(q, 288)[1]
float natr = 100 * atr14 / math.max(close, 1e-12)
float pctl = ta.percentrank(natr, 96)
float move5 = 100 * (close / math.max(open, 1e-12) - 1)
float rawRvol = q / math.max(avg5, 1e-12)
float rangeX = tr / math.max(atr14[1], 1e-12)
float eff = math.abs(close - open) / math.max(tr, 1e-12)
bool continuous24 = not na(time[288]) and time - time[288] == 86400000
int sh = 0
if mode == "CLOSED"
    sh := 1
Snapshot source = Snapshot.new(time[sh], time_close[sh], close[sh], volume[sh], unitCode, natr[sh], pctl[sh], move5[sh], rawRvol[sh], rawRvol[sh + 1], rangeX[sh], eff[sh], avg5[sh], q24[sh], continuous24[sh])
// 04 / POOL PAGES. Only selected symbols are ever requested.
var array<string> allSymbols = array.new_string()
var array<string> symbols = array.new_string()
var int pages = 1
var int page = 1
if barstate.isfirst
    if not chart.is_standard or timeframe.in_seconds() != 300
        runtime.error(f_lang("ARTIO: Use standard 5-minute crypto candles.", "ARTIO: Нужны обычные 5-минутные криптосвечи."))
    array.push(allSymbols, exchange + ":BTCUSDT.P")
    string normalized = str.replace_all(str.replace_all(poolText, "\n", ","), ";", ",")
    array<string> tokens = str.split(normalized, ",")
    for token in tokens
        if str.length(str.trim(token)) > 0
            string sym = f_symbol(token)
            if not str.startswith(sym, exchange + ":") or not str.endswith(sym, "USDT.P")
                runtime.error(f_lang("Only the selected exchange and USDT perpetuals: ", "Только выбранная биржа и USDT perpetual: ") + sym)
            if not array.includes(allSymbols, sym)
                array.push(allSymbols, sym)
    int slots = perPage - 1
    pages := math.max(1, int(math.ceil(float(array.size(allSymbols) - 1) / slots)))
    page := math.min(pageInput, pages)
    array.push(symbols, array.get(allSymbols, 0))
    int first = 1 + (page - 1) * slots
    int last = math.min(first + slots, array.size(allSymbols)) - 1
    if first <= last
        for i = first to last
            array.push(symbols, array.get(allSymbols, i))
    if array.size(symbols) > 40
        runtime.error(f_lang("Too many requested symbols on this page.", "Превышен лимит тикеров на странице."))
int count = array.size(symbols)
int drawRows = math.min(maxRows, count)
var array<Snapshot> data = array.new<Snapshot>()
array.clear(data)
for sym in symbols
    Snapshot d = request.security(sym, "5", source, gaps=barmerge.gaps_off, lookahead=barmerge.lookahead_off, ignore_invalid_symbol=true, calc_bars_count=500)
    array.push(data, d)
// 05 / INTRABAR OBSERVATION MEMORY. No extra requests.
varip array<int> sampleAt = array.new_int(count, 0)
varip array<int> sampleBar = array.new_int(count, 0)
varip array<float> sampleVol = array.new_float(count, na)
varip array<float> samplePrice = array.new_float(count, na)
varip array<float> qRate = array.new_float(count, na)
varip array<float> velocity = array.new_float(count, na)
varip array<int> rateAt = array.new_int(count, 0)
varip array<float> windowSecs = array.new_float(count, na)
varip array<int> held = array.new_int()
varip int lastOrder = na
varip array<int> seenBar = array.new_int(count, 0)
varip array<int> seenState = array.new_int(count, 0)
// RICH adds ROT / ACT / PCTL / ACCEL / REL. COMPACT keeps live speed columns.
var array<string> titles = array.from("#", "SYMBOL", "STATE", "SCR", "ROT", "ACT", "NATR%", "PCTL", "PACE", "ACCEL", "BURST", "Q/s", "VEL%/m", "RNG", "MOVE%", "REL pp", "AVG5", "24H")
if barstate.isfirst and language == "RU"
    titles := array.from("#", "МОНЕТА", "СОСТ.", "БАЛЛ", "РОТ", "АКТ", "NATR%", "ПРЦ", "ТЕМП", "УСКОР", "РЫВОК", "Q/с", "СКОР%/м", "ДИАП", "ХОД%", "К BTC п.п.", "СР5", "24Ч")
var array<int> cols = array.from(0, 1, 2, 3, 6, 8, 10, 11, 12, 13, 14, 16, 17)
var array<float> widths = array.from(2.5, 9.0, 9.0, 5.5, 6.5, 6.5, 6.5, 8.0, 8.0, 6.0, 7.0, 10.0, 10.0)
if barstate.isfirst and layout == "RICH"
    cols := array.from(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17)
    widths := array.from(2.5, 8.5, 8.5, 5.0, 4.5, 4.5, 5.5, 4.5, 5.0, 5.0, 5.5, 6.0, 6.0, 4.0, 5.5, 5.5, 7.0, 7.0)
int nCols = array.size(cols)
var table panel = table.new(position.top_center, nCols, drawRows + 5, bgcolor=BG, frame_color=GRID, frame_width=1, border_color=GRID, border_width=1)
if barstate.isfirst
    table.merge_cells(panel, 0, 0, nCols - 1, 0)
    table.merge_cells(panel, 0, 1, nCols - 1, 1)
    table.merge_cells(panel, 0, drawRows + 3, nCols - 1, drawRows + 3)
    table.merge_cells(panel, 0, drawRows + 4, nCols - 1, drawRows + 4)
// 06 / EVALUATION
if barstate.islast
    array<Rating> ratings = array.new<Rating>()
    array<string> labels = array.new_string(count, f_status("NO DATA"))
    array<float> paces = array.new_float(count, na)
    array<float> accels = array.new_float(count, na)
    array<float> rels = array.new_float(count, na)
    array<float> bursts = array.new_float(count, na)
    array<float> keys = array.new_float(count, -1.0)
    array<bool> visibleOK = array.new_bool(count, false)
    array<bool> aligned = array.new_bool(count, false)
    array<float> marketN = array.new_float()
    array<float> marketP = array.new_float()
    int validCount = 0
    int liquidCount = 0
    int passCount = 0
    int hotCount = 0
    int wakeCount = 0
    int upCount = 0
    int issueCount = 0
    int refTime = time[sh]
    string alertText = ""
    float btcMove = na
    Snapshot btc = array.get(data, 0)
    if not na(btc)
        if btc.t0 == refTime and btc.price > 0
            btcMove := btc.move
    for i = 0 to count - 1
        Snapshot d = array.get(data, i)
        Rating r = Rating.new()
        string statusText = "NO DATA"
        bool priceOK = false
        bool volumeOK = false
        bool liquid = false
        bool qualified = false
        bool mature = true
        float pace = na
        float accel = na
        float rel = na
        if not na(d)
            priceOK := d.t0 == refTime and not na(d.price) and d.price > 0 and not na(d.natr) and not na(d.pctl) and not na(d.rng) and not na(d.move)
            if not priceOK
                statusText := "HISTORY"
                if not na(d.t0) and d.t0 != refTime
                    statusText := "OLD BAR"
            else
                validCount += 1
                array.push(marketN, d.natr)
                if d.move > 0
                    upCount += 1
                if not na(btcMove)
                    rel := d.move - btcMove
                volumeOK := d.units > 0 and not na(d.rawVol) and not na(d.avg5) and d.avg5 > 0 and not na(d.rvol)
                statusText := "VOL UNIT"
                if d.units > 0 and not volumeOK
                    statusText := "NO VOL"
                if volumeOK
                    float fraction = 1.0
                    if mode == "LIVE" and timenow < d.t1
                        mature := timenow - d.t0 >= warmupSec * 1000
                        fraction := f_clip(float(timenow - d.t0) / math.max(float(d.t1 - d.t0), 1), float(warmupSec) / 300, 1)
                    if mature
                        pace := d.rvol / fraction
                        array.push(marketP, pace)
                        if not na(d.prevRvol) and d.prevRvol >= 0.25
                            accel := pace / d.prevRvol
                    bool dayOK = min24 == 0 or (d.contiguous and not na(d.q24) and d.q24 >= min24)
                    liquid := d.avg5 >= minAvg and dayOK
                    qualified := liquid and d.natr >= minNatr
                    r := f_rating(d, pace, accel, rel, mature, qualified)
                    statusText := f_state(r.state)
                    if not liquid
                        statusText := "LOW LIQ"
                        if min24 > 0 and (not d.contiguous or na(d.q24))
                            statusText := "GAP24"
                    else if not qualified
                        statusText := "LOW N"
                    else if not mature
                        statusText := "WARMUP"
                    if liquid
                        liquidCount += 1
                    if qualified
                        passCount += 1
                    if r.state == 4 or r.state == 5
                        hotCount += 1
                    else if r.state == 3
                        wakeCount += 1
        // Speed samples exist only in LIVE realtime, inside one current bar.
        bool liveSample = false
        if priceOK and volumeOK and mode == "LIVE" and barstate.isrealtime
            liveSample := timenow >= d.t0 and timenow < d.t1
        if liveSample
            int at = array.get(sampleAt, i)
            float oldV = array.get(sampleVol, i)
            float oldP = array.get(samplePrice, i)
            int elapsedMs = timenow - at
            bool reset = at == 0 or array.get(sampleBar, i) != d.t0 or na(oldV) or na(oldP) or oldP <= 0 or d.rawVol < oldV or elapsedMs < 0 or elapsedMs > sampleSec * 3000
            if reset
                array.set(qRate, i, na)
                array.set(velocity, i, na)
                array.set(rateAt, i, 0)
                array.set(windowSecs, i, na)
            else if elapsedMs >= sampleSec * 1000
                float dt = float(elapsedMs) / 1000
                // Differencing raw volume prevents price-only moves inventing turnover.
                float deltaQ = d.rawVol - oldV
                if d.units == 1
                    deltaQ *= (d.price + oldP) / 2
                array.set(qRate, i, deltaQ / dt)
                array.set(velocity, i, 100 * (d.price / oldP - 1) * 60 / dt)
                array.set(rateAt, i, timenow)
                array.set(windowSecs, i, dt)
            if reset or elapsedMs >= sampleSec * 1000
                array.set(sampleAt, i, timenow)
                array.set(sampleBar, i, d.t0)
                array.set(sampleVol, i, d.rawVol)
                array.set(samplePrice, i, d.price)
        else
            array.set(sampleAt, i, 0)
            array.set(qRate, i, na)
            array.set(velocity, i, na)
            array.set(rateAt, i, 0)
            array.set(windowSecs, i, na)
        float burst = na
        if liveSample and array.get(rateAt, i) > 0
            if timenow - array.get(rateAt, i) <= sampleSec * 2000
                burst := array.get(qRate, i) / (d.avg5 / 300)
            else
                array.set(qRate, i, na)
                array.set(velocity, i, na)
        array.push(ratings, r)
        array.set(labels, i, statusText)
        array.set(aligned, i, priceOK)
        array.set(paces, i, pace)
        array.set(accels, i, accel)
        array.set(rels, i, rel)
        array.set(bursts, i, burst)
        bool allow = true
        if show == "QUALIFIED"
            allow := qualified
        else if show == "ACTIVE ONLY"
            allow := r.state == 3 or r.state == 4 or r.state == 5
        array.set(visibleOK, i, allow)
        float key = nz(r.score, -1)
        if sortMode == "NATR %" and priceOK
            key := d.natr
        else if sortMode == "BURST"
            key := nz(burst, -1)
        else if sortMode == "SPEED"
            key := nz(math.abs(array.get(velocity, i)), -1)
        else if sortMode == "POOL ORDER"
            key := count - i
        array.set(keys, i, key - i * 0.00000001)
        if not priceOK or not volumeOK or statusText == "GAP24"
            issueCount += 1
        // Record every aligned CLOSED state, including below-threshold states.
        if enableAlerts and mode == "CLOSED" and barstate.isrealtime and priceOK
            int oldBar = array.get(seenBar, i)
            int oldState = array.get(seenState, i)
            if d.t0 > oldBar
                bool wasHot = oldState == 4 or oldState == 5
                if oldBar > 0 and d.t0 - oldBar == 300000 and (r.state == 4 or r.state == 5) and not wasHot
                    alertText += f_name(array.get(symbols, i)) + " " + f_state(r.state) + "; "
                array.set(seenBar, i, d.t0)
                array.set(seenState, i, r.state)
    if str.length(alertText) > 0
        alert("ARTIO ROTATION RADAR | " + exchange + f_lang(" | CLOSED 5m | ", " | 5м ЗАКР. | ") + alertText, alert.freq_all)
    // Membership changes only on reorder. ALL POOL retains even invalid rows.
    bool reorder = na(lastOrder)
    if not freezeOrder and not na(lastOrder)
        reorder := timenow - lastOrder >= reorderSec * 1000
    if reorder
        array<int> orderIdx = array.sort_indices(keys, order.descending)
        array.clear(held)
        for i in orderIdx
            if array.get(visibleOK, i) and array.size(held) < drawRows
                array.push(held, i)
        lastOrder := timenow
    // 07 / TWO COMPACT HEADERS, TWO COMPACT FOOTERS
    float medN = na
    float medP = na
    float breadth = na
    if array.size(marketN) > 0
        medN := array.median(marketN)
    if array.size(marketP) > 0
        medP := array.median(marketP)
    if validCount > 0
        breadth := 100.0 * upCount / validCount
    string orderText = str.tostring(reorderSec) + "s"
    if freezeOrder
        orderText := f_lang("FIXED", "ФИКС.")
    string title = "ARTIO / ROTATION RADAR v3.6  |  " + exchange + "  ·  " + mode + "  |  " + f_lang("PAGE ", "СТР. ") + str.tostring(page) + "/" + str.tostring(pages) + "  |  " + f_lang("TRACKED ", "ТИКЕРОВ ") + str.tostring(count) + "/" + str.tostring(array.size(allSymbols)) + "  |  " + sortMode
    string market = f_lang("VALID ", "ДАННЫЕ ") + str.tostring(validCount) + "  |  " + f_lang("LIQUID ", "ЛИКВ. ") + str.tostring(liquidCount) + "  |  " + f_lang("PASS ", "ОТОБР. ") + str.tostring(passCount) + "  |  HOT " + str.tostring(hotCount) + "  |  WAKE " + str.tostring(wakeCount) + "  |  UP " + f_num(breadth, "0") + "%  |  Nmed " + f_num(medN, "0.00") + "  |  Pmed " + f_num(medP, "0.00") + "  |  BTC " + f_sign(btcMove) + "%"
    table.cell(panel, 0, 0, title, bgcolor=HEAD, text_color=TXT, text_size=math.max(fontSize, 11), text_halign=text.align_left, height=2.2)
    table.cell(panel, 0, 1, market, bgcolor=ALT, text_color=CYAN, text_size=fontSize, text_halign=text.align_left, height=2.2)
    float totalWidth = array.sum(widths)
    for c = 0 to nCols - 1
        int field = array.get(cols, c)
        table.cell(panel, c, 2, array.get(titles, field), width=98 * array.get(widths, c) / totalWidth, height=2.2, bgcolor=HEAD, text_color=DIM, text_size=fontSize)
    for row = 0 to drawRows - 1
        color bg = BG
        if row % 2 == 1
            bg := ALT
        array<string> values = array.new_string(18, "")
        array<color> colors = array.new_color(18, TXT)
        array<color> bgs = array.new_color(18, bg)
        string tip = f_lang("No matching row. ALL POOL displays the full selected page.", "Нет подходящей строки. ALL POOL показывает всю выбранную страницу.")
        if row < array.size(held)
            int i = array.get(held, row)
            Snapshot d = array.get(data, i)
            Rating r = array.get(ratings, i)
            string sym = array.get(symbols, i)
            string statusText = array.get(labels, i)
            color stateCol = f_stateColor(r.state)
            if statusText == "OLD BAR" or statusText == "VOL UNIT" or statusText == "NO DATA" or statusText == "HISTORY" or statusText == "NO VOL" or statusText == "GAP24"
                stateCol := AMBER
            array.set(values, 0, str.tostring(row + 1))
            array.set(values, 1, f_name(sym))
            array.set(values, 2, f_status(statusText))
            array.set(colors, 2, stateCol)
            array.set(bgs, 2, color.new(stateCol, 88))
            array.set(values, 3, f_num(r.score, "0"))
            array.set(values, 4, f_num(r.rot, "0"))
            array.set(values, 5, f_num(r.act, "0"))
            tip := sym + "\nROT " + f_num(r.rot, "0") + " | ACT " + f_num(r.act, "0") + " | ACCEL " + f_num(array.get(accels, i), "0.00")
            tip += f_lang("\nSpeed observation: ", "\nОкно скорости: ") + f_num(array.get(windowSecs, i), "0.0") + f_lang("s. Q/s = observed quote turnover/s; VEL = price change %/min.", "с. Q/с = наблюдаемое изменение оборота в секунду; СКОР = изменение цены %/мин.")
            tip += f_lang("\nBURST = Q/s divided by AVG5/300. Not trade count, true delta or MBO.", "\nРЫВОК = Q/с / (средний оборот за 5м / 300). Не количество сделок, не дельта и не MBO.")
            if not na(d)
                tip += "\nPCTL " + f_num(d.pctl, "0") + " | REL " + f_sign(array.get(rels, i)) + f_lang(" pp vs BTC.", " п.п. к BTC.")
                tip += f_lang("\nNATR14 / 5m; percentile: 96 bars; AVG5: previous 48 completed bars; 24H: previous 288 bars.", "\nNATR14 / 5м; перцентиль: 96 свечей; СР5: предыдущие 48 закрытых; 24Ч: предыдущие 288.")
                if array.get(aligned, i)
                    array.set(values, 6, f_num(d.natr, "0.00"))
                    array.set(values, 7, f_num(d.pctl, "0"))
                    array.set(values, 8, f_num(array.get(paces, i), "0.00"))
                    array.set(values, 9, f_num(array.get(accels, i), "0.00"))
                    array.set(values, 10, f_num(array.get(bursts, i), "0.00"))
                    array.set(values, 11, f_money(array.get(qRate, i)))
                    array.set(values, 12, f_sign(array.get(velocity, i)))
                    array.set(values, 13, f_num(d.rng, "0.00"))
                    array.set(values, 14, f_sign(d.move))
                    array.set(values, 15, f_sign(array.get(rels, i)))
                    array.set(values, 16, f_money(d.avg5))
                    array.set(values, 17, "--")
                    if d.contiguous
                        array.set(values, 17, f_money(d.q24))
                    array.set(colors, 12, f_dir(array.get(velocity, i)))
                    array.set(colors, 14, f_dir(d.move))
                    array.set(colors, 15, f_dir(array.get(rels, i)))
                    array.set(bgs, 6, color.from_gradient(d.natr, 0, minNatr * 3, bg, color.new(PURPLE, 58)))
                    array.set(bgs, 8, color.from_gradient(nz(array.get(paces, i)), 1, 3, bg, color.new(GREEN, 68)))
                    array.set(bgs, 10, color.from_gradient(nz(array.get(bursts, i)), 1, 4, bg, color.new(AMBER, 65)))
        for c = 0 to nCols - 1
            int field = array.get(cols, c)
            table.cell(panel, c, row + 3, array.get(values, field), width=98 * array.get(widths, c) / totalWidth, height=88.0 / drawRows, bgcolor=array.get(bgs, field), text_color=array.get(colors, field), text_size=fontSize, tooltip=tip)
    string footer = show + "  |  " + f_lang("REORDER ", "СОРТИРОВКА ") + orderText + "  |  NATR " + f_num(minNatr, "0.00") + "%  |  AVG5 " + f_money(minAvg) + "  |  24H " + f_money(min24) + "  |  " + f_lang("DATA ISSUES ", "ПРОБЛЕМЫ ДАННЫХ ") + str.tostring(issueCount)
    string footnote = f_lang("LIVE: ~", "LIVE: ~") + str.tostring(sampleSec) + f_lang("s sampled feed changes; speed resets on bar change/reload. Q/s is NOT trade count.", "с — выборка изменений фида; скорость сбрасывается при смене свечи/перезагрузке. Q/с — НЕ количество сделок.")
    if mode == "CLOSED"
        footnote := f_lang("CLOSED: previous completed 5m candle | realtime speeds disabled | score measures activity, not trade edge.", "CLOSED: предыдущая закрытая свеча 5м | LIVE-скорости выключены | балл — активность, не вероятность прибыли.")
    if ticker.standard(syminfo.tickerid) != exchange + ":BTCUSDT.P"
        footnote := f_lang("HOST: use ", "ГРАФИК: открой ") + exchange + ":BTCUSDT.P 5m. " + footnote
    table.cell(panel, 0, drawRows + 3, footer, bgcolor=HEAD, text_color=TXT, text_size=fontSize, text_halign=text.align_left, height=2.0)
    table.cell(panel, 0, drawRows + 4, footnote, bgcolor=BG, text_color=DIM, text_size=math.max(8, fontSize - 1), text_halign=text.align_left, height=2.0)
plot(na, title="Dashboard", display=display.none)

← 返回列表