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. اقرأ المزيد في شروط الاستخدام.