Fisher Transform + ADX

oxaam1 · study · 62 行 · 点赞 16 · TradingView 原页

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

Pine Script

//@version=6
indicator("Fisher Transform + ADX", shorttitle="Fisher+ADX", overlay=false)
 
// ── Inputs ──────────────────────────────────────────────
grpF = "Fisher Transform"
fisherLen   = input.int(9, "Fisher Length", minval=1, group=grpF)
fisherScale = input.float(10.0, "Fisher Scale (to fit ADX range)", minval=0.1, step=0.5, group=grpF,
     tooltip="Fisher usually sits between -3 and +3. It is multiplied by this value so it is visible next to ADX (0-100). Zero line stays at 0.")
 
grpA = "ADX"
adxLen    = input.int(14, "ADX Length", minval=1, group=grpA)
adxSmooth = input.int(14, "DI Length", minval=1, group=grpA)
adxLevel  = input.float(25.0, "ADX Trend Level", group=grpA)
showDI    = input.bool(false, "Show +DI / -DI", group=grpA)
 
grpS = "Signals"
showSig = input.bool(true, "Show signals (ADX > level & Fisher side)", group=grpS)
 
// ── Fisher Transform ────────────────────────────────────
hiH = ta.highest(hl2, fisherLen)
loL = ta.lowest(hl2, fisherLen)
rng = math.max(hiH - loL, 0.000001)
 
var float v = 0.0
v := 0.66 * ((hl2 - loL) / rng - 0.5) + 0.67 * nz(v[1])
v := math.max(math.min(v, 0.999), -0.999)
 
var float fish = 0.0
fish := 0.5 * math.log((1 + v) / (1 - v)) + 0.5 * nz(fish[1])
 
fishTrig   = nz(fish[1])
fishScaled = fish * fisherScale
trigScaled = fishTrig * fisherScale
 
// ── ADX ─────────────────────────────────────────────────
[diPlus, diMinus, adx] = ta.dmi(adxLen, adxSmooth)
 
// ── Plots ───────────────────────────────────────────────
hline(0, "Zero", color=color.gray, linestyle=hline.style_dashed)
hline(adxLevel, "ADX Level", color=color.new(color.orange, 40), linestyle=hline.style_dotted)
 
plot(adx, "ADX", color=color.orange, linewidth=2)
plot(showDI ? diPlus : na, "+DI", color=color.new(color.green, 30))
plot(showDI ? diMinus : na, "-DI", color=color.new(color.red, 30))
 
plot(fishScaled, "Fisher (scaled)", color=color.new(color.aqua, 0), linewidth=2)
plot(trigScaled, "Fisher Trigger (scaled)", color=color.new(color.fuchsia, 0), linewidth=1)
 
// ── Signals ─────────────────────────────────────────────
longCond  = adx > adxLevel and fish > 0
shortCond = adx > adxLevel and fish < 0
longSig   = longCond and not longCond[1]
shortSig  = shortCond and not shortCond[1]
 
bgcolor(showSig and longCond ? color.new(color.green, 90) : na)
bgcolor(showSig and shortCond ? color.new(color.red, 90) : na)
 
plotshape(showSig and longSig, "Long", shape.triangleup, location.bottom, color.green, size=size.tiny)
plotshape(showSig and shortSig, "Short", shape.triangledown, location.top, color.red, size=size.tiny)
 
alertcondition(longSig, "Fisher+ADX Long", "ADX above level and Fisher above 0")
alertcondition(shortSig, "Fisher+ADX Short", "ADX above level and Fisher below 0")

← 返回列表