OPEN-SOURCE SCRIPT

Standing Wave Phase Coherence [JOAT]

421
STANDING WAVE PHASE COHERENCE [JOAT]

A phase-coherence engine that asks a question almost no public indicator can answer: are the LTF and HTF oscillators in phase or out of phase? Two oscillators that move together (peaks and troughs aligned) form a standing wave — a state of constructive interference where the trend is amplified. Two oscillators that move opposite (peaks aligned with troughs) form an anti-standing wave — a state of destructive interference where a reversal is forming. Standing Wave Phase Coherence measures phase, computes the coherence between the two timeframes, and surfaces a single number bounded in [−1, +1] that tells you which regime you are in.

snapshot

Phase, not just direction

A moving average tells you "where price is sitting". A momentum oscillator tells you "which way it is moving". Phase is the location inside the cycle — are we approaching a peak, leaving a peak, approaching a trough, leaving a trough? Two oscillators on different timeframes can be:

  • In phase — both rising or both falling at the same rate of cycle progression. Constructive interference. Trend amplifies.
  • Anti-phase — one rising, the other falling at the same cycle rate. Destructive interference. Reversal forms.
  • Decoherent — phases are uncorrelated. The wave structure is breaking down. No directional edge from coherence.


The script estimates phase from each timeframe's RSI series (both legs at the same RSI length for fair comparison), differences the phase smoothly, then takes the cosine of the phase difference — which is exactly the quantum-mechanical coherence metric on a [−1, +1] scale.

Non-repainting HTF construction

The HTF leg uses request.security with lookahead_on AND a [1] offset on the expression — the only non-repainting form per Pine v6 docs. This is exposed as a toggle but ON by default; the warning in the input tooltip explains the trade-off (turn off only for research, never live).

Three thresholds, three states

  • Coherence > +0.70 (configurable) — IN PHASE. Standing wave constructive. Trend amplifies. Bull-palette background tint.
  • Coherence < −0.70ANTI PHASE. Standing wave destructive. Reversal forms. Bear-palette background tint.
  • |Coherence| < 0.30 (decoherent band) — DECOHERENT. No standing wave. Mid-palette neutral.
  • In between — transitional.


Phase-status arrows print inside the pane at every regime entry, so the chart history shows when each standing wave formed and collapsed.

Visual system

  • Coherence line with configurable width.
  • Glow halo — a wider semi-transparent copy of the coherence line below the main line, creating a soft glow effect.
  • Background tint by phase status — bull when IN PHASE, bear when ANTI PHASE, none when decoherent. Transparency configurable.
  • Threshold lines at ±0.70 (toggleable).
  • Zero line.
  • Fill between threshold and ±1 — soft bull / bear fill highlights the active phase zone so it is immediately obvious which side is engaged.
  • Phase status arrows inside the pane on state transitions.


The pane uses the JOAT default palette (cyan-teal bull / magenta bear).

Amplification factor

A separate EMA-smoothed trend amplification factor is computed from the coherence and surfaced in the dashboard. When coherence is sustained high (in-phase), the amplification factor rises — quantifying how much the LTF/HTF agreement is reinforcing the move. Useful as a position-sizing input: bigger amplification = stronger conviction = larger size.

Dashboard

Monospaced table, positionable to any of nine corners. Surfaces:

  • Current coherence value and bar age.
  • Phase status (IN PHASE / ANTI PHASE / DECOHERENT) with glyph.
  • LTF and HTF RSI values.
  • Phase difference in radians and degrees.
  • Trend amplification factor (smoothed).
  • HTF timeframe in use with non-repaint flag.


Alerts

Multiple alert conditions:

  • Coherence crosses above +0.70 (IN PHASE entry)
  • Coherence crosses below −0.70 (ANTI PHASE entry)
  • Coherence returns to decoherent band
  • Sustained IN PHASE (held above threshold for N bars)
  • Sustained ANTI PHASE


snapshot

How to read it

Three reads, in order of conviction:

  1. Sustained IN PHASE — the highest-conviction trend read. LTF and HTF oscillators are decisively moving together. This is the regime in which momentum tools have their largest edge.
  2. Entry into ANTI PHASE — the reversal warning. The two timeframes have rotated opposite each other; whichever direction LTF is moving, HTF is opposing. Often precedes meaningful reversals.
  3. Decoherent zone — stand-aside signal. The wave structure has broken down. Coherence-based reads are not actionable; switch to a regime-classification tool (FDI, Hurst, Entropy).


The cleanest workflow: only take trend trades when IN PHASE; only take reversal trades when ANTI PHASE; do nothing when DECOHERENT.

Suggested settings

Defaults (RSI 14, HTF 4H, phase smoothing 3, coherence smoothing 8, ±0.70 thresholds, ±0.30 decoherent band) are tuned for 15m–1H charts. The HTF should always be greater than or equal to the chart timeframe; mismatching produces meaningless phase reads. For HTF (4H+ chart timeframes) raise HTF to Daily and consider the LTF/HTF coherence as a daily-vs-weekly read.

Originality

The implementation — the dual-timeframe RSI phase estimator, the smoothed phase-difference cosine coherence (quantum-style metric), the non-repainting HTF request with [1]-offset + lookahead_on pattern, the three-threshold phase classifier with decoherent band, the trend amplification factor formulation, the glow-halo line render, and the pane-overlay phase-status arrows — is JOAT-original. No third-party code reused. The notion of phase coherence between timeframes as a market regime metric is the original quantitative contribution, borrowed conceptually from optical and quantum physics.

Limitations

Phase estimation from discrete bar data is inherently noisy on short windows; the smoothing inputs (phase EMA and coherence EMA) exist to address that — over-smoothing destroys phase information, so the defaults are intentionally light. The HTF request is non-repainting in the useStrictHtf = ON configuration; do not turn it off in live trading. The decoherent band is a heuristic to avoid acting on noise reads; widen it on instruments with naturally choppy oscillator structure.



-made with passion by jackofalltrades

Wyłączenie odpowiedzialności

Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.