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提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。