Aquila Reale Gold Drivers

giua64 · study · 389 行 · 点赞 57 · TradingView 原页

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

Pine Script

//@version=6
// ============================================================================
// Aquila Reale – Gold Drivers (AR Drivers)
// Gli asset che muovono l'oro, in tempo reale, mentre fai trading sull'oro.
// Variazione su 15m · 1H · 4H · 1D · 1W · 1M (adesso contro X tempo fa)
// Colore = effetto sull'oro: verde aiuta l'oro, rosso va contro, grigio piatto
// INFL = inflazione attesa (TIP/IEF) · TIP = costo dell'oro (rend. reali al contrario)
// ⚡ = scatto anomalo in 15 minuti · ⚠ DIV = oro contro il macro · fuori orario vale l'ultima rilevazione
// Freccia finale: 1ª = intraday (15m 1H 4H), 2ª = fondo (1D 1W 1M) · REALE = rend. reale 10 anni (FRED, giornaliero)
// Verdetto: STRONG LONG · LONG · FLAT · SHORT · STRONG SHORT
// Avvisi: crea UN allarme sull'indicatore con "Qualsiasi chiamata alert()"
// Opinione personale, non consulenza finanziaria.
// Nate per volare, nate per osare · Be Stable. Be Strong. 🦅
// ============================================================================
indicator("Aquila Reale – Gold Drivers", shorttitle = "AR Drivers", overlay = true)
 
// ============================ IMPOSTAZIONI ============================
gV = "Visualizzazione"
modeIn  = input.string("Semi", "Modalità", options = ["Completa", "Semi", "Compatta", "Super compatta"], group = gV, tooltip = "Completa: tutti i tempi · Semi: 15m 1H 1D 1W · Compatta: solo la freccia finale per asset · Super compatta: solo il verdetto")
posIn   = input.string("In alto a destra", "Posizione", options = ["In alto a sinistra", "In alto al centro", "In alto a destra", "Al centro a sinistra", "Al centro", "Al centro a destra", "In basso a sinistra", "In basso al centro", "In basso a destra"], group = gV)
sizeIn  = input.string("Piccolo", "Testo", options = ["Minuscolo", "Piccolo", "Normale"], group = gV)
showPx  = input.bool(false, "Colonna prezzo in modalità Completa (in Semi è sempre attiva)", group = gV)
 
gC = "Calcoli"
thPct   = input.float(0.05, "Soglia piatto (%)", minval = 0, step = 0.01, group = gC, tooltip = "Sotto questa variazione la cella è grigia")
thBp    = input.float(0.5, "Soglia piatto rendimenti (bp)", minval = 0, step = 0.1, group = gC)
spkMult = input.float(2.0, "Scatto ⚡: volte il movimento normale in 15m", minval = 1.2, step = 0.1, group = gC, tooltip = "2 = il doppio del movimento medio delle ultime 20 candele da 15 minuti")
 
gA = "Asset  ·  mostra · simbolo · relazione con l'oro"
sh1 = input.bool(true, "", inline = "1", group = gA)
s1  = input.symbol("TVC:DXY", "DXY", inline = "1", group = gA)
q1  = input.string("Contrario", "", options = ["Contrario", "Con l'oro", "Info"], inline = "1", group = gA)
sh2 = input.bool(true, "", inline = "2", group = gA)
s2  = input.symbol("TVC:US02Y", "2Y", inline = "2", group = gA)
q2  = input.string("Contrario", "", options = ["Contrario", "Con l'oro", "Info"], inline = "2", group = gA)
sh3 = input.bool(true, "", inline = "3", group = gA)
s3  = input.symbol("TVC:US10Y", "10Y", inline = "3", group = gA)
q3  = input.string("Contrario", "", options = ["Contrario", "Con l'oro", "Info"], inline = "3", group = gA)
sh4 = input.bool(true, "", inline = "4", group = gA)
s4  = input.symbol("FPMARKETS:BRENT", "BRENT", inline = "4", group = gA)
q4  = input.string("Contrario", "", options = ["Contrario", "Con l'oro", "Info"], inline = "4", group = gA)
sh5 = input.bool(true, "", inline = "5", group = gA)
s5  = input.symbol("FPMARKETS:US100", "NDQ", inline = "5", group = gA)
q5  = input.string("Contrario", "", options = ["Contrario", "Con l'oro", "Info"], inline = "5", group = gA)
sh6 = input.bool(true, "", inline = "6", group = gA)
s6  = input.symbol("FPMARKETS:USDJPY", "JPY", inline = "6", group = gA)
q6  = input.string("Contrario", "", options = ["Contrario", "Con l'oro", "Info"], inline = "6", group = gA)
sh7 = input.bool(true, "", inline = "7", group = gA)
s7  = input.symbol("TVC:VIX", "VIX", inline = "7", group = gA)
q7  = input.string("Con l'oro", "", options = ["Contrario", "Con l'oro", "Info"], inline = "7", group = gA)
sh8 = input.bool(true, "", inline = "8", group = gA)
s8  = input.symbol("FPMARKETS:XAGUSD", "AG", inline = "8", group = gA)
q8  = input.string("Con l'oro", "", options = ["Contrario", "Con l'oro", "Info"], inline = "8", group = gA)
sh9 = input.bool(true, "", inline = "9", group = gA)
s9  = input.symbol("OANDA:USDCNH", "CNH", inline = "9", group = gA)
q9  = input.string("Con l'oro", "", options = ["Contrario", "Con l'oro", "Info"], inline = "9", group = gA)
sh10 = input.bool(true, "", inline = "10", group = gA)
s10  = input.symbol("AMEX:TIP", "TIP (costo dell'oro: rend. reali al contrario)", inline = "10", group = gA)
q10  = input.string("Con l'oro", "", options = ["Contrario", "Con l'oro", "Info"], inline = "10", group = gA)
sh11 = input.bool(true, "", inline = "11", group = gA)
s11  = input.string("AMEX:TIP/NASDAQ:IEF", "INFL (inflazione attesa = TIP/IEF)", inline = "11", group = gA)
q11  = input.string("Con l'oro", "", options = ["Contrario", "Con l'oro", "Info"], inline = "11", group = gA)
sh12 = input.bool(true, "", inline = "12", group = gA)
s12  = input.symbol("FRED:DFII10", "REALE (rend. reale 10 anni, solo giornaliero)", inline = "12", group = gA)
q12  = input.string("Contrario", "", options = ["Contrario", "Con l'oro", "Info"], inline = "12", group = gA)
 
gL = "Avvisi livelli chiave"
lvOn1 = input.bool(true, "DXY attraversa", inline = "l1", group = gL)
lv1   = input.float(102.0, "", step = 0.1, inline = "l1", group = gL)
lvOn2 = input.bool(true, "2Y attraversa", inline = "l2", group = gL)
lv2   = input.float(4.50, "", step = 0.01, inline = "l2", group = gL)
lvOn4 = input.bool(true, "Brent attraversa", inline = "l4", group = gL)
lv4   = input.float(100.0, "", step = 0.5, inline = "l4", group = gL)
 
// ============================ DATI ============================
// variazione: % per i prezzi, punti base per i rendimenti
f_chg(float src, int n, bool y) =>
    y ? (src - src[n]) * 100.0 : (src / src[n] - 1.0) * 100.0
 
// scatto: movimento dell'ultima candela da 15m diviso la media delle 20 precedenti
f_spk(bool y) =>
    float ch = math.abs(f_chg(close, 1, y))
    float avg = ta.sma(ch, 20)[1]
    avg > 0 ? ch / avg : 0.0
 
// 2 richieste per asset
f_get(string sym, bool y) =>
    [c15, c1h, c4h, sp, px, tt] = request.security(sym, "15", [f_chg(close, 1, y), f_chg(close, 4, y), f_chg(close, 16, y), f_spk(y), close, time], ignore_invalid_symbol = true)
    [cD, cW, cM, dc] = request.security(sym, "D", [f_chg(close, 1, y), f_chg(close, 5, y), f_chg(close, 21, y), close], ignore_invalid_symbol = true)
    [c15, c1h, c4h, cD, cW, cM, sp, na(px) ? dc : px, tt]
 
[O0, O1, O2, O3, O4, O5, O6, O7, O8] = f_get(syminfo.tickerid, false)
[A0, A1, A2, A3, A4, A5, A6, A7, A8] = f_get(s1, false)
[B0, B1, B2, B3, B4, B5, B6, B7, B8] = f_get(s2, true)
[C0, C1, C2, C3, C4, C5, C6, C7, C8] = f_get(s3, true)
[D0, D1, D2, D3, D4, D5, D6, D7, D8] = f_get(s4, false)
[E0, E1, E2, E3, E4, E5, E6, E7, E8] = f_get(s5, false)
[F0, F1, F2, F3, F4, F5, F6, F7, F8] = f_get(s6, false)
[G0, G1, G2, G3, G4, G5, G6, G7, G8] = f_get(s7, false)
[H0, H1, H2, H3, H4, H5, H6, H7, H8] = f_get(s8, false)
[I0, I1, I2, I3, I4, I5, I6, I7, I8] = f_get(s9, false)
[J0, J1, J2, J3, J4, J5, J6, J7, J8] = f_get(s10, false)
[K0, K1, K2, K3, K4, K5, K6, K7, K8] = f_get(s11, false)
[L0, L1, L2, L3, L4, L5, L6, L7, L8] = f_get(s12, true)
 
// ============================ AIUTI ============================
pos = switch posIn
    "In alto a sinistra"   => position.top_left
    "In alto al centro"    => position.top_center
    "Al centro a sinistra" => position.middle_left
    "Al centro"            => position.middle_center
    "Al centro a destra"   => position.middle_right
    "In basso a sinistra"  => position.bottom_left
    "In basso al centro"   => position.bottom_center
    "In basso a destra"    => position.bottom_right
    => position.top_right
tsz = sizeIn == "Minuscolo" ? size.tiny : sizeIn == "Normale" ? size.normal : size.small
 
f_rel(string q) => q == "Contrario" ? -1 : q == "Con l'oro" ? 1 : 0
f_fmt(float v) => na(v) ? "—" : (v >= 0 ? "+" : "") + str.tostring(v, "0.0")
f_pxf(float p, bool y) => na(p) ? "—" : y ? str.tostring(p, "0.00") + "%" : p >= 1000 ? str.tostring(p, "#,###") : p >= 10 ? str.tostring(p, "0.00") : str.tostring(p, "0.0000")
f_lvl(float sc, float mx) => mx <= 0 ? 0 : sc >= 0.55 * mx ? 2 : sc >= 0.25 * mx ? 1 : sc <= -0.55 * mx ? -2 : sc <= -0.25 * mx ? -1 : 0
f_ltx(int l) => l == 2 ? "▲▲" : l == 1 ? "▲" : l == -1 ? "▼" : l == -2 ? "▼▼" : "•"
f_vtx(int l) => l == 2 ? "STRONG LONG" : l == 1 ? "LONG" : l == -1 ? "SHORT" : l == -2 ? "STRONG SHORT" : "FLAT"
 
cHead = color.new(#0e1018, 0)
cName = color.new(#1c2030, 0)
cSep  = color.new(#14161f, 0)
cGold = color.new(#e0a832, 0)
cGrn  = color.new(#1f9d55, 10)
cGrnS = color.new(#0f7a3e, 0)
cRed  = color.new(#d64545, 10)
cRedS = color.new(#a01f1f, 0)
cGry  = color.new(#4a5060, 20)
cInfo = color.new(#3a5a8a, 20)
cStl  = color.new(#2a2d36, 0)
cReal = color.new(#e0a832, 0)  // REAL row highlight
 
f_bg(int d, int rel, bool st) => st ? cStl : d == 0 ? cGry : rel == 0 ? cInfo : d * rel > 0 ? cGrn : cRed
f_arr(int d) => d > 0 ? "▲" : d < 0 ? "▼" : "•"
f_lbg(int l) => l == 2 ? cGrnS : l == 1 ? cGrn : l == -1 ? cRed : l == -2 ? cRedS : cGry
 
var table tb = table.new(pos, 9, 24, border_width = 1, border_color = color.new(color.black, 0))
 
// stato per gli avvisi (varip = non si azzera a ogni tick)
varip int k1 = 0
varip int k2 = 0
varip int k3 = 0
varip int k4 = 0
varip int k5 = 0
varip int k6 = 0
varip int k7 = 0
varip int k8 = 0
varip int k9 = 0
varip int k10 = 0
varip int k11 = 0
varip int prevLvl = 99
varip bool prevDiv = false
varip float pL1 = na
varip float pL2 = na
varip float pL4 = na
 
// ============================ CALCOLO E DISEGNO ============================
if barstate.islast
    names = array.from("ORO", "DXY", "2Y", "10Y", "BRENT", "NDQ", "JPY", "VIX", "AG", "CNH", "TIP", "INFL", "REALE")
    rel   = array.from(1, f_rel(q1), f_rel(q2), f_rel(q3), f_rel(q4), f_rel(q5), f_rel(q6), f_rel(q7), f_rel(q8), f_rel(q9), f_rel(q10), f_rel(q11), f_rel(q12))
    wgt   = array.from(0, 2, 2, 2, 1, 1, 1, 1, 1, 1, 2, 1, 2)
    isY   = array.from(false, false, true, true, false, false, false, false, false, false, false, false, true)
    isDay = array.from(false, false, false, false, false, false, false, false, false, false, false, false, true)
    ord   = array.from(0, 1, 2, 3, 12, 4, 5, 6, 7, 8, 9, 10, 11)
    shw   = array.from(true, sh1, sh2, sh3, sh4, sh5, sh6, sh7, sh8, sh9, sh10, sh11, sh12)
    v0 = array.from(O0, A0, B0, C0, D0, E0, F0, G0, H0, I0, J0, K0, L0)
    v1 = array.from(O1, A1, B1, C1, D1, E1, F1, G1, H1, I1, J1, K1, L1)
    v2 = array.from(O2, A2, B2, C2, D2, E2, F2, G2, H2, I2, J2, K2, L2)
    v3 = array.from(O3, A3, B3, C3, D3, E3, F3, G3, H3, I3, J3, K3, L3)
    v4 = array.from(O4, A4, B4, C4, D4, E4, F4, G4, H4, I4, J4, K4, L4)
    v5 = array.from(O5, A5, B5, C5, D5, E5, F5, G5, H5, I5, J5, K5, L5)
    spr = array.from(O6, A6, B6, C6, D6, E6, F6, G6, H6, I6, J6, K6, L6)
    pxs = array.from(O7, A7, B7, C7, D7, E7, F7, G7, H7, I7, J7, K7, L7)
    tms = array.from(O8, A8, B8, C8, D8, E8, F8, G8, H8, I8, J8, K8, L8)
 
    vals = matrix.new<float>(13, 6, na)
    dirs = matrix.new<int>(13, 6, 0)
    for i = 0 to 12
        matrix.set(vals, i, 0, array.get(isDay, i) ? na : array.get(v0, i))
        matrix.set(vals, i, 1, array.get(isDay, i) ? na : array.get(v1, i))
        matrix.set(vals, i, 2, array.get(isDay, i) ? na : array.get(v2, i))
        matrix.set(vals, i, 3, array.get(v3, i))
        matrix.set(vals, i, 4, array.get(v4, i))
        matrix.set(vals, i, 5, array.get(v5, i))
 
    rowDir = array.new<int>(13, 0)
    shDir  = array.new<int>(13, 0)
    lgDir  = array.new<int>(13, 0)
    stale  = array.new<bool>(13, false)
    spike  = array.new<bool>(13, false)
    eff15  = array.new<int>(13, 0)
    for i = 0 to 12
        float th = array.get(isY, i) ? thBp : thPct
        int s = 0
        for k = 0 to 5
            float v = matrix.get(vals, i, k)
            int d = na(v) or math.abs(v) < th ? 0 : v > 0 ? 1 : -1
            matrix.set(dirs, i, k, d)
            s += d
        array.set(rowDir, i, s >= 2 ? 1 : s <= -2 ? -1 : 0)
        int sS = matrix.get(dirs, i, 0) + matrix.get(dirs, i, 1) + matrix.get(dirs, i, 2)
        int sL = matrix.get(dirs, i, 3) + matrix.get(dirs, i, 4) + matrix.get(dirs, i, 5)
        array.set(shDir, i, sS > 0 ? 1 : sS < 0 ? -1 : 0)
        array.set(lgDir, i, sL > 0 ? 1 : sL < 0 ? -1 : 0)
        bool st = false  // si usa sempre l'ultima rilevazione
        array.set(stale, i, st)
        float v15 = matrix.get(vals, i, 0)
        float sr = array.get(spr, i)
        array.set(spike, i, not array.get(isDay, i) and not st and not na(sr) and sr >= spkMult and not na(v15) and math.abs(v15) >= th * 2)
        array.set(eff15, i, matrix.get(dirs, i, 0) * array.get(rel, i))
 
    // totali per tempo e totale finale
    float maxW = 0.0
    float fsc = 0.0
    tfSc = array.new<float>(6, 0.0)
    for i = 1 to 12
        int rl = array.get(rel, i)
        if array.get(shw, i) and not array.get(stale, i) and rl != 0
            int w = array.get(wgt, i)
            maxW += w
            fsc += array.get(rowDir, i) * rl * w
            for k = 0 to 5
                array.set(tfSc, k, array.get(tfSc, k) + matrix.get(dirs, i, k) * rl * w)
    int lvl = f_lvl(fsc, maxW)
    // scatto contrario su un asset pesante (DXY, 2Y, 10Y, Brent): il verdetto scende di un gradino
    bool down = false
    string spkTxt = ""
    for i = 1 to 12
        if array.get(shw, i) and array.get(spike, i)
            spkTxt += "⚡" + array.get(names, i) + " "
            int e = array.get(eff15, i)
            if (array.get(wgt, i) == 2 or i == 4) and e != 0 and lvl != 0 and math.sign(e) != math.sign(lvl)
                down := true
    if down
        lvl := lvl > 0 ? lvl - 1 : lvl + 1
    int gDir = array.get(rowDir, 0)
    bool div = gDir != 0 and lvl != 0 and gDir != math.sign(lvl)
    string verdict = "ORO ⇢ " + f_vtx(lvl) + (spkTxt != "" ? "  " + spkTxt : "") + (div ? " ⚠DIV" : "")
 
    // ---------------- DISEGNO ----------------
    table.clear(tb, 0, 0, 8, 23)
    tfN = array.from("15m", "1H", "4H", "1D", "1W", "1M")
    if modeIn == "Completa" or modeIn == "Semi"
        cols = modeIn == "Completa" ? array.from(0, 1, 2, 3, 4, 5) : array.from(0, 1, 3, 4)
        bool px = modeIn == "Semi" or showPx
        int c0 = px ? 2 : 1
        int cA = c0 + array.size(cols)
        // intestazione
        table.cell(tb, 0, 0, "🦅 AQUILE REALI", text_color = cGold, bgcolor = cHead, text_size = tsz)
        table.merge_cells(tb, 0, 0, cA, 0)
        table.cell(tb, 0, 1, "", bgcolor = cHead, text_size = tsz)
        if px
            table.cell(tb, 1, 1, "PREZZO", text_color = cGold, bgcolor = cHead, text_size = tsz)
        for j = 0 to array.size(cols) - 1
            table.cell(tb, c0 + j, 1, array.get(tfN, array.get(cols, j)), text_color = cGold, bgcolor = cHead, text_size = tsz)
        table.cell(tb, cA, 1, "➜", text_color = cGold, bgcolor = cHead, text_size = tsz)
        int r = 2
        for j0 = 0 to 12
            int i = array.get(ord, j0)
            if i == 1 or i == 7
                table.cell(tb, 0, r, i == 1 ? "CONTRARI" : "CON L'ORO", text_color = color.new(color.white, 40), bgcolor = cSep, text_size = size.tiny, text_halign = text.align_left)
                table.merge_cells(tb, 0, r, cA, r)
                r += 1
            if array.get(shw, i)
                bool st = array.get(stale, i)
                bool y = array.get(isY, i)
                int rl = array.get(rel, i)
                string nm = array.get(names, i)
                table.cell(tb, 0, r, i == 12 ? "★ REALE" : nm, text_color = i == 12 ? color.black : i == 0 ? cGold : color.white, bgcolor = i == 12 ? cReal : cName, text_size = tsz, text_halign = text.align_left, tooltip = nm + " · prezzo " + f_pxf(array.get(pxs, i), y))
                if px
                    table.cell(tb, 1, r, f_pxf(array.get(pxs, i), y), text_color = i == 12 ? color.black : color.white, bgcolor = i == 12 ? cReal : cName, text_size = tsz)
                for j = 0 to array.size(cols) - 1
                    int k = array.get(cols, j)
                    float v = matrix.get(vals, i, k)
                    int d = matrix.get(dirs, i, k)
                    bool sk = k == 0 and array.get(spike, i)
                    string tip = nm + " " + array.get(tfN, k) + ": " + f_fmt(v) + (y ? " bp" : " %") + (sk ? " · scatto " + str.tostring(array.get(spr, i), "0.0") + "x il normale" : "")
                    table.cell(tb, c0 + j, r, f_fmt(v) + (sk ? "⚡" : ""), text_color = color.white, bgcolor = f_bg(d, rl, st), text_size = tsz, tooltip = tip)
                int rd = array.get(rowDir, i)
                int dS = array.get(shDir, i)
                int dL = array.get(lgDir, i)
                string at = array.get(isDay, i) ? f_arr(dL) : f_arr(dS) + f_arr(dL)
                table.cell(tb, cA, r, at, text_color = color.white, bgcolor = f_bg(rd != 0 ? rd : dS, rl, false), text_size = tsz, tooltip = "1ª freccia = intraday (15m 1H 4H) · 2ª freccia = fondo (1D 1W 1M)")
                r += 1
        // riga totale
        table.cell(tb, 0, r, "TOTALE", text_color = cGold, bgcolor = cHead, text_size = tsz, text_halign = text.align_left)
        if px
            table.cell(tb, 1, r, "", bgcolor = cHead, text_size = tsz)
        for j = 0 to array.size(cols) - 1
            int k = array.get(cols, j)
            int l = f_lvl(array.get(tfSc, k), maxW)
            table.cell(tb, c0 + j, r, f_ltx(l), text_color = color.white, bgcolor = f_lbg(l), text_size = tsz, tooltip = array.get(tfN, k) + ": " + f_vtx(l) + " (punteggio " + str.tostring(array.get(tfSc, k), "0") + " su " + str.tostring(maxW, "0") + ")")
        table.cell(tb, cA, r, f_ltx(lvl), text_color = color.white, bgcolor = f_lbg(lvl), text_size = tsz)
        r += 1
        table.cell(tb, 0, r, verdict, text_color = color.white, bgcolor = f_lbg(lvl), text_size = tsz, tooltip = "Amici contro nemici su tutti i tempi · dollaro e rendimenti valgono doppio")
        table.merge_cells(tb, 0, r, cA, r)
        if modeIn == "Completa"
            r += 1
            table.cell(tb, 0, r, "Aquila Reale · Be Stable. Be Strong. · non è consulenza finanziaria", text_color = color.new(cGold, 40), bgcolor = cHead, text_size = size.tiny)
            table.merge_cells(tb, 0, r, cA, r)
    else if modeIn == "Compatta"
        table.cell(tb, 0, 0, "🦅 AQUILE REALI", text_color = cGold, bgcolor = cHead, text_size = tsz)
        table.merge_cells(tb, 0, 0, 2, 0)
        int r = 1
        for j0 = 0 to 12
            int i = array.get(ord, j0)
            if array.get(shw, i)
                bool st = array.get(stale, i)
                int rd = array.get(rowDir, i)
                string nm = array.get(names, i)
                string tip = nm + "  15m " + f_fmt(matrix.get(vals, i, 0)) + " · 1H " + f_fmt(matrix.get(vals, i, 1)) + " · 4H " + f_fmt(matrix.get(vals, i, 2)) + " · 1D " + f_fmt(matrix.get(vals, i, 3)) + " · 1W " + f_fmt(matrix.get(vals, i, 4)) + " · 1M " + f_fmt(matrix.get(vals, i, 5))
                table.cell(tb, 0, r, i == 12 ? "★ REALE" : nm, text_color = i == 12 ? color.black : i == 0 ? cGold : color.white, bgcolor = i == 12 ? cReal : cName, text_size = tsz, text_halign = text.align_left, tooltip = tip)
                table.cell(tb, 1, r, f_pxf(array.get(pxs, i), array.get(isY, i)), text_color = i == 12 ? color.black : st ? color.new(color.white, 40) : color.white, bgcolor = i == 12 ? cReal : cName, text_size = tsz, tooltip = st ? "ultimo prezzo (mercato fermo)" : "prezzo attuale")
                int dS = array.get(shDir, i)
                int dL = array.get(lgDir, i)
                string at = (array.get(isDay, i) ? f_arr(dL) : f_arr(dS) + f_arr(dL)) + (array.get(spike, i) ? "⚡" : "")
                table.cell(tb, 2, r, at, text_color = color.white, bgcolor = f_bg(rd != 0 ? rd : dS, array.get(rel, i), false), text_size = tsz, tooltip = tip + "  ·  1ª freccia = intraday (15m 1H 4H), 2ª = fondo (1D 1W 1M)")
                r += 1
        table.cell(tb, 0, r, f_vtx(lvl) + (div ? " ⚠" : ""), text_color = color.white, bgcolor = f_lbg(lvl), text_size = tsz, tooltip = verdict)
        table.merge_cells(tb, 0, r, 2, r)
    else
        table.cell(tb, 0, 0, "🦅 AQUILE REALI", text_color = cGold, bgcolor = cHead, text_size = tsz)
        table.cell(tb, 0, 1, verdict, text_color = color.white, bgcolor = f_lbg(lvl), text_size = tsz)
        table.cell(tb, 0, 2, "★ REALE " + f_pxf(array.get(pxs, 12), true) + " " + f_arr(array.get(lgDir, 12)), text_color = color.black, bgcolor = cReal, text_size = tsz)
 
    // ---------------- AVVISI ----------------
    string tail = " · ORO " + f_vtx(lvl)
    // scatti ⚡ (uno per candela da 15 minuti per asset)
    if array.get(shw, 1) and array.get(spike, 1) and array.get(tms, 1) != k1
        k1 := array.get(tms, 1)
        alert("⚡ DXY " + f_fmt(A0) + "% in 15m · " + (array.get(eff15, 1) > 0 ? "PRO ORO" : "CONTRO ORO") + tail, alert.freq_all)
    if array.get(shw, 2) and array.get(spike, 2) and array.get(tms, 2) != k2
        k2 := array.get(tms, 2)
        alert("⚡ 2Y " + f_fmt(B0) + "bp in 15m · " + (array.get(eff15, 2) > 0 ? "PRO ORO" : "CONTRO ORO") + tail, alert.freq_all)
    if array.get(shw, 3) and array.get(spike, 3) and array.get(tms, 3) != k3
        k3 := array.get(tms, 3)
        alert("⚡ 10Y " + f_fmt(C0) + "bp in 15m · " + (array.get(eff15, 3) > 0 ? "PRO ORO" : "CONTRO ORO") + tail, alert.freq_all)
    if array.get(shw, 4) and array.get(spike, 4) and array.get(tms, 4) != k4
        k4 := array.get(tms, 4)
        alert("⚡ BRENT " + f_fmt(D0) + "% in 15m · " + (array.get(eff15, 4) > 0 ? "PRO ORO" : "CONTRO ORO") + tail, alert.freq_all)
    if array.get(shw, 5) and array.get(spike, 5) and array.get(tms, 5) != k5
        k5 := array.get(tms, 5)
        alert("⚡ NASDAQ " + f_fmt(E0) + "% in 15m · " + (array.get(eff15, 5) > 0 ? "PRO ORO" : "CONTRO ORO") + tail, alert.freq_all)
    if array.get(shw, 6) and array.get(spike, 6) and array.get(tms, 6) != k6
        k6 := array.get(tms, 6)
        alert("⚡ USD/JPY " + f_fmt(F0) + "% in 15m · " + (array.get(eff15, 6) > 0 ? "PRO ORO" : "CONTRO ORO") + tail, alert.freq_all)
    if array.get(shw, 7) and array.get(spike, 7) and array.get(tms, 7) != k7
        k7 := array.get(tms, 7)
        alert("⚡ VIX " + f_fmt(G0) + "% in 15m · " + (array.get(eff15, 7) > 0 ? "PRO ORO" : "CONTRO ORO") + tail, alert.freq_all)
    if array.get(shw, 8) and array.get(spike, 8) and array.get(tms, 8) != k8
        k8 := array.get(tms, 8)
        alert("⚡ ARGENTO " + f_fmt(H0) + "% in 15m · " + (array.get(eff15, 8) > 0 ? "PRO ORO" : "CONTRO ORO") + tail, alert.freq_all)
    if array.get(shw, 9) and array.get(spike, 9) and array.get(tms, 9) != k9
        k9 := array.get(tms, 9)
        alert("⚡ USD/CNH " + f_fmt(I0) + "% in 15m · " + (array.get(eff15, 9) > 0 ? "PRO ORO" : "CONTRO ORO") + tail, alert.freq_all)
    if array.get(shw, 10) and array.get(spike, 10) and array.get(tms, 10) != k10
        k10 := array.get(tms, 10)
        alert("⚡ TIP " + f_fmt(J0) + "% in 15m (rend. reali " + (J0 > 0 ? "giù" : "su") + ") · " + (array.get(eff15, 10) > 0 ? "PRO ORO" : "CONTRO ORO") + tail, alert.freq_all)
    if array.get(shw, 11) and array.get(spike, 11) and array.get(tms, 11) != k11
        k11 := array.get(tms, 11)
        alert("⚡ INFLAZIONE ATTESA " + (K0 > 0 ? "SU " : "GIÙ ") + f_fmt(K0) + "% in 15m · " + (array.get(eff15, 11) > 0 ? "PRO ORO" : "CONTRO ORO") + tail, alert.freq_all)
    // cambio di verdetto
    if lvl != prevLvl
        if prevLvl != 99
            alert("🦅 ORO: da " + f_vtx(prevLvl) + " a " + f_vtx(lvl) + (spkTxt != "" ? "  " + spkTxt : ""), alert.freq_all)
        prevLvl := lvl
    // divergenza
    if div and not prevDiv
        alert("⚠ DIVERGENZA: l'oro va " + (gDir > 0 ? "SU" : "GIÙ") + " ma il macro dice " + f_vtx(lvl), alert.freq_all)
    prevDiv := div
    // livelli chiave
    if lvOn1 and not na(A7)
        if not na(pL1) and ((pL1 < lv1 and A7 >= lv1) or (pL1 > lv1 and A7 <= lv1))
            alert("🎯 DXY " + (A7 >= lv1 ? "sopra " : "sotto ") + str.tostring(lv1) + " (" + f_pxf(A7, false) + ")" + tail, alert.freq_all)
        pL1 := A7
    if lvOn2 and not na(B7)
        if not na(pL2) and ((pL2 < lv2 and B7 >= lv2) or (pL2 > lv2 and B7 <= lv2))
            alert("🎯 2Y " + (B7 >= lv2 ? "sopra " : "sotto ") + str.tostring(lv2) + "% (" + f_pxf(B7, true) + ")" + tail, alert.freq_all)
        pL2 := B7
    if lvOn4 and not na(D7)
        if not na(pL4) and ((pL4 < lv4 and D7 >= lv4) or (pL4 > lv4 and D7 <= lv4))
            alert("🎯 BRENT " + (D7 >= lv4 ? "sopra " : "sotto ") + str.tostring(lv4) + " (" + f_pxf(D7, false) + ")" + tail, alert.freq_all)
        pL4 := D7

← 返回列表