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.
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 : 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.
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 : 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.
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.