OPEN-SOURCE SCRIPT

Harmonic Periodicity Matrix [Pineify]

1 560
Harmonic Periodicity Matrix — Multi-Cycle Stochastic Oscillator with Momentum Ribbon & Adaptive Signals

The Harmonic Periodicity Matrix is an advanced cycle-detection oscillator that identifies market rhythm, momentum shifts, and high-probability reversal zones by harmonically combining three stochastic waves at different periodicities. Rather than relying on a single fixed lookback window — which inevitably misses cycles of differing durations — this indicator synthesizes a short-cycle, a primary-cycle, and a long-cycle stochastic into a single composite wave. The result is a smoother, more robust picture of where the market currently sits within its natural oscillation pattern.

Key Features

  • Three harmonically spaced stochastic cycles fused into one composite wave
  • Weighted Moving Average (WMA) smoothing to reduce noise without excessive lag
  • EMA-based signal line that generates precise momentum-crossover triggers
  • Dynamic gradient coloring that visually encodes cycle strength and direction
  • Momentum Ribbon fill between the cycle wave and signal line for at-a-glance bias confirmation
  • Overbought / Oversold reference zones with subtle background shading
  • Filtered Buy and Sell signals that fire only when reversals originate from extreme cycle territory


How It Works

At its core, the indicator computes three stochastic oscillators (%K) across three harmonically related lengths derived from a user-defined Primary Cycle Length:

  1. Short cycle — half the primary length (cycleLen / 2), capturing fast intraday or shorter-term oscillations.
  2. Primary cycle — the user-defined length (cycleLen), representing the dominant market rhythm.
  3. Long cycle — 1.5× the primary length (cycleLen × 1.5), anchoring the broader trend context.


These three stochastic readings are averaged into a single composite cycle and then smoothed with a Weighted Moving Average (WMA) over the user-defined Smoothing Factor. Subtracting 50 centers the result around zero (range: −50 to +50), making overbought and oversold conditions immediately intuitive.

A Signal Line — an EMA calculated over twice the smoothing period — acts as a lagging reference. Crossovers between the composite wave and the signal line mark momentum inflection points.

Trading Ideas and Insights

  • Zero-line crosses — When the composite wave crosses above 0, market momentum is transitioning bullish; below 0 signals bearish transition.
  • Overbought / Oversold extremes — Readings above +25 indicate potential exhaustion; readings below −25 indicate potential recovery opportunity.
  • Signal crossovers from extremes — The highest-conviction signals occur when the wave crosses the signal line while already in oversold (< −15, Buy) or overbought (> +15, Sell) territory.
  • Momentum Ribbon color — A green ribbon confirms bullish momentum continuation; a red ribbon warns of bearish pressure even if price is still rising.


How Multiple Indicators Work Together

The power of the Harmonic Periodicity Matrix comes from the deliberate combination of three stochastic oscillators and two moving average types:

The three stochastics represent different frequency bands of market activity — fast, medium, and slow. Averaging them suppresses random noise that would appear in any single stochastic while preserving genuine cyclical structure that repeats across all three timeframes simultaneously.


The WMA smoothing is applied to the averaged cycle rather than to each individual stochastic. WMA front-weights recent data, keeping the smoothed line more responsive than a Simple Moving Average while avoiding the excessive lag of longer EMAs — the ideal balance for a cycle oscillator.

The EMA signal line is computed over a longer period (2× the smoothing factor), intentionally lagging behind the main wave. This lag creates meaningful crossover events: when the faster composite wave crosses the slower signal line, it indicates a genuine shift in momentum rather than a transient fluctuation.

The gradient coloring system encodes amplitude into color, providing an instant visual read of cycle intensity that raw numbers cannot convey. The background zone shading reinforces awareness of extreme readings without cluttering the visual space.

Together, these components form a self-contained cycle analysis system: the three stochastics define the oscillation, the WMA refines it, the EMA signal line contextualizes momentum, and the visual layer communicates everything instantly.

Unique Aspects

  • Harmonic period spacing — Using 0.5×, 1×, and 1.5× ratios is inspired by harmonic analysis principles, where related frequencies reinforce true cyclical signals and cancel spurious noise.
  • Amplitude-coded gradient — Color intensity scales with distance from zero (0→40 bullish, −40→0 bearish), making it easy to distinguish a mild rebound from a powerful trend.
  • Filtered signals — Buy signals require the crossover to occur below −15; Sell signals require it above +15. This prevents signal generation in neutral mid-range territory where momentum reversals are statistically less reliable.
  • Zero-centered display — Centering around 0 (rather than displaying 0–100) aligns naturally with how traders think about bullish vs. bearish bias.


How to Use

  1. Add the indicator to any chart and timeframe. It plots in a separate panel below the price chart.
  2. Watch for green circles (Buy signals) — these appear when the cycle wave crosses up through the signal line from oversold territory (below −15).
  3. Watch for red circles (Sell signals) — these appear when the cycle wave crosses down through the signal line from overbought territory (above +15).
  4. Use the Momentum Ribbon fill color to confirm trend direction before entering trades.
  5. Pay attention to the overbought (+25) and oversold (−25) zones — readings beyond these thresholds suggest cycle exhaustion and potential reversal.
  6. Combine with price action or volume analysis for additional confirmation before executing trades.


Customization

  • Primary Cycle Length (default: 20) — Increase for longer-term swing cycle detection; decrease for faster, shorter-term cycle tracking.
  • Smoothing Factor (default: 6) — Higher values produce a smoother wave with more lag; lower values are more reactive but noisier.
  • Bullish Wave color — Default green (#089981); customizable.
  • Bearish Wave color — Default red (#F23645); customizable.
  • Equilibrium color — Default gray (#787b86); customizable.


Conclusion

The Harmonic Periodicity Matrix offers a methodologically grounded approach to market cycle analysis by combining multi-frequency stochastic decomposition, adaptive smoothing, and momentum-crossover detection into a single, visually intuitive oscillator. It is designed for traders who want more than a standard stochastic — those who seek to understand the rhythm of the market across multiple cycle lengths simultaneously. Whether you are swing trading, trend following, or timing entries within a larger move, this indicator provides a structured, repeatable framework for identifying when momentum is genuinely shifting versus when the market is simply oscillating in neutral territory.

คำจำกัดสิทธิ์ความรับผิดชอบ

ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน