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.
סקריפט קוד פתוח
ברוח האמיתית של TradingView, יוצר הסקריפט הזה הפך אותו לקוד פתוח, כך שסוחרים יוכלו לעיין בו ולאמת את פעולתו. כל הכבוד למחבר! אמנם ניתן להשתמש בו בחינם, אך זכור כי פרסום חוזר של הקוד כפוף ל־כללי הבית שלנו.
🔵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.
כתב ויתור
המידע והפרסומים אינם מיועדים להיות, ואינם מהווים, ייעוץ או המלצה פיננסית, השקעתית, מסחרית או מכל סוג אחר המסופקת או מאושרת על ידי TradingView. קרא עוד ב־תנאי השימוש.
סקריפט קוד פתוח
ברוח האמיתית של TradingView, יוצר הסקריפט הזה הפך אותו לקוד פתוח, כך שסוחרים יוכלו לעיין בו ולאמת את פעולתו. כל הכבוד למחבר! אמנם ניתן להשתמש בו בחינם, אך זכור כי פרסום חוזר של הקוד כפוף ל־כללי הבית שלנו.
🔵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.
כתב ויתור
המידע והפרסומים אינם מיועדים להיות, ואינם מהווים, ייעוץ או המלצה פיננסית, השקעתית, מסחרית או מכל סוג אחר המסופקת או מאושרת על ידי TradingView. קרא עוד ב־תנאי השימוש.