Goertzel Cycle Hunter TradingView Indicator

Goertzel Cycle Hunter is a dominant cycle indicator TradingView users can run on any market. Also, the script measures spectral power at seven Fibonacci periods – 5, 8, 13, 21, 34, 55 and 89 bars – with the Goertzel algorithm, a tuned single-frequency DFT. The strongest period wins. Indeed, when that period holds a large enough share of total power, the script calls the market rhythmic and acts on its phase flips.

It is free and open source. Still, you can add it to any chart from the Goertzel Cycle Hunter script page on TradingView, and the full Pine source is published there for you to read.

What Goertzel Cycle Hunter plots on the price chart

One grey line plots the 120-bar SMA of hl2, the same average the script subtracts to detrend price. Thus, diamonds mark signals, tagged GCH up below the bar or GCH dn above it, each backed by two larger translucent diamonds for the glow. Signal bars change colour. Hence, a faint background tint appears whenever the rhythmic test passes, mint while the cycle value sits above zero and coral while it sits below. The top-right dashboard lists the dominant period in bars, the power ratio, your threshold, cycle phase, regime, position and bars since the last signal.

How Goertzel Cycle Hunter is built

The Goertzel filter itself

Goertzel is a genuine signal-processing method, and this script implements it properly. Next, it evaluates one frequency at a time with a second-order recurrence instead of computing a whole FFT. That costs a single pass per period, which is why seven periods stay affordable on a chart.

Detrending comes first. Then, the script takes hl2, subtracts its 120-bar SMA, and feeds the residual in. Each call then sets omega to two pi divided by the cycle period, and coeff to twice the cosine of omega. Yet, it runs s equals x plus coeff times s1 minus s2 across all 120 samples. Power comes out as s1 squared plus s2 squared minus coeff times s1 times s2, the textbook Goertzel magnitude.

One honest note on naming. Truly, the value the header calls a reconstructed cosine is s1 minus s2 times cosine omega, which is the real part of the DFT coefficient. It swings as cycle phase rotates, so its zero cross does mark a phase flip. Plainly, it is not a time-domain waveform of the cycle drawn back onto price.

From spectrum to signal

The seven power figures get summed. Also, the largest divided by that total gives the power ratio. Sizing matters here. Indeed, with seven bins a flat spectrum lands near 0.14, so the default 0.20 threshold asks for only a modest peak. Push it toward 0.40 if you want a truly dominant cycle before anything fires.

A second gate checks activity. Still, ATR over 14 bars must exceed 0.20 times its own 50-bar SMA. That floor is lenient and passes nearly all the time. Thus, raise it toward 1.0 to demand above-average movement. Note also the window default of 120 bars against a longest tested period of 89. Hence, the script’s own tooltip asks for twice the longest period, which would be 178, so the 89-bar bin sees under two full cycles at stock settings.

Entries need the dominant cycle value to cross zero. Next, a buy takes the up cross, a sell the down cross, and both require the rhythmic flag. Position state must alternate, four bars of cooldown must pass, and barstate.isconfirmed must read true. Then, every diamond and every glow layer reads that final flag.

How to read the signals

Start with the regime row on the dashboard. Yet, RHYTHMIC means the leading period holds at least your power share and the market is moving. NOISE means the spectrum sits flat, and flat spectra are the normal state for trending or choppy price. Truly, no diamond can print while the row reads NOISE.

Then read the dominant period. Plainly, a reading of 13 bars and a reading of 89 bars call for very different holding times, even on the same chart. Check the number before you size a trade off a diamond, and watch whether it stays stable across several bars or jumps around.

Diamonds confirm on the close, so each one lands at the open of the next candle. Also, treat the phase flip as a timing cue inside a cycle the script has already judged real. It says the measured rhythm turned. Indeed, it says nothing about how far price travels next.

Every Goertzel Cycle Hunter setting explained

The script exposes 9 inputs, grouped in the settings panel exactly as shown below. Defaults are the published values.

Goertzel

SettingWhat it doesDefaultRange
Goertzel WindowBars per Goertzel evaluation. Must be >= 2x longest cycle period to be tested.12060 to 300

Signal Logic

SettingWhat it doesDefaultRange
Min Power RatioDominant cycle power must be >= this fraction of total power for a ‘rhythmic’ regime.0.200.05 to 0.80
ATR Activity FloorATR must exceed k x its 50-bar SMA. Filters dead/holiday markets.0.200.05 to 2.00
Cooldown BarsSets the cooldown bars used in the calculation.41 to 20

Visual

SettingWhat it doesDefaultRange
Show DashboardToggles show dashboard on the chart.onon / off
Show 3-Layer GlowToggles show 3-layer glow on the chart.onon / off
Show Trend MidToggles show trend mid on the chart.onon / off
Buy Color (Mint)Colour used for buy color (mint).#1de9b6
Sell Color (Coral)Colour used for sell color (coral).#ff5252

Alerts built into Goertzel Cycle Hunter

The script ships 11 alert conditions. Still, open the alert dialog on the chart, pick the indicator as the condition source, then choose the event you want. Alerts fire on the close of the bar, so they follow the same confirmed-bar rule the on-chart signals use.

  • 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

Other markets and timeframes

Nothing here is tied to forex. Thus, the power ratio is a share of total spectral energy, so it is dimensionless. The activity gate compares ATR with its own 50-bar average, so it scales with the instrument. Hence, the window and the seven periods count bars, not pips. The same defaults therefore run on gold, indices, crypto and equities unchanged. Next, the setting worth revisiting per chart is the window, since faster timeframes suit shorter analysis lengths.

Limitations worth knowing

It measures rhythm, not direction, and it forecasts nothing. Then, there is no stop, target, exit or sizing logic anywhere in the script. A rhythmic regime can end on the bar after a diamond prints, and the tool will not tell you to leave.

The spectral estimate has real weaknesses. Yet, the script applies no window function, so a rectangular window leaks energy between bins. The seven Fibonacci periods are not orthogonal either, so a strong 21-bar cycle also lifts the 13 and 34 readings. Truly, the power ratio is an approximation, not a clean decomposition. Note too that the dominant period can switch between bars, which means a zero cross can compare two different bins rather than track one cycle.

Cost is high. Plainly, seven periods across a 120-bar window run 840 loop iterations per bar, and max_bars_back sits at 500. Expect slower loading than a moving average. Also, the default 120-bar window under-resolves the 89-bar candidate, so raise it to roughly 200 if the long end matters to you.

Get Goertzel Cycle Hunter on TradingView

Open Goertzel Cycle Hunter on TradingView

If you also trade MetaTrader, the MT4 and MT5 indicator library is available below.

Get the complete indicator library

One email unlocks the full MT4 and MT5 indicator library. Also, this TradingView script stays free on TradingView – the button above adds it to your chart.

Using it alongside MetaTrader

Adding a script on TradingView takes one click, so there is no install step here. Indeed, if you want the same idea on MetaTrader, the MT4 and MT5 indicator installation guide walks through copying files into the data folder and attaching them to a chart. You can also browse the full MetaTrader indicator library, the MT4 indicators section, or the other free TradingView scripts published on this profile. For related chart tools see the MT5 indicators section and the forex trading strategies guides.

External references

Frequently asked questions

Does the Goertzel Cycle Hunter repaint?

No. Still, both signal flags require barstate.isconfirmed, and the diamonds and glow layers all read those flags. A signal prints after the bar closes and then stays. Thus, the script calls no request.security, so it is single timeframe and cannot pull in higher timeframe data that shifts later.

What does the power ratio actually mean?

It is the dominant period’s power divided by the total across all seven periods. Hence, with seven bins, an even spread sits near 0.14. A reading of 0.35 says one period carries far more energy than its neighbours. Next, it measures how rhythmic the detrended price looks, nothing about trade outcomes.

Why do the seven periods use Fibonacci numbers?

They give wide, roughly logarithmic spacing across the range a trader cares about, from a 5-bar swing to an 89-bar cycle, using only seven evaluations. Then, any spread of periods would work. Fibonacci spacing simply keeps the bins far enough apart to reduce overlap between neighbours.

Why does the dashboard period keep changing?

Because the script re-runs all seven filters on every bar and picks whichever holds the most power right then. Yet, when two bins sit close in strength, the winner alternates. That is a sign the spectrum is not clearly peaked, and a higher Min Power Ratio will filter those bars out.

How much should I rely on this indicator?

Treat it as one input, not a decision. Truly, it is a chart analysis tool, not trading advice. Test it on your own markets and timeframes before relying on it. Results are not guaranteed; past performance is not indicative of future results.

Dominic Walsh - Forex trader and MT4/MT5 developer

About the author

Written by Dominic Walsh, a Forex trader and MT4/MT5 indicator, Expert Advisor and script developer. Every tool on forexmt4systems.com is tested on live charts before release and ships with ready-to-use compiled MT4 (.ex4) and MT5 (.ex5) files. Learn more about the trader and developer behind this site.

Leave a Comment