mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-16 01:28:05 +00:00
43 lines
1.3 KiB
Plaintext
43 lines
1.3 KiB
Plaintext
// Fisher04: Ehlers Fisher Transform (2004 Cybernetic Analysis)
|
|
// Source: John Ehlers, "Cybernetic Analysis for Stocks and Futures", Wiley, 2004, Chapter 1
|
|
//
|
|
// Key differences from 2002 TASC article (fisher.pine):
|
|
// Normalization: 1.0 * ((price-low)/range - 0.5) vs 0.66 * (...)
|
|
// IIR feedback on Value1: 0.5 vs 0.67
|
|
// Clamp threshold: 0.9999 vs 0.99→0.999
|
|
// Fisher multiplier: 0.25 vs 0.5
|
|
// Fisher IIR: 0.5 (same)
|
|
|
|
//@version=6
|
|
indicator("Fisher04 - Ehlers 2004 Cybernetic Analysis", shorttitle="Fisher04", overlay=false)
|
|
|
|
length = input.int(10, "Length", minval=1)
|
|
|
|
price = hl2
|
|
|
|
maxH = ta.highest(price, length)
|
|
minL = ta.lowest(price, length)
|
|
|
|
var float value1 = 0.0
|
|
var float fisher = 0.0
|
|
var float signal = 0.0
|
|
|
|
range_ = maxH - minL
|
|
|
|
if range_ != 0
|
|
// Ehlers 2004: normalization coefficient = 1.0 (0.5 * 2)
|
|
value1 := ((price - minL) / range_ - 0.5) + 0.5 * nz(value1[1])
|
|
else
|
|
value1 := 0.0
|
|
|
|
// Ehlers 2004: clamp to ±0.9999
|
|
value1 := math.max(math.min(value1, 0.9999), -0.9999)
|
|
|
|
// Ehlers 2004: 0.25 * arctanh + 0.5 * Fish[1]
|
|
signal := fisher
|
|
fisher := 0.25 * math.log((1 + value1) / (1 - value1)) + 0.5 * nz(fisher[1])
|
|
|
|
plot(fisher, "Fisher04", color.yellow, 2)
|
|
plot(signal, "Signal", color.orange, 1)
|
|
hline(0, "Zero", color.gray, linestyle=hline.style_dotted)
|