OPEN-SOURCE SCRIPT
Fourier Phase Rotation [forexobroker]

Fourier Phase Rotation reconstructs the fundamental phase of a 4-bar sliding window using sine and cosine projections. The phase angle phi rotates through the unit circle as the cycle progresses; a zero-cross of phi marks a cycle low (buy timing) or high (sell timing). Distinct from Hilbert: 4-point projection, no IIR filter ringing.
🔶 ALGORITHM
1. Detrended source = close - sma(close, N).
2. 4-point DFT bin 1 cosine: re = c0 - c2; sine: im = c1 - c3 where c_k = detrended source at lag k.
3. phase phi = atan(im / re), in [-pi/2, +pi/2].
4. Cycle-low complete = phi crosses zero up; cycle-high complete = phi crosses zero down.
5. Bias from close vs detrend SMA gates direction.
🔶 SIGNAL LOGIC
- Buy: phase up-cross AND close > detrend SMA AND not already long AND cooldown elapsed AND barstate.isconfirmed.
- Sell: phase down-cross AND close < detrend SMA.
- Position-lock state machine.
🔶 INPUTS
- Detrend SMA Length (default 20)
- Pullback EMA Length (default 8)
- Cooldown Bars (default 4)
- Visual: dashboard, glow, SMA toggle, buy / sell colors
🔶 ALERTS
FPR Buy, FPR Sell, FPR Any Signal, FPR Phase Up, FPR Phase Down, FPR Bias Up, FPR Bias Down, FPR Near Pi/2, FPR Webhook JSON.
🔶 LIMITATIONS
- 4-point projection has a fixed period of 4 bars; assumes any cycle of interest is roughly that scale. Longer cycles fold into the bias trend.
- atan (vs atan2) gives phase in [-pi/2, +pi/2]; sufficient for zero-cross detection but does not preserve quadrant disambiguation.
- Detrend SMA length is the dominant smoothing knob; longer SMA = cleaner cycle, more lag.
- Best on instruments with rhythmic intraday patterns; pure trends give muted phase oscillations.
🔶 ALGORITHM
1. Detrended source = close - sma(close, N).
2. 4-point DFT bin 1 cosine: re = c0 - c2; sine: im = c1 - c3 where c_k = detrended source at lag k.
3. phase phi = atan(im / re), in [-pi/2, +pi/2].
4. Cycle-low complete = phi crosses zero up; cycle-high complete = phi crosses zero down.
5. Bias from close vs detrend SMA gates direction.
🔶 SIGNAL LOGIC
- Buy: phase up-cross AND close > detrend SMA AND not already long AND cooldown elapsed AND barstate.isconfirmed.
- Sell: phase down-cross AND close < detrend SMA.
- Position-lock state machine.
🔶 INPUTS
- Detrend SMA Length (default 20)
- Pullback EMA Length (default 8)
- Cooldown Bars (default 4)
- Visual: dashboard, glow, SMA toggle, buy / sell colors
🔶 ALERTS
FPR Buy, FPR Sell, FPR Any Signal, FPR Phase Up, FPR Phase Down, FPR Bias Up, FPR Bias Down, FPR Near Pi/2, FPR Webhook JSON.
🔶 LIMITATIONS
- 4-point projection has a fixed period of 4 bars; assumes any cycle of interest is roughly that scale. Longer cycles fold into the bias trend.
- atan (vs atan2) gives phase in [-pi/2, +pi/2]; sufficient for zero-cross detection but does not preserve quadrant disambiguation.
- Detrend SMA length is the dominant smoothing knob; longer SMA = cleaner cycle, more lag.
- Best on instruments with rhythmic intraday patterns; pure trends give muted phase oscillations.
Script de código abierto
Fiel al espíritu de TradingView, el creador de este script lo ha convertido en código abierto, para que los traders puedan revisar y verificar su funcionalidad. ¡Enhorabuena al autor! Aunque puede utilizarlo de forma gratuita, recuerde que cualquier republicación del código está sujeta a nuestras Normas internas.
🔵Gain access to our powerful tools : forexobroker.com/tv
🔵Join our free telegram for updates : t.me/dominicwalsfxhtrader
All scripts & content provided by Forexobroker are for informational & educational purposes only.
🔵Join our free telegram for updates : t.me/dominicwalsfxhtrader
All scripts & content provided by Forexobroker are for informational & educational purposes only.
Exención de responsabilidad
La información y las publicaciones no constituyen, ni deben considerarse como, asesoramiento o recomendaciones financieras, de inversión, de trading u otro tipo, proporcionadas o respaldadas por TradingView. Obtenga más información en Condiciones de uso.
Script de código abierto
Fiel al espíritu de TradingView, el creador de este script lo ha convertido en código abierto, para que los traders puedan revisar y verificar su funcionalidad. ¡Enhorabuena al autor! Aunque puede utilizarlo de forma gratuita, recuerde que cualquier republicación del código está sujeta a nuestras Normas internas.
🔵Gain access to our powerful tools : forexobroker.com/tv
🔵Join our free telegram for updates : t.me/dominicwalsfxhtrader
All scripts & content provided by Forexobroker are for informational & educational purposes only.
🔵Join our free telegram for updates : t.me/dominicwalsfxhtrader
All scripts & content provided by Forexobroker are for informational & educational purposes only.
Exención de responsabilidad
La información y las publicaciones no constituyen, ni deben considerarse como, asesoramiento o recomendaciones financieras, de inversión, de trading u otro tipo, proporcionadas o respaldadas por TradingView. Obtenga más información en Condiciones de uso.