// @version=2 indicator(precision = 2) // GH850 v1.4 —— 相对 v1.3 只改五处,其余判定逐项不变: // ① 旧「缩量过滤 volRatio < 0.8」移除,改为新的量能确认过滤: // 只作用于反弹多 / 回落空(路径① / ①b),默认要求放量(volRatio > minVolRatio); // 共振多 / 共振空完全不引用 volOk;useShrinkVol = true 可切回缩量语义 // ② 新增路径①b「超买回落做空」:与超卖反弹对称,RSI > 68 且 c1 < c2, // 走独立首次触发判定,不进 curDir、不屏蔽任何既有信号,可一键关(enableReboundShort = false) // ③ 反弹多 / 回落空共用 volOk,量比全部基于已收盘根计算 // ④ 两处修复:路径②屏蔽改用 reboundCore(不含量能),共振信号不随量能开关变化; // 量能数据缺失时 volOk 自动放行,避免反弹多 / 回落空一根都不出 // ⑤ 新增三项过滤(只挂信号本体,不碰 reboundCore):布林位置、K 线实体位置、 // minVolRatio 由 1.0 提到 1.2;反弹多 / 回落空减少,共振信号数量不变 // // ★ 共振多 / 共振空(路径②):判定公式与 v1.3 一致,且与量能过滤彻底解耦; // 回落空与它们互不屏蔽,同根可同时出现。 // v1.3 的显示设定保留:弱多 / 弱空默认不显示(showWeakMarks = false), // TD 触发点拆成 TD9 / TD13 分别标注(showTdMarks 可一键清除全部 TD 标注) // ══════════ 开关 ══════════ enableRebound = true // pRebound 超卖反弹(多) enableReboundShort = true // ★ v1.4 新增:超买回落(空),false = 关闭 enableVolFilter = true // ★ v1.4:量能过滤,只作用于反弹多 / 回落空 useShrinkVol = false // false = 放量确认;true = 缩量过滤(回到 v1.3 语义) enableBollPos = true // ★ v1.4:布林位置确认(多 c1mb1) enableBodyPos = true // ★ v1.4:K 线实体位置确认(收盘在 K 线上 / 下半部) enableTDCombo = true // pTDCombo TD+combo 双共振(用户要求保持打开) td9 = true td13 = true showAuxMarks = true // 三档强度 / TD 触发点参考标注,可关;不参与判定 showWeakMarks = false // 弱多 / 弱空标注,false = 不显示(仅关绘图,判定不变) showTdMarks = true // TD9 / TD13 触发点标注,false = 清除全部 TD 标注(判定不变) // ══════════ 参数 ══════════ reboundRsi = 32 // 超卖阈值 reboundRsiHigh = 68 // ★ v1.4 新增:超买阈值(100 - 32 对称) minAtrPct = 0.0111 maxAtrPct = 0.6 comboWeak = 0.60 comboMid = 0.70 comboStrong = 0.85 winBars = 5 // 共振窗口(根);本版展开支持 1..5,默认 5 rsiP = 14 bollN = 20 bollM = 2 atrP = 14 volN = 20 // ★ v1.4:量能均线周期 minVolRatio = 1.2 // ★ v1.4:放量模式下限(由 1.0 收紧到 1.2) maxVolRatio = 0.8 // 缩量模式上限,仅 useShrinkVol = true 时生效 // ══════════ 收盘序列:全部显式平移一根,杜绝未收盘根参与 ══════════ c1 = close[1] // 页面 last.c c2 = close[2] // 页面 prev.c c3 = close[3] // 页面 closes[len-3],2 根前(动量) rsiS = rsi(close, rsiP) rsi1 = rsiS[1] // 已提交值,定格 [mid, ub, lb] = boll(close, bollN, bollM) mb1 = mid[1] ub1 = ub[1] // 收盘 TR:整根用 [1] / [2],等价于 v1.1 的 ma(tr,14)[1](14 根 TR 简单平均) 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 // ★ v1.4 收盘量比:volC / 20 根均量,全部以已收盘根为基准,等价 ma(volume,20)[1] volC = volume[1] avgVolC = ma(volC, volN) // ★ 修复:无成交量 / 均量为 0 时判定「量能不可用」,volOk 自动放行 volValid = avgVolC > 0 and volC > 0 volRatio = volValid ? volC / avgVolC : 1 // 锚点:用上一根已收盘 K 线的低 / 高点,文字位置不再随实时价跳动 lowC = low[1] highC = high[1] // ══════════ 市场过滤(页面 marketFilter) ══════════ atrOk = atrPct >= minAtrPct and atrPct <= maxAtrPct // ★ v1.4:volOk 只给反弹多 / 回落空用;路径②共振多 / 共振空不引用 // ★ 修复:量能数据不可用时自动放行,不再需要手动关 enableVolFilter volOk = (not enableVolFilter or not volValid) or (useShrinkVol ? volRatio < maxVolRatio : volRatio > minVolRatio) // ══════════ 路径① 超卖反弹(多) / 路径①b 超买回落(空) ══════════ // ★ 新增过滤:只用已收盘根;每个都有独立开关,关掉即可单独验证该项效果 bodyMid = (highC + lowC) / 2 bollPosLong = not enableBollPos or c1 < mb1 bollPosShort = not enableBollPos or c1 > mb1 bodyPosLong = not enableBodyPos or c1 > bodyMid bodyPosShort = not enableBodyPos or c1 < bodyMid reboundFilterLong = bollPosLong and bodyPosLong reboundFilterShort = bollPosShort and bodyPosShort // 纯形态,保持 v1.3 原样 → reboundCore 不变,共振信号数量不受本次过滤影响 reboundRaw = rsi1 < reboundRsi and c1 > c2 reboundShortRaw = rsi1 > reboundRsiHigh and c1 < c2 // ★ 修复:屏蔽路径②只看形态 + 开关 + ATR,摘掉 volOk 与新增过滤 reboundCore = enableRebound and reboundRaw and atrOk reboundOk = reboundCore and volOk and reboundFilterLong // ★ v1.4 新增:与路径① 完全对称的做空分支(阈值 68,方向相反) reboundShortOk = enableReboundShort and reboundShortRaw and atrOk and volOk and reboundFilterShort // ══════════ 路径② combo 预测信号(三档 强88 / 中74 / 弱64) ══════════ 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) // 供自动交易版阈值用,本指标不下单 // 注:v1.4 的「回落空」不走 combo 评分,自动交易版若要接入需单独定阈值 // ══════════ TD 连续计数:无状态展开(替代 var tdBuy / tdSell) ══════════ // v1.1:tdBuy := c1 < c5 ? tdBuy + 1 : 0,只在 ==9 / ==13 触发(不封顶累加)。 // 等价展开:「恰好连续 9 根 / 13 根满足 close[k] < close[k+4]」。 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 // ★ v1.3:把 9 / 13 拆成四路,绘图时才能写清楚是 TD9 还是 TD13; // seq9* 含 not d10/u10、seq13* 含 d10/u10,二者天然互斥,同一根不会重复标注。 hitB9 = td9 and seq9D hitB13 = td13 and seq13D hitS9 = td9 and seq9U hitS13 = td13 and seq13U hitB = hitB9 or hitB13 hitS = hitS9 or hitS13 // ══════════ 共振窗口:无状态展开(替代 4 个 var sinceXXX) ══════════ // TD 窗口 = 最近 winBars 根内出现过 9/13 触发(触发当根 since=0,共亮 5 根) 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]) // 预测窗口 = 最近 winBars 根内「最后一次非零 fcDir」的方向; // 反向信号会把对方窗口置 99(永久失效直到同向再次出现),与 v1.1 一致。 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) // ══════════ 两条路径合成(共振多 / 共振空:判定与 v1.3 逐项一致) ══════════ wantBuy = enableTDCombo and fcBuyWin and tdBuyWin and atrOk wantSell = enableTDCombo and fcSellWin and tdSellWin and atrOk // ★ 修复:改用 reboundCore(不含量能),共振多 / 共振空的出现不再随量能开关变化 // 回落空仍不屏蔽共振信号;反弹多形态出现时,路径②照旧让位 path2Buy = wantBuy and not reboundCore path2Sell = wantSell and not reboundCore // ══════════ 首次出现标记:无状态(替代 var activeDir) ══════════ // v1.1 的 activeDir 在本根开头读到的是【上一根】的 curDir; // 故 freshBuy = 方向由非多转多的那一刻,等价于 curDir[1] != 1。 // ★ 修复:curDir 改用 reboundCore,路径②方向状态机完全不含量能输入, // 共振多 / 共振空的首次标记不再随 minVolRatio / enableVolFilter 漂移 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 // ★ 路径① / ①b 各自独立首次触发,互不依赖 curDir reboundPrev = reboundOk[1] tagRebound = reboundOk and not reboundPrev reboundShortPrev = reboundShortOk[1] tagReboundShort = reboundShortOk and not reboundShortPrev // ══════════ 绘图(所有锚点均为已收盘值) ══════════ plot(mb1, title = '布林中轨(已收盘)', color = '#f0b90b') // —— 路径① 超卖反弹 —— plotText(tagRebound, title = '反弹多', text = '反弹多', color = '#00e676', refSeries = lowC, placement = 'bottom') // —— 路径①b 超买回落做空(★ v1.4 新增)—— plotText(tagReboundShort, title = '回落空', text = '回落空', color = '#ff1744', refSeries = highC, placement = 'top') // —— 路径② 双共振信号(默认打开)—— plotText(tagBuy2, title = '共振多', text = '共振多', color = '#00e676', refSeries = lowC, placement = 'bottom') plotText(tagSell2, title = '共振空', text = '共振空', color = '#ff1744', refSeries = highC, placement = 'top') // —— combo 强度参考:只是强度,不是开单信号;锚点已收盘定格 —— // ★ v1.3:弱档默认不显示(showWeakMarks = false),需要时改成 true 即可恢复; // 注意弱档仍参与 fcDir / 共振判定,这里只关绘图。 plotText(showAuxMarks and showWeakMarks and (fcLvl == 3) and (combo > 0), title = '弱多', text = '弱多', color = '#66bb6a', refSeries = lowC, placement = 'bottom') plotText(showAuxMarks and showWeakMarks and (fcLvl == 3) and (combo < 0), title = '弱空', text = '弱空', color = '#ef9a9a', refSeries = highC, placement = 'top') plotText(showAuxMarks and (fcLvl == 2) and (combo > 0), title = '中多', text = '中多', color = '#26a69a', refSeries = lowC, placement = 'bottom') plotText(showAuxMarks and (fcLvl == 1) and (combo > 0), title = '强多', text = '★多', color = '#69f0ae', refSeries = lowC, placement = 'bottom') plotText(showAuxMarks and (fcLvl == 2) and (combo < 0), title = '中空', text = '中空', color = '#ef5350', refSeries = highC, placement = 'top') plotText(showAuxMarks and (fcLvl == 1) and (combo < 0), title = '强空', text = '★空', color = '#ff8a80', refSeries = highC, placement = 'top') // —— TD 触发点:文字区分写清 TD9 / TD13(不再统一写 'TD')—— plotText(showAuxMarks and showTdMarks and hitB9, title = 'TD9买', text = 'TD9', color = '#26a69a', refSeries = lowC, placement = 'bottom') plotText(showAuxMarks and showTdMarks and hitB13, title = 'TD13买', text = 'TD13', color = '#00e5ff', refSeries = lowC, placement = 'bottom') plotText(showAuxMarks and showTdMarks and hitS9, title = 'TD9卖', text = 'TD9', color = '#ef5350', refSeries = highC, placement = 'top') plotText(showAuxMarks and showTdMarks and hitS13, title = 'TD13卖', text = 'TD13', color = '#ff1744', refSeries = highC, placement = 'top') // ══════════ 预警 ══════════ alertcondition(tagRebound, title = 'GH850-超卖反弹做多', direction = 'buy') alertcondition(tagReboundShort, title = 'GH850-超买回落做空', direction = 'sell') // ★ v1.4 新增 alertcondition(tagBuy2, title = 'GH850-双共振做多', direction = 'buy') alertcondition(tagSell2, title = 'GH850-双共振做空', direction = 'sell')