// @version=2 indicator(precision = 2) // GH850 v1.4-S 简版 —— 图表只显示「共振多」「共振空」 // ★ 判定链与 GH850_v1.4.txt 完整版逐项一致,共振信号位置一根不差 // ★ 保留 reboundRaw / reboundCore:路径②要按完整版规则让位, // 删掉它共振信号会凭空变多;这段只参与判定,不产生任何标注 // ★ 已删除:反弹多 / 回落空、量能过滤、布林位置 / 实体位置过滤、 // 布林中轨线、combo 三档强度标注、TD9 / TD13 触发点标注及相关预警 // ★ 保留:TD 计数、combo、共振窗口、ATR 过滤、双共振首次出现标记 // ══════════ 开关 ══════════ enableRebound = true // 仅用于路径②让位判定(本版不画反弹多) enableTDCombo = true // TD+combo 双共振 td9 = true td13 = true // ══════════ 参数 ══════════ reboundRsi = 32 // 让位形态的 RSI 阈值(不产生信号) minAtrPct = 0.0111 maxAtrPct = 0.6 comboWeak = 0.60 comboMid = 0.70 comboStrong = 0.85 winBars = 5 rsiP = 14 bollN = 20 bollM = 2 atrP = 14 // ══════════ 收盘序列:全部显式平移一根 ══════════ c1 = close[1] c2 = close[2] c3 = close[3] rsiS = rsi(close, rsiP) rsi1 = rsiS[1] [mid, ub, lb] = boll(close, bollN, bollM) mb1 = mid[1] ub1 = ub[1] trC = max(high[1] - low[1], max(abs(high[1] - close[2]), abs(low[1] - close[2]))) atrC = ma(trC, atrP) atrPct = c1 > 0 ? atrC / c1 * 100 : 0 atrOk = atrPct >= minAtrPct and atrPct <= maxAtrPct lowC = low[1] highC = high[1] // ══════════ 让位形态(只参与判定,不绘图) ══════════ reboundRaw = rsi1 < reboundRsi and c1 > c2 reboundCore = enableRebound and reboundRaw and atrOk // ══════════ 路径② combo 预测信号 ══════════ devw = (ub1 - mb1) / 2 zval = devw > 0 ? (c1 - mb1) / devw : 0 relvol = mb1 > 0 ? devw / mb1 : 0 momN = relvol > 0 and c3 > 0 ? (c1 / c3 - 1) / relvol : 0 rsiN = (rsi1 - 50) / 50 combo = 0.4 * momN - 0.4 * zval + 0.2 * rsiN aCombo = combo > 0 ? combo : -combo fcLvl = aCombo >= comboStrong ? 1 : (aCombo >= comboMid ? 2 : (aCombo >= comboWeak ? 3 : 0)) fcDir = fcLvl > 0 ? (combo > 0 ? 1 : -1) : 0 scoreTD = fcLvl == 1 ? 88 : (fcLvl == 2 ? 74 : 64) // 供自动交易版阈值用,本指标不下单 // ══════════ TD 连续计数:无状态展开 ══════════ d1 = close[1] < close[5] d2 = close[2] < close[6] d3 = close[3] < close[7] d4 = close[4] < close[8] d5 = close[5] < close[9] d6 = close[6] < close[10] d7 = close[7] < close[11] d8 = close[8] < close[12] d9 = close[9] < close[13] d10 = close[10] < close[14] d11 = close[11] < close[15] d12 = close[12] < close[16] d13 = close[13] < close[17] d14 = close[14] < close[18] u1 = close[1] > close[5] u2 = close[2] > close[6] u3 = close[3] > close[7] u4 = close[4] > close[8] u5 = close[5] > close[9] u6 = close[6] > close[10] u7 = close[7] > close[11] u8 = close[8] > close[12] u9 = close[9] > close[13] u10 = close[10] > close[14] u11 = close[11] > close[15] u12 = close[12] > close[16] u13 = close[13] > close[17] u14 = close[14] > close[18] seq9D = d1 and d2 and d3 and d4 and d5 and d6 and d7 and d8 and d9 and not d10 seq13D = d1 and d2 and d3 and d4 and d5 and d6 and d7 and d8 and d9 and d10 and d11 and d12 and d13 and not d14 seq9U = u1 and u2 and u3 and u4 and u5 and u6 and u7 and u8 and u9 and not u10 seq13U = u1 and u2 and u3 and u4 and u5 and u6 and u7 and u8 and u9 and u10 and u11 and u12 and u13 and not u14 hitB9 = td9 and seq9D hitB13 = td13 and seq13D hitS9 = td9 and seq9U hitS13 = td13 and seq13U hitB = hitB9 or hitB13 hitS = hitS9 or hitS13 // ══════════ 共振窗口:无状态展开 ══════════ tdBuyWin = hitB or (winBars > 1 and hitB[1]) or (winBars > 2 and hitB[2]) or (winBars > 3 and hitB[3]) or (winBars > 4 and hitB[4]) tdSellWin = hitS or (winBars > 1 and hitS[1]) or (winBars > 2 and hitS[2]) or (winBars > 3 and hitS[3]) or (winBars > 4 and hitS[4]) f0 = fcDir f1 = fcDir[1] f2 = fcDir[2] f3 = fcDir[3] f4 = fcDir[4] z0 = f0 == 0 z1 = f1 == 0 z2 = f2 == 0 z3 = f3 == 0 fcBuyWin = (f0 > 0) or (winBars > 1 and z0 and f1 > 0) or (winBars > 2 and z0 and z1 and f2 > 0) or (winBars > 3 and z0 and z1 and z2 and f3 > 0) or (winBars > 4 and z0 and z1 and z2 and z3 and f4 > 0) fcSellWin = (f0 < 0) or (winBars > 1 and z0 and f1 < 0) or (winBars > 2 and z0 and z1 and f2 < 0) or (winBars > 3 and z0 and z1 and z2 and f3 < 0) or (winBars > 4 and z0 and z1 and z2 and z3 and f4 < 0) // ══════════ 两条路径合成 + 首次出现标记 ══════════ wantBuy = enableTDCombo and fcBuyWin and tdBuyWin and atrOk wantSell = enableTDCombo and fcSellWin and tdSellWin and atrOk path2Buy = wantBuy and not reboundCore path2Sell = wantSell and not reboundCore curDir = reboundCore ? 1 : (path2Buy ? 1 : (path2Sell ? -1 : 0)) prevDir = curDir[1] freshBuy = curDir == 1 and not (prevDir == 1) freshSell = curDir == -1 and not (prevDir == -1) tagBuy2 = freshBuy and path2Buy tagSell2 = freshSell and path2Sell // ══════════ 绘图:只有两个 ══════════ plotText(tagBuy2, title = '共振多', text = '共振多', color = '#00e676', refSeries = lowC, placement = 'bottom') plotText(tagSell2, title = '共振空', text = '共振空', color = '#ff1744', refSeries = highC, placement = 'top') // ══════════ 预警 ══════════ alertcondition(tagBuy2, title = 'GH850-双共振做多', direction = 'buy') alertcondition(tagSell2, title = 'GH850-双共振做空', direction = 'sell')