OPEN-SOURCE SCRIPT

Fisher

59
//version=5
indicator("Fisher + EMA + Histogram (Working)", overlay=false)

// Inputs
fLen = input.int(125, "Fisher Length")
emaLen = input.int(21, "EMA Length")
src = input.source(close, "Source")

// Fisher Transform
var float x = na
minL = ta.lowest(src, fLen)
maxH = ta.highest(src, fLen)
rng = maxH - minL
val = rng != 0 ? (src - minL) / rng : 0.5

x := 0.33 * 2 * (val - 0.5) + 0.67 * nz(x[1])
x := math.max(math.min(x, 0.999), -0.999)
fish = 0.5 * math.log((1 + x) / (1 - x))

// EMA of Fisher
fishEma = ta.ema(fish, emaLen)

// Histogram
hist = fish - fishEma
histColor = hist >= 0 ? color.new(color.lime, 50) : color.new(color.red, 50)
plot(hist, style=plot.style_histogram, color=histColor, title="Histogram")

// Fisher Plot
fishColor = fish > 2 ? color.red : fish < -2 ? color.lime : color.teal
plot(fish, "Fisher", color=fishColor, linewidth=2)
plot(fishEma, "Fisher EMA", color=color.orange, linewidth=2)

// Horizontal Lines
hline(2, "Upper Extreme", color=color.new(color.red, 70))
hline(-2, "Lower Extreme", color=color.new(color.green, 70))
hline(0, "Zero", color=color.gray)

// Cross Signals
bull = ta.crossover(fish, fishEma)
bear = ta.crossunder(fish, fishEma)
plotshape(bull, style=shape.triangleup, location=location.bottom, color=color.lime, size=size.tiny)
plotshape(bear, style=shape.triangledown, location=location.top, color=color.red, size=size.tiny)

// Background for extremes
bgcolor(fish > 2 ? color.new(color.red, 80) : fish < -2 ? color.new(color.green, 80) : na)

Thông báo miễn trừ trách nhiệm

Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.