OPEN-SOURCE SCRIPT

OTE Cycle Regime

494
Rest in Peace Veryfid.
---

Cycle Regime (Ehlers Dominant Cycle)

Measures the market's dominant cycle length and flags whether it's compressing or expanding.

---


**What it does**

Cycle Regime plots a single, clean estimate of the market's current **dominant cycle period** — how many bars one full up-down rhythm is currently taking — and classifies it against its own recent baseline into three states:

- 🟢 **Compression** — the cycle is shorter than usual; price is coiling / oscillating tightly.
- 🔴 **Expansion** — the cycle is longer than usual; swings are stretching out (often a trend maturing).
- ⚪ **Neutral** — the cycle is near its typical length; no strong reading.

The current state is shown as a colored line, an optional background tint during compression, and a status label reading e.g. `COMPRESSION · 23b (base 49)`.

**The math**


Under the hood this is John Ehlers' **homodyne (in-phase / quadrature) dominant-cycle measurement**. Price is detrended and smoothed, a quadrature (90°-shifted) copy is built via a Hilbert-transform approximation, and the per-bar phase advance between the two is converted into a cycle period ( period = 2π / phase-rate ), then median-filtered and smoothed for stability.

It is a distillation of the open-source **"Tesla Coil"** indicator: I kept only the single robust cycle estimator and replaced the original's fixed reference level with a self-scaling baseline (the rolling median of the period), so the regime adapts to any symbol or timeframe without manual tuning.

**How to read it**

- Watch the **color**, not just the level. A rising line into red = the market is trending/stretching. A falling line into green = it's compressing/coiling.
- The **baseline** (gray line) is the median cycle length over the lookback window — the line's own "normal." Regime is always relative to that, so a "compression" on a fast asset and a slow one mean the same thing structurally.
- It describes **rhythm and volatility state, not direction.** It never tells you up or down — pair it with your own structure, trend, or entry method.

**Settings**

- **Source** — price input (default close).
- **Baseline window** — bars used for the median baseline (default 40).
- **Expansion / Compression thresholds** — how far above/below baseline triggers each state (default 1.10× / 0.90×).
- **Colors, baseline visibility, background highlight** — all optional.

Alerts fire when the cycle enters compression or expansion.

**How I use it**

I treat cycle state as a **context filter**, not a signal. It's most useful applied on your higher timeframe to judge *when* your setups are worth taking versus when the market is in a state you'd rather avoid — a modifier on decisions your own method already made, not a standalone buy/sell.

**Credits**

Built on Ehlers' instantaneous-frequency / homodyne cycle work and distilled from the open-source "Tesla Coil" indicator by **veryfid** (with contributions by DasanC and KryptoBeau). Published open-source under MPL-2.0.

**Disclaimer**

For research and education only. This is not financial advice and makes no claim about future performance. Cycle measurements are inherently lagging and smoothed — always confirm with your own analysis and risk management.

---

Declinazione di responsabilità

Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.