OPEN-SOURCE SCRIPT
Goertzel Cycle Hunter [forexobroker]

Goertzel Cycle Hunter scans seven Fibonacci-spaced cycle periods (5, 8, 13, 21, 34, 55, 89) using the Goertzel filter — a tuned single-frequency DFT that runs in O(N) per period. The dominant cycle's reconstructed cosine drives the trigger, gated by a power-ratio regime that confirms the cycle is real and not noise.
🔶 ALGORITHM
1. Detrend source = (high + low) / 2 minus its N-bar SMA, isolating the oscillatory component.
2. For each period N in [5, 8, 13, 21, 34, 55, 89], run the Goertzel recursion: s[n] = x[n] + 2 cos(2 pi / N) * s[n-1] - s[n-2].
3. Power = s1^2 + s2^2 - 2 cos(omega) * s1 * s2; reconstructed cosine = s1 - s2 * cos(omega).
4. Dominant period = argmax(power); power ratio = max_power / sum_power.
5. Rhythm regime active when power ratio >= threshold AND ATR > k * 50-bar SMA.
🔶 SIGNAL LOGIC
- Buy: rhythm active AND reconstructed cosine crosses zero up AND not already long AND cooldown elapsed AND barstate.isconfirmed.
- Sell: mirror with crossunder.
- Position-lock state machine.
🔶 INPUTS
- Goertzel Window (default 120)
- Min Power Ratio (default 0.20)
- ATR Activity Floor (default 0.20)
- Cooldown Bars (default 4)
- Visual: dashboard, glow, trend mid line, buy / sell colors
🔶 ALERTS
GCH Buy, GCH Sell, GCH Any Signal, GCH Rhythm Start, GCH Rhythm End, GCH Phase Up, GCH Phase Down, GCH Strong Cycle, GCH Webhook JSON.
🔶 LIMITATIONS
- Cycle hunting is meaningful only when the market actually has a dominant rhythm; in trending or trapped regimes the power ratio stays low and signals mute correctly.
- Computational cost = 7 Goertzel runs of N samples per bar. Defaults (N = 120) balance fidelity vs load.
- The seven Fibonacci periods are a coarse grid; true dominant cycle may fall between (e.g., 16, 27 bars). User can re-tune the window length to bias toward shorter or longer cycles.
- Detrend is SMA-based; structural breaks within the window can bias the cosine reconstruction for a few bars.
🔶 ALGORITHM
1. Detrend source = (high + low) / 2 minus its N-bar SMA, isolating the oscillatory component.
2. For each period N in [5, 8, 13, 21, 34, 55, 89], run the Goertzel recursion: s[n] = x[n] + 2 cos(2 pi / N) * s[n-1] - s[n-2].
3. Power = s1^2 + s2^2 - 2 cos(omega) * s1 * s2; reconstructed cosine = s1 - s2 * cos(omega).
4. Dominant period = argmax(power); power ratio = max_power / sum_power.
5. Rhythm regime active when power ratio >= threshold AND ATR > k * 50-bar SMA.
🔶 SIGNAL LOGIC
- Buy: rhythm active AND reconstructed cosine crosses zero up AND not already long AND cooldown elapsed AND barstate.isconfirmed.
- Sell: mirror with crossunder.
- Position-lock state machine.
🔶 INPUTS
- Goertzel Window (default 120)
- Min Power Ratio (default 0.20)
- ATR Activity Floor (default 0.20)
- Cooldown Bars (default 4)
- Visual: dashboard, glow, trend mid line, buy / sell colors
🔶 ALERTS
GCH Buy, GCH Sell, GCH Any Signal, GCH Rhythm Start, GCH Rhythm End, GCH Phase Up, GCH Phase Down, GCH Strong Cycle, GCH Webhook JSON.
🔶 LIMITATIONS
- Cycle hunting is meaningful only when the market actually has a dominant rhythm; in trending or trapped regimes the power ratio stays low and signals mute correctly.
- Computational cost = 7 Goertzel runs of N samples per bar. Defaults (N = 120) balance fidelity vs load.
- The seven Fibonacci periods are a coarse grid; true dominant cycle may fall between (e.g., 16, 27 bars). User can re-tune the window length to bias toward shorter or longer cycles.
- Detrend is SMA-based; structural breaks within the window can bias the cosine reconstruction for a few bars.
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
🔵Gain access to our powerful tools : kestutisbalciunas.com/tradingview/
🔵Join our free telegram for updates : t.me/algotradingedge
All scripts & content provided by Forexobroker are for informational & educational purposes only.
🔵Join our free telegram for updates : t.me/algotradingedge
All scripts & content provided by Forexobroker are for informational & educational purposes only.
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
🔵Gain access to our powerful tools : kestutisbalciunas.com/tradingview/
🔵Join our free telegram for updates : t.me/algotradingedge
All scripts & content provided by Forexobroker are for informational & educational purposes only.
🔵Join our free telegram for updates : t.me/algotradingedge
All scripts & content provided by Forexobroker are for informational & educational purposes only.
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。