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.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
🔵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.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
🔵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.
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.