mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-16 01:28:05 +00:00
- Updated the name and description of the Hilbert Trendline (HTIT) to "Ehlers Hilbert Transform Instantaneous Trend (HTIT)". - Changed the name and description of the MESA Adaptive Moving Average (MAMA) to "Ehlers MESA Adaptive Moving Average". - Modified the Center of Gravity (CG) indicator to "Ehlers Center of Gravity (CG)". - Renamed the Detrended Synthetic Price (DSP) to "Ehlers Detrended Synthetic Price (DSP)". - Updated the Autocorrelation Periodogram (EACP) to "Ehlers Autocorrelation Periodogram (EACP)". - Changed the Homodyne Discriminator (HOMOD) to "Ehlers Homodyne Discriminator (HOMOD)". - Updated the Hilbert Transform Dominant Cycle Period and Phase indicators to include "Ehlers" in their names. - Renamed the Hilbert Transform Phasor Components to "Ehlers Hilbert Transform Phasor Components (HT_PHASOR)". - Updated the SineWave indicator to "Ehlers Hilbert Transform SineWave (HT_SINE)". - Changed the Phasor Analysis indicator to "Ehlers Hilbert Transform Phasor Components (HT_PHASOR)". - Updated the SSF-Based Detrended Synthetic Price to "Ehlers SSF Detrended Synthetic Price (SSFDSP)". - Renamed the Ultimate Channel to "Ehlers Ultimate Channel (UCHANNEL)". - Added new indicators: Moving Average Variable Period (MAVP), Ehlers Predictive Moving Average (PMA), Ehlers Reverse EMA (REVERSEEMA), and Ehlers Trendflex Indicator (TRENDFLEX). - Updated various SVG badges to reflect changes in classes, comments, source files, lines of code, methods, and public types.
50 lines
1.6 KiB
Plaintext
50 lines
1.6 KiB
Plaintext
// The MIT License (MIT)
|
|
// © mihakralj
|
|
//@version=6
|
|
indicator("Ehlers Fisher Transform (FISHER)", "FISHER", overlay=false)
|
|
|
|
//@function Calculates the Fisher Transform oscillator
|
|
//@param source Source price (typically hl2)
|
|
//@param period Lookback period for min/max normalization
|
|
//@returns [fisher, signal] Fisher Transform value and signal line
|
|
fisher(series float source, simple int period) =>
|
|
if period <= 0
|
|
runtime.error("Period must be greater than 0")
|
|
if period > 500
|
|
runtime.error("Period exceeds maximum of 500")
|
|
|
|
var float value = 0.0
|
|
var float fisher = 0.0
|
|
var float signal = 0.0
|
|
|
|
float highest = ta.highest(source, period)
|
|
float lowest = ta.lowest(source, period)
|
|
|
|
float price_range = highest - lowest
|
|
float normalized = price_range > 0 ? (source - lowest) / price_range : 0.5
|
|
normalized := 2.0 * normalized - 1.0
|
|
|
|
float alpha = 0.33
|
|
value := alpha * normalized + (1.0 - alpha) * value
|
|
|
|
value := math.max(-0.999, math.min(0.999, value))
|
|
|
|
fisher := 0.5 * math.log((1.0 + value) / (1.0 - value))
|
|
|
|
signal := alpha * fisher + (1.0 - alpha) * signal
|
|
|
|
[fisher, signal]
|
|
|
|
// ---------- Main loop ----------
|
|
|
|
i_period = input.int(10, "Period", minval=1, maxval=500)
|
|
i_source = input.source(hl2, "Source")
|
|
|
|
[fisher_line, signal_line] = fisher(i_source, i_period)
|
|
|
|
plot(fisher_line, "Fisher", color=color.yellow, linewidth=2)
|
|
plot(signal_line, "Signal", color=color.orange, linewidth=1)
|
|
hline(0, "Zero", color=color.gray, linestyle=hline.style_dotted)
|
|
hline(2, "Overbought", color=color.red, linestyle=hline.style_dashed)
|
|
hline(-2, "Oversold", color=color.green, linestyle=hline.style_dashed)
|