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.
Skrip open-source
Dengan semangat TradingView yang sesungguhnya, pembuat skrip ini telah menjadikannya sebagai sumber terbuka, sehingga para trader dapat meninjau dan memverifikasi fungsinya. Salut untuk penulisnya! Meskipun Anda dapat menggunakannya secara gratis, perlu diingat bahwa penerbitan ulang kode ini tunduk pada Tata Tertib kami.
🔵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.
Pernyataan Penyangkalan
Informasi dan publikasi ini tidak dimaksudkan, dan bukan merupakan, saran atau rekomendasi keuangan, investasi, trading, atau jenis lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Ketentuan Penggunaan.
Skrip open-source
Dengan semangat TradingView yang sesungguhnya, pembuat skrip ini telah menjadikannya sebagai sumber terbuka, sehingga para trader dapat meninjau dan memverifikasi fungsinya. Salut untuk penulisnya! Meskipun Anda dapat menggunakannya secara gratis, perlu diingat bahwa penerbitan ulang kode ini tunduk pada Tata Tertib kami.
🔵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.
Pernyataan Penyangkalan
Informasi dan publikasi ini tidak dimaksudkan, dan bukan merupakan, saran atau rekomendasi keuangan, investasi, trading, atau jenis lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Ketentuan Penggunaan.